mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Fixed #63 nasty timing bug, now dynamically changing BPM is with audio as it should.
This commit is contained in:
parent
aa4d50be62
commit
96dd502d67
2 changed files with 19 additions and 13 deletions
|
@ -42,7 +42,7 @@ TimeManager::TimeManager():
|
||||||
barCounter = 0;
|
barCounter = 0;
|
||||||
beatCounter = 0;
|
beatCounter = 0;
|
||||||
|
|
||||||
beatFrameCountdown = fpb;
|
previousBeat = 0;
|
||||||
|
|
||||||
totalFrameCounter = 0;
|
totalFrameCounter = 0;
|
||||||
|
|
||||||
|
@ -138,7 +138,8 @@ void TimeManager::tap()
|
||||||
|
|
||||||
int TimeManager::getNframesToBeat()
|
int TimeManager::getNframesToBeat()
|
||||||
{
|
{
|
||||||
return beatFrameCountdown;
|
// FIXME
|
||||||
|
return -1; //beatFrameCountdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeManager::process(Buffers* buffers)
|
void TimeManager::process(Buffers* buffers)
|
||||||
|
@ -147,19 +148,21 @@ void TimeManager::process(Buffers* buffers)
|
||||||
//buffers->transportPosition->beats_per_bar = 4;
|
//buffers->transportPosition->beats_per_bar = 4;
|
||||||
//buffers->transportPosition->beat_type = 4;
|
//buffers->transportPosition->beat_type = 4;
|
||||||
|
|
||||||
totalFrameCounter += buffers->nframes;
|
|
||||||
|
|
||||||
// calculate beat / bar position in nframes
|
// calculate beat / bar position in nframes
|
||||||
int beat = totalFrameCounter / fpb;
|
//beatFrameCountdown = totalFrameCounter - (beat*fpb);
|
||||||
beatFrameCountdown = totalFrameCounter - (beat*fpb);
|
|
||||||
|
|
||||||
|
|
||||||
if ( beatFrameCountdown < buffers->nframes )
|
if ( previousBeat + fpb < totalFrameCounter + buffers->nframes )
|
||||||
{
|
{
|
||||||
beatCounter++;
|
beatCounter++;
|
||||||
|
|
||||||
|
long remaining = (totalFrameCounter + buffers->nframes) - (previousBeat + fpb);
|
||||||
|
|
||||||
|
//printf("remaining %li",remaining);
|
||||||
|
|
||||||
// process *upto* beat frame:
|
// process *upto* beat frame:
|
||||||
jack->processFrames( beatFrameCountdown );
|
jack->processFrames( buffers->nframes - remaining );
|
||||||
|
|
||||||
// inform observers of new beat FIRST
|
// inform observers of new beat FIRST
|
||||||
for(uint i = 0; i < observers.size(); i++)
|
for(uint i = 0; i < observers.size(); i++)
|
||||||
|
@ -180,21 +183,21 @@ void TimeManager::process(Buffers* buffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// process frames after beat()
|
// process frames after beat()
|
||||||
int remaining = long(buffers->nframes) - beatFrameCountdown;
|
//int remaining = long(buffers->nframes) - beatFrameCountdown;
|
||||||
/*
|
/*
|
||||||
char buffer [50];
|
char buffer [50];
|
||||||
sprintf (buffer, "r: %i, nfr: %i, bFC %li\ttFC %lli", remaining, buffers->nframes, beatFrameCountdown, totalFrameCounter );
|
sprintf (buffer, "r: %i, nfr: %i, bFC %li\ttFC %lli", remaining, buffers->nframes, beatFrameCountdown, totalFrameCounter );
|
||||||
EventGuiPrint e2( buffer );
|
EventGuiPrint e2( buffer );
|
||||||
writeToGuiRingbuffer( &e2 );
|
writeToGuiRingbuffer( &e2 );
|
||||||
*/
|
*/
|
||||||
if ( remaining > 0 )
|
if ( remaining > 0 && remaining < buffers->nframes )
|
||||||
{
|
{
|
||||||
jack->processFrames( remaining );
|
jack->processFrames( remaining );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buffer [50];
|
char buffer [50];
|
||||||
sprintf (buffer, "Timing Error: negative samples %i", remaining );
|
sprintf (buffer, "Timing Error: negative samples %li", remaining );
|
||||||
EventGuiPrint e2( buffer );
|
EventGuiPrint e2( buffer );
|
||||||
writeToGuiRingbuffer( &e2 );
|
writeToGuiRingbuffer( &e2 );
|
||||||
}
|
}
|
||||||
|
@ -203,7 +206,8 @@ void TimeManager::process(Buffers* buffers)
|
||||||
EventTimeBarBeat e( barCounter, beatCounter );
|
EventTimeBarBeat e( barCounter, beatCounter );
|
||||||
writeToGuiRingbuffer( &e );
|
writeToGuiRingbuffer( &e );
|
||||||
|
|
||||||
beatFrameCountdown = fpb;
|
//beatFrameCountdown = fpb;
|
||||||
|
previousBeat += fpb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -211,6 +215,8 @@ void TimeManager::process(Buffers* buffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
totalFrameCounter += buffers->nframes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int tick = int( (beatFloat - beat) * 1920 );
|
int tick = int( (beatFloat - beat) * 1920 );
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ class TimeManager
|
||||||
/// holds the number of frames processed
|
/// holds the number of frames processed
|
||||||
long long totalFrameCounter;
|
long long totalFrameCounter;
|
||||||
|
|
||||||
/// counts down frames until the next beat
|
/// frame number of the last beat
|
||||||
long beatFrameCountdown;
|
long previousBeat;
|
||||||
|
|
||||||
/// counts bars / beats processed
|
/// counts bars / beats processed
|
||||||
int barCounter;
|
int barCounter;
|
||||||
|
|
Loading…
Add table
Reference in a new issue