| #define Audio_h_ | #define Audio_h_ | ||||
| #if TEENSYDUINO < 120 | #if TEENSYDUINO < 120 | ||||
| #error "Teensyduino version 1.20 or later is required to compile the Audio library" | |||||
| #error "Teensyduino version 1.20 or later is required to compile the Audio library." | |||||
| #endif | |||||
| #ifdef __AVR__ | |||||
| #error "The Audio Library only works with Teensy 3.X. Teensy 2.0 is unsupported." | |||||
| #endif | #endif | ||||
| // When changing multiple audio object settings that must update at | // When changing multiple audio object settings that must update at | ||||
| #include "synth_whitenoise.h" | #include "synth_whitenoise.h" | ||||
| #include "synth_pinknoise.h" | #include "synth_pinknoise.h" | ||||
| // TODO: more audio processing objects.... | |||||
| // waveforms with bandwidth limited tables for synth | |||||
| #endif | #endif |
| release(block); | release(block); | ||||
| } | } | ||||
| uint16_t AudioSynthNoiseWhite::instance_count = 0; | |||||
| class AudioSynthNoiseWhite : public AudioStream | class AudioSynthNoiseWhite : public AudioStream | ||||
| { | { | ||||
| public: | public: | ||||
| AudioSynthNoiseWhite() : AudioStream(0, NULL), level(0), seed(1) {} | |||||
| AudioSynthNoiseWhite() : AudioStream(0, NULL) { | |||||
| level = 0; | |||||
| seed = 1 + instance_count++; | |||||
| } | |||||
| void amplitude(float n) { | void amplitude(float n) { | ||||
| if (n < 0.0) n = 0.0; | if (n < 0.0) n = 0.0; | ||||
| else if (n > 1.0) n = 1.0; | else if (n > 1.0) n = 1.0; | ||||
| private: | private: | ||||
| int32_t level; // 0=off, 65536=max | int32_t level; // 0=off, 65536=max | ||||
| uint32_t seed; // must start at 1 | uint32_t seed; // must start at 1 | ||||
| static uint16_t instance_count; | |||||
| }; | }; | ||||
| #endif | #endif |