void addNote( Note & n ) { if( !p || n.pos() > lastEnd + DefaultTicksPerTact ) { MidiTime pPos = MidiTime( n.pos().getTact(), 0 ); p = dynamic_cast<Pattern*>( it->createTCO( 0 ) ); p->movePosition( pPos ); } hasNotes = true; lastEnd = n.pos() + n.length(); n.setPos( n.pos( p->startPosition() ) ); p->addNote( n, false ); }
void testInlineAutomation() { auto song = Engine::getSong(); InstrumentTrack* instrumentTrack = dynamic_cast<InstrumentTrack*>(Track::create(Track::InstrumentTrack, song)); Pattern* notePattern = dynamic_cast<Pattern*>(instrumentTrack->createTCO(0)); notePattern->changeLength(MidiTime(4, 0)); Note* note = notePattern->addNote(Note(MidiTime(4, 0)), false); note->createDetuning(); DetuningHelper* dh = note->detuning(); auto pattern = dh->automationPattern(); pattern->setProgressionType( AutomationPattern::LinearProgression ); pattern->putValue(MidiTime(0, 0), 0.0); pattern->putValue(MidiTime(4, 0), 1.0); QCOMPARE(pattern->valueAt(MidiTime(0, 0)), 0.0f); QCOMPARE(pattern->valueAt(MidiTime(1, 0)), 0.25f); QCOMPARE(pattern->valueAt(MidiTime(2, 0)), 0.5f); QCOMPARE(pattern->valueAt(MidiTime(4, 0)), 1.0f); }