47 if (_points.empty()) {
51 auto f = _points.begin();
56 auto l = _points.rbegin();
61 auto i = _points.lower_bound(x);
69 float d = (x-x1)/(x2 - x1);
71 return y1 + (y2-y1)*d;
111 sOutput = QString(
"%1[AutomationPath]\n" ).arg( sPrefix )
112 .append( QString(
"%1%2min: %3\n" ).arg( sPrefix ).arg( s ).arg(
_min ) )
113 .append( QString(
"%1%2max: %3\n" ).arg( sPrefix ).arg( s ).arg(
_max ) )
114 .append( QString(
"%1%2def: %3\n" ).arg( sPrefix ).arg( s ).arg(
_def ) )
115 .append( QString(
"%1%2points:\n" ).arg( sPrefix ).arg( s ) );
117 sOutput.append( QString(
"%1%2%3 : %4\n" ).arg( sPrefix ).arg( s ).arg( pp.first ).arg( pp.second ) );
121 sOutput = QString(
"[AutomationPath]" )
122 .append( QString(
" min: %1" ).arg(
_min ) )
123 .append( QString(
", max: %1" ).arg(
_max ) )
124 .append( QString(
", def: %1" ).arg(
_def ) )
125 .append( QString(
", [points: " ) );
127 sOutput.append( QString(
"(%1: %4) " ).arg( pp.first ).arg( pp.second ) );
129 sOutput.append(
"]" );
143 const float limit = 0.5f;
149 auto i =
_points.lower_bound(x);
152 if( i->first - x <= limit) {
161 if( x - i->first <= limit) {
179 auto rv =
_points.insert(std::make_pair(x,y));
std::map< float, float >::iterator iterator
AutomationPath(float min, float max, float def)
std::map< float, float > _points
float get_value(float x) const noexcept
Get value at given location.
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
void remove_point(float x)
Remove point from path.
iterator move(iterator &in, float x, float y)
Move point to other location.
iterator find(float x)
Find point near specific location.
void add_point(float x, float y)
Add a point to path.
static QString sPrintIndention
String used to format the debugging string output of some core classes.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
bool operator==(const AutomationPath &lhs, const AutomationPath &rhs)
Compare two paths.
bool operator!=(const AutomationPath &lhs, const AutomationPath &rhs)