Merge pull request #109 from geraldmwangi/master

Fixed the issue: Loosing sync after N Beats, and some more stuff. Huge thanks @geraldmwangi, appreciate the contribution, its a good fix :)
This commit is contained in:
Harry van Haaren 2016-09-19 18:31:04 +01:00 committed by GitHub
commit daa852b071
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

@ -262,6 +262,11 @@ long LooperClip::getBufferLenght()
return _recordhead;
}
long LooperClip::getActualAudioLength()
{
return _buffer->getAudioFrames();
}
void LooperClip::bar()
{
bool change = false;

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;
};