diff --git a/MicroDexed.ino b/MicroDexed.ino
index fa8152c..27066bd 100644
--- a/MicroDexed.ino
+++ b/MicroDexed.ino
@@ -303,6 +303,11 @@ int perform_release_mod[NUM_DEXED] = { 0 };
// Allocate the delay lines for chorus
int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER];
#endif
+#if NUM_DRUMS >1
+static uint8_t drum_counter;
+static uint8_t drum_type[NUM_DRUMS];
+enum {DRUM_NONE, DRUM_BASS, DRUM_SNAREDRUM, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM};
+#endif
#ifdef ENABLE_LCD_UI
extern LCDMenuLib2 LCDML;
@@ -709,8 +714,6 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
}
#if NUM_DRUMS > 0
- static uint8_t drum_counter;
-
// Check for Drum
if (inChannel == DRUM_MIDI_CHANNEL)
{
@@ -729,50 +732,72 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
switch (inNumber - 48)
{
case 0:
- Drum[drum_counter % 4]->play("/DRM/BD01.RAW");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_BASS)]->play("/DRM/BD01.RAW");
break;
case 1:
- Drum[drum_counter % 4]->play("/drm/cp02.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_HANDCLAP)]->play("/drm/cp02.raw");
break;
case 2:
- Drum[drum_counter % 4]->play("/drm/sd15.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_SNAREDRUM)]->play("/drm/sd15.raw");
break;
case 6:
- Drum[drum_counter % 4]->play("/drm/hh01.wav");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh01.wav");
break;
case 8:
- Drum[drum_counter % 4]->play("/drm/hh02.wav");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh02.wav");
break;
case 10:
- Drum[drum_counter % 4]->play("/drm/oh02.wav");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/oh02.wav");
break;
case 5:
- Drum[drum_counter % 4]->play("/drm/lt01.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_LOWTOM)]->play("/drm/lt01.raw");
break;
case 7:
- Drum[drum_counter % 4]->play("/drm/ht01.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_HIGHTOM)]->play("/drm/ht01.raw");
break;
case 13:
- Drum[drum_counter % 4]->play("/drm/rd01.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd01.raw");
break;
case 15:
- Drum[drum_counter % 4]->play("/drm/rd02.raw");
- drum_counter++;
+ Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd02.raw");
break;
}
}
#endif
}
+#if NUM_DRUMS > 0
+uint8_t drum_get_slot(uint8_t dt)
+{
+ for (uint8_t i = 0; i < NUM_DRUMS; i++)
+ {
+ if (!Drum[i]->isPlaying())
+ drum_type[i] = DRUM_NONE;
+ else
+ {
+ if (drum_type[i] == dt)
+ {
+#ifdef DEBUG
+ Serial.print(F("Stopping Drum "));
+ Serial.print(i);
+ Serial.print(F(" type "));
+ Serial.println(dt);
+#endif
+ Drum[i]->stop();
+ return (i);
+ }
+ }
+ }
+#ifdef DEBUG
+ Serial.print(F("Using next free Drum slot "));
+ Serial.println(drum_counter % 4);
+#endif
+ drum_type[drum_counter % 4] = dt;
+ drum_counter++;
+ return (drum_counter - 1 % 4);
+}
+#endif
+
void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
diff --git a/effect_auto_pan.cpp b/effect_auto_pan.cpp
index 455ac31..d3d8bf3 100644
--- a/effect_auto_pan.cpp
+++ b/effect_auto_pan.cpp
@@ -29,6 +29,33 @@
// Written by Holger Wirtz
// 20191205 - initial version
+static const audio_block_t zeroblock = {
+ 0, 0, 0, {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#if AUDIO_BLOCK_SAMPLES > 16
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 32
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 48
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 64
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 80
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 96
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+#if AUDIO_BLOCK_SAMPLES > 112
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#endif
+ }
+};
+
void AudioEffectAutoPan::update(void)
{
audio_block_t *in;
@@ -37,12 +64,12 @@ void AudioEffectAutoPan::update(void)
in = receiveReadOnly(0);
if (!in)
- return;
+ in = (audio_block_t*)&zeroblock;
mod = receiveReadOnly(1);
if (!mod)
- return;
-
+ mod = (audio_block_t*)&zeroblock;
+
out[0] = allocate();
out[1] = allocate();
@@ -66,10 +93,15 @@ void AudioEffectAutoPan::update(void)
{
release(in);
}
- if (mod)
+ if (in != (audio_block_t*)&zeroblock)
+ {
+ release(in);
+ }
+ if (mod != (audio_block_t*)&zeroblock)
{
release(mod);
}
+
for (uint8_t i = 0; i < 2; i++)
{
if (out[i])
diff --git a/effect_stereo_mono.cpp b/effect_stereo_mono.cpp
index 0a5d924..4137fef 100644
--- a/effect_stereo_mono.cpp
+++ b/effect_stereo_mono.cpp
@@ -77,6 +77,7 @@ void AudioEffectStereoMono::update(void)
transmit(block[0], 0);
release(block[0]);
}
+
if (block[1])
{
transmit(block[1], 1);
diff --git a/mixer8.cpp b/mixer8.cpp
new file mode 100644
index 0000000..98328b8
--- /dev/null
+++ b/mixer8.cpp
@@ -0,0 +1,1964 @@
+
+
+
+
+
+
+ dcoredump/MicroDexed: MicroDexed is a compatible 6-operator-FM-synth based on the Teensy(-3.6/-4.x) Microcontroller. - mixer8.cpp at 890f7690b3bb6141fb4d8493c5f85a4cf2a3e51c - MicroDexed - Codeberg.org
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ You can not select more than 25 topics
+ Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ /* Audio Library for Teensy 3.X
+ |
+
+
+
+
+
+ |
+
+ * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * Development of this audio library was funded by PJRC.COM, LLC by sales of
+ |
+
+
+
+
+
+ |
+
+ * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
+ |
+
+
+
+
+
+ |
+
+ * open source software by purchasing Teensy or other PJRC products.
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ |
+
+
+
+
+
+ |
+
+ * of this software and associated documentation files (the "Software"), to deal
+ |
+
+
+
+
+
+ |
+
+ * in the Software without restriction, including without limitation the rights
+ |
+
+
+
+
+
+ |
+
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ |
+
+
+
+
+
+ |
+
+ * copies of the Software, and to permit persons to whom the Software is
+ |
+
+
+
+
+
+ |
+
+ * furnished to do so, subject to the following conditions:
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * The above copyright notice, development funding notice, and this permission
+ |
+
+
+
+
+
+ |
+
+ * notice shall be included in all copies or substantial portions of the Software.
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ |
+
+
+
+
+
+ |
+
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ |
+
+
+
+
+
+ |
+
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ |
+
+
+
+
+
+ |
+
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ |
+
+
+
+
+
+ |
+
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ |
+
+
+
+
+
+ |
+
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ |
+
+
+
+
+
+ |
+
+ * THE SOFTWARE.
+ |
+
+
+
+
+
+ |
+
+ */
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #include <Arduino.h>
+ |
+
+
+
+
+
+ |
+
+ #include "mixer8.h"
+ |
+
+
+
+
+
+ |
+
+ #include "utility/dspinst.h"
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ #if defined(__ARM_ARCH_7EM__)
+ |
+
+
+
+
+
+ |
+
+ #define MULTI_UNITYGAIN 65536
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ static void applyGain(int16_t *data, int32_t mult)
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ uint32_t *p = (uint32_t *)data;
+ |
+
+
+
+
+
+ |
+
+ const uint32_t *end = (uint32_t *)(data + AUDIO_BLOCK_SAMPLES);
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ uint32_t tmp32 = *p; // read 2 samples from *data
+ |
+
+
+
+
+
+ |
+
+ int32_t val1 = signed_multiply_32x16b(mult, tmp32);
+ |
+
+
+
+
+
+ |
+
+ int32_t val2 = signed_multiply_32x16t(mult, tmp32);
+ |
+
+
+
+
+
+ |
+
+ val1 = signed_saturate_rshift(val1, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ val2 = signed_saturate_rshift(val2, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ *p++ = pack_16b_16b(val2, val1);
+ |
+
+
+
+
+
+ |
+
+ } while (p < end);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ static void applyGainThenAdd(int16_t *data, const int16_t *in, int32_t mult)
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ uint32_t *dst = (uint32_t *)data;
+ |
+
+
+
+
+
+ |
+
+ const uint32_t *src = (uint32_t *)in;
+ |
+
+
+
+
+
+ |
+
+ const uint32_t *end = (uint32_t *)(data + AUDIO_BLOCK_SAMPLES);
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ if (mult == MULTI_UNITYGAIN) {
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ uint32_t tmp32 = *dst;
+ |
+
+
+
+
+
+ |
+
+ *dst++ = signed_add_16_and_16(tmp32, *src++);
+ |
+
+
+
+
+
+ |
+
+ tmp32 = *dst;
+ |
+
+
+
+
+
+ |
+
+ *dst++ = signed_add_16_and_16(tmp32, *src++);
+ |
+
+
+
+
+
+ |
+
+ } while (dst < end);
+ |
+
+
+
+
+
+ |
+
+ } else {
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ uint32_t tmp32 = *src++; // read 2 samples from *data
+ |
+
+
+
+
+
+ |
+
+ int32_t val1 = signed_multiply_32x16b(mult, tmp32);
+ |
+
+
+
+
+
+ |
+
+ int32_t val2 = signed_multiply_32x16t(mult, tmp32);
+ |
+
+
+
+
+
+ |
+
+ val1 = signed_saturate_rshift(val1, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ val2 = signed_saturate_rshift(val2, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ tmp32 = pack_16b_16b(val2, val1);
+ |
+
+
+
+
+
+ |
+
+ uint32_t tmp32b = *dst;
+ |
+
+
+
+
+
+ |
+
+ *dst++ = signed_add_16_and_16(tmp32, tmp32b);
+ |
+
+
+
+
+
+ |
+
+ } while (dst < end);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #elif defined(KINETISL)
+ |
+
+
+
+
+
+ |
+
+ #define MULTI_UNITYGAIN 256
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ static void applyGain(int16_t *data, int32_t mult)
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ const int16_t *end = data + AUDIO_BLOCK_SAMPLES;
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ int32_t val = *data * mult;
+ |
+
+
+
+
+
+ |
+
+ *data++ = signed_saturate_rshift(val, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ } while (data < end);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ static void applyGainThenAdd(int16_t *dst, const int16_t *src, int32_t mult)
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ const int16_t *end = dst + AUDIO_BLOCK_SAMPLES;
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ if (mult == MULTI_UNITYGAIN) {
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ int32_t val = *dst + *src++;
+ |
+
+
+
+
+
+ |
+
+ *dst++ = signed_saturate_rshift(val, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ } while (dst < end);
+ |
+
+
+
+
+
+ |
+
+ } else {
+ |
+
+
+
+
+
+ |
+
+ do {
+ |
+
+
+
+
+
+ |
+
+ int32_t val = *dst + ((*src++ * mult) >> 8); // overflow possible??
+ |
+
+
+
+
+
+ |
+
+ *dst++ = signed_saturate_rshift(val, 16, 0);
+ |
+
+
+
+
+
+ |
+
+ } while (dst < end);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #endif
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ void AudioMixer8::update(void)
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ audio_block_t *in, *out=NULL;
+ |
+
+
+
+
+
+ |
+
+ unsigned int channel;
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ for (channel=0; channel < 8; channel++) {
+ |
+
+
+
+
+
+ |
+
+ if (!out) {
+ |
+
+
+
+
+
+ |
+
+ out = receiveWritable(channel);
+ |
+
+
+
+
+
+ |
+
+ if (out) {
+ |
+
+
+
+
+
+ |
+
+ int32_t mult = multiplier[channel];
+ |
+
+
+
+
+
+ |
+
+ if (mult != MULTI_UNITYGAIN) applyGain(out->data, mult);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ } else {
+ |
+
+
+
+
+
+ |
+
+ in = receiveReadOnly(channel);
+ |
+
+
+
+
+
+ |
+
+ if (in) {
+ |
+
+
+
+
+
+ |
+
+ applyGainThenAdd(out->data, in->data, multiplier[channel]);
+ |
+
+
+
+
+
+ |
+
+ release(in);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ if (out) {
+ |
+
+
+
+
+
+ |
+
+ transmit(out);
+ |
+
+
+
+
+
+ |
+
+ release(out);
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ }
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mixer8.h b/mixer8.h
new file mode 100644
index 0000000..85f6f77
--- /dev/null
+++ b/mixer8.h
@@ -0,0 +1,1390 @@
+
+
+
+
+
+
+ dcoredump/MicroDexed: MicroDexed is a compatible 6-operator-FM-synth based on the Teensy(-3.6/-4.x) Microcontroller. - mixer8.h at 890f7690b3bb6141fb4d8493c5f85a4cf2a3e51c - MicroDexed - Codeberg.org
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ You can not select more than 25 topics
+ Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ /* Audio Library for Teensy 3.X
+ |
+
+
+
+
+
+ |
+
+ * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * Development of this audio library was funded by PJRC.COM, LLC by sales of
+ |
+
+
+
+
+
+ |
+
+ * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
+ |
+
+
+
+
+
+ |
+
+ * open source software by purchasing Teensy or other PJRC products.
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ |
+
+
+
+
+
+ |
+
+ * of this software and associated documentation files (the "Software"), to deal
+ |
+
+
+
+
+
+ |
+
+ * in the Software without restriction, including without limitation the rights
+ |
+
+
+
+
+
+ |
+
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ |
+
+
+
+
+
+ |
+
+ * copies of the Software, and to permit persons to whom the Software is
+ |
+
+
+
+
+
+ |
+
+ * furnished to do so, subject to the following conditions:
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * The above copyright notice, development funding notice, and this permission
+ |
+
+
+
+
+
+ |
+
+ * notice shall be included in all copies or substantial portions of the Software.
+ |
+
+
+
+
+
+ |
+
+ *
+ |
+
+
+
+
+
+ |
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ |
+
+
+
+
+
+ |
+
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ |
+
+
+
+
+
+ |
+
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ |
+
+
+
+
+
+ |
+
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ |
+
+
+
+
+
+ |
+
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ |
+
+
+
+
+
+ |
+
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ |
+
+
+
+
+
+ |
+
+ * THE SOFTWARE.
+ |
+
+
+
+
+
+ |
+
+ */
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #ifndef mixer8_h_
+ |
+
+
+
+
+
+ |
+
+ #define mixer8_h_
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ #include "Arduino.h"
+ |
+
+
+
+
+
+ |
+
+ #include "AudioStream.h"
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+ |
+
+ class AudioMixer8 : public AudioStream
+ |
+
+
+
+
+
+ |
+
+ {
+ |
+
+
+
+
+
+ |
+
+ #if defined(__ARM_ARCH_7EM__)
+ |
+
+
+
+
+
+ |
+
+ public:
+ |
+
+
+
+
+
+ |
+
+ AudioMixer8(void) : AudioStream(8, inputQueueArray) {
+ |
+
+
+
+
+
+ |
+
+ for (int i=0; i<8; i++) multiplier[i] = 65536;
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ virtual void update(void);
+ |
+
+
+
+
+
+ |
+
+ void gain(unsigned int channel, float gain) {
+ |
+
+
+
+
+
+ |
+
+ if (channel >= 8) return;
+ |
+
+
+
+
+
+ |
+
+ if (gain > 32767.0f) gain = 32767.0f;
+ |
+
+
+
+
+
+ |
+
+ else if (gain < -32767.0f) gain = -32767.0f;
+ |
+
+
+
+
+
+ |
+
+ multiplier[channel] = gain * 65536.0f; // TODO: proper roundoff?
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ private:
+ |
+
+
+
+
+
+ |
+
+ int32_t multiplier[8];
+ |
+
+
+
+
+
+ |
+
+ audio_block_t *inputQueueArray[8];
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #elif defined(KINETISL)
+ |
+
+
+
+
+
+ |
+
+ public:
+ |
+
+
+
+
+
+ |
+
+ AudioMixer8(void) : AudioStream(8, inputQueueArray) {
+ |
+
+
+
+
+
+ |
+
+ for (int i=0; i<8; i++) multiplier[i] = 256;
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ virtual void update(void);
+ |
+
+
+
+
+
+ |
+
+ void gain(unsigned int channel, float gain) {
+ |
+
+
+
+
+
+ |
+
+ if (channel >= 8) return;
+ |
+
+
+
+
+
+ |
+
+ if (gain > 127.0f) gain = 127.0f;
+ |
+
+
+
+
+
+ |
+
+ else if (gain < -127.0f) gain = -127.0f;
+ |
+
+
+
+
+
+ |
+
+ multiplier[channel] = gain * 256.0f; // TODO: proper roundoff?
+ |
+
+
+
+
+
+ |
+
+ }
+ |
+
+
+
+
+
+ |
+
+ private:
+ |
+
+
+
+
+
+ |
+
+ int16_t multiplier[8];
+ |
+
+
+
+
+
+ |
+
+ audio_block_t *inputQueueArray[8];
+ |
+
+
+
+
+
+ |
+
+ #endif
+ |
+
+
+
+
+
+ |
+
+ };
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+ #endif
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+