void AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( _search_dup ) { for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ++it ) { if( *it == _obj ) { // Already exists // TODO: Maybe let the user know in some non-annoying way return; } } } // the automation track is unconnected and there is nothing in the track if( m_objects.isEmpty() && hasAutomation() == false ) { // then initialize first value putValue( MidiTime(0), _obj->value<float>(), false ); } m_objects += _obj; connect( _obj, SIGNAL( destroyed( jo_id_t ) ), this, SLOT( objectDestroyed( jo_id_t ) ), Qt::DirectConnection ); emit dataChanged(); }
void AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( _search_dup ) { for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ++it ) { if( *it == _obj ) { TextFloat::displayMessage( _obj->displayName(), tr( "Model is already connected " "to this pattern." ), embed::getIconPixmap( "automation" ), 2000 ); return; } } } // the automation track is unconnected and there is nothing in the track if( m_objects.isEmpty() && hasAutomation() == false ) { // then initialize first value putValue( MidiTime(0), _obj->inverseScaledValue( _obj->value<float>() ), false ); } m_objects += _obj; connect( _obj, SIGNAL( destroyed( jo_id_t ) ), this, SLOT( objectDestroyed( jo_id_t ) ), Qt::DirectConnection ); emit dataChanged(); }
void AutomationPattern::processMidiTime( const MidiTime & time ) { if( ! isRecording() ) { if( time >= 0 && hasAutomation() ) { const float val = valueAt( time ); for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ++it ) { if( *it ) { ( *it )->setAutomatedValue( val ); } } } } else { if( time >= 0 && ! m_objects.isEmpty() ) { const float value = static_cast<float>( firstObject()->value<float>() ); if( value != m_lastRecordedValue ) { putValue( time, value, true ); m_lastRecordedValue = value; } else if( valueAt( time ) != value ) { removeValue( time, false ); } } } }
bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( _search_dup ) { for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ++it ) { if( *it == _obj ) { return false; } } } // the automation track is unconnected and there is nothing in the track if( m_objects.isEmpty() && hasAutomation() == false ) { // then initialize first value putValue( MidiTime(0), _obj->inverseScaledValue( _obj->value<float>() ), false ); } m_objects += _obj; connect( _obj, SIGNAL( destroyed( jo_id_t ) ), this, SLOT( objectDestroyed( jo_id_t ) ), Qt::DirectConnection ); emit dataChanged(); return true; }