Fixed problems with input block handling in modulated_delay and mono_stereo.

pull/48/head
Holger Wirtz 3 years ago
parent 912684b132
commit 3f0279987d
  1. 47
      MicroDexed.ino
  2. 4
      config.h
  3. 35
      effect_modulated_delay.cpp
  4. 33
      effect_mono_stereo.cpp

@ -82,7 +82,7 @@ AudioMixer4 audio_thru_mixer_l;
#endif #endif
// Drumset // Drumset
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
AudioPlaySdRaw* Drum[NUM_DRUMS]; AudioPlaySdRaw* Drum[NUM_DRUMS];
AudioEffectMonoStereo* drum_mono2stereo[NUM_DRUMS]; AudioEffectMonoStereo* drum_mono2stereo[NUM_DRUMS];
AudioMixer4 drum_mixer_r; AudioMixer4 drum_mixer_r;
@ -158,7 +158,7 @@ AudioConnection patchCord19(audio_thru_mixer_r, 0, i2s1, 0);
AudioConnection patchCord20(audio_thru_mixer_l, 0, i2s1, 1); AudioConnection patchCord20(audio_thru_mixer_l, 0, i2s1, 1);
#endif #endif
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
#ifdef USE_FX #ifdef USE_FX
AudioConnection patchCord21(drum_mixer_r, 0, reverb_mixer_r, 2); AudioConnection patchCord21(drum_mixer_r, 0, reverb_mixer_r, 2);
AudioConnection patchCord22(drum_mixer_l, 0, reverb_mixer_l, 2); AudioConnection patchCord22(drum_mixer_l, 0, reverb_mixer_l, 2);
@ -173,13 +173,13 @@ AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2);
// //
// Dynamic patching of MicroDexed objects // Dynamic patching of MicroDexed objects
// //
uint16_t nDynamic = 0; uint8_t nDynamic = 0;
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioConnection * dynamicConnections[NUM_DEXED * 17]; AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 3 ];
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT #elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT
AudioConnection * dynamicConnections[NUM_DEXED * 16]; AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 3];
#else #else
AudioConnection * dynamicConnections[NUM_DEXED * 5]; AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 3];
#endif #endif
void create_audio_dexed_chain(uint8_t instance_id) void create_audio_dexed_chain(uint8_t instance_id)
{ {
@ -198,10 +198,9 @@ void create_audio_dexed_chain(uint8_t instance_id)
#endif #endif
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id);
#if defined(USE_FX) #if defined(USE_FX)
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0); dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0); dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0); //////////////////////
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
dynamicConnections[nDynamic++] = new AudioConnection(*chorus_modulator[instance_id], 0, *modchorus_filter[instance_id], 0); dynamicConnections[nDynamic++] = new AudioConnection(*chorus_modulator[instance_id], 0, *modchorus_filter[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*modchorus_filter[instance_id], 0, *modchorus[instance_id], 1); dynamicConnections[nDynamic++] = new AudioConnection(*modchorus_filter[instance_id], 0, *modchorus[instance_id], 1);
@ -222,22 +221,34 @@ void create_audio_dexed_chain(uint8_t instance_id)
#endif #endif
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id);
#ifdef DEBUG
Serial.print(F("Dexed-Instance: "));
Serial.println(instance_id);
Serial.print(F("Dynamic-Connection-Counter="));
Serial.println(nDynamic);
#endif
} }
// //
// Dynamic patching of Drum objects // Dynamic patching of Drum objects
// //
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
uint16_t nDrumDynamic = 0;
AudioConnection* dynamicDrumConnections[NUM_DRUMS * 3];
void create_audio_drum_chain(uint8_t instance_id) void create_audio_drum_chain(uint8_t instance_id)
{ {
Drum[instance_id] = new AudioPlaySdRaw(); Drum[instance_id] = new AudioPlaySdRaw();
drum_mono2stereo[instance_id] = new AudioEffectMonoStereo(); drum_mono2stereo[instance_id] = new AudioEffectMonoStereo();
dynamicDrumConnections[nDrumDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_mono2stereo[instance_id], 0); dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_mono2stereo[instance_id], 0);
dynamicDrumConnections[nDrumDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 0, drum_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 0, drum_mixer_r, instance_id);
dynamicDrumConnections[nDrumDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 1, drum_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 1, drum_mixer_l, instance_id);
#ifdef DEBUG
Serial.print(F("Drum-Instance: "));
Serial.println(instance_id);
Serial.print(F("Dynamic-Connection-Counter="));
Serial.println(nDynamic);
#endif
} }
#endif #endif
@ -423,7 +434,7 @@ void setup()
} }
#endif #endif
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
// create dynamic Drum instances // create dynamic Drum instances
for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++)
{ {
@ -534,7 +545,7 @@ void setup()
master_mixer_r.gain(1, 0.0); master_mixer_r.gain(1, 0.0);
master_mixer_l.gain(1, 0.0); master_mixer_l.gain(1, 0.0);
#endif #endif
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
master_mixer_r.gain(2, 1.0); master_mixer_r.gain(2, 1.0);
master_mixer_l.gain(2, 1.0); master_mixer_l.gain(2, 1.0);
#else #else
@ -697,7 +708,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
} }
} }
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
static uint8_t drum_counter; static uint8_t drum_counter;
// Check for Drum // Check for Drum
@ -2040,7 +2051,7 @@ void set_fx_params(void)
freeverb.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); freeverb.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif #endif
#ifdef NUM_DRUMS #if NUM_DRUMS > 0
#ifdef USE_FX #ifdef USE_FX
reverb_mixer_r.gain(2, 1.0); // Drums-Send reverb_mixer_r.gain(2, 1.0); // Drums-Send
reverb_mixer_l.gain(2, 1.0); // Drums-Send reverb_mixer_l.gain(2, 1.0); // Drums-Send

