Skip to content

Commit 2c5cda5

Browse files
DomClarkPhysSong
authored andcommitted
Fix kVstTransportChanged flag usage in VST sync
Changed according to feedback from AudioBlast. The flag used to be set most of the time, now it is only set when playback starts/stops, looping is toggled, or playback jumps around.
1 parent cc2ae66 commit 2c5cda5

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

include/Song.h

+9
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,19 @@ class EXPORT Song : public TrackContainer
8787
{
8888
return m_currentFrame;
8989
}
90+
inline void setJumped( const bool jumped )
91+
{
92+
m_jumped = jumped;
93+
}
94+
inline bool jumped() const
95+
{
96+
return m_jumped;
97+
}
9098
TimeLineWidget * m_timeLine;
9199

92100
private:
93101
float m_currentFrame;
102+
bool m_jumped;
94103

95104
} ;
96105

include/VstSyncController.h

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class VstSyncController : public QObject
6161
m_syncData->isCycle = false;
6262
}
6363

64+
void setPlaybackJumped( bool jumped )
65+
{
66+
m_syncData->m_playbackJumped = jumped;
67+
}
68+
6469
void update();
6570

6671

@@ -79,6 +84,7 @@ private slots:
7984
bool hasSHM;
8085
float cycleStart;
8186
float cycleEnd;
87+
bool m_playbackJumped;
8288
int m_bufferSize;
8389
int m_sampleRate;
8490
int m_bpm;

include/VstSyncData.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct VstSyncData
4949
bool hasSHM;
5050
float cycleStart;
5151
float cycleEnd;
52+
bool m_playbackJumped;
5253
int m_bufferSize;
5354
int m_sampleRate;
5455
int m_bpm;

plugins/vst_base/RemoteVstPlugin.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class RemoteVstPlugin : public RemotePluginClient
396396
{
397397
float lastppqPos;
398398
float m_Timestamp;
399+
int32_t m_lastFlags;
399400
} ;
400401

401402
in * m_in;
@@ -478,12 +479,14 @@ RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) :
478479
m_vstSyncData->ppqPos = 0;
479480
m_vstSyncData->isCycle = false;
480481
m_vstSyncData->hasSHM = false;
482+
m_vstSyncData->m_playbackJumped = false;
481483
m_vstSyncData->m_sampleRate = sampleRate();
482484
}
483485

484486
m_in = ( in* ) new char[ sizeof( in ) ];
485487
m_in->lastppqPos = 0;
486488
m_in->m_Timestamp = -1;
489+
m_in->m_lastFlags = 0;
487490

488491
// process until we have loaded the plugin
489492
while( 1 )
@@ -1588,7 +1591,6 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode,
15881591
__plugin->m_in->m_Timestamp )
15891592
{
15901593
_timeInfo.ppqPos = __plugin->m_vstSyncData->ppqPos;
1591-
_timeInfo.flags |= kVstTransportChanged;
15921594
__plugin->m_in->lastppqPos = __plugin->m_vstSyncData->ppqPos;
15931595
__plugin->m_in->m_Timestamp = __plugin->m_vstSyncData->ppqPos;
15941596
}
@@ -1615,6 +1617,14 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode,
16151617

16161618
_timeInfo.flags |= kVstBarsValid;
16171619

1620+
if( ( _timeInfo.flags & ( kVstTransportPlaying | kVstTransportCycleActive ) ) !=
1621+
( __plugin->m_in->m_lastFlags & ( kVstTransportPlaying | kVstTransportCycleActive ) )
1622+
|| __plugin->m_vstSyncData->m_playbackJumped )
1623+
{
1624+
_timeInfo.flags |= kVstTransportChanged;
1625+
}
1626+
__plugin->m_in->m_lastFlags = _timeInfo.flags;
1627+
16181628
#ifdef LMMS_BUILD_WIN64
16191629
return (long long) &_timeInfo;
16201630
#else

src/core/Song.cpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ void Song::savePos()
193193

194194
void Song::processNextBuffer()
195195
{
196+
m_vstSyncController.setPlaybackJumped( false );
197+
196198
// if not playing, nothing to do
197199
if( m_playing == false )
198200
{
@@ -262,10 +264,21 @@ void Song::processNextBuffer()
262264
( tl->loopBegin().getTicks() * 60 * 1000 / 48 ) / getTempo();
263265
m_playPos[m_playMode].setTicks(
264266
tl->loopBegin().getTicks() );
267+
268+
m_vstSyncController.setAbsolutePosition(
269+
tl->loopBegin().getTicks() );
270+
m_vstSyncController.setPlaybackJumped( true );
271+
265272
emit updateSampleTracks();
266273
}
267274
}
268275

276+
if( m_playPos[m_playMode].jumped() )
277+
{
278+
m_vstSyncController.setPlaybackJumped( true );
279+
m_playPos[m_playMode].setJumped( false );
280+
}
281+
269282
f_cnt_t framesPlayed = 0;
270283
const float framesPerTick = Engine::framesPerTick();
271284

@@ -320,6 +333,7 @@ void Song::processNextBuffer()
320333
( ticks * 60 * 1000 / 48 ) / getTempo();
321334

322335
m_vstSyncController.setAbsolutePosition( ticks );
336+
m_vstSyncController.setPlaybackJumped( true );
323337
}
324338
}
325339
m_playPos[m_playMode].setTicks( ticks );
@@ -334,11 +348,14 @@ void Song::processNextBuffer()
334348
// beginning of the range
335349
if( m_playPos[m_playMode] >= tl->loopEnd() )
336350
{
337-
m_playPos[m_playMode].setTicks( tl->loopBegin().getTicks() );
351+
ticks = tl->loopBegin().getTicks();
352+
m_playPos[m_playMode].setTicks( ticks );
338353

339354
m_elapsedMilliSeconds =
340-
( ( tl->loopBegin().getTicks() ) * 60 * 1000 / 48 ) /
341-
getTempo();
355+
( ticks * 60 * 1000 / 48 ) / getTempo();
356+
357+
m_vstSyncController.setAbsolutePosition( ticks );
358+
m_vstSyncController.setPlaybackJumped( true );
342359
}
343360
else if( m_playPos[m_playMode] == tl->loopEnd() - 1 )
344361
{
@@ -609,6 +626,7 @@ void Song::setPlayPos( tick_t ticks, PlayModes playMode )
609626
getTempo() );
610627
m_playPos[playMode].setTicks( ticks );
611628
m_playPos[playMode].setCurrentFrame( 0.0f );
629+
m_playPos[playMode].setJumped( true );
612630

613631
// send a signal if playposition changes during playback
614632
if( isPlaying() )

src/gui/TimeLineWidget.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
375375
( 60 * 1000 / 48 ) ) /
376376
Engine::getSong()->getTempo() );
377377
m_pos.setCurrentFrame( 0 );
378+
m_pos.setJumped( true );
378379
updatePosition();
379380
positionMarkerMoved();
380381
break;

0 commit comments

Comments
 (0)