├── hard ├── minitrash.fpd └── BOM.md ├── README.md └── soft ├── libraries └── Audio │ ├── control_wm8731.h │ ├── synth_fm_drum.h │ ├── control_wm8731.cpp │ ├── synth_fm_drum.cpp │ └── synth_drum_data.c ├── minitrash_spi_ram_test └── minitrash_spi_ram_test.ino └── mini-codec-record-test └── mini-codec-record-test.ino /hard/minitrash.fpd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mxmxmx/minitrash/HEAD/hard/minitrash.fpd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minitrash 2 | 3 | ### 6HP teensy 3.1 / wm8731 codec thingie. 4 | 5 | ![My image](https://c2.staticflickr.com/2/1634/24267153383_4128cd6da1_c.jpg) 6 | 7 | - still deliberating a proper name. pjrc audio adapter compatible eurorack module. 8 | ``` 9 | - stereo i/o : 10 VPP; 44.1k / 16 bit (when using pjrc audio lib) 10 | - 2 x ADC; buffered, range: +/- 5V 11 | - 4 x pots 12 | - 2 x digital inputs; treshold is ~ 2.5V; up to 12V/15V 13 | - 2 x illum. tact switches 14 | - microSD card socket 15 | - ext. SPI flash (w25 / soic 8) or SPI SRAM (23LC1024) 16 | - depth: ~ 40mm 17 | ``` 18 | - find the BOM [here](https://github.com/mxmxmx/minitrash/blob/master/hard/BOM.md) 19 | / preliminary build guide: [here](https://github.com/mxmxmx/minitrash/wiki/Building-it) 20 | 21 | - two simple examples (recorder, delay using external 1Mbit SRAM) can be found [here](https://github.com/mxmxmx/minitrash/tree/master/soft) 22 | 23 | - pinout is identical to pjrc audio adapter; being a module, the thing also has: 24 | ``` 25 | - 4x pots < > pins A10, A11, A7, A6 26 | - 2x CV in < > pins A1, A2 27 | - 2x clk in < > pins 0, 3 28 | - 2x switches < > pins 1, 4 29 | - 2x LEDs < > pins 2, 5 30 | ``` 31 | -------------------------------------------------------------------------------- /soft/libraries/Audio/control_wm8731.h: -------------------------------------------------------------------------------- 1 | /* Audio Library for Teensy 3.X 2 | * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com 3 | * 4 | * Development of this audio library was funded by PJRC.COM, LLC by sales of 5 | * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop 6 | * open source software by purchasing Teensy or other PJRC products. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice, development funding notice, and this permission 16 | * notice shall be included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef control_wm8731_h_ 28 | #define control_wm8731_h_ 29 | 30 | #include "AudioControl.h" 31 | 32 | class AudioControlWM8731 : public AudioControl 33 | { 34 | public: 35 | bool enable(void); 36 | bool disable(void) { return false; } 37 | bool volume(float n) { return volumeInteger(n * 80.0 + 47.499); } 38 | bool inputLevel(float n); // range 0.0f -1.0f 39 | bool inputSelect(int n) { return false; } 40 | protected: 41 | bool write(unsigned int reg, unsigned int val); 42 | bool volumeInteger(unsigned int n); // range: 0x2F to 0x7F 43 | }; 44 | 45 | class AudioControlWM8731master : public AudioControlWM8731 46 | { 47 | public: 48 | bool enable(void); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /soft/minitrash_spi_ram_test/minitrash_spi_ram_test.ino: -------------------------------------------------------------------------------- 1 | // test for spi ram . based on paul stoffregen's example -- 2 | // https://forum.pjrc.com/threads/29276-Limits-of-delay-effect-in-audio-library 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | AudioInputI2S i2s_ADC; 12 | AudioEffectEnvelope env; 13 | AudioEffectDelayExternal dly1(AUDIO_MEMORY_23LC1024, 570); 14 | AudioEffectDelayExternal dly2(AUDIO_MEMORY_23LC1024, 570); 15 | AudioMixer4 mix; 16 | AudioOutputI2S i2s_DAC; 17 | 18 | AudioConnection patchCord1(i2s_ADC, env); 19 | AudioConnection patchCord2(env, dly1); 20 | AudioConnection patchCord3(env, dly2); 21 | AudioConnection patchCord4(dly1, 0, mix, 0); 22 | AudioConnection patchCord5(dly2, 0, mix, 1); 23 | AudioConnection patchCord6(env, 0, mix, 2); 24 | AudioConnection patchCord7(mix, 0, i2s_DAC, 0); 25 | AudioConnection patchCord8(mix, 0, i2s_DAC, 1); 26 | 27 | AudioControlWM8731 wm8731; 28 | 29 | const int audio_Input = AUDIO_INPUT_LINEIN; 30 | 31 | #define CS_MEM 6 32 | #define CS_SD 10 33 | 34 | #define SDCARD_MOSI_PIN 7 35 | #define SDCARD_SCK_PIN 14 36 | 37 | #define POT1 A10 38 | #define POT2 A11 39 | 40 | // remaining i/o, unused here: 41 | /* 42 | #define POT3 A7 43 | #define POT4 A6 44 | 45 | #define CV1 A1 46 | #define CV2 A2 47 | 48 | #define CLK1 0 49 | #define CLK2 3 50 | 51 | #define SW1 1 52 | #define SW2 4 53 | 54 | #define LED1 2 55 | #define LED2 5 56 | */ 57 | 58 | IntervalTimer ADC_timer; 59 | volatile uint16_t _ADC; 60 | 61 | void ADC_Callback() 62 | { 63 | _ADC = true; 64 | } 65 | 66 | void setup() { 67 | 68 | AudioMemory(10); 69 | 70 | wm8731.enable(); 71 | wm8731.inputSelect(audio_Input); // not doing anything 72 | wm8731.inputLevel(0.9f); // 0.0 - 1.0 73 | wm8731.volume(0.7f); 74 | 75 | SPI.setMOSI(SDCARD_MOSI_PIN); 76 | SPI.setSCK(SDCARD_SCK_PIN); 77 | 78 | pinMode(CS_MEM, OUTPUT); 79 | digitalWrite(CS_MEM, HIGH); 80 | 81 | pinMode(CS_SD, OUTPUT); 82 | digitalWrite(CS_SD, HIGH); 83 | 84 | ADC_timer.begin(ADC_Callback, 5000); 85 | } 86 | 87 | void loop() { 88 | 89 | if (_ADC) { 90 | _ADC = false; 91 | uint16_t p1 = analogRead(POT1); 92 | uint16_t p2 = analogRead(POT2); 93 | dly1.delay(0, p1+2); 94 | dly2.delay(0, p2+2); 95 | } 96 | env.noteOn(); 97 | delay(50); 98 | env.noteOff(); 99 | delay(1000); 100 | 101 | } 102 | -------------------------------------------------------------------------------- /soft/libraries/Audio/synth_fm_drum.h: -------------------------------------------------------------------------------- 1 | /* Audio Library for Teensy 3.X 2 | * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com 3 | * 4 | * Development of this audio library was funded by PJRC.COM, LLC by sales of 5 | * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop 6 | * open source software by purchasing Teensy or other PJRC products. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice, development funding notice, and this permission 16 | * notice shall be included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef synth_fm_drum_h_ 28 | #define synth_fm_drum_h_ 29 | #include "AudioStream.h" 30 | #include "utility/dspinst.h" 31 | 32 | 33 | class AudioSynthFMDrum : public AudioStream 34 | { 35 | public: 36 | AudioSynthFMDrum() : AudioStream(1, inputQueueArray), magnitude(16384) {} 37 | 38 | void frequency(uint16_t frequency) { 39 | 40 | if (frequency <= 16384) { 41 | aux_envelope_strength_ = 1024; 42 | } 43 | else if (frequency <= 32768) { 44 | aux_envelope_strength_ = 2048 - (frequency >> 4); 45 | } else { 46 | aux_envelope_strength_ = 0; 47 | } 48 | frequency_ = (24 << 7) + ((72 << 7) * frequency >> 16); 49 | } 50 | void morph(uint16_t x, uint16_t y); 51 | void fm_amount(uint16_t _fm_a) { 52 | fm_amount_ = _fm_a >> 2; 53 | } 54 | void decay(uint16_t decay) { 55 | am_decay_ = 16384 + (decay >> 1); 56 | fm_decay_ = 8192 + (decay >> 2); 57 | } 58 | void set_noise(uint16_t noise) { 59 | uint32_t n = noise; 60 | noise_ = noise >= 32768 ? ((n - 32768) * (n - 32768) >> 15) : 0; 61 | noise_ = (noise_ >> 2) * 5; 62 | overdrive_ = noise <= 32767 ? ((32767 - n) * (32767 - n) >> 14) : 0; 63 | }; 64 | virtual void update(void); 65 | void init(uint8_t clock_pin); 66 | private: 67 | 68 | inline uint16_t Interpolate824(const uint16_t* table, uint32_t phase); 69 | inline int16_t Interpolate1022(const int16_t* table, uint32_t phase); 70 | inline int16_t Mix(int16_t a, int16_t b, uint16_t balance); 71 | uint32_t ComputeEnvelopeIncrement(uint16_t decay); 72 | uint32_t ComputePhaseIncrement(int16_t midi_pitch); 73 | audio_block_t *inputQueueArray[1]; 74 | uint8_t sd_range_; 75 | int32_t magnitude; 76 | uint8_t _clk; 77 | uint8_t _prev_clk; 78 | uint16_t frequency_; 79 | uint16_t fm_amount_; 80 | uint16_t am_decay_; 81 | uint16_t fm_decay_; 82 | uint32_t noise_; 83 | uint32_t overdrive_; 84 | uint16_t aux_envelope_strength_; 85 | int16_t previous_sample_; 86 | uint32_t phase_; 87 | uint32_t fm_envelope_phase_; 88 | uint32_t am_envelope_phase_; 89 | uint32_t aux_envelope_phase_; 90 | uint32_t phase_increment_; 91 | }; 92 | 93 | #endif -------------------------------------------------------------------------------- /hard/BOM.md: -------------------------------------------------------------------------------- 1 | 2 | BOM --- minitrash 3 | ================= 4 | 5 | 6 | 7 | A. core pcb: 8 | ================= 9 | 10 | 11 | ICs/regulators/etc: 12 | 13 | - wm8731 (SSOP 28) : 1 x (mouser # 238-WM8731SEDS/V) 14 | - TL072 (SOIC-8): 3 x (or use something fancier for audio i/o; in which case: 1 x TL072 + 2 x something fancier) 15 | - ADP150 (3v3 regulator, TSOT): 1 x (mouser # 584-ADP150AUJZ-3.3R7) 16 | - SM5817 diodes : 2 x (mouser # 833-SM5817PL-TP) 17 | - LM1117-50 (5v0 LDO reg., SOT-223): 1 x (mouser # 511-LD1117S50) 18 | - lm4040-5v0 (sot-23) : 1 x 19 | - teensy3.1 : 1 x (don't forget to cut the usb/power trace) 20 | 21 | resistors (0603): 22 | 23 | - 100R : 2 x 24 | - 120R : 2 x 25 | - 510R : 1 x 26 | - 910R : 2 x 27 | - 1k : 2 x 28 | - 4k7 : 2 x 29 | - 5k6 : 2 x 30 | - 27k : 4 x 31 | - 30k : 1 x (††) 32 | - 33k : 2 x (*) 33 | - 47k : 3 x (††) 34 | - 100k : 6 x (*) 35 | 36 | caps, SMD: 37 | 38 | - 15p (NP0/C0G): 2 x (0603) 39 | - 10n (NP0/C0G): 2 x (0805 or 1206) 40 | - 68n (NP0/C0G): 2 x (0805) 41 | - 100n : 22 x (0603) 42 | - 10uF : 5 x (0805) (ceramic or tantalum) 43 | 44 | 45 | electrolytic caps, through-hole: 46 | 47 | - 22uF (35V or better): 2 x (power decoupling) 48 | - 10uF (16V or better): 2 x (in audio path/AC coupling) 49 | 50 | 51 | misc: 52 | 53 | - 2x5 pin pin header (euro power connector): 1 x 54 | - 3-pin single row precision ("machined" / "round") socket (female), RM 2.54mm : 1 x 55 | - 5-pin single row precision ("machined" / "round") socket (female), RM 2.54mm : 2 x 56 | - 10-pin single row precision ("machined" / "round") socket (female), RM 2.54mm : 1 x 57 | - 14-pin single row precision ("machined" / "round") socket (female), RM 2.54mm : 2 x 58 | - 3-pin single row precision ("machined" / "round") pin header (male), RM 2.54mm : 1 x 59 | - 14-pin single row precision ("machined" / "round") pin headers (male), RM 2.54mm : 2 x 60 | 61 | 62 | optional: 63 | 64 | - microSD socket (molex) : 1 x (# 502774-0891, mouser # 538-502774-0891) 65 | - SOIC-8 spi flash (W25), e.g. winbond W25Q128FV. 66 | - alternatively, SOIC-8 spi RAM, notably microchip 23LC1024, does fit, too. 67 | - lm4040-2v5 or lm4040-3v0 (sot-23, for teensy 3.x AREF) (NB: in this case, some resistor values need adjustment. see note below) 68 | 69 | 70 | B. control pcb: 71 | ================= 72 | 73 | - NPN transistors (MMBT3904, SOT-23) : 2 x 74 | 75 | 0603 resistors: 76 | 77 | - 0R : 1 x (or use piece of wire) 78 | - 470R : 2 x (adust, depending on LED) 79 | - 510R : 2 x (or use 470R, value is non-critical) 80 | - 33k : 2 x (may be 0805) 81 | - 100k : 2 x (may be 0805) 82 | 83 | 0603 caps: 84 | 85 | - 100n : 2 x 86 | 87 | 0805 caps: 88 | 89 | - 1uF : 4 x (may be 1206) 90 | 91 | misc: 92 | 93 | - 1k-10k 9mm pots, vertical "tall trimmer" / song huei : 4 x 94 | - jacks, thonkiconn : 8 x 95 | - tact switches, illuminated - recommended is e-switch TL1265 series: 2 x (†) 96 | - M3 spacer/standoff 10mm : 1 x 97 | - M3 screws, 5mm : 2 x 98 | - 5-pin single row precision ("machined" / "round") pin headers (male), RM 2.54mm : 2 x 99 | - 10-pin single row precision ("machined" / "round") pin headers (male), RM 2.54mm : 1 x 100 | 101 | notes: 102 | ================= 103 | 104 | ( * ) if using a LM4040 for AREF, the CV range needs adjustment. for instance, when using a lm4040-3v0, the effective range reduces to 0 - 3v0. to compensate, use 110k resistors instead. the CV inputs are inverting op amps, so 33/110 * 10V = 3.0V; ditto for lm4040-2v5 -- in this case, 30k and 120k would get you there (30/120 * 10V = 2.5V) 105 | 106 | ( † ) e.g. mouser # 612-TL1265YQSCLR (yellow), 612-TL1265BQSCLR (blue), 612-TL1265RQSCLR (red), 612-TL1265GQSCLR (green); if illumination isn't a must, any 5x5 (ish) switch should do. e.g. TL1105SPF250Q (+ caps) 107 | 108 | (††) used for voltage divider / V_bias (NB: labelled 10k* on the silkscreen -- use 47k/30k instead (see build doc)) 109 | -------------------------------------------------------------------------------- /soft/libraries/Audio/control_wm8731.cpp: -------------------------------------------------------------------------------- 1 | /* Audio Library for Teensy 3.X 2 | * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com 3 | * 4 | * Development of this audio library was funded by PJRC.COM, LLC by sales of 5 | * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop 6 | * open source software by purchasing Teensy or other PJRC products. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice, development funding notice, and this permission 16 | * notice shall be included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include "control_wm8731.h" 28 | #include "Wire.h" 29 | 30 | #define WM8731_I2C_ADDR 0x1A 31 | //#define WM8731_I2C_ADDR 0x1B 32 | 33 | #define WM8731_REG_LLINEIN 0 34 | #define WM8731_REG_RLINEIN 1 35 | #define WM8731_REG_LHEADOUT 2 36 | #define WM8731_REG_RHEADOUT 3 37 | #define WM8731_REG_ANALOG 4 38 | #define WM8731_REG_DIGITAL 5 39 | #define WM8731_REG_POWERDOWN 6 40 | #define WM8731_REG_INTERFACE 7 41 | #define WM8731_REG_SAMPLING 8 42 | #define WM8731_REG_ACTIVE 9 43 | #define WM8731_REG_RESET 15 44 | 45 | bool AudioControlWM8731::enable(void) 46 | { 47 | Wire.begin(); 48 | delay(5); 49 | //write(WM8731_REG_RESET, 0); 50 | 51 | write(WM8731_REG_INTERFACE, 0x02); // I2S, 16 bit, MCLK slave 52 | write(WM8731_REG_SAMPLING, 0x20); // 256*Fs, 44.1 kHz, MCLK/1 53 | 54 | // In order to prevent pops, the DAC should first be soft-muted (DACMU), 55 | // the output should then be de-selected from the line and headphone output 56 | // (DACSEL), then the DAC powered down (DACPD). 57 | 58 | write(WM8731_REG_DIGITAL, 0x08); // DAC soft mute 59 | write(WM8731_REG_ANALOG, 0x00); // disable all 60 | 61 | write(WM8731_REG_POWERDOWN, 0x00); // codec powerdown 62 | 63 | write(WM8731_REG_LHEADOUT, 0x80); // volume off 64 | write(WM8731_REG_RHEADOUT, 0x80); 65 | 66 | delay(100); // how long to power up? 67 | 68 | write(WM8731_REG_ACTIVE, 1); 69 | delay(5); 70 | write(WM8731_REG_DIGITAL, 0x00); // DAC unmuted 71 | write(WM8731_REG_ANALOG, 0x10); // DAC selected + ADC 72 | 73 | return true; 74 | } 75 | 76 | bool AudioControlWM8731::inputLevel(float n) 77 | { 78 | // range is 0x00 (min) - 0x1F (max) 79 | 80 | int _level = int(n * 31.f); 81 | 82 | _level = _level > 0x1F ? 0x1F : _level; 83 | write(WM8731_REG_LLINEIN, _level); 84 | write(WM8731_REG_RLINEIN, _level); 85 | return true; 86 | } 87 | 88 | bool AudioControlWM8731::write(unsigned int reg, unsigned int val) 89 | { 90 | Wire.beginTransmission(WM8731_I2C_ADDR); 91 | Wire.write((reg << 1) | ((val >> 8) & 1)); 92 | Wire.write(val & 0xFF); 93 | Wire.endTransmission(); 94 | return true; 95 | } 96 | 97 | bool AudioControlWM8731::volumeInteger(unsigned int n) 98 | { 99 | // n = 127 for max volume (+6 dB) 100 | // n = 48 for min volume (-73 dB) 101 | // n = 0 to 47 for mute 102 | if (n > 127) n = 127; 103 | //Serial.print("volumeInteger, n = "); 104 | //Serial.println(n); 105 | write(WM8731_REG_LHEADOUT, n | 0x180); 106 | write(WM8731_REG_RHEADOUT, n | 0x80); 107 | return true; 108 | } 109 | 110 | 111 | 112 | /******************************************************************/ 113 | 114 | 115 | bool AudioControlWM8731master::enable(void) 116 | { 117 | Wire.begin(); 118 | delay(5); 119 | //write(WM8731_REG_RESET, 0); 120 | 121 | write(WM8731_REG_INTERFACE, 0x42); // I2S, 16 bit, MCLK master 122 | write(WM8731_REG_SAMPLING, 0x20); // 256*Fs, 44.1 kHz, MCLK/1 123 | 124 | // In order to prevent pops, the DAC should first be soft-muted (DACMU), 125 | // the output should then be de-selected from the line and headphone output 126 | // (DACSEL), then the DAC powered down (DACPD). 127 | 128 | write(WM8731_REG_DIGITAL, 0x08); // DAC soft mute 129 | write(WM8731_REG_ANALOG, 0x00); // disable all 130 | 131 | write(WM8731_REG_POWERDOWN, 0x00); // codec powerdown 132 | 133 | write(WM8731_REG_LHEADOUT, 0x80); // volume off 134 | write(WM8731_REG_RHEADOUT, 0x80); 135 | 136 | delay(100); // how long to power up? 137 | 138 | write(WM8731_REG_ACTIVE, 1); 139 | delay(5); 140 | write(WM8731_REG_DIGITAL, 0x00); // DAC unmuted 141 | write(WM8731_REG_ANALOG, 0x10); // DAC selected 142 | 143 | return true; 144 | } 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /soft/mini-codec-record-test/mini-codec-record-test.ino: -------------------------------------------------------------------------------- 1 | /* mini trash rec/play test; basically, the pjrc "recorder" example ; needs modded wm8731 files (wm8731.h/cpp in audio lib) 2 | * 3 | * top button / trig input = arm track + record, lower button / trig input = play 4 | * pots/CV unused 5 | * recording is mono (only left input is used); output is to L and R channel 6 | */ 7 | 8 | #include 9 | #include 10 | #include // #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Audio API: 16 | AudioInputI2S i2s_ADC; 17 | AudioRecordQueue queue1; 18 | AudioPlaySdRaw raw_file; 19 | AudioEffectFade fade1; 20 | AudioOutputI2S i2s_DAC; 21 | AudioConnection ac0(i2s_ADC, 0, queue1, 0); 22 | AudioConnection ac1(raw_file, 0, fade1, 0); 23 | AudioConnection ac2(fade1, 0, i2s_DAC, 0); 24 | AudioConnection ac3(fade1, 0, i2s_DAC, 1); 25 | AudioControlWM8731 wm8731; 26 | 27 | // buttons : 28 | #define BUT1 1 29 | #define BUT2 4 30 | #define LED1 2 31 | #define LED2 5 32 | // CS pins : 33 | #define CS_MEM 6 34 | #define CS_SD 10 35 | // trig inputs : 36 | #define CLK1 0 37 | #define CLK2 3 38 | 39 | // remaining i/o, unused here : 40 | /* 41 | #define POT1 A10 42 | #define POT2 A11 43 | #define POT3 A7 44 | #define POT4 A6 45 | #define CV1 A1 46 | #define CV2 A2 47 | */ 48 | 49 | Bounce buttonRecord = Bounce(BUT1, 50); 50 | Bounce buttonPlay = Bounce(BUT2, 50); 51 | 52 | // trigger inputs : 53 | volatile uint16_t _CLK1, _CLK2; 54 | 55 | void CLK_ISR_1() { _CLK1 = true; } 56 | void CLK_ISR_2() { _CLK2 = true; } 57 | 58 | enum MODE { 59 | STOP, 60 | REC, 61 | PLAY, 62 | ARM 63 | }; 64 | 65 | int mode = 0; // 0=stopped, 1=recording, 2=playing, 3=armed 66 | int wait = 0; 67 | uint32_t timestamp = 0; 68 | uint32_t file_length = 0; 69 | const uint16_t FADE_OUT = 100; 70 | const uint16_t FADE_IN = 100; 71 | 72 | // The file where data is recorded : 73 | File frec; 74 | 75 | // blink top led when track is recorded : 76 | IntervalTimer blink; 77 | volatile uint16_t _LED = false; 78 | const uint32_t BLINK_RATE = 100000; 79 | 80 | void _blink() { 81 | 82 | if (mode == REC) { 83 | digitalWriteFast(LED1, _LED); 84 | _LED = ~_LED & 1u; 85 | } 86 | } 87 | 88 | void setup() { 89 | 90 | // buttons 1,2 91 | pinMode(BUT1, INPUT_PULLUP); 92 | pinMode(BUT2, INPUT_PULLUP); 93 | pinMode(LED1, OUTPUT); 94 | pinMode(LED2, OUTPUT); 95 | // 96 | pinMode(CLK1, INPUT_PULLUP); 97 | pinMode(CLK2, INPUT_PULLUP); 98 | pinMode(CS_MEM, OUTPUT); 99 | digitalWrite(CS_MEM, HIGH); 100 | 101 | AudioMemory(150); 102 | 103 | wm8731.enable(); // this enables both the ADC and DAC 104 | wm8731.inputLevel(0.7f); // input level 105 | wm8731.volume(0.7f); // output level 106 | 107 | SPI.setMOSI(7); 108 | SPI.setSCK(14); 109 | if (!(SD.begin(CS_SD))) { 110 | 111 | uint8_t xxx = 0x0; 112 | while (1) { 113 | Serial.println("Unable to access the SD card"); 114 | delay(500); 115 | digitalWriteFast(LED1, xxx); 116 | digitalWriteFast(LED2, xxx); 117 | xxx = ~xxx & 1u; 118 | } 119 | } 120 | // trigger inputs 121 | attachInterrupt(CLK1, CLK_ISR_1, FALLING); 122 | attachInterrupt(CLK2, CLK_ISR_2, FALLING); 123 | blink.begin(_blink, BLINK_RATE); 124 | } 125 | 126 | 127 | void loop() { 128 | 129 | buttonRecord.update(); 130 | buttonPlay.update(); 131 | 132 | // rec button = top button 133 | // press to arm track; press again to record; press again to stop; when playing, pressing "rec" stops playing and arms track 134 | if (_CLK1 || buttonRecord.fallingEdge()) { 135 | 136 | switch (mode) { 137 | 138 | case STOP: { 139 | 140 | if (!_CLK1) { 141 | // only arm track manually 142 | mode = ARM; 143 | digitalWriteFast(LED1, HIGH); 144 | digitalWriteFast(LED2, LOW); 145 | } 146 | break; 147 | } 148 | case REC: { 149 | 150 | stopRecording(); 151 | digitalWriteFast(LED1, LOW); 152 | digitalWriteFast(LED2, LOW); 153 | mode = STOP; 154 | break; 155 | } 156 | case PLAY: { 157 | 158 | if (!_CLK1) { 159 | // only arm track manually 160 | stopPlaying(); 161 | digitalWriteFast(LED1, HIGH); 162 | digitalWriteFast(LED2, LOW); 163 | mode = ARM; 164 | } 165 | break; 166 | } 167 | case ARM: { 168 | 169 | startRecording(); 170 | digitalWriteFast(LED1, HIGH); 171 | digitalWriteFast(LED2, LOW); 172 | mode = REC; 173 | break; 174 | } 175 | default: break; 176 | 177 | } 178 | _CLK1 = false; 179 | } 180 | // play button = lower button 181 | // press to play file; press again to stop; when recording, pressing "play" does nothing 182 | if (_CLK2 || buttonPlay.fallingEdge()) { 183 | 184 | switch (mode) { 185 | 186 | case STOP: { 187 | 188 | startPlaying(); 189 | digitalWriteFast(LED1, LOW); 190 | digitalWriteFast(LED2, HIGH); 191 | mode = PLAY; 192 | break; 193 | 194 | } 195 | 196 | case REC: { 197 | 198 | if (!_CLK2) { 199 | // only stop recording manually 200 | stopRecording(); 201 | digitalWriteFast(LED1, LOW); 202 | digitalWriteFast(LED2, LOW); 203 | mode = STOP; 204 | } 205 | else mode = REC; 206 | break; 207 | } 208 | 209 | case PLAY: { 210 | 211 | stopPlaying(); 212 | digitalWriteFast(LED1, LOW); 213 | digitalWriteFast(LED2, LOW); 214 | break; 215 | } 216 | 217 | case ARM: { 218 | 219 | if (!_CLK2) { 220 | // de-active manually 221 | mode = STOP; 222 | } 223 | break; 224 | } 225 | 226 | default: break; 227 | } 228 | _CLK2 = false; 229 | } 230 | 231 | if (mode == REC) continueRecording(); 232 | 233 | if (mode == PLAY) { 234 | continuePlaying(); 235 | // fade out file when we reach near the end : 236 | if (raw_file.positionMillis() > file_length - FADE_OUT) fade1.fadeOut(FADE_OUT); 237 | } 238 | 239 | if (wait && millis() - timestamp > FADE_OUT) { 240 | wait = 0x0; 241 | raw_file.stop(); 242 | } 243 | } 244 | 245 | 246 | // misc functions: 247 | 248 | void startRecording() { 249 | // start rec 250 | if (SD.exists("RECORD.RAW")) { 251 | // The SD library writes new data to the end of the 252 | // file, so to start a new recording, the old file 253 | // must be deleted before new data is written. 254 | SD.remove("RECORD.RAW"); 255 | } 256 | frec = SD.open("RECORD.RAW", FILE_WRITE); 257 | if (frec) { 258 | queue1.begin(); 259 | } 260 | } 261 | 262 | void continueRecording() { 263 | 264 | if (queue1.available() >= 2) { 265 | byte buffer[512]; 266 | memcpy(buffer, queue1.readBuffer(), 256); 267 | queue1.freeBuffer(); 268 | memcpy(buffer+256, queue1.readBuffer(), 256); 269 | queue1.freeBuffer(); 270 | // write all 512 bytes to the SD card 271 | //elapsedMicros usec = 0; 272 | frec.write(buffer, 512); 273 | } 274 | } 275 | 276 | void stopRecording() { 277 | queue1.end(); 278 | if (mode == 1) { 279 | while (queue1.available() > 0) { 280 | frec.write((byte*)queue1.readBuffer(), 256); 281 | queue1.freeBuffer(); 282 | } 283 | frec.close(); 284 | } 285 | } 286 | 287 | void startPlaying() { 288 | 289 | fade1.fadeIn(FADE_IN); 290 | raw_file.play("RECORD.RAW"); 291 | file_length = raw_file.lengthMillis(); 292 | } 293 | 294 | void continuePlaying() { 295 | if (!raw_file.isPlaying()) { 296 | raw_file.stop(); 297 | mode = STOP; 298 | digitalWriteFast(LED2, LOW); 299 | } 300 | } 301 | 302 | void stopPlaying() { 303 | 304 | if (mode == PLAY) { 305 | fade1.fadeOut(FADE_OUT); 306 | wait = 0x1; 307 | timestamp = millis(); 308 | mode = STOP; 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /soft/libraries/Audio/synth_fm_drum.cpp: -------------------------------------------------------------------------------- 1 | /* Audio Library for Teensy 3.X 2 | * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com 3 | * 4 | * Development of this audio library was funded by PJRC.COM, LLC by sales of 5 | * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop 6 | * open source software by purchasing Teensy or other PJRC products. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice, development funding notice, and this permission 16 | * notice shall be included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | /* 27 | 28 | // Copyright 2013 Olivier Gillet. 29 | // 30 | // Author: Olivier Gillet (ol.gillet@gmail.com) 31 | // 32 | // Permission is hereby granted, free of charge, to any person obtaining a copy 33 | // of this software and associated documentation files (the "Software"), to deal 34 | // in the Software without restriction, including without limitation the rights 35 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 36 | // copies of the Software, and to permit persons to whom the Software is 37 | // furnished to do so, subject to the following conditions: 38 | // 39 | // The above copyright notice and this permission notice shall be included in 40 | // all copies or substantial portions of the Software. 41 | // 42 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 43 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 44 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 45 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 46 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 47 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 48 | // THE SOFTWARE. 49 | // 50 | // See http://creativecommons.org/licenses/MIT/ for more information. 51 | // 52 | // ----------------------------------------------------------------------------- 53 | // 54 | // Sine FM drum - similar to the BD/SD in Anushri. 55 | 56 | */ 57 | 58 | 59 | #include "synth_fm_drum.h" 60 | #include "utility/dspinst.h" 61 | 62 | // drum_data.c 63 | extern "C" { 64 | extern const uint32_t lut_env_increments[257]; 65 | extern const int16_t wav_overdrive[1025]; 66 | extern const int16_t wav_sine[1025]; 67 | extern const uint16_t lut_env_expo[257]; 68 | extern const uint32_t lut_oscillator_increments[101]; 69 | } 70 | 71 | 72 | static const uint16_t bd_map[10][4] = { 73 | { 4096, 0, 65535, 32768 }, 74 | { 8192 + 4096, 0, 65535, 32768 }, 75 | 76 | { 8192, 4096, 49512, 32768 }, 77 | { 8192, 16384, 40960, 32768 }, 78 | 79 | { 10240, 4096, 24576, 32768 }, 80 | { 10240, 16384, 24576, 16384 }, 81 | 82 | { 8192, 8192, 32768, 16384 }, 83 | { 8192, 24576, 49152, 8192 }, 84 | 85 | { 4096, 16384, 40960, 16384 }, 86 | { 8192, 24576, 49152, 0 }, 87 | }; 88 | 89 | static const uint16_t sd_map[10][4] = { 90 | { 24576, 0, 24576, 36864 }, 91 | { 24576, 0, 16384, 65535 }, 92 | 93 | { 28672, 0, 16384, 36864 }, 94 | { 28672, 0, 16384, 65535 }, 95 | 96 | { 20488, 0, 32768, 57344 }, 97 | { 28672, 0, 24576, 65535 }, 98 | 99 | { 20488, 0, 24576, 65535 }, 100 | { 28672, 0, 32768, 65535 }, 101 | 102 | { 20488, 65535, 16384, 0 }, 103 | { 65535, 0, 8192, 32768 }, 104 | }; 105 | 106 | static const uint16_t kHighestNote = 128 * 128; 107 | static const uint16_t kPitchTableStart = 116 * 128; 108 | static const uint16_t kOctave = 128 * 12; 109 | static const uint8_t kNumZones = 6; 110 | 111 | const uint8_t CLK0 = 0; 112 | const uint8_t CLK1 = 3; 113 | 114 | void AudioSynthFMDrum::init(uint8_t clock_pin) 115 | { 116 | 117 | pinMode(clock_pin, INPUT_PULLUP); 118 | 119 | if (clock_pin == CLK0) _clk = 0x0; 120 | else if (clock_pin == CLK1) _clk = 0x1; 121 | else _clk = 0x0; // default to 0x0 122 | 123 | phase_ = 0; 124 | fm_envelope_phase_ = 0xffffffff; 125 | am_envelope_phase_ = 0xffffffff; 126 | previous_sample_ = 0; 127 | } 128 | 129 | 130 | uint32_t AudioSynthFMDrum::ComputeEnvelopeIncrement(uint16_t decay) 131 | { 132 | uint32_t a = lut_env_increments[decay >> 8]; 133 | uint32_t b = lut_env_increments[(decay >> 8) + 1]; 134 | return a - ((a - b) * (decay & 0xff) >> 8); 135 | } 136 | 137 | uint32_t AudioSynthFMDrum::ComputePhaseIncrement(int16_t midi_pitch) { 138 | 139 | if (midi_pitch >= kHighestNote) { 140 | midi_pitch = kHighestNote - 1; 141 | } 142 | 143 | int32_t ref_pitch = midi_pitch; 144 | ref_pitch -= kPitchTableStart; 145 | 146 | size_t num_shifts = 0; 147 | while (ref_pitch < 0) { 148 | ref_pitch += kOctave; 149 | ++num_shifts; 150 | } 151 | 152 | uint32_t a = lut_oscillator_increments[ref_pitch >> 4]; 153 | uint32_t b = lut_oscillator_increments[(ref_pitch >> 4) + 1]; 154 | uint32_t phase_increment = a + \ 155 | (static_cast(b - a) * (ref_pitch & 0xf) >> 4); 156 | phase_increment >>= num_shifts; 157 | return phase_increment; 158 | } 159 | 160 | inline uint16_t AudioSynthFMDrum::Interpolate824(const uint16_t* table, uint32_t phase) { 161 | uint32_t a = table[phase >> 24]; 162 | uint32_t b = table[(phase >> 24) + 1]; 163 | return a + ((b - a) * static_cast((phase >> 8) & 0xffff) >> 16); 164 | } 165 | 166 | 167 | inline int16_t AudioSynthFMDrum::Interpolate1022(const int16_t* table, uint32_t phase) { 168 | int32_t a = table[phase >> 22]; 169 | int32_t b = table[(phase >> 22) + 1]; 170 | return a + ((b - a) * static_cast((phase >> 6) & 0xffff) >> 16); 171 | } 172 | 173 | inline int16_t AudioSynthFMDrum::Mix(int16_t a, int16_t b, uint16_t balance) { 174 | return (a * (65535 - balance) + b * balance) >> 16; 175 | } 176 | 177 | void AudioSynthFMDrum::morph(uint16_t x, uint16_t y) 178 | { 179 | const uint16_t (*map)[4] = sd_range_ ? sd_map : bd_map; 180 | uint16_t parameters[4]; 181 | 182 | for (uint8_t i = 0; i < 4; ++i) { 183 | uint16_t x_integral = (x >> 14) << 1; 184 | uint16_t x_fractional = x << 2; 185 | uint16_t a = map[x_integral][i]; 186 | uint16_t b = map[x_integral + 2][i]; 187 | uint16_t c = map[x_integral + 1][i]; 188 | uint16_t d = map[x_integral + 3][i]; 189 | 190 | uint16_t e = a + ((b - a) * x_fractional >> 16); 191 | uint16_t f = c + ((d - c) * x_fractional >> 16); 192 | parameters[i] = e + ((f - e) * y >> 16); 193 | } 194 | // test 195 | frequency(20000);//(parameters[0]); 196 | fm_amount(45000);//((parameters[1] >> 2) * 3); 197 | decay(35000);//(parameters[2]); 198 | set_noise(4000); 199 | } 200 | 201 | 202 | void AudioSynthFMDrum::update(void) 203 | { 204 | 205 | audio_block_t *block, *modinput; 206 | 207 | modinput = receiveReadOnly(); 208 | 209 | block = allocate(); 210 | 211 | if (!block) return; 212 | 213 | if (modinput) { 214 | 215 | uint32_t am_envelope_increment = ComputeEnvelopeIncrement(am_decay_); 216 | uint32_t fm_envelope_increment = ComputeEnvelopeIncrement(fm_decay_); 217 | uint32_t phase = phase_; 218 | uint32_t fm_envelope_phase = fm_envelope_phase_; 219 | uint32_t am_envelope_phase = am_envelope_phase_; 220 | uint32_t aux_envelope_phase = aux_envelope_phase_; 221 | uint32_t phase_increment = phase_increment_; 222 | 223 | for (uint8_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) { 224 | 225 | uint8_t trig = _clk ? digitalReadFast(CLK1) : digitalReadFast(CLK0); 226 | 227 | if (!trig && _prev_clk) { 228 | fm_envelope_phase = 0; 229 | am_envelope_phase = 0; 230 | aux_envelope_phase = 0; 231 | phase = 0x3fff * fm_amount_ >> 16; 232 | } 233 | 234 | _prev_clk = trig; 235 | 236 | fm_envelope_phase += fm_envelope_increment; 237 | 238 | if (fm_envelope_phase < fm_envelope_increment) fm_envelope_phase = 0xffffffff; 239 | 240 | aux_envelope_phase += 4473924; 241 | 242 | if (aux_envelope_phase < 4473924) aux_envelope_phase = 0xffffffff; 243 | 244 | if ((i & 3) == 0) { 245 | 246 | uint32_t aux_envelope = 65535 - Interpolate824(lut_env_expo, aux_envelope_phase); 247 | uint32_t fm_envelope = 65535 - Interpolate824(lut_env_expo, fm_envelope_phase); 248 | 249 | phase_increment = ComputePhaseIncrement( 250 | 251 | frequency_ + \ 252 | (fm_envelope * fm_amount_ >> 16) + \ 253 | (aux_envelope * aux_envelope_strength_ >> 15) + \ 254 | (previous_sample_ >> 6)); 255 | } 256 | 257 | phase += phase_increment; 258 | 259 | int16_t mix = Interpolate1022(wav_sine, phase); 260 | 261 | if (noise_) mix = Mix(mix, random(65335), noise_); 262 | 263 | am_envelope_phase += am_envelope_increment; 264 | 265 | if (am_envelope_phase < am_envelope_increment) am_envelope_phase = 0xffffffff; 266 | 267 | uint32_t am_envelope = 65535 - Interpolate824(lut_env_expo, am_envelope_phase); 268 | 269 | mix = mix * am_envelope >> 16; 270 | 271 | if (overdrive_) { 272 | 273 | uint32_t phi = (static_cast(mix) << 16) + (1L << 31); 274 | int16_t overdriven = Interpolate1022(wav_overdrive, phi); 275 | mix = Mix(mix, overdriven, overdrive_); 276 | } 277 | 278 | previous_sample_ = mix; 279 | block->data[i] = mix; 280 | } 281 | 282 | phase_ = phase; 283 | fm_envelope_phase_ = fm_envelope_phase; 284 | am_envelope_phase_ = am_envelope_phase; 285 | aux_envelope_phase_ = aux_envelope_phase; 286 | phase_increment_ = phase_increment; 287 | } // if modinput 288 | 289 | release(modinput); 290 | transmit(block); 291 | release(block); 292 | } 293 | 294 | -------------------------------------------------------------------------------- /soft/libraries/Audio/synth_drum_data.c: -------------------------------------------------------------------------------- 1 | /* Audio Library for Teensy 3.X 2 | * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com 3 | * 4 | * Development of this audio library was funded by PJRC.COM, LLC by sales of 5 | * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop 6 | * open source software by purchasing Teensy or other PJRC products. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice, development funding notice, and this permission 16 | * notice shall be included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include 28 | 29 | const uint32_t lut_env_increments[] = { 30 | 178956970, 162203921, 147263779, 133914742, 31 | 121965179, 111249129, 101622525, 92960022, 32 | 85152324, 78103929, 71731214, 65960813, 33 | 60728233, 55976673, 51656020, 47721976, 34 | 44135321, 40861270, 37868923, 35130786, 35 | 32622357, 30321772, 28209484, 26268003, 36 | 24481648, 22836346, 21319451, 19919582, 37 | 18626484, 17430905, 16324491, 15299685, 38 | 14349647, 13468178, 12649652, 11888959, 39 | 11181454, 10522909, 9909470, 9337624, 40 | 8804164, 8306157, 7840925, 7406012, 41 | 6999170, 6618338, 6261623, 5927288, 42 | 5613733, 5319488, 5043200, 4783621, 43 | 4539601, 4310076, 4094068, 3890668, 44 | 3699040, 3518407, 3348049, 3187303, 45 | 3035548, 2892213, 2756766, 2628711, 46 | 2507588, 2392971, 2284460, 2181685, 47 | 2084301, 1991984, 1904435, 1821372, 48 | 1742534, 1667676, 1596567, 1528995, 49 | 1464759, 1403670, 1345553, 1290243, 50 | 1237585, 1187435, 1139655, 1094119, 51 | 1050706, 1009303, 969803, 932108, 52 | 896122, 861758, 828932, 797565, 53 | 767584, 738918, 711503, 685274, 54 | 660174, 636148, 613143, 591109, 55 | 569999, 549770, 530379, 511787, 56 | 493956, 476850, 460436, 444683, 57 | 429558, 415035, 401085, 387683, 58 | 374804, 362424, 350523, 339078, 59 | 328069, 317479, 307287, 297478, 60 | 288035, 278942, 270184, 261748, 61 | 253620, 245786, 238236, 230956, 62 | 223936, 217166, 210635, 204334, 63 | 198253, 192383, 186717, 181245, 64 | 175961, 170858, 165927, 161162, 65 | 156558, 152107, 147805, 143644, 66 | 139621, 135729, 131964, 128321, 67 | 124796, 121384, 118081, 114883, 68 | 111787, 108788, 105883, 103069, 69 | 100343, 97700, 95139, 92657, 70 | 90250, 87917, 85654, 83459, 71 | 81330, 79265, 77261, 75316, 72 | 73428, 71596, 69817, 68090, 73 | 66413, 64784, 63202, 61666, 74 | 60173, 58722, 57312, 55942, 75 | 54610, 53315, 52056, 50832, 76 | 49641, 48484, 47357, 46262, 77 | 45196, 44159, 43149, 42167, 78 | 41211, 40280, 39374, 38492, 79 | 37632, 36796, 35981, 35187, 80 | 34414, 33660, 32926, 32211, 81 | 31513, 30834, 30172, 29526, 82 | 28896, 28282, 27684, 27100, 83 | 26531, 25975, 25434, 24905, 84 | 24390, 23886, 23395, 22916, 85 | 22449, 21992, 21546, 21111, 86 | 20687, 20272, 19867, 19471, 87 | 19085, 18708, 18339, 17979, 88 | 17627, 17283, 16947, 16619, 89 | 16298, 15985, 15678, 15378, 90 | 15085, 14799, 14519, 14245, 91 | 13977, 13716, 13459, 13209, 92 | 12964, 12724, 12490, 12260, 93 | 12036, 11816, 11601, 11390, 94 | 11184, 95 | }; 96 | 97 | const int16_t wav_overdrive[] = { 98 | -32767, -32767, -32767, -32767, 99 | -32767, -32767, -32767, -32767, 100 | -32766, -32766, -32766, -32766, 101 | -32766, -32766, -32766, -32766, 102 | -32766, -32766, -32766, -32766, 103 | -32766, -32765, -32765, -32765, 104 | -32765, -32765, -32765, -32765, 105 | -32765, -32765, -32765, -32765, 106 | -32764, -32764, -32764, -32764, 107 | -32764, -32764, -32764, -32764, 108 | -32763, -32763, -32763, -32763, 109 | -32763, -32763, -32763, -32763, 110 | -32762, -32762, -32762, -32762, 111 | -32762, -32762, -32761, -32761, 112 | -32761, -32761, -32761, -32761, 113 | -32760, -32760, -32760, -32760, 114 | -32760, -32759, -32759, -32759, 115 | -32759, -32759, -32758, -32758, 116 | -32758, -32758, -32757, -32757, 117 | -32757, -32757, -32756, -32756, 118 | -32756, -32756, -32755, -32755, 119 | -32755, -32754, -32754, -32754, 120 | -32753, -32753, -32753, -32752, 121 | -32752, -32752, -32751, -32751, 122 | -32751, -32750, -32750, -32749, 123 | -32749, -32749, -32748, -32748, 124 | -32747, -32747, -32746, -32746, 125 | -32745, -32745, -32744, -32744, 126 | -32743, -32743, -32742, -32742, 127 | -32741, -32741, -32740, -32740, 128 | -32739, -32738, -32738, -32737, 129 | -32736, -32736, -32735, -32734, 130 | -32734, -32733, -32732, -32732, 131 | -32731, -32730, -32729, -32728, 132 | -32728, -32727, -32726, -32725, 133 | -32724, -32723, -32722, -32721, 134 | -32720, -32719, -32718, -32717, 135 | -32716, -32715, -32714, -32713, 136 | -32712, -32711, -32710, -32709, 137 | -32707, -32706, -32705, -32704, 138 | -32702, -32701, -32700, -32698, 139 | -32697, -32695, -32694, -32692, 140 | -32691, -32689, -32688, -32686, 141 | -32684, -32683, -32681, -32679, 142 | -32678, -32676, -32674, -32672, 143 | -32670, -32668, -32666, -32664, 144 | -32662, -32660, -32658, -32655, 145 | -32653, -32651, -32649, -32646, 146 | -32644, -32641, -32639, -32636, 147 | -32633, -32631, -32628, -32625, 148 | -32622, -32619, -32617, -32614, 149 | -32610, -32607, -32604, -32601, 150 | -32597, -32594, -32591, -32587, 151 | -32584, -32580, -32576, -32572, 152 | -32568, -32564, -32560, -32556, 153 | -32552, -32548, -32543, -32539, 154 | -32534, -32530, -32525, -32520, 155 | -32515, -32510, -32505, -32500, 156 | -32495, -32489, -32484, -32478, 157 | -32473, -32467, -32461, -32455, 158 | -32448, -32442, -32436, -32429, 159 | -32422, -32416, -32409, -32402, 160 | -32394, -32387, -32380, -32372, 161 | -32364, -32356, -32348, -32340, 162 | -32331, -32323, -32314, -32305, 163 | -32296, -32287, -32277, -32268, 164 | -32258, -32248, -32237, -32227, 165 | -32216, -32206, -32195, -32183, 166 | -32172, -32160, -32148, -32136, 167 | -32124, -32111, -32098, -32085, 168 | -32072, -32058, -32044, -32030, 169 | -32016, -32001, -31986, -31971, 170 | -31955, -31939, -31923, -31907, 171 | -31890, -31873, -31855, -31838, 172 | -31819, -31801, -31782, -31763, 173 | -31743, -31723, -31703, -31682, 174 | -31661, -31640, -31618, -31596, 175 | -31573, -31550, -31526, -31502, 176 | -31478, -31453, -31427, -31401, 177 | -31375, -31348, -31320, -31293, 178 | -31264, -31235, -31205, -31175, 179 | -31145, -31113, -31082, -31049, 180 | -31016, -30983, -30948, -30913, 181 | -30878, -30842, -30805, -30767, 182 | -30729, -30690, -30650, -30610, 183 | -30569, -30527, -30484, -30440, 184 | -30396, -30351, -30305, -30258, 185 | -30211, -30162, -30113, -30063, 186 | -30012, -29959, -29906, -29853, 187 | -29798, -29742, -29685, -29627, 188 | -29568, -29508, -29447, -29385, 189 | -29321, -29257, -29191, -29125, 190 | -29057, -28988, -28918, -28846, 191 | -28774, -28700, -28625, -28548, 192 | -28470, -28391, -28311, -28229, 193 | -28146, -28061, -27975, -27887, 194 | -27798, -27708, -27616, -27522, 195 | -27427, -27331, -27232, -27132, 196 | -27031, -26928, -26823, -26717, 197 | -26609, -26499, -26387, -26274, 198 | -26158, -26041, -25923, -25802, 199 | -25679, -25555, -25428, -25300, 200 | -25170, -25038, -24904, -24767, 201 | -24629, -24489, -24346, -24202, 202 | -24056, -23907, -23756, -23603, 203 | -23448, -23291, -23131, -22970, 204 | -22806, -22640, -22471, -22301, 205 | -22128, -21952, -21775, -21595, 206 | -21413, -21228, -21041, -20852, 207 | -20660, -20466, -20270, -20071, 208 | -19870, -19666, -19460, -19252, 209 | -19041, -18828, -18613, -18395, 210 | -18174, -17951, -17726, -17499, 211 | -17269, -17036, -16802, -16565, 212 | -16325, -16083, -15839, -15593, 213 | -15344, -15093, -14840, -14584, 214 | -14327, -14067, -13805, -13540, 215 | -13274, -13005, -12735, -12462, 216 | -12187, -11910, -11632, -11351, 217 | -11068, -10784, -10498, -10210, 218 | -9920, -9628, -9335, -9040, 219 | -8744, -8446, -8146, -7845, 220 | -7543, -7239, -6934, -6628, 221 | -6320, -6012, -5702, -5391, 222 | -5079, -4766, -4453, -4138, 223 | -3823, -3507, -3190, -2873, 224 | -2555, -2237, -1918, -1599, 225 | -1279, -960, -640, -320, 226 | 0, 320, 640, 960, 227 | 1279, 1599, 1918, 2237, 228 | 2555, 2873, 3190, 3507, 229 | 3823, 4138, 4453, 4766, 230 | 5079, 5391, 5702, 6012, 231 | 6320, 6628, 6934, 7239, 232 | 7543, 7845, 8146, 8446, 233 | 8744, 9040, 9335, 9628, 234 | 9920, 10210, 10498, 10784, 235 | 11068, 11351, 11632, 11910, 236 | 12187, 12462, 12735, 13005, 237 | 13274, 13540, 13805, 14067, 238 | 14327, 14584, 14840, 15093, 239 | 15344, 15593, 15839, 16083, 240 | 16325, 16565, 16802, 17036, 241 | 17269, 17499, 17726, 17951, 242 | 18174, 18395, 18613, 18828, 243 | 19041, 19252, 19460, 19666, 244 | 19870, 20071, 20270, 20466, 245 | 20660, 20852, 21041, 21228, 246 | 21413, 21595, 21775, 21952, 247 | 22128, 22301, 22471, 22640, 248 | 22806, 22970, 23131, 23291, 249 | 23448, 23603, 23756, 23907, 250 | 24056, 24202, 24346, 24489, 251 | 24629, 24767, 24904, 25038, 252 | 25170, 25300, 25428, 25555, 253 | 25679, 25802, 25923, 26041, 254 | 26158, 26274, 26387, 26499, 255 | 26609, 26717, 26823, 26928, 256 | 27031, 27132, 27232, 27331, 257 | 27427, 27522, 27616, 27708, 258 | 27798, 27887, 27975, 28061, 259 | 28146, 28229, 28311, 28391, 260 | 28470, 28548, 28625, 28700, 261 | 28774, 28846, 28918, 28988, 262 | 29057, 29125, 29191, 29257, 263 | 29321, 29385, 29447, 29508, 264 | 29568, 29627, 29685, 29742, 265 | 29798, 29853, 29906, 29959, 266 | 30012, 30063, 30113, 30162, 267 | 30211, 30258, 30305, 30351, 268 | 30396, 30440, 30484, 30527, 269 | 30569, 30610, 30650, 30690, 270 | 30729, 30767, 30805, 30842, 271 | 30878, 30913, 30948, 30983, 272 | 31016, 31049, 31082, 31113, 273 | 31145, 31175, 31205, 31235, 274 | 31264, 31293, 31320, 31348, 275 | 31375, 31401, 31427, 31453, 276 | 31478, 31502, 31526, 31550, 277 | 31573, 31596, 31618, 31640, 278 | 31661, 31682, 31703, 31723, 279 | 31743, 31763, 31782, 31801, 280 | 31819, 31838, 31855, 31873, 281 | 31890, 31907, 31923, 31939, 282 | 31955, 31971, 31986, 32001, 283 | 32016, 32030, 32044, 32058, 284 | 32072, 32085, 32098, 32111, 285 | 32124, 32136, 32148, 32160, 286 | 32172, 32183, 32195, 32206, 287 | 32216, 32227, 32237, 32248, 288 | 32258, 32268, 32277, 32287, 289 | 32296, 32305, 32314, 32323, 290 | 32331, 32340, 32348, 32356, 291 | 32364, 32372, 32380, 32387, 292 | 32394, 32402, 32409, 32416, 293 | 32422, 32429, 32436, 32442, 294 | 32448, 32455, 32461, 32467, 295 | 32473, 32478, 32484, 32489, 296 | 32495, 32500, 32505, 32510, 297 | 32515, 32520, 32525, 32530, 298 | 32534, 32539, 32543, 32548, 299 | 32552, 32556, 32560, 32564, 300 | 32568, 32572, 32576, 32580, 301 | 32584, 32587, 32591, 32594, 302 | 32597, 32601, 32604, 32607, 303 | 32610, 32614, 32617, 32619, 304 | 32622, 32625, 32628, 32631, 305 | 32633, 32636, 32639, 32641, 306 | 32644, 32646, 32649, 32651, 307 | 32653, 32655, 32658, 32660, 308 | 32662, 32664, 32666, 32668, 309 | 32670, 32672, 32674, 32676, 310 | 32678, 32679, 32681, 32683, 311 | 32684, 32686, 32688, 32689, 312 | 32691, 32692, 32694, 32695, 313 | 32697, 32698, 32700, 32701, 314 | 32702, 32704, 32705, 32706, 315 | 32707, 32709, 32710, 32711, 316 | 32712, 32713, 32714, 32715, 317 | 32716, 32717, 32718, 32719, 318 | 32720, 32721, 32722, 32723, 319 | 32724, 32725, 32726, 32727, 320 | 32728, 32728, 32729, 32730, 321 | 32731, 32732, 32732, 32733, 322 | 32734, 32734, 32735, 32736, 323 | 32736, 32737, 32738, 32738, 324 | 32739, 32740, 32740, 32741, 325 | 32741, 32742, 32742, 32743, 326 | 32743, 32744, 32744, 32745, 327 | 32745, 32746, 32746, 32747, 328 | 32747, 32748, 32748, 32749, 329 | 32749, 32749, 32750, 32750, 330 | 32751, 32751, 32751, 32752, 331 | 32752, 32752, 32753, 32753, 332 | 32753, 32754, 32754, 32754, 333 | 32755, 32755, 32755, 32756, 334 | 32756, 32756, 32756, 32757, 335 | 32757, 32757, 32757, 32758, 336 | 32758, 32758, 32758, 32759, 337 | 32759, 32759, 32759, 32759, 338 | 32760, 32760, 32760, 32760, 339 | 32760, 32761, 32761, 32761, 340 | 32761, 32761, 32761, 32762, 341 | 32762, 32762, 32762, 32762, 342 | 32762, 32763, 32763, 32763, 343 | 32763, 32763, 32763, 32763, 344 | 32763, 32764, 32764, 32764, 345 | 32764, 32764, 32764, 32764, 346 | 32764, 32765, 32765, 32765, 347 | 32765, 32765, 32765, 32765, 348 | 32765, 32765, 32765, 32765, 349 | 32766, 32766, 32766, 32766, 350 | 32766, 32766, 32766, 32766, 351 | 32766, 32766, 32766, 32766, 352 | 32766, 32767, 32767, 32767, 353 | 32767, 32767, 32767, 32767, 354 | 32767, 355 | }; 356 | 357 | const int16_t wav_sine[] = { 358 | 0, 201, 402, 603, 359 | 804, 1005, 1206, 1406, 360 | 1607, 1808, 2009, 2209, 361 | 2410, 2610, 2811, 3011, 362 | 3211, 3411, 3611, 3811, 363 | 4011, 4210, 4409, 4608, 364 | 4807, 5006, 5205, 5403, 365 | 5601, 5799, 5997, 6195, 366 | 6392, 6589, 6786, 6982, 367 | 7179, 7375, 7571, 7766, 368 | 7961, 8156, 8351, 8545, 369 | 8739, 8932, 9126, 9319, 370 | 9511, 9703, 9895, 10087, 371 | 10278, 10469, 10659, 10849, 372 | 11038, 11227, 11416, 11604, 373 | 11792, 11980, 12166, 12353, 374 | 12539, 12724, 12909, 13094, 375 | 13278, 13462, 13645, 13827, 376 | 14009, 14191, 14372, 14552, 377 | 14732, 14911, 15090, 15268, 378 | 15446, 15623, 15799, 15975, 379 | 16150, 16325, 16499, 16672, 380 | 16845, 17017, 17189, 17360, 381 | 17530, 17699, 17868, 18036, 382 | 18204, 18371, 18537, 18702, 383 | 18867, 19031, 19194, 19357, 384 | 19519, 19680, 19840, 20000, 385 | 20159, 20317, 20474, 20631, 386 | 20787, 20942, 21096, 21249, 387 | 21402, 21554, 21705, 21855, 388 | 22004, 22153, 22301, 22448, 389 | 22594, 22739, 22883, 23027, 390 | 23169, 23311, 23452, 23592, 391 | 23731, 23869, 24006, 24143, 392 | 24278, 24413, 24546, 24679, 393 | 24811, 24942, 25072, 25201, 394 | 25329, 25456, 25582, 25707, 395 | 25831, 25954, 26077, 26198, 396 | 26318, 26437, 26556, 26673, 397 | 26789, 26905, 27019, 27132, 398 | 27244, 27355, 27466, 27575, 399 | 27683, 27790, 27896, 28001, 400 | 28105, 28208, 28309, 28410, 401 | 28510, 28608, 28706, 28802, 402 | 28897, 28992, 29085, 29177, 403 | 29268, 29358, 29446, 29534, 404 | 29621, 29706, 29790, 29873, 405 | 29955, 30036, 30116, 30195, 406 | 30272, 30349, 30424, 30498, 407 | 30571, 30643, 30713, 30783, 408 | 30851, 30918, 30984, 31049, 409 | 31113, 31175, 31236, 31297, 410 | 31356, 31413, 31470, 31525, 411 | 31580, 31633, 31684, 31735, 412 | 31785, 31833, 31880, 31926, 413 | 31970, 32014, 32056, 32097, 414 | 32137, 32176, 32213, 32249, 415 | 32284, 32318, 32350, 32382, 416 | 32412, 32441, 32468, 32495, 417 | 32520, 32544, 32567, 32588, 418 | 32609, 32628, 32646, 32662, 419 | 32678, 32692, 32705, 32717, 420 | 32727, 32736, 32744, 32751, 421 | 32757, 32761, 32764, 32766, 422 | 32767, 32766, 32764, 32761, 423 | 32757, 32751, 32744, 32736, 424 | 32727, 32717, 32705, 32692, 425 | 32678, 32662, 32646, 32628, 426 | 32609, 32588, 32567, 32544, 427 | 32520, 32495, 32468, 32441, 428 | 32412, 32382, 32350, 32318, 429 | 32284, 32249, 32213, 32176, 430 | 32137, 32097, 32056, 32014, 431 | 31970, 31926, 31880, 31833, 432 | 31785, 31735, 31684, 31633, 433 | 31580, 31525, 31470, 31413, 434 | 31356, 31297, 31236, 31175, 435 | 31113, 31049, 30984, 30918, 436 | 30851, 30783, 30713, 30643, 437 | 30571, 30498, 30424, 30349, 438 | 30272, 30195, 30116, 30036, 439 | 29955, 29873, 29790, 29706, 440 | 29621, 29534, 29446, 29358, 441 | 29268, 29177, 29085, 28992, 442 | 28897, 28802, 28706, 28608, 443 | 28510, 28410, 28309, 28208, 444 | 28105, 28001, 27896, 27790, 445 | 27683, 27575, 27466, 27355, 446 | 27244, 27132, 27019, 26905, 447 | 26789, 26673, 26556, 26437, 448 | 26318, 26198, 26077, 25954, 449 | 25831, 25707, 25582, 25456, 450 | 25329, 25201, 25072, 24942, 451 | 24811, 24679, 24546, 24413, 452 | 24278, 24143, 24006, 23869, 453 | 23731, 23592, 23452, 23311, 454 | 23169, 23027, 22883, 22739, 455 | 22594, 22448, 22301, 22153, 456 | 22004, 21855, 21705, 21554, 457 | 21402, 21249, 21096, 20942, 458 | 20787, 20631, 20474, 20317, 459 | 20159, 20000, 19840, 19680, 460 | 19519, 19357, 19194, 19031, 461 | 18867, 18702, 18537, 18371, 462 | 18204, 18036, 17868, 17699, 463 | 17530, 17360, 17189, 17017, 464 | 16845, 16672, 16499, 16325, 465 | 16150, 15975, 15799, 15623, 466 | 15446, 15268, 15090, 14911, 467 | 14732, 14552, 14372, 14191, 468 | 14009, 13827, 13645, 13462, 469 | 13278, 13094, 12909, 12724, 470 | 12539, 12353, 12166, 11980, 471 | 11792, 11604, 11416, 11227, 472 | 11038, 10849, 10659, 10469, 473 | 10278, 10087, 9895, 9703, 474 | 9511, 9319, 9126, 8932, 475 | 8739, 8545, 8351, 8156, 476 | 7961, 7766, 7571, 7375, 477 | 7179, 6982, 6786, 6589, 478 | 6392, 6195, 5997, 5799, 479 | 5601, 5403, 5205, 5006, 480 | 4807, 4608, 4409, 4210, 481 | 4011, 3811, 3611, 3411, 482 | 3211, 3011, 2811, 2610, 483 | 2410, 2209, 2009, 1808, 484 | 1607, 1406, 1206, 1005, 485 | 804, 603, 402, 201, 486 | 0, -201, -402, -603, 487 | -804, -1005, -1206, -1406, 488 | -1607, -1808, -2009, -2209, 489 | -2410, -2610, -2811, -3011, 490 | -3211, -3411, -3611, -3811, 491 | -4011, -4210, -4409, -4608, 492 | -4807, -5006, -5205, -5403, 493 | -5601, -5799, -5997, -6195, 494 | -6392, -6589, -6786, -6982, 495 | -7179, -7375, -7571, -7766, 496 | -7961, -8156, -8351, -8545, 497 | -8739, -8932, -9126, -9319, 498 | -9511, -9703, -9895, -10087, 499 | -10278, -10469, -10659, -10849, 500 | -11038, -11227, -11416, -11604, 501 | -11792, -11980, -12166, -12353, 502 | -12539, -12724, -12909, -13094, 503 | -13278, -13462, -13645, -13827, 504 | -14009, -14191, -14372, -14552, 505 | -14732, -14911, -15090, -15268, 506 | -15446, -15623, -15799, -15975, 507 | -16150, -16325, -16499, -16672, 508 | -16845, -17017, -17189, -17360, 509 | -17530, -17699, -17868, -18036, 510 | -18204, -18371, -18537, -18702, 511 | -18867, -19031, -19194, -19357, 512 | -19519, -19680, -19840, -20000, 513 | -20159, -20317, -20474, -20631, 514 | -20787, -20942, -21096, -21249, 515 | -21402, -21554, -21705, -21855, 516 | -22004, -22153, -22301, -22448, 517 | -22594, -22739, -22883, -23027, 518 | -23169, -23311, -23452, -23592, 519 | -23731, -23869, -24006, -24143, 520 | -24278, -24413, -24546, -24679, 521 | -24811, -24942, -25072, -25201, 522 | -25329, -25456, -25582, -25707, 523 | -25831, -25954, -26077, -26198, 524 | -26318, -26437, -26556, -26673, 525 | -26789, -26905, -27019, -27132, 526 | -27244, -27355, -27466, -27575, 527 | -27683, -27790, -27896, -28001, 528 | -28105, -28208, -28309, -28410, 529 | -28510, -28608, -28706, -28802, 530 | -28897, -28992, -29085, -29177, 531 | -29268, -29358, -29446, -29534, 532 | -29621, -29706, -29790, -29873, 533 | -29955, -30036, -30116, -30195, 534 | -30272, -30349, -30424, -30498, 535 | -30571, -30643, -30713, -30783, 536 | -30851, -30918, -30984, -31049, 537 | -31113, -31175, -31236, -31297, 538 | -31356, -31413, -31470, -31525, 539 | -31580, -31633, -31684, -31735, 540 | -31785, -31833, -31880, -31926, 541 | -31970, -32014, -32056, -32097, 542 | -32137, -32176, -32213, -32249, 543 | -32284, -32318, -32350, -32382, 544 | -32412, -32441, -32468, -32495, 545 | -32520, -32544, -32567, -32588, 546 | -32609, -32628, -32646, -32662, 547 | -32678, -32692, -32705, -32717, 548 | -32727, -32736, -32744, -32751, 549 | -32757, -32761, -32764, -32766, 550 | -32767, -32766, -32764, -32761, 551 | -32757, -32751, -32744, -32736, 552 | -32727, -32717, -32705, -32692, 553 | -32678, -32662, -32646, -32628, 554 | -32609, -32588, -32567, -32544, 555 | -32520, -32495, -32468, -32441, 556 | -32412, -32382, -32350, -32318, 557 | -32284, -32249, -32213, -32176, 558 | -32137, -32097, -32056, -32014, 559 | -31970, -31926, -31880, -31833, 560 | -31785, -31735, -31684, -31633, 561 | -31580, -31525, -31470, -31413, 562 | -31356, -31297, -31236, -31175, 563 | -31113, -31049, -30984, -30918, 564 | -30851, -30783, -30713, -30643, 565 | -30571, -30498, -30424, -30349, 566 | -30272, -30195, -30116, -30036, 567 | -29955, -29873, -29790, -29706, 568 | -29621, -29534, -29446, -29358, 569 | -29268, -29177, -29085, -28992, 570 | -28897, -28802, -28706, -28608, 571 | -28510, -28410, -28309, -28208, 572 | -28105, -28001, -27896, -27790, 573 | -27683, -27575, -27466, -27355, 574 | -27244, -27132, -27019, -26905, 575 | -26789, -26673, -26556, -26437, 576 | -26318, -26198, -26077, -25954, 577 | -25831, -25707, -25582, -25456, 578 | -25329, -25201, -25072, -24942, 579 | -24811, -24679, -24546, -24413, 580 | -24278, -24143, -24006, -23869, 581 | -23731, -23592, -23452, -23311, 582 | -23169, -23027, -22883, -22739, 583 | -22594, -22448, -22301, -22153, 584 | -22004, -21855, -21705, -21554, 585 | -21402, -21249, -21096, -20942, 586 | -20787, -20631, -20474, -20317, 587 | -20159, -20000, -19840, -19680, 588 | -19519, -19357, -19194, -19031, 589 | -18867, -18702, -18537, -18371, 590 | -18204, -18036, -17868, -17699, 591 | -17530, -17360, -17189, -17017, 592 | -16845, -16672, -16499, -16325, 593 | -16150, -15975, -15799, -15623, 594 | -15446, -15268, -15090, -14911, 595 | -14732, -14552, -14372, -14191, 596 | -14009, -13827, -13645, -13462, 597 | -13278, -13094, -12909, -12724, 598 | -12539, -12353, -12166, -11980, 599 | -11792, -11604, -11416, -11227, 600 | -11038, -10849, -10659, -10469, 601 | -10278, -10087, -9895, -9703, 602 | -9511, -9319, -9126, -8932, 603 | -8739, -8545, -8351, -8156, 604 | -7961, -7766, -7571, -7375, 605 | -7179, -6982, -6786, -6589, 606 | -6392, -6195, -5997, -5799, 607 | -5601, -5403, -5205, -5006, 608 | -4807, -4608, -4409, -4210, 609 | -4011, -3811, -3611, -3411, 610 | -3211, -3011, -2811, -2610, 611 | -2410, -2209, -2009, -1808, 612 | -1607, -1406, -1206, -1005, 613 | -804, -603, -402, -201, 614 | 0, 615 | }; 616 | 617 | const uint16_t lut_env_expo[] = { 618 | 0, 1035, 2054, 3057, 619 | 4045, 5018, 5975, 6918, 620 | 7846, 8760, 9659, 10545, 621 | 11416, 12275, 13120, 13952, 622 | 14771, 15577, 16371, 17152, 623 | 17921, 18679, 19425, 20159, 624 | 20881, 21593, 22294, 22983, 625 | 23662, 24331, 24989, 25637, 626 | 26274, 26902, 27520, 28129, 627 | 28728, 29318, 29899, 30471, 628 | 31034, 31588, 32133, 32670, 629 | 33199, 33720, 34232, 34737, 630 | 35233, 35722, 36204, 36678, 631 | 37145, 37604, 38056, 38502, 632 | 38940, 39371, 39796, 40215, 633 | 40626, 41032, 41431, 41824, 634 | 42211, 42592, 42967, 43336, 635 | 43699, 44057, 44409, 44756, 636 | 45097, 45434, 45764, 46090, 637 | 46411, 46727, 47037, 47344, 638 | 47645, 47941, 48233, 48521, 639 | 48804, 49083, 49357, 49627, 640 | 49893, 50155, 50412, 50666, 641 | 50916, 51162, 51404, 51642, 642 | 51877, 52108, 52335, 52559, 643 | 52780, 52997, 53210, 53421, 644 | 53628, 53831, 54032, 54230, 645 | 54424, 54616, 54804, 54990, 646 | 55173, 55353, 55530, 55704, 647 | 55876, 56045, 56211, 56375, 648 | 56536, 56695, 56851, 57005, 649 | 57157, 57306, 57453, 57597, 650 | 57740, 57880, 58018, 58153, 651 | 58287, 58419, 58548, 58676, 652 | 58801, 58925, 59047, 59167, 653 | 59285, 59401, 59515, 59628, 654 | 59739, 59848, 59955, 60061, 655 | 60165, 60267, 60368, 60468, 656 | 60566, 60662, 60757, 60850, 657 | 60942, 61032, 61121, 61209, 658 | 61295, 61380, 61464, 61546, 659 | 61628, 61707, 61786, 61863, 660 | 61939, 62014, 62088, 62161, 661 | 62233, 62303, 62372, 62441, 662 | 62508, 62574, 62639, 62703, 663 | 62767, 62829, 62890, 62950, 664 | 63010, 63068, 63125, 63182, 665 | 63238, 63293, 63347, 63400, 666 | 63452, 63504, 63554, 63604, 667 | 63654, 63702, 63750, 63797, 668 | 63843, 63888, 63933, 63977, 669 | 64021, 64063, 64105, 64147, 670 | 64188, 64228, 64267, 64306, 671 | 64344, 64382, 64419, 64456, 672 | 64492, 64527, 64562, 64596, 673 | 64630, 64664, 64696, 64729, 674 | 64760, 64792, 64822, 64853, 675 | 64883, 64912, 64941, 64969, 676 | 64997, 65025, 65052, 65079, 677 | 65105, 65131, 65157, 65182, 678 | 65206, 65231, 65255, 65278, 679 | 65302, 65324, 65347, 65369, 680 | 65391, 65412, 65434, 65454, 681 | 65475, 65495, 65515, 65535, 682 | 65535, 683 | }; 684 | 685 | const uint32_t lut_oscillator_increments[] = { 686 | 594570139, 598878640, 603218361, 607589530, 687 | 611992374, 616427123, 620894008, 625393262, 688 | 629925120, 634489817, 639087591, 643718683, 689 | 648383334, 653081787, 657814287, 662581081, 690 | 667382416, 672218544, 677089717, 681996188, 691 | 686938214, 691916051, 696929960, 701980202, 692 | 707067040, 712190739, 717351567, 722549792, 693 | 727785686, 733059521, 738371572, 743722117, 694 | 749111434, 754539804, 760007511, 765514839, 695 | 771062075, 776649508, 782277431, 787946136, 696 | 793655918, 799407076, 805199909, 811034720, 697 | 816911812, 822831491, 828794068, 834799851, 698 | 840849155, 846942294, 853079587, 859261354, 699 | 865487916, 871759598, 878076727, 884439633, 700 | 890848647, 897304104, 903806339, 910355693, 701 | 916952505, 923597121, 930289887, 937031151, 702 | 943821265, 950660583, 957549461, 964488259, 703 | 971477339, 978517064, 985607802, 992749922, 704 | 999943798, 1007189803, 1014488315, 1021839716, 705 | 1029244387, 1036702717, 1044215092, 1051781905, 706 | 1059403550, 1067080425, 1074812930, 1082601467, 707 | 1090446444, 1098348268, 1106307352, 1114324111, 708 | 1122398963, 1130532329, 1138724632, 1146976300, 709 | 1155287763, 1163659455, 1172091811, 1180585271, 710 | 1189140279, 711 | }; --------------------------------------------------------------------------------