Make ppqPos in VST sync sample accurate
This commit is contained in:
committed by
Oskar Wallgren
parent
3a94ed3f3f
commit
614bca7f04
@@ -265,8 +265,6 @@ void Song::processNextBuffer()
|
||||
m_playPos[m_playMode].setTicks(
|
||||
tl->loopBegin().getTicks() );
|
||||
|
||||
m_vstSyncController.setAbsolutePosition(
|
||||
tl->loopBegin().getTicks() );
|
||||
m_vstSyncController.setPlaybackJumped( true );
|
||||
|
||||
emit updateSampleTracks();
|
||||
@@ -293,8 +291,6 @@ void Song::processNextBuffer()
|
||||
int ticks = m_playPos[m_playMode].getTicks() +
|
||||
( int )( currentFrame / framesPerTick );
|
||||
|
||||
m_vstSyncController.setAbsolutePosition( ticks );
|
||||
|
||||
// did we play a whole tact?
|
||||
if( ticks >= MidiTime::ticksPerTact() )
|
||||
{
|
||||
@@ -332,7 +328,6 @@ void Song::processNextBuffer()
|
||||
m_elapsedMilliSeconds =
|
||||
( ticks * 60 * 1000 / 48 ) / getTempo();
|
||||
|
||||
m_vstSyncController.setAbsolutePosition( ticks );
|
||||
m_vstSyncController.setPlaybackJumped( true );
|
||||
}
|
||||
}
|
||||
@@ -354,7 +349,6 @@ void Song::processNextBuffer()
|
||||
m_elapsedMilliSeconds =
|
||||
( ticks * 60 * 1000 / 48 ) / getTempo();
|
||||
|
||||
m_vstSyncController.setAbsolutePosition( ticks );
|
||||
m_vstSyncController.setPlaybackJumped( true );
|
||||
|
||||
emit updateSampleTracks();
|
||||
@@ -369,6 +363,16 @@ void Song::processNextBuffer()
|
||||
m_playPos[m_playMode].setCurrentFrame( currentFrame );
|
||||
}
|
||||
|
||||
if( framesPlayed == 0 )
|
||||
{
|
||||
// update VST sync position after we've corrected frame/
|
||||
// tick count but before actually playing any frames
|
||||
m_vstSyncController.setAbsolutePosition(
|
||||
m_playPos[m_playMode].getTicks()
|
||||
+ m_playPos[m_playMode].currentFrame()
|
||||
/ (double) framesPerTick );
|
||||
}
|
||||
|
||||
f_cnt_t framesToPlay =
|
||||
Engine::mixer()->framesPerPeriod() - framesPlayed;
|
||||
|
||||
@@ -716,7 +720,10 @@ void Song::stop()
|
||||
m_playPos[m_playMode].setCurrentFrame( 0 );
|
||||
|
||||
m_vstSyncController.setPlaybackState( m_exporting );
|
||||
m_vstSyncController.setAbsolutePosition( m_playPos[m_playMode].getTicks() );
|
||||
m_vstSyncController.setAbsolutePosition(
|
||||
m_playPos[m_playMode].getTicks()
|
||||
+ m_playPos[m_playMode].currentFrame()
|
||||
/ (double) Engine::framesPerTick() );
|
||||
|
||||
// remove all note-play-handles that are active
|
||||
Engine::mixer()->clear();
|
||||
|
||||
@@ -136,12 +136,12 @@ VstSyncController::~VstSyncController()
|
||||
|
||||
|
||||
|
||||
void VstSyncController::setAbsolutePosition( int ticks )
|
||||
void VstSyncController::setAbsolutePosition( double ticks )
|
||||
{
|
||||
#ifdef VST_SNC_LATENCY
|
||||
m_syncData->ppqPos = ( ( ticks + 0 ) / (float)48 ) - m_syncData->m_latency;
|
||||
m_syncData->ppqPos = ( ( ticks + 0 ) / 48.0 ) - m_syncData->m_latency;
|
||||
#else
|
||||
m_syncData->ppqPos = ( ( ticks + 0 ) / (float)48 );
|
||||
m_syncData->ppqPos = ( ( ticks + 0 ) / 48.0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user