Implemented drumtype locking.

pull/48/head
Holger Wirtz 3 years ago
parent 3f0279987d
commit 4764799bb9
  1. 69
      MicroDexed.ino
  2. 38
      effect_auto_pan.cpp
  3. 1
      effect_stereo_mono.cpp
  4. 1964
      mixer8.cpp
  5. 1390
      mixer8.h

@ -303,6 +303,11 @@ int perform_release_mod[NUM_DEXED] = { 0 };
// Allocate the delay lines for chorus // Allocate the delay lines for chorus
int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER]; int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER];
#endif #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 #ifdef ENABLE_LCD_UI
extern LCDMenuLib2 LCDML; extern LCDMenuLib2 LCDML;
@ -709,8 +714,6 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
} }
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
static uint8_t drum_counter;
// Check for Drum // Check for Drum
if (inChannel == DRUM_MIDI_CHANNEL) if (inChannel == DRUM_MIDI_CHANNEL)
{ {
@ -729,50 +732,72 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
switch (inNumber - 48) switch (inNumber - 48)
{ {
case 0: case 0:
Drum[drum_counter % 4]->play("/DRM/BD01.RAW"); Drum[drum_get_slot(DRUM_BASS)]->play("/DRM/BD01.RAW");
drum_counter++;
break; break;
case 1: case 1:
Drum[drum_counter % 4]->play("/drm/cp02.raw"); Drum[drum_get_slot(DRUM_HANDCLAP)]->play("/drm/cp02.raw");
drum_counter++;
break; break;
case 2: case 2:
Drum[drum_counter % 4]->play("/drm/sd15.raw"); Drum[drum_get_slot(DRUM_SNAREDRUM)]->play("/drm/sd15.raw");
drum_counter++;
break; break;
case 6: case 6:
Drum[drum_counter % 4]->play("/drm/hh01.wav"); Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh01.wav");
drum_counter++;
break; break;
case 8: case 8:
Drum[drum_counter % 4]->play("/drm/hh02.wav"); Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh02.wav");
drum_counter++;
break; break;
case 10: case 10:
Drum[drum_counter % 4]->play("/drm/oh02.wav"); Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/oh02.wav");
drum_counter++;
break; break;
case 5: case 5:
Drum[drum_counter % 4]->play("/drm/lt01.raw"); Drum[drum_get_slot(DRUM_LOWTOM)]->play("/drm/lt01.raw");
drum_counter++;
break; break;
case 7: case 7:
Drum[drum_counter % 4]->play("/drm/ht01.raw"); Drum[drum_get_slot(DRUM_HIGHTOM)]->play("/drm/ht01.raw");
drum_counter++;
break; break;
case 13: case 13:
Drum[drum_counter % 4]->play("/drm/rd01.raw"); Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd01.raw");
drum_counter++;
break; break;
case 15: case 15:
Drum[drum_counter % 4]->play("/drm/rd02.raw"); Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd02.raw");
drum_counter++;
break; break;
} }
} }
#endif #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) void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{ {
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)

@ -29,6 +29,33 @@
// Written by Holger Wirtz // Written by Holger Wirtz
// 20191205 - initial version // 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) void AudioEffectAutoPan::update(void)
{ {
audio_block_t *in; audio_block_t *in;
@ -37,11 +64,11 @@ void AudioEffectAutoPan::update(void)
in = receiveReadOnly(0); in = receiveReadOnly(0);
if (!in) if (!in)
return; in = (audio_block_t*)&zeroblock;
mod = receiveReadOnly(1); mod = receiveReadOnly(1);
if (!mod) if (!mod)
return; mod = (audio_block_t*)&zeroblock;
out[0] = allocate(); out[0] = allocate();
out[1] = allocate(); out[1] = allocate();
@ -66,10 +93,15 @@ void AudioEffectAutoPan::update(void)
{ {
release(in); release(in);
} }
if (mod) if (in != (audio_block_t*)&zeroblock)
{
release(in);
}
if (mod != (audio_block_t*)&zeroblock)
{ {
release(mod); release(mod);
} }
for (uint8_t i = 0; i < 2; i++) for (uint8_t i = 0; i < 2; i++)
{ {
if (out[i]) if (out[i])

@ -77,6 +77,7 @@ void AudioEffectStereoMono::update(void)
transmit(block[0], 0); transmit(block[0], 0);
release(block[0]); release(block[0]);
} }
if (block[1]) if (block[1])
{ {
transmit(block[1], 1); transmit(block[1], 1);

File diff suppressed because it is too large Load Diff

1390
mixer8.h

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save