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
main
Gerald 2016-09-15 14:39:13 +02:00
parent 2531177223
commit 25560ed160
6 changed files with 33 additions and 10 deletions

View File

@ -23,7 +23,11 @@
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
{
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 );
writeToDspRingbuffer( &e );
}

View File

@ -107,7 +107,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
{
// copy data into tmpBuffer, then pitch-stretch into track buffer
long targetFrames = clips[clip]->getBeats() * fpb;
long actualFrames = clips[clip]->getBufferLenght();
long actualFrames = clips[clip]->getActualAudioLength();//getBufferLenght();
float playSpeed = 1.0;
if ( targetFrames != 0 && actualFrames != 0 )

View File

@ -259,7 +259,12 @@ int LooperClip::getBeats()
long LooperClip::getBufferLenght()
{
return _recordhead;
return _recordhead;
}
long LooperClip::getActualAudioLength()
{
return _buffer->getAudioFrames();
}
void LooperClip::bar()

View File

@ -76,7 +76,10 @@ class LooperClip : public Stately
/// get buffer details
int getBeats();
float getProgress();
//Return the length of the complete buffer
long getBufferLenght();
//Return the nr of samples holding actual audio. This is less then getBufferLength();
long getActualAudioLength();
size_t audioBufferSize();
/// set clip state

View File

@ -36,21 +36,32 @@ Metronome::Metronome() :
playPoint (0),
vol (1)
{
//Create Beat/Bar samples
beatSample=new float[jack->getSamplerate()];
barSample=new float[jack->getSamplerate()];
// create beat and bar samples
endPoint = ( jack->getSamplerate() / 441 );
endPoint = ( jack->getSamplerate()/10 );
// samples per cycle of
float scale = 2 * 3.1415 / endPoint;
float scale = 2 * 3.1415 *880/jack->getSamplerate();
// 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);
barSample [i]= sin(i*scale*1.5);
barSample [i]= sin(i*scale*2);
}
// don't play after creation
playPoint = endPoint + 1;
}
Metronome::~Metronome()
{
if(beatSample)
delete [] beatSample;
if(barSample)
delete [] barSample;
}
void Metronome::setActive(bool a)
{
active = a;

View File

@ -32,7 +32,7 @@ class Metronome : public TimeObserver
{
public:
Metronome();
~Metronome(){};
~Metronome();
void setActive(bool a);
@ -51,8 +51,8 @@ class Metronome : public TimeObserver
float vol;
int playPoint, endPoint;
float barSample[44100];
float beatSample[44100];
float* barSample;
float* beatSample;
};