mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Debugging looper progress, algorithm not working right yet
This commit is contained in:
parent
a55800115e
commit
c7dac28706
2 changed files with 28 additions and 9 deletions
|
@ -28,15 +28,21 @@ void Looper::process(int nframes, Buffers* buffers)
|
||||||
{
|
{
|
||||||
if ( playPoint < endPoint )
|
if ( playPoint < endPoint )
|
||||||
{
|
{
|
||||||
out[i] += sample[playPoint++];
|
out[i] += sample[playPoint];
|
||||||
}
|
}
|
||||||
|
// always update playPoint, even when not playing sound.
|
||||||
|
// it updates the UI of progress
|
||||||
|
playPoint++;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventLooperProgress e(track, float(playPoint) / endPoint );
|
float prog = (float(playPoint) / fpb * numBeats);
|
||||||
|
if ( track == 0 )
|
||||||
|
cout << prog << " fpb*numBeats " << fpb * numBeats << endl;
|
||||||
|
EventLooperProgress e(track, prog );
|
||||||
writeToGuiRingbuffer( &e );
|
writeToGuiRingbuffer( &e );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( state == STATE_RECORDING )
|
else if ( state == STATE_RECORDING || stopRecordOnBar )
|
||||||
{
|
{
|
||||||
for(int i = 0; i < nframes; i++)
|
for(int i = 0; i < nframes; i++)
|
||||||
{
|
{
|
||||||
|
@ -51,12 +57,11 @@ void Looper::process(int nframes, Buffers* buffers)
|
||||||
|
|
||||||
void Looper::bar()
|
void Looper::bar()
|
||||||
{
|
{
|
||||||
// only reset if we're on the last beat of a loop
|
stopRecordOnBar = false;
|
||||||
if ( playedBeats >= numBeats )
|
|
||||||
|
if ( state == STATE_RECORDING )
|
||||||
{
|
{
|
||||||
//cout << "Looper " << track << " restting to 0 " << endl;
|
stopRecordOnBar = true;
|
||||||
playPoint = 0;
|
|
||||||
playedBeats = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( state == STATE_PLAY_QUEUED )
|
if ( state == STATE_PLAY_QUEUED )
|
||||||
|
@ -87,6 +92,18 @@ void Looper::bar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Looper::beat()
|
||||||
|
{
|
||||||
|
playedBeats++; // only reset if we're on the last beat of a loop
|
||||||
|
|
||||||
|
if ( playedBeats >= numBeats )
|
||||||
|
{
|
||||||
|
//cout << "Looper " << track << " restting to 0 " << endl;
|
||||||
|
playPoint = 0;
|
||||||
|
playedBeats = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Looper::setLoopLength(float l)
|
void Looper::setLoopLength(float l)
|
||||||
{
|
{
|
||||||
numBeats *= l;
|
numBeats *= l;
|
||||||
|
|
|
@ -26,14 +26,15 @@ class Looper : public Observer // for notifications
|
||||||
state(STATE_STOPPED),
|
state(STATE_STOPPED),
|
||||||
numBeats (4),
|
numBeats (4),
|
||||||
playedBeats(0),
|
playedBeats(0),
|
||||||
|
stopRecordOnBar(false),
|
||||||
endPoint (0),
|
endPoint (0),
|
||||||
playPoint (0),
|
playPoint (0),
|
||||||
lastWrittenSampleIndex(0)
|
lastWrittenSampleIndex(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void bar();
|
void bar();
|
||||||
|
void beat();
|
||||||
|
|
||||||
void beat() { playedBeats++; }
|
|
||||||
void setFpb(int f) { fpb = f; }
|
void setFpb(int f) { fpb = f; }
|
||||||
|
|
||||||
void setState(State s);
|
void setState(State s);
|
||||||
|
@ -48,6 +49,7 @@ class Looper : public Observer // for notifications
|
||||||
int fpb;
|
int fpb;
|
||||||
int numBeats;
|
int numBeats;
|
||||||
int playedBeats;
|
int playedBeats;
|
||||||
|
bool stopRecordOnBar;
|
||||||
|
|
||||||
int endPoint, playPoint, lastWrittenSampleIndex;
|
int endPoint, playPoint, lastWrittenSampleIndex;
|
||||||
float sample[44100*60];
|
float sample[44100*60];
|
||||||
|
|
Loading…
Add table
Reference in a new issue