mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 17:11:40 -05:00
-Refactored LooperClip into own header
This commit is contained in:
parent
3f60cb52a6
commit
731e3c14c3
3 changed files with 72 additions and 84 deletions
|
@ -12,18 +12,7 @@
|
||||||
extern Jack* jack;
|
extern Jack* jack;
|
||||||
|
|
||||||
Looper::Looper(int t) :
|
Looper::Looper(int t) :
|
||||||
track(t),
|
track(t)
|
||||||
scene(0),
|
|
||||||
fpb(120),
|
|
||||||
gain(1.f),
|
|
||||||
numBeats (4),
|
|
||||||
playedBeats(0),
|
|
||||||
stopRecordOnBar(false),
|
|
||||||
endPoint (0),
|
|
||||||
lastWrittenSampleIndex(0),
|
|
||||||
playPoint (0),
|
|
||||||
uiUpdateConstant(44100/30),
|
|
||||||
uiUpdateCounter(44100/30)
|
|
||||||
{
|
{
|
||||||
// pre-zero the internal sample
|
// pre-zero the internal sample
|
||||||
tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE );
|
tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE );
|
||||||
|
@ -87,7 +76,7 @@ void Looper::midi(unsigned char* data)
|
||||||
void Looper::setScene( int sc )
|
void Looper::setScene( int sc )
|
||||||
{
|
{
|
||||||
// update Looper to play different scene
|
// update Looper to play different scene
|
||||||
scene = sc;
|
//scene = sc;
|
||||||
//sample = samples[scene];
|
//sample = samples[scene];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,69 +6,15 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "buffers.hxx"
|
#include "buffers.hxx"
|
||||||
|
|
||||||
#include "audioprocessor.hxx"
|
#include "audioprocessor.hxx"
|
||||||
|
|
||||||
|
#include "looperclip.hxx"
|
||||||
#include "observer/observer.hxx"
|
#include "observer/observer.hxx"
|
||||||
|
|
||||||
class AudioBuffer;
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/** LooperClip
|
|
||||||
* Represents each clip that a looper can playback. The core of the audio
|
|
||||||
* samples is stored in AudioBuffer objects which are dynamically resized. The
|
|
||||||
* base size of a AudioBuffer is 1 second's worth, after which larger buffers
|
|
||||||
* will be requested.
|
|
||||||
* The transition between AudioBuffer instances is seamless: when the clip is
|
|
||||||
* running out, the new one is requested. Upon its arrival the current data is
|
|
||||||
* copied, and the old buffer is returned for deallocation.
|
|
||||||
*
|
|
||||||
* This system allows for arbitrary length recordings, without huge
|
|
||||||
* pre-allocated buffers while it is still quite simple.
|
|
||||||
*
|
|
||||||
* Each clip has its properties like length and bars/beats, so the Looper knows
|
|
||||||
* to dynamically stretch / process the audio appropriately. Controllers and the
|
|
||||||
* UI are updated from this data.
|
|
||||||
**/
|
|
||||||
class LooperClip
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum State {
|
|
||||||
STATE_PLAYING = 0,
|
|
||||||
STATE_PLAY_QUEUED,
|
|
||||||
STATE_RECORDING,
|
|
||||||
STATE_RECORD_QUEUED,
|
|
||||||
STATE_STOPPED,
|
|
||||||
STATE_STOP_QUEUED,
|
|
||||||
};
|
|
||||||
|
|
||||||
LooperClip()
|
|
||||||
{
|
|
||||||
_loaded = false;
|
|
||||||
_buffer = 0;
|
|
||||||
_state = STATE_STOPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRequestedBuffer( AudioBuffer* ab )
|
|
||||||
{
|
|
||||||
// here we copy the data from the existing buffer into the new one,
|
|
||||||
// and send the old one away to be deallocated.
|
|
||||||
}
|
|
||||||
|
|
||||||
bool loaded(){return _loaded;}
|
|
||||||
State state(){return _state;}
|
|
||||||
|
|
||||||
// Set
|
|
||||||
void clipLength(int l){_clipLenght = l;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _loaded;
|
|
||||||
State _state;
|
|
||||||
AudioBuffer* _buffer;
|
|
||||||
|
|
||||||
// Clip Properties
|
|
||||||
int _clipLenght;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Looper
|
/** Looper
|
||||||
* The class which reads from LooperClips, and reads/ writes the data using the
|
* The class which reads from LooperClips, and reads/ writes the data using the
|
||||||
* track buffer. Scene recording / playback is the essential functionality here.
|
* track buffer. Scene recording / playback is the essential functionality here.
|
||||||
|
@ -76,8 +22,6 @@ class LooperClip
|
||||||
class Looper : public Observer, public AudioProcessor
|
class Looper : public Observer, public AudioProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
Looper(int t);
|
Looper(int t);
|
||||||
|
|
||||||
void setSample(int c, AudioBuffer* ab);
|
void setSample(int c, AudioBuffer* ab);
|
||||||
|
@ -87,7 +31,7 @@ class Looper : public Observer, public AudioProcessor
|
||||||
void bar();
|
void bar();
|
||||||
void beat();
|
void beat();
|
||||||
|
|
||||||
void setFpb(int f) { fpb = f; }
|
void setFpb(int f) { /*fpb = f;*/ }
|
||||||
|
|
||||||
void setScene( int sc );
|
void setScene( int sc );
|
||||||
//void setState( State s);
|
//void setState( State s);
|
||||||
|
@ -98,20 +42,11 @@ class Looper : public Observer, public AudioProcessor
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int track;
|
const int track;
|
||||||
//State state;
|
|
||||||
int scene;
|
|
||||||
|
|
||||||
int fpb;
|
|
||||||
float gain;
|
|
||||||
int numBeats;
|
|
||||||
int playedBeats;
|
|
||||||
bool stopRecordOnBar;
|
|
||||||
|
|
||||||
int endPoint, lastWrittenSampleIndex;
|
|
||||||
float playPoint;
|
|
||||||
float* sample;
|
|
||||||
float* tmpRecordBuffer;
|
float* tmpRecordBuffer;
|
||||||
|
|
||||||
|
LooperClip clips[10];
|
||||||
|
|
||||||
// Pitch Shifting
|
// Pitch Shifting
|
||||||
void pitchShift(int count, float* input, float* output);
|
void pitchShift(int count, float* input, float* output);
|
||||||
vector<float> tmpBuffer;
|
vector<float> tmpBuffer;
|
||||||
|
|
64
src/looperclip.hxx
Normal file
64
src/looperclip.hxx
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
|
||||||
|
#ifndef LUPPP_LOOPER_CLIP_H
|
||||||
|
#define LUPPP_LOOPER_CLIP_H
|
||||||
|
|
||||||
|
class AudioBuffer;
|
||||||
|
|
||||||
|
/** LooperClip
|
||||||
|
* Represents each clip that a looper can playback. The core of the audio
|
||||||
|
* samples is stored in AudioBuffer objects which are dynamically resized. The
|
||||||
|
* base size of a AudioBuffer is 1 second's worth, after which larger buffers
|
||||||
|
* will be requested.
|
||||||
|
* The transition between AudioBuffer instances is seamless: when the clip is
|
||||||
|
* running out, the new one is requested. Upon its arrival the current data is
|
||||||
|
* copied, and the old buffer is returned for deallocation.
|
||||||
|
*
|
||||||
|
* This system allows for arbitrary length recordings, without huge
|
||||||
|
* pre-allocated buffers while it is still quite simple.
|
||||||
|
*
|
||||||
|
* Each clip has its properties like length and bars/beats, so the Looper knows
|
||||||
|
* to dynamically stretch / process the audio appropriately. Controllers and the
|
||||||
|
* UI are updated from this data.
|
||||||
|
**/
|
||||||
|
class LooperClip
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum State {
|
||||||
|
STATE_PLAYING = 0,
|
||||||
|
STATE_PLAY_QUEUED,
|
||||||
|
STATE_RECORDING,
|
||||||
|
STATE_RECORD_QUEUED,
|
||||||
|
STATE_STOPPED,
|
||||||
|
STATE_STOP_QUEUED,
|
||||||
|
};
|
||||||
|
|
||||||
|
LooperClip()
|
||||||
|
{
|
||||||
|
_loaded = false;
|
||||||
|
_buffer = 0;
|
||||||
|
_state = STATE_STOPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRequestedBuffer( AudioBuffer* ab )
|
||||||
|
{
|
||||||
|
// here we copy the data from the existing buffer into the new one,
|
||||||
|
// and send the old one away to be deallocated.
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loaded(){return _loaded;}
|
||||||
|
State state(){return _state;}
|
||||||
|
|
||||||
|
// Set
|
||||||
|
void clipLength(int l){_clipLenght = l;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _loaded;
|
||||||
|
State _state;
|
||||||
|
AudioBuffer* _buffer;
|
||||||
|
|
||||||
|
// Clip Properties
|
||||||
|
int _clipLenght;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LUPPP_LOOPER_CLIP_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue