diff --git a/MicroDexed.ino b/MicroDexed.ino
index 27066bd..7a4eb77 100644
--- a/MicroDexed.ino
+++ b/MicroDexed.ino
@@ -41,6 +41,9 @@
#include "effect_freeverbf.h"
#endif
#include "UI.hpp"
+#if NUM_DRUMS > 0
+#include "drums.h"
+#endif
// Audio engines
AudioSynthDexed* MicroDexed[NUM_DEXED];
@@ -84,6 +87,7 @@ AudioMixer4 audio_thru_mixer_l;
// Drumset
#if NUM_DRUMS > 0
AudioPlaySdRaw* Drum[NUM_DRUMS];
+AudioAmplifier* drum_volume[NUM_DRUMS];
AudioEffectMonoStereo* drum_mono2stereo[NUM_DRUMS];
AudioMixer4 drum_mixer_r;
AudioMixer4 drum_mixer_l;
@@ -175,11 +179,11 @@ AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2);
//
uint8_t nDynamic = 0;
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
-AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 3 ];
+AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 4 ];
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT
-AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 3];
+AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 4];
#else
-AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 3];
+AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 4];
#endif
void create_audio_dexed_chain(uint8_t instance_id)
{
@@ -237,9 +241,11 @@ void create_audio_dexed_chain(uint8_t instance_id)
void create_audio_drum_chain(uint8_t instance_id)
{
Drum[instance_id] = new AudioPlaySdRaw();
+ drum_volume[instance_id] = new AudioAmplifier();
drum_mono2stereo[instance_id] = new AudioEffectMonoStereo();
- dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_mono2stereo[instance_id], 0);
+ dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_volume[instance_id], 0);
+ dynamicConnections[nDynamic++] = new AudioConnection(*drum_volume[instance_id], 0, *drum_mono2stereo[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 0, drum_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 1, drum_mixer_l, instance_id);
@@ -303,10 +309,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};
+
+#if NUM_DRUMS > 1
+extern uint8_t drum_counter;
+extern uint8_t drum_type[NUM_DRUMS];
+extern drum_config_t drum_config[NUM_DRUMCONFIG];
#endif
#ifdef ENABLE_LCD_UI
@@ -709,6 +716,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
Serial.print(inChannel, DEC);
Serial.println();
#endif
+ return;
}
}
}
@@ -729,38 +737,16 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
Serial.println(note_name);
#endif
- switch (inNumber - 48)
+ for (uint8_t d = 0; d < NUM_DRUMCONFIG; d++)
{
- case 0:
- Drum[drum_get_slot(DRUM_BASS)]->play("/DRM/BD01.RAW");
- break;
- case 1:
- Drum[drum_get_slot(DRUM_HANDCLAP)]->play("/drm/cp02.raw");
- break;
- case 2:
- Drum[drum_get_slot(DRUM_SNAREDRUM)]->play("/drm/sd15.raw");
- break;
- case 6:
- Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh01.wav");
- break;
- case 8:
- Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh02.wav");
- break;
- case 10:
- Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/oh02.wav");
- break;
- case 5:
- Drum[drum_get_slot(DRUM_LOWTOM)]->play("/drm/lt01.raw");
- break;
- case 7:
- Drum[drum_get_slot(DRUM_HIGHTOM)]->play("/drm/ht01.raw");
- break;
- case 13:
- Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd01.raw");
- break;
- case 15:
- Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd02.raw");
+ if (inNumber == drum_config[d].midinote)
+ {
+ uint8_t slot = drum_get_slot(drum_config[d].type);
+ drum_volume[slot]->gain(drum_config[d].vol);
+ drum_mono2stereo[slot]->panorama(drum_config[d].pan);
+ Drum[slot]->play(drum_config[d].filename);
break;
+ }
}
}
#endif
diff --git a/drums.h b/drums.h
new file mode 100644
index 0000000..0d9a32d
--- /dev/null
+++ b/drums.h
@@ -0,0 +1,112 @@
+/*
+ Copyright (c) 2019-2021 H. Wirtz
+
+ 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 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.
+*/
+
+#pragma once
+
+#if NUM_DRUMS >1
+uint8_t drum_counter;
+uint8_t drum_type[NUM_DRUMS];
+
+enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM};
+
+typedef struct drum_config_s {
+ uint8_t type; // Type of drum
+ uint8_t midinote; // Triggered by note
+ char filename[18]; // 44.1kHz mono LSB raw-sample to play
+ float32_t pan; // Panorama (-1.0 - +1.0)
+ float32_t vol; // Volume (0.0 - 1.0)
+} drum_config_t;
+
+#define NUM_DRUMCONFIG 10
+drum_config_t drum_config[NUM_DRUMCONFIG] = {
+ {
+ DRUM_BASS,
+ MIDI_C3,
+ "/drm/bd01.raw",
+ 0.0,
+ 0.8
+ },
+ {
+ DRUM_HANDCLAP,
+ MIDI_CIS3,
+ "/drm/cp02.raw",
+ -0.4,
+ 0.6
+ },
+ {
+ DRUM_SNARE,
+ MIDI_D3,
+ "/drm/sd15.raw",
+ 0.2,
+ 0.8
+ },
+ {
+ DRUM_HIHAT,
+ MIDI_FIS3,
+ "/drm/hh01.raw",
+ 0.8,
+ 0.8
+ },
+ {
+ DRUM_HIHAT,
+ MIDI_GIS3,
+ "/drm/hh02.raw",
+ 0.8,
+ 0.8
+ },
+ {
+ DRUM_HIHAT,
+ MIDI_AIS3,
+ "/drm/oh02.raw",
+ 0.8,
+ 0.8
+ },
+ {
+ DRUM_LOWTOM,
+ MIDI_G3,
+ "/drm/lt01.raw",
+ -0.7,
+ 0.8
+ },
+ {
+ DRUM_HIGHTOM,
+ MIDI_A3,
+ "/drm/ht01.raw",
+ -0.5,
+ 0.8
+ },
+ {
+ DRUM_RIDE,
+ MIDI_CIS4,
+ "/drm/rd01.raw",
+ -0.6,
+ 0.8
+ },
+ {
+ DRUM_RIDE,
+ MIDI_DIS4,
+ "/drm/rd02.raw",
+ -0.6,
+ 0.8
+ }
+};
+#endif
diff --git a/mixer8.cpp b/mixer8.cpp
index 98328b8..0f71e4c 100644
--- a/mixer8.cpp
+++ b/mixer8.cpp
@@ -1,1964 +1,133 @@
-
-
-
-
-
-
- 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This website works better with JavaScript.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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 ) ;
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+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
index 85f6f77..a4bd841 100644
--- a/mixer8.h
+++ b/mixer8.h
@@ -1,1390 +1,70 @@
-
-
-
-
-
-
- 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This website works better with JavaScript.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+/* 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