@ -301,6 +301,10 @@
#define EEPROM_MARKER 0x4242 #define EEPROM_MARKER 0x4242
#ifndef NUM_DRUMS
#define NUM_DRUMS 0
#endif
// MAX_NOTES SETTINGS // MAX_NOTES SETTINGS
// Teensy-4.x settings // Teensy-4.x settings
#ifdef TEENSY4 #ifdef TEENSY4

@ -37,6 +37,33 @@ extern config_t configuration;
// 140219 - correct storage class (not static) // 140219 - correct storage class (not static)
// 190527 - added modulation input (by Holger Wirtz) // 190527 - added modulation input (by Holger Wirtz)
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
}
};
boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length) boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length)
{ {
#if 0 #if 0
@ -78,11 +105,11 @@ void AudioEffectModulatedDelay::update(void)
block = receiveWritable(0); block = receiveWritable(0);
if (!block) if (!block)
return; block = (audio_block_t*)&zeroblock;
modulation = receiveReadOnly(1); modulation = receiveReadOnly(1);
if (!modulation) if (!modulation)
return; modulation = (audio_block_t*)&zeroblock;
if (block && modulation) if (block && modulation)
{ {
@ -128,10 +155,10 @@ void AudioEffectModulatedDelay::update(void)
} }
} }
if (modulation) if (modulation != (audio_block_t*)&zeroblock)
release(modulation); release(modulation);
if (block) if (block != (audio_block_t*)&zeroblock)
{ {
transmit(block, 0); transmit(block, 0);
release(block); release(block);

@ -30,6 +30,33 @@
// Written by Holger Wirtz // Written by Holger Wirtz
// 20191122 - initial version // 20191122 - 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
}
};
#if !defined(_MAPFLOAT) #if !defined(_MAPFLOAT)
#define _MAPFLOAT #define _MAPFLOAT
inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max)
@ -50,7 +77,7 @@ void AudioEffectMonoStereo::update(void)
in = receiveReadOnly(0); in = receiveReadOnly(0);
if (!in) if (!in)
return; in = (audio_block_t*)&zeroblock;
out[0] = allocate(); out[0] = allocate();
out[1] = allocate(); out[1] = allocate();
@ -67,8 +94,9 @@ void AudioEffectMonoStereo::update(void)
*out_p[0]++ = int16_t(in_f[n] * _pseudo_log * fsin * SHRT_MAX); *out_p[0]++ = int16_t(in_f[n] * _pseudo_log * fsin * SHRT_MAX);
*out_p[1]++ = int16_t(in_f[n] * _pseudo_log * fcos * SHRT_MAX); *out_p[1]++ = int16_t(in_f[n] * _pseudo_log * fcos * SHRT_MAX);
} }
}
if (in) if (in != (audio_block_t*)&zeroblock)
{ {
release(in); release(in);
} }
@ -82,5 +110,4 @@ void AudioEffectMonoStereo::update(void)
transmit(out[1], 1); transmit(out[1], 1);
release(out[1]); release(out[1]);
} }
}
} }

Loading…
Cancel
Save