-Implemented bar() / beat() handling inside nframes: timing issues resolved
This commit is contained in:
parent
652e54df41
commit
1105553c63
3 changed files with 50 additions and 21 deletions
36
src/jack.cxx
36
src/jack.cxx
|
@ -258,7 +258,6 @@ void Jack::unregisterMidiIO( MidiIO* mo )
|
|||
//midiIO.push_back( mo );
|
||||
}
|
||||
|
||||
|
||||
int Jack::process (jack_nframes_t nframes)
|
||||
{
|
||||
/// get buffers
|
||||
|
@ -274,15 +273,6 @@ int Jack::process (jack_nframes_t nframes)
|
|||
|
||||
//buffers.midi [Buffers::MASTER_MIDI_INPUT] = (void*) jack_port_get_buffer( masterMidiInput, nframes );
|
||||
|
||||
memset( buffers.audio[Buffers::JACK_MASTER_OUT_L] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::JACK_MASTER_OUT_R] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::MASTER_OUT_L] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::MASTER_OUT_R] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SEND] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SIDECHAIN_KEY] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SIDECHAIN_SIGNAL] , 0, sizeof(float) * nframes );
|
||||
|
||||
|
||||
/// init buffers for each MidiIO
|
||||
for(unsigned int i = 0; i < midiIO.size(); i++ )
|
||||
{
|
||||
|
@ -324,6 +314,17 @@ int Jack::process (jack_nframes_t nframes)
|
|||
|
||||
void Jack::processFrames(int nframes)
|
||||
{
|
||||
// clear the buffers
|
||||
memset( buffers.audio[Buffers::JACK_MASTER_OUT_L] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::JACK_MASTER_OUT_R] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::MASTER_OUT_L] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::MASTER_OUT_R] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SEND] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SIDECHAIN_KEY] , 0, sizeof(float) * nframes );
|
||||
memset( buffers.audio[Buffers::SIDECHAIN_SIGNAL] , 0, sizeof(float) * nframes );
|
||||
|
||||
|
||||
|
||||
/// process each MidiIO registered MIDI port
|
||||
for(unsigned int i = 0; i < midiIO.size(); i++ )
|
||||
{
|
||||
|
@ -408,6 +409,21 @@ void Jack::processFrames(int nframes)
|
|||
//buffers.audio[Buffers::SEND], // uncomment to listen to reverb send only
|
||||
sizeof(float)*nframes);
|
||||
|
||||
|
||||
// move buffer pointers up nframes: allows processing of one "nframes" from
|
||||
// JACK in multiple parts internally in Luppp: used for processing bar() / beat()
|
||||
// if a full JACK nframes has been processed, this is extra work: its not that expensive
|
||||
/// update buffers by nframes
|
||||
buffers.audio[Buffers::MASTER_INPUT] = &buffers.audio[Buffers::MASTER_INPUT][nframes];
|
||||
buffers.audio[Buffers::MASTER_RETURN_L] = &buffers.audio[Buffers::MASTER_RETURN_L][nframes];
|
||||
buffers.audio[Buffers::MASTER_RETURN_R] = &buffers.audio[Buffers::MASTER_RETURN_R][nframes];
|
||||
|
||||
buffers.audio[Buffers::JACK_SEND_OUT] = &buffers.audio[Buffers::JACK_SEND_OUT][nframes];
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_L] = &buffers.audio[Buffers::JACK_MASTER_OUT_L][nframes];
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_R] = &buffers.audio[Buffers::JACK_MASTER_OUT_R][nframes];
|
||||
buffers.audio[Buffers::JACK_SIDECHAIN_KEY] = &buffers.audio[Buffers::JACK_SIDECHAIN_KEY][nframes];
|
||||
buffers.audio[Buffers::JACK_SIDECHAIN_SIGNAL]=&buffers.audio[Buffers::JACK_SIDECHAIN_SIGNAL][nframes];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,6 +235,11 @@ void LooperClip::bar()
|
|||
_buffer->setAudioFrames( jack->getTimeManager()->getFpb() * _buffer->getBeats() );
|
||||
}
|
||||
|
||||
if ( _playhead > 0.9 * _recordhead )
|
||||
{
|
||||
_playhead = 0.f;
|
||||
}
|
||||
|
||||
if ( _queuePlay && _loaded )
|
||||
{
|
||||
LUPPP_NOTE("QPLay + loaded" );
|
||||
|
|
|
@ -138,19 +138,18 @@ void TimeManager::process(Buffers* buffers)
|
|||
int beat = buffers->transportFrame / fpb;
|
||||
nframesToBeat = buffers->transportFrame - (beat*fpb);
|
||||
|
||||
|
||||
|
||||
// convert BBT position to a frame number in this period
|
||||
//double frames_per_beat = _audio.samplerate() * 60.0 / pos.beats_per_minute;
|
||||
//nframes_t offset = (frames_per_beat * (1.0 - (pos.tick / pos.ticks_per_beat)) );
|
||||
|
||||
|
||||
|
||||
if ( beat != oldBeat )
|
||||
{
|
||||
beatInProcess = true;
|
||||
|
||||
//LUPPP_NOTE("Beat %i, nframesToBeat %i", beat, nframesToBeat );
|
||||
if ( nframesToBeat > buffers->nframes )
|
||||
{
|
||||
nframesToBeat = buffers->nframes;
|
||||
}
|
||||
|
||||
|
||||
// process *upto* beat frame:
|
||||
jack->processFrames( nframesToBeat );
|
||||
|
||||
// inform observers of new beat FIRST
|
||||
for(uint i = 0; i < observers.size(); i++)
|
||||
|
@ -170,6 +169,16 @@ void TimeManager::process(Buffers* buffers)
|
|||
//buffers->transportPosition->bar++;
|
||||
}
|
||||
|
||||
// process frames after beat()
|
||||
int remaining = buffers->nframes - nframesToBeat;
|
||||
if ( remaining > 0 )
|
||||
{
|
||||
char buffer [50];
|
||||
sprintf (buffer, "remaining %i", remaining );
|
||||
EventGuiPrint e2( buffer );
|
||||
writeToGuiRingbuffer( &e2 );
|
||||
jack->processFrames( remaining );
|
||||
}
|
||||
// write new beat to UI (bar info currently not used)
|
||||
EventTimeBarBeat e( 0, beat );
|
||||
writeToGuiRingbuffer( &e );
|
||||
|
@ -179,6 +188,7 @@ void TimeManager::process(Buffers* buffers)
|
|||
else
|
||||
{
|
||||
beatInProcess = false;
|
||||
jack->processFrames( buffers->nframes );
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,7 +209,5 @@ void TimeManager::process(Buffers* buffers)
|
|||
//LUPPP_NOTE("BPM = %i " , bpm );
|
||||
//buffers->transportPosition->beats_per_minute = bpm;
|
||||
|
||||
jack->processFrames( buffers->nframes );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue