mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Fixed TimeManager timestretch / metronome mashing bug, now uses beatCounter for delta between beats
This commit is contained in:
parent
e34197a1f1
commit
840d0710d9
3 changed files with 28 additions and 12 deletions
|
@ -410,8 +410,8 @@ void Jack::processFrames(int nframes)
|
|||
buffers.audio[Buffers::SIDECHAIN_SIGNAL][i] += input * inputToXSideVol;
|
||||
|
||||
/// mixdown returns into master buffers
|
||||
buffers.audio[Buffers::MASTER_OUT_L][i] = (L + returnL) * masterVol;
|
||||
buffers.audio[Buffers::MASTER_OUT_R][i] = (R + returnR) * masterVol;
|
||||
buffers.audio[Buffers::MASTER_OUT_L][i] = (L + returnL*returnVol) * masterVol;
|
||||
buffers.audio[Buffers::MASTER_OUT_R][i] = (R + returnR*returnVol) * masterVol;
|
||||
|
||||
/// write SEND content to JACK port
|
||||
buffers.audio[Buffers::JACK_SEND_OUT][i] = buffers.audio[Buffers::SEND][i];
|
||||
|
|
|
@ -16,13 +16,16 @@ extern Jack* jack;
|
|||
using namespace std;
|
||||
|
||||
TimeManager::TimeManager():
|
||||
oldBeat(0),
|
||||
observers()
|
||||
{
|
||||
samplerate = jack->getSamplerate();
|
||||
// 120 BPM default
|
||||
fpb = samplerate / 2;
|
||||
|
||||
beatCounter = 0;
|
||||
|
||||
beatFrameCountdown = 0;
|
||||
|
||||
tapTempoPos = 0;
|
||||
tapTempo[0] = 0;
|
||||
tapTempo[1] = 0;
|
||||
|
@ -136,17 +139,27 @@ void TimeManager::process(Buffers* buffers)
|
|||
|
||||
|
||||
// calculate beat / bar position in nframes
|
||||
int beat = buffers->transportFrame / fpb;
|
||||
nframesToBeat = buffers->transportFrame - (beat*fpb);
|
||||
//int beat = buffers->transportFrame / int(fpb);
|
||||
|
||||
if ( beat != oldBeat )
|
||||
|
||||
beatFrameCountdown -= buffers->nframes;
|
||||
|
||||
//nframesToBeat = buffers->transportFrame - (beat*int(fpb));
|
||||
|
||||
if ( beatFrameCountdown <= 0 )
|
||||
{
|
||||
beatCounter++;
|
||||
|
||||
beatInProcess = true;
|
||||
|
||||
if ( nframesToBeat > int(buffers->nframes) )
|
||||
{
|
||||
nframesToBeat = buffers->nframes;
|
||||
}
|
||||
if ( nframesToBeat < 0 )
|
||||
{
|
||||
LUPPP_ERROR("NframesToBeat: %i, cannot be less than zero!", nframesToBeat );
|
||||
}
|
||||
|
||||
|
||||
// process *upto* beat frame:
|
||||
|
@ -159,7 +172,7 @@ void TimeManager::process(Buffers* buffers)
|
|||
}
|
||||
|
||||
// FIXME: 4 == beats in time sig
|
||||
if ( beat % 4 == 0 )
|
||||
if ( beatCounter % 4 == 0 )
|
||||
{
|
||||
// inform observers of new bar SECOND
|
||||
for(uint i = 0; i < observers.size(); i++)
|
||||
|
@ -182,10 +195,10 @@ void TimeManager::process(Buffers* buffers)
|
|||
jack->processFrames( remaining );
|
||||
}
|
||||
// write new beat to UI (bar info currently not used)
|
||||
EventTimeBarBeat e( 0, beat );
|
||||
EventTimeBarBeat e( 0, beatCounter );
|
||||
writeToGuiRingbuffer( &e );
|
||||
|
||||
oldBeat = beat;
|
||||
beatFrameCountdown = int(fpb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,10 +39,13 @@ class TimeManager
|
|||
int nframesToBeat;
|
||||
bool beatInProcess;
|
||||
|
||||
float fpb;
|
||||
int oldBeat;
|
||||
/// counts down frames until the next beat
|
||||
int beatFrameCountdown;
|
||||
|
||||
// tap tempo measurements
|
||||
float fpb;
|
||||
int beatCounter;
|
||||
|
||||
/// tap tempo measurements
|
||||
int frame;
|
||||
|
||||
int tapTempoPos;
|
||||
|
|
Loading…
Add table
Reference in a new issue