AutomationEditor: add option for smooth lines and curves

Besides discrete automation it's now possible to setup interpolation
modes such as linear and cubic-hermite.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Joel Muzzerall
2014-01-08 00:04:18 +01:00
committed by Tobias Doerffel
parent ddad2da162
commit 6249b23f1f
8 changed files with 534 additions and 123 deletions

View File

@@ -94,14 +94,16 @@ protected:
virtual void wheelEvent( QWheelEvent * _we );
float getLevel( int _y );
static inline void drawValueRect( QPainter & _p, int _x, int _y,
int _width, int _height,
const bool _is_selected );
int xCoordOfTick( int _tick );
int yCoordOfLevel( float _level );
inline void drawLevelTick( QPainter & _p, int _tick,
float _value, bool _is_selected );
void removeSelection();
void selectAll();
void getSelectedValues( timeMap & _selected_values );
void drawLine( int x0, float y0, int x1, float y1 );
void disableTensionComboBox();
protected slots:
void play();
@@ -115,6 +117,11 @@ protected slots:
void selectButtonToggled();
void moveButtonToggled();
void discreteButtonToggled();
void linearButtonToggled();
void cubicHermiteButtonToggled();
void tensionChanged();
void copySelectedValues();
void cutSelectedValues();
void pasteValues();
@@ -178,6 +185,13 @@ private:
toolButton * m_selectButton;
toolButton * m_moveButton;
toolButton * m_discreteButton;
toolButton * m_linearButton;
toolButton * m_cubicHermiteButton;
comboBox * m_tensionComboBox;
ComboBoxModel m_tensionModel;
ComboBoxModel m_tensionDisabledModel;
toolButton * m_cutButton;
toolButton * m_copyButton;
toolButton * m_pasteButton;
@@ -250,4 +264,3 @@ signals:
#endif

View File

@@ -41,6 +41,13 @@ class EXPORT AutomationPattern : public trackContentObject
{
Q_OBJECT
public:
enum ProgressionTypes
{
DiscreteProgression,
LinearProgression,
CubicHermiteProgression
} ;
typedef QMap<int, float> timeMap;
typedef QVector<QPointer<AutomatableModel> > objectVector;
@@ -52,6 +59,19 @@ public:
const AutomatableModel * firstObject() const;
// progression-type stuff
inline ProgressionTypes progressionType() const
{
return m_progressionType;
}
void setProgressionType( ProgressionTypes _new_progression_type );
inline QString getTension() const
{
return m_tension;
}
void setTension( QString _new_tension );
virtual midiTime length() const;
midiTime putValue( const midiTime & _time, const float _value,
@@ -69,12 +89,23 @@ public:
return m_timeMap;
}
inline const timeMap & getTangents() const
{
return m_tangents;
}
inline timeMap & getTangents()
{
return m_tangents;
}
inline bool hasAutomation() const
{
return m_timeMap.isEmpty() == false;
}
float valueAt( const midiTime & _time ) const;
float *valuesAfter( const midiTime & _time ) const;
const QString name() const;
@@ -110,12 +141,18 @@ public slots:
private:
void cleanObjects();
void generateTangents();
void generateTangents( timeMap::const_iterator it, int numToGenerate );
float valueAt( timeMap::const_iterator v, int offset ) const;
AutomationTrack * m_autoTrack;
QVector<jo_id_t> m_idsToResolve;
objectVector m_objects;
timeMap m_timeMap; // actual values
timeMap m_tangents; // slope at each point for calculating spline
QString m_tension;
bool m_hasAutomation;
ProgressionTypes m_progressionType;
friend class AutomationPatternView;