/* * Thin C++ wrapper around the C library */ #ifndef GUTTERSYNTH_HPP #define GUTTERSYNTH_HPP #include "guttersynth.h" #include #include class GutterSynth { protected: gutter_state* s; public: GutterSynth(int bankCount, int filterCount, int samplerate) { s = gutter_init(bankCount, filterCount, samplerate); } GutterSynth(int bankCount, int filterCount, int samplerate, void* (*allocator)(size_t), void (*deallocator)(void*) ) { s = gutter_init_ca(bankCount, filterCount, samplerate, allocator, deallocator); } ~GutterSynth() { gutter_cleanup(s); } // simple accessors FLT gamma() { return s->gamma; } void gamma(FLT value) { s->gamma = value; } FLT omega() { return s->omega; } void omega(FLT value) { s->omega = value; } FLT c() { return s->c; } void c(FLT value) { s->c = value; } FLT dt() { return s->dt; } void dt(FLT value) { s->dt = value; } FLT singleGain() { return s->singleGain; } void singleGain(FLT value) { s->singleGain = value; } int filterCount() { return s->filterCount; } int bankCount() { return s->bankCount; } bool enableAudioInput() { return bool(s->enableAudioInput); } void enableAudioInput(bool value) { s->enableAudioInput = int(value); } bool filtersOn() { return bool(s->filtersOn); } void filtersOn(bool value) { s->filtersOn = int(value); } int smoothing() { return s->smoothing; } void smoothing(int smoothing) { s->smoothing = smoothing; } int distortionMethod() { return s->distortionMethod; } void distortionMethod(int method) { int result = gutter_setdistortionmethod(s, method); if (result != 0) { throw std::invalid_argument("Filter out of range"); } } void randomiseFilters() { gutter_randomisefilters(s); } void calcCoeffs() { gutter_calccoeffs(s); } void setFreq(int bank, int filter, FLT value, bool recalculate=true) { int result = gutter_setfreq(s, bank, filter, value); if (result != 0) { throw std::invalid_argument("Filter out of range"); } if (recalculate) { calcCoeffs(); } } void setQ(int bank, int filter, FLT value, bool recalculate=true) { int result = gutter_setq(s, bank, filter, value); if (result != 0) { throw std::invalid_argument("Filter out of range"); } if (recalculate) { calcCoeffs(); } } void setQ(FLT value, bool recalculate=true) { gutter_setqall(s, value); if (recalculate) { calcCoeffs(); } } void setGain(int bank, int filter, FLT value, bool recalculate=true) { int result = gutter_setgain(s, bank, filter, value); if (result != 0) { throw std::invalid_argument("Filter out of range"); } if (recalculate) { calcCoeffs(); } } void reset() { gutter_reset(s); } // process audio members FLT process() { return gutter_process(s); } FLT process(FLT audioInput) { return gutter_process_input(s, audioInput); } void process(FLT* audioOutput, int nsamps) { gutter_process_samples(s, audioOutput, nsamps); } void process(FLT* audioInput, FLT* audioOutput, int nsamps) { gutter_process_input_samples(s, audioInput, audioOutput, nsamps); } }; #endif /* GUTTERSYNTH_HPP */