3#include "AudioTools/CoreAudio/AudioEffects/AudioEffect.h"
4#include "AudioTools/CoreAudio/AudioStreams.h"
5#include "AudioToolsConfig.h"
8#include "freertos/FreeRTOS.h"
34template <
class StkCls=stk::Generator,
class T=
int16_t>
41 this->p_instrument = &instrument;
44 void setInput(StkCls& instrument) { this->p_instrument = &instrument; }
68 if (p_instrument !=
nullptr) {
69 result = p_instrument->tick() * max_value;
75 StkCls* p_instrument =
nullptr;
83template <
class StkCls=stk::Instrmnt,
class T=
int16_t>
92 this->p_instrument->noteOn(frequency, amplitude);
95 void noteOn(
float freq,
float vol) { this->p_instrument->noteOn(freq, vol); }
97 void noteOff() { this->p_instrument->noteOff(); }
101 this->amplitude = amplitude;
102 if (this->amplitude > 1.0) this->amplitude = 1.0;
103 if (this->amplitude < 0.0) this->amplitude = 0.0;
107 float amplitude = 1.0;
114template <
class StkCls>
120 generator.setInput(instrument);
123 void setInput(StkCls& instrument) {
124 generator.setInput(instrument);
127 void setInput(StkCls* instrument) {
128 generator.setInput(*instrument);
154 STKEffect(stk::Effect& stkEffect) { p_effect = &stkEffect; }
158 float value =
static_cast<float>(in) / 32767.0;
159 return p_effect->tick(value) * 32767.0;
163 stk::Effect* p_effect =
nullptr;
174 STKChorus(
float baseDelay = 6000) : stk::Chorus(baseDelay) {}
181 float value =
static_cast<float>(in) / 32767.0;
182 return stk::Chorus::tick(value) * 32767.0;
194 STKEcho(
unsigned long maximumDelay = (
unsigned long)Stk::sampleRate())
195 : stk::Echo(maximumDelay) {}
202 float value =
static_cast<float>(in) / 32767.0;
203 return stk::Echo::tick(value) * 32767.0;
220 float value =
static_cast<float>(in) / 32767.0;
221 return stk::FreeVerb::tick(value) * 32767.0;
239 float value =
static_cast<float>(in) / 32767.0;
240 return stk::JCRev::tick(value) * 32767.0;
257 float value =
static_cast<float>(in) / 32767.0;
258 return stk::NRev::tick(value) * 32767.0;
275 float value =
static_cast<float>(in) / 32767.0;
276 return stk::PRCRev::tick(value) * 32767.0;
289 : stk::LentPitShift(periodRatio, tMax) {}
295 float value =
static_cast<float>(in) / 32767.0;
296 return stk::LentPitShift::tick(value) * 32767.0;
315 float value =
static_cast<float>(in) / 32767.0;
316 return stk::PitShift::tick(value) * 32767.0;