Fixed the issue: Loosing sync after N Beats, found and fixed issue with
metronome dial (integeger numbers where getting translated to fraktional floats in setBpm()), needs more testing
This commit is contained in:
parent
2531177223
commit
25560ed160
6 changed files with 33 additions and 10 deletions
|
@ -23,7 +23,11 @@
|
||||||
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
||||||
{
|
{
|
||||||
Avtk::Dial* b = (Avtk::Dial*)w;
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
||||||
float bpm = b->value() * 160.f + 60;
|
float bpm = (int)(b->value() * 160.f + 60);
|
||||||
|
if(std::fabs(bpm-round(bpm)))
|
||||||
|
{
|
||||||
|
LUPPP_WARN("%f",bpm);
|
||||||
|
}
|
||||||
EventTimeBPM e = EventTimeBPM( bpm );
|
EventTimeBPM e = EventTimeBPM( bpm );
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
|
||||||
{
|
{
|
||||||
// copy data into tmpBuffer, then pitch-stretch into track buffer
|
// copy data into tmpBuffer, then pitch-stretch into track buffer
|
||||||
long targetFrames = clips[clip]->getBeats() * fpb;
|
long targetFrames = clips[clip]->getBeats() * fpb;
|
||||||
long actualFrames = clips[clip]->getBufferLenght();
|
long actualFrames = clips[clip]->getActualAudioLength();//getBufferLenght();
|
||||||
float playSpeed = 1.0;
|
float playSpeed = 1.0;
|
||||||
|
|
||||||
if ( targetFrames != 0 && actualFrames != 0 )
|
if ( targetFrames != 0 && actualFrames != 0 )
|
||||||
|
|
|
@ -259,7 +259,12 @@ int LooperClip::getBeats()
|
||||||
|
|
||||||
long LooperClip::getBufferLenght()
|
long LooperClip::getBufferLenght()
|
||||||
{
|
{
|
||||||
return _recordhead;
|
return _recordhead;
|
||||||
|
}
|
||||||
|
|
||||||
|
long LooperClip::getActualAudioLength()
|
||||||
|
{
|
||||||
|
return _buffer->getAudioFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LooperClip::bar()
|
void LooperClip::bar()
|
||||||
|
|
|
@ -76,7 +76,10 @@ class LooperClip : public Stately
|
||||||
/// get buffer details
|
/// get buffer details
|
||||||
int getBeats();
|
int getBeats();
|
||||||
float getProgress();
|
float getProgress();
|
||||||
|
//Return the length of the complete buffer
|
||||||
long getBufferLenght();
|
long getBufferLenght();
|
||||||
|
//Return the nr of samples holding actual audio. This is less then getBufferLength();
|
||||||
|
long getActualAudioLength();
|
||||||
size_t audioBufferSize();
|
size_t audioBufferSize();
|
||||||
|
|
||||||
/// set clip state
|
/// set clip state
|
||||||
|
|
|
@ -36,21 +36,32 @@ Metronome::Metronome() :
|
||||||
playPoint (0),
|
playPoint (0),
|
||||||
vol (1)
|
vol (1)
|
||||||
{
|
{
|
||||||
|
//Create Beat/Bar samples
|
||||||
|
beatSample=new float[jack->getSamplerate()];
|
||||||
|
barSample=new float[jack->getSamplerate()];
|
||||||
// create beat and bar samples
|
// create beat and bar samples
|
||||||
endPoint = ( jack->getSamplerate() / 441 );
|
endPoint = ( jack->getSamplerate()/10 );
|
||||||
// samples per cycle of
|
// samples per cycle of
|
||||||
float scale = 2 * 3.1415 / endPoint;
|
float scale = 2 * 3.1415 *880/jack->getSamplerate();
|
||||||
|
|
||||||
// And fill it up
|
// And fill it up
|
||||||
for(int i=0;i < endPoint*40;i++){
|
for(int i=0;i < jack->getSamplerate();i++){
|
||||||
beatSample[i]= sin(i*scale);
|
beatSample[i]= sin(i*scale);
|
||||||
barSample [i]= sin(i*scale*1.5);
|
barSample [i]= sin(i*scale*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't play after creation
|
// don't play after creation
|
||||||
playPoint = endPoint + 1;
|
playPoint = endPoint + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Metronome::~Metronome()
|
||||||
|
{
|
||||||
|
if(beatSample)
|
||||||
|
delete [] beatSample;
|
||||||
|
if(barSample)
|
||||||
|
delete [] barSample;
|
||||||
|
}
|
||||||
|
|
||||||
void Metronome::setActive(bool a)
|
void Metronome::setActive(bool a)
|
||||||
{
|
{
|
||||||
active = a;
|
active = a;
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Metronome : public TimeObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Metronome();
|
Metronome();
|
||||||
~Metronome(){};
|
~Metronome();
|
||||||
|
|
||||||
void setActive(bool a);
|
void setActive(bool a);
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ class Metronome : public TimeObserver
|
||||||
float vol;
|
float vol;
|
||||||
|
|
||||||
int playPoint, endPoint;
|
int playPoint, endPoint;
|
||||||
float barSample[44100];
|
float* barSample;
|
||||||
float beatSample[44100];
|
float* beatSample;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue