mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
Merge branch 'master' of https://github.com/geraldmwangi/openAV-Luppp into jimson
This commit is contained in:
commit
cfd0dc36d9
3 changed files with 36 additions and 12 deletions
|
@ -202,6 +202,13 @@ void LooperClip::record(int count, float* L, float* R)
|
|||
{
|
||||
_buffer->getData().at( _recordhead ) = *L++;
|
||||
_recordhead++;
|
||||
if(_recordhead>=90112)
|
||||
{
|
||||
char buffer [50];
|
||||
sprintf (buffer, "LooperClip t %i, s %i, recordhead %f\n",track, scene,_recordhead);
|
||||
EventGuiPrint e( buffer );
|
||||
//writeToGuiRingbuffer( &e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -264,6 +271,11 @@ long LooperClip::getBufferLenght()
|
|||
|
||||
long LooperClip::getActualAudioLength()
|
||||
{
|
||||
char cbuffer [50];
|
||||
// sprintf (cbuffer, "LooperClip recordhead %f,audioFrames %d \n",_recordhead,(int)_buffer->getAudioFrames());
|
||||
// EventGuiPrint e( cbuffer );
|
||||
// writeToGuiRingbuffer( &e );
|
||||
// printf(cbuffer);
|
||||
return _buffer->getAudioFrames();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,12 +40,16 @@ TimeManager::TimeManager():
|
|||
// 120 BPM default
|
||||
fpb = samplerate / 2;
|
||||
|
||||
//Counter for current bar/beat
|
||||
barCounter = 0;
|
||||
beatCounter = 0;
|
||||
|
||||
previousBeat = 0;
|
||||
|
||||
beatFrameCountdown = fpb;
|
||||
//In process() we want to immediately process bar(), beat() of all observers
|
||||
// thats why beatFrameCountdown<nframes, but we don't know yet what value nframes has
|
||||
// so set beatFrameCountdown to a value that garantees beatFrameCountdown<nframes
|
||||
beatFrameCountdown = -1;//fpb;
|
||||
|
||||
totalFrameCounter = 0;
|
||||
|
||||
|
@ -173,20 +177,23 @@ void TimeManager::process(Buffers* buffers)
|
|||
|
||||
int nframes = buffers->nframes;
|
||||
|
||||
totalFrameCounter += nframes;
|
||||
beatFrameCountdown -= nframes;
|
||||
|
||||
if ( beatFrameCountdown < 0 )
|
||||
|
||||
|
||||
if ( beatFrameCountdown < nframes )
|
||||
{
|
||||
int before = nframes + beatFrameCountdown;
|
||||
int after = - beatFrameCountdown;
|
||||
//length of beat is not multiple of nframes, so need to process last frames *before*
|
||||
//then set beat (get the queued actions: play, rec etc)
|
||||
// then process first frames *after* beat
|
||||
int before=(beatCounter*fpb)%nframes;
|
||||
int after=nframes-before;
|
||||
|
||||
if ( before < nframes && after < nframes && before + after == nframes )
|
||||
if ( before < nframes && after <= nframes && before + after == nframes )
|
||||
{
|
||||
char buffer [50];
|
||||
// sprintf (buffer, "Timing OK: before %i, after %i, b+a %i", before, after, before+after );
|
||||
EventGuiPrint e2( buffer );
|
||||
writeToGuiRingbuffer( &e2 );
|
||||
// EventGuiPrint e2( buffer );
|
||||
// writeToGuiRingbuffer( &e2 );
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -215,6 +222,7 @@ void TimeManager::process(Buffers* buffers)
|
|||
observers.at(i)->bar();
|
||||
}
|
||||
barCounter++;
|
||||
//beatCounter=0;
|
||||
}
|
||||
|
||||
// process after
|
||||
|
@ -226,14 +234,18 @@ void TimeManager::process(Buffers* buffers)
|
|||
|
||||
|
||||
|
||||
beatFrameCountdown = fpb;
|
||||
beatFrameCountdown = fpb-after;
|
||||
beatCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
jack->processFrames( nframes );
|
||||
beatFrameCountdown -= nframes;
|
||||
|
||||
}
|
||||
|
||||
totalFrameCounter += nframes;
|
||||
|
||||
// write BPM / transport info to JACK
|
||||
int bpm = ( samplerate * 60) / fpb;
|
||||
if ( buffers->transportPosition )
|
||||
|
|
|
@ -65,7 +65,7 @@ class TimeManager
|
|||
TRANSPORT_STATE transportState;
|
||||
|
||||
/// number of frames per beat
|
||||
float fpb;
|
||||
int fpb;
|
||||
|
||||
/// holds the number of frames processed
|
||||
long long totalFrameCounter;
|
||||
|
|
Loading…
Add table
Reference in a new issue