diff --git a/src/looper.cxx b/src/looper.cxx index b093509..daa4272 100644 --- a/src/looper.cxx +++ b/src/looper.cxx @@ -12,18 +12,7 @@ extern Jack* jack; Looper::Looper(int 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) + track(t) { // pre-zero the internal sample tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE ); @@ -87,7 +76,7 @@ void Looper::midi(unsigned char* data) void Looper::setScene( int sc ) { // update Looper to play different scene - scene = sc; + //scene = sc; //sample = samples[scene]; } diff --git a/src/looper.hxx b/src/looper.hxx index dba3ffe..d57b862 100644 --- a/src/looper.hxx +++ b/src/looper.hxx @@ -6,69 +6,15 @@ #include #include "buffers.hxx" + #include "audioprocessor.hxx" + +#include "looperclip.hxx" #include "observer/observer.hxx" -class AudioBuffer; 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 * The class which reads from LooperClips, and reads/ writes the data using the * track buffer. Scene recording / playback is the essential functionality here. @@ -76,8 +22,6 @@ class LooperClip class Looper : public Observer, public AudioProcessor { public: - - Looper(int t); void setSample(int c, AudioBuffer* ab); @@ -87,7 +31,7 @@ class Looper : public Observer, public AudioProcessor void bar(); void beat(); - void setFpb(int f) { fpb = f; } + void setFpb(int f) { /*fpb = f;*/ } void setScene( int sc ); //void setState( State s); @@ -98,20 +42,11 @@ class Looper : public Observer, public AudioProcessor private: 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; + LooperClip clips[10]; + // Pitch Shifting void pitchShift(int count, float* input, float* output); vector tmpBuffer; diff --git a/src/looperclip.hxx b/src/looperclip.hxx new file mode 100644 index 0000000..3c9979e --- /dev/null +++ b/src/looperclip.hxx @@ -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 +