Skip to content

Instantly share code, notes, and snippets.

@pingdynasty
Created June 16, 2015 15:36
Show Gist options
  • Save pingdynasty/3e0564397b6a470bbbb9 to your computer and use it in GitHub Desktop.
Save pingdynasty/3e0564397b6a470bbbb9 to your computer and use it in GitHub Desktop.
OWL Patch API changes
class FloatArray {
private:
float* data;
int sz;
public:
FloatArray(float* d, int s) :
data(d), sz(s) {}
int size(){
return sz;
}
float getMinValue();
float getMaxValue();
int getMinIndex();
int getMaxIndex();
float getPeakValue();
int getPeakIndex();
float getDb();
void reverse();
void rectify();
float& operator [](const int index){
return data[index];
}
operator float*() {
return data;
}
};
class AudioBuffer {
public:
virtual ~AudioBuffer();
virtual FloatArray getSamples(int channel) = 0;
virtual int getChannels() = 0;
virtual int getSize() = 0;
virtual void clear() = 0;
};
struct ComplexNumber {
float re;
float im;
};
class ComplexArray {
private:
ComplexNumber* data;
int sz;
public:
ComplexNumber(ComplexNumber* d, int s) :
data(d), sz(s) {}
float re(const int i){
return data[i].re;
}
float im(const int i){
return data[i].im;
}
float mag(const int i){
return sqrtf(data[i].re*data[i].re + data[i].im*data[i].im);
}
int size(){
return sz;
}
float getPeakMagnitudeValue();
int getPeakMagnitudeIndex();
void getMagnitudeValues(FloatArray& buf);
ComplexNumber& operator [](const int i){
return data[i];
}
operator ComplexNumber*() {
return data;
}
};
class Patch {
public:
Patch();
virtual ~Patch();
void registerParameter(PatchParameterId pid, const char* name, const char* description = "");
float getParameterValue(PatchParameterId pid);
bool isButtonPressed(PatchButtonId bid);
void setButton(PatchButtonId bid, bool pressed);
int getBlockSize();
double getSampleRate();
AudioBuffer* createMemoryBuffer(int channels, int samples);
FloatArray createFloatArray(int size);
ComplexArray createComplexArray(int size);
virtual void processAudio(AudioBuffer& output) = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment