diff --git a/MicroDexed.ino b/MicroDexed.ino index 21bdf6b..e103a6e 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -89,9 +89,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]; +AudioPlaySdWav* Drum[NUM_DRUMS]; #if NUM_DRUMS < 5 AudioMixer4 drum_mixer_r; AudioMixer4 drum_mixer_l; @@ -196,11 +194,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 * 6 ]; +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 * 6]; +AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 4]; #else -AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 4]; +AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 2]; #endif void create_audio_dexed_chain(uint8_t instance_id) { @@ -257,17 +255,13 @@ void create_audio_dexed_chain(uint8_t instance_id) #if NUM_DRUMS > 0 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_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); + Drum[instance_id] = new AudioPlaySdWav(); + + dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_mixer_r, instance_id); + dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 1, drum_mixer_l, instance_id); #ifdef USE_FX - dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 0, drum_reverb_send_mixer_r, instance_id); - dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 1, drum_reverb_send_mixer_l, instance_id); + dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_r, instance_id); + dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 1, drum_reverb_send_mixer_l, instance_id); #endif #ifdef DEBUG @@ -823,13 +817,14 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) if (inNumber == drum_config[d].midinote) { uint8_t slot = drum_get_slot(drum_config[d].type); - if (Drum[slot]->isPlaying()) - Drum[slot]->stop(); - drum_volume[slot]->gain(pseudo_log_curve(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); - drum_mono2stereo[slot]->panorama(drum_config[d].pan); - drum_reverb_send_mixer_r.gain(slot, pseudo_log_curve(drum_config[d].reverb_send)); - drum_reverb_send_mixer_l.gain(slot, pseudo_log_curve(drum_config[d].reverb_send)); + float fsin = mapfloat(arm_sin_f32(drum_config[d].pan * PI / 2.0), -1.0, 1.0, 0.0, 1.0); + + drum_mixer_r.gain(slot, (1.0 - fsin) * pseudo_log_curve(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); + drum_mixer_l.gain(slot, fsin * pseudo_log_curve(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); + drum_reverb_send_mixer_r.gain(slot, (1.0 - fsin) * pseudo_log_curve(drum_config[d].reverb_send)); + drum_reverb_send_mixer_l.gain(slot, fsin * pseudo_log_curve(drum_config[d].reverb_send)); Drum[slot]->play(drum_config[d].filename); + #ifdef DEBUG Serial.print(F("Drum ")); Serial.print(drum_config[d].shortname); @@ -842,7 +837,9 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) Serial.print(F(" P")); Serial.print(drum_config[d].pan, 2); Serial.print(F(" RS")); - Serial.println(drum_config[d].reverb_send, 2); + Serial.print(drum_config[d].reverb_send, 2); + Serial.print(F(" fsin")); + Serial.println(fsin, 2); #endif break; } diff --git a/addon/SD/drm/808Clap1.wav b/addon/SD/drm/808Clap1.wav new file mode 100644 index 0000000..fc3413d Binary files /dev/null and b/addon/SD/drm/808Clap1.wav differ diff --git a/addon/SD/drm/808HHCL1.wav b/addon/SD/drm/808HHCL1.wav new file mode 100644 index 0000000..53eea44 Binary files /dev/null and b/addon/SD/drm/808HHCL1.wav differ diff --git a/addon/SD/drm/808RimS1.wav b/addon/SD/drm/808RimS1.wav new file mode 100644 index 0000000..6ee7f9c Binary files /dev/null and b/addon/SD/drm/808RimS1.wav differ diff --git a/addon/SD/drm/CFG_MDDrums.json b/addon/SD/drm/CFG_MDDrums.json index d94b1ce..bfdbcd4 100644 --- a/addon/SD/drm/CFG_MDDrums.json +++ b/addon/SD/drm/CFG_MDDrums.json @@ -1,24 +1,22 @@ { - [ - type: "DRUM_BASS", - midinote: "MIDI_C3", - filename: "bd01.raw", - shortname: "B", - pan: 0.0, - vol_max: 0.8, - vol_min: 0.0, - reverb_send: 0.0 - ], - [ - type: "DRUM_HANDCLAP", - midinote: "MIDI_CIS3", - filename: "cp02.raw", - shortname: "C", - pan: -0.4, - vol_max: 0.6, - vol_min: 0.0, - reverb_send: 0.4 - ], + "bd01": { + "type": "DRUM_BASS", + "midinote": "MIDI_C3", + "shortname": "B", + "pan": 0.0, + "vol_max": 0.8, + "vol_min": 0.0, + "reverb_send": 0.0 + }, + "cp02": { + "type": "DRUM_HANDCLAP", + "midinote": "MIDI_CIS3", + "shortname": "C", + "pan": -0.4, + "vol_max:" 0.6, + "vol_min:" 0.0, + "reverb_send:" 0.4 + }, [ type: "DRUM_SNARE", midinote: "MIDI_D3", diff --git a/addon/SD/drm/PHKick1.wav b/addon/SD/drm/PHKick1.wav new file mode 100644 index 0000000..45ab6ea Binary files /dev/null and b/addon/SD/drm/PHKick1.wav differ diff --git a/addon/SD/drm/bd01.wav b/addon/SD/drm/bd01.wav new file mode 100644 index 0000000..18d258e Binary files /dev/null and b/addon/SD/drm/bd01.wav differ diff --git a/addon/SD/drm/bd02.wav b/addon/SD/drm/bd02.wav new file mode 100644 index 0000000..a7cb59b Binary files /dev/null and b/addon/SD/drm/bd02.wav differ diff --git a/addon/SD/drm/bd03.wav b/addon/SD/drm/bd03.wav new file mode 100644 index 0000000..ea36827 Binary files /dev/null and b/addon/SD/drm/bd03.wav differ diff --git a/addon/SD/drm/bd04.wav b/addon/SD/drm/bd04.wav new file mode 100644 index 0000000..1526776 Binary files /dev/null and b/addon/SD/drm/bd04.wav differ diff --git a/addon/SD/drm/bd05.wav b/addon/SD/drm/bd05.wav new file mode 100644 index 0000000..8aa8047 Binary files /dev/null and b/addon/SD/drm/bd05.wav differ diff --git a/addon/SD/drm/bd06.wav b/addon/SD/drm/bd06.wav new file mode 100644 index 0000000..adbc3fa Binary files /dev/null and b/addon/SD/drm/bd06.wav differ diff --git a/addon/SD/drm/bd07.wav b/addon/SD/drm/bd07.wav new file mode 100644 index 0000000..7ac44f1 Binary files /dev/null and b/addon/SD/drm/bd07.wav differ diff --git a/addon/SD/drm/bd08.wav b/addon/SD/drm/bd08.wav new file mode 100644 index 0000000..34d09eb Binary files /dev/null and b/addon/SD/drm/bd08.wav differ diff --git a/addon/SD/drm/bd09.wav b/addon/SD/drm/bd09.wav new file mode 100644 index 0000000..42bb992 Binary files /dev/null and b/addon/SD/drm/bd09.wav differ diff --git a/addon/SD/drm/bd10.wav b/addon/SD/drm/bd10.wav new file mode 100644 index 0000000..8bac3e1 Binary files /dev/null and b/addon/SD/drm/bd10.wav differ diff --git a/addon/SD/drm/cp01.wav b/addon/SD/drm/cp01.wav new file mode 100644 index 0000000..9a8e03c Binary files /dev/null and b/addon/SD/drm/cp01.wav differ diff --git a/addon/SD/drm/cp02.wav b/addon/SD/drm/cp02.wav new file mode 100644 index 0000000..dd92b82 Binary files /dev/null and b/addon/SD/drm/cp02.wav differ diff --git a/addon/SD/drm/cr01.wav b/addon/SD/drm/cr01.wav new file mode 100644 index 0000000..fdd12d8 Binary files /dev/null and b/addon/SD/drm/cr01.wav differ diff --git a/addon/SD/drm/cr02.wav b/addon/SD/drm/cr02.wav new file mode 100644 index 0000000..1a08eb0 Binary files /dev/null and b/addon/SD/drm/cr02.wav differ diff --git a/addon/SD/drm/hh01.wav b/addon/SD/drm/hh01.wav new file mode 100644 index 0000000..0f2ab71 Binary files /dev/null and b/addon/SD/drm/hh01.wav differ diff --git a/addon/SD/drm/hh02.wav b/addon/SD/drm/hh02.wav new file mode 100644 index 0000000..33302b9 Binary files /dev/null and b/addon/SD/drm/hh02.wav differ diff --git a/addon/SD/drm/ht01.wav b/addon/SD/drm/ht01.wav new file mode 100644 index 0000000..65cbcff Binary files /dev/null and b/addon/SD/drm/ht01.wav differ diff --git a/addon/SD/drm/ht02.wav b/addon/SD/drm/ht02.wav new file mode 100644 index 0000000..52a112e Binary files /dev/null and b/addon/SD/drm/ht02.wav differ diff --git a/addon/SD/drm/lt01.wav b/addon/SD/drm/lt01.wav new file mode 100644 index 0000000..970f0f0 Binary files /dev/null and b/addon/SD/drm/lt01.wav differ diff --git a/addon/SD/drm/lt02.wav b/addon/SD/drm/lt02.wav new file mode 100644 index 0000000..5dd8ce8 Binary files /dev/null and b/addon/SD/drm/lt02.wav differ diff --git a/addon/SD/drm/mt01.wav b/addon/SD/drm/mt01.wav new file mode 100644 index 0000000..864e607 Binary files /dev/null and b/addon/SD/drm/mt01.wav differ diff --git a/addon/SD/drm/mt02.wav b/addon/SD/drm/mt02.wav new file mode 100644 index 0000000..4cf3192 Binary files /dev/null and b/addon/SD/drm/mt02.wav differ diff --git a/addon/SD/drm/oh01.wav b/addon/SD/drm/oh01.wav new file mode 100644 index 0000000..2c25099 Binary files /dev/null and b/addon/SD/drm/oh01.wav differ diff --git a/addon/SD/drm/oh02.wav b/addon/SD/drm/oh02.wav new file mode 100644 index 0000000..7e04a6c Binary files /dev/null and b/addon/SD/drm/oh02.wav differ diff --git a/addon/SD/drm/rd01.wav b/addon/SD/drm/rd01.wav new file mode 100644 index 0000000..ef8cd62 Binary files /dev/null and b/addon/SD/drm/rd01.wav differ diff --git a/addon/SD/drm/rd02.wav b/addon/SD/drm/rd02.wav new file mode 100644 index 0000000..28c311b Binary files /dev/null and b/addon/SD/drm/rd02.wav differ diff --git a/addon/SD/drm/rs01.wav b/addon/SD/drm/rs01.wav new file mode 100644 index 0000000..a63ad27 Binary files /dev/null and b/addon/SD/drm/rs01.wav differ diff --git a/addon/SD/drm/sd01.wav b/addon/SD/drm/sd01.wav new file mode 100644 index 0000000..37738f0 Binary files /dev/null and b/addon/SD/drm/sd01.wav differ diff --git a/addon/SD/drm/sd02.wav b/addon/SD/drm/sd02.wav new file mode 100644 index 0000000..9b2ffed Binary files /dev/null and b/addon/SD/drm/sd02.wav differ diff --git a/addon/SD/drm/sd03.wav b/addon/SD/drm/sd03.wav new file mode 100644 index 0000000..0e4a5aa Binary files /dev/null and b/addon/SD/drm/sd03.wav differ diff --git a/addon/SD/drm/sd04.wav b/addon/SD/drm/sd04.wav new file mode 100644 index 0000000..6d82f11 Binary files /dev/null and b/addon/SD/drm/sd04.wav differ diff --git a/addon/SD/drm/sd05.wav b/addon/SD/drm/sd05.wav new file mode 100644 index 0000000..b1e32c7 Binary files /dev/null and b/addon/SD/drm/sd05.wav differ diff --git a/addon/SD/drm/sd06.wav b/addon/SD/drm/sd06.wav new file mode 100644 index 0000000..6773cd2 Binary files /dev/null and b/addon/SD/drm/sd06.wav differ diff --git a/addon/SD/drm/sd07.wav b/addon/SD/drm/sd07.wav new file mode 100644 index 0000000..890b8e7 Binary files /dev/null and b/addon/SD/drm/sd07.wav differ diff --git a/addon/SD/drm/sd08.wav b/addon/SD/drm/sd08.wav new file mode 100644 index 0000000..74463a3 Binary files /dev/null and b/addon/SD/drm/sd08.wav differ diff --git a/addon/SD/drm/sd09.wav b/addon/SD/drm/sd09.wav new file mode 100644 index 0000000..8a0738c Binary files /dev/null and b/addon/SD/drm/sd09.wav differ diff --git a/addon/SD/drm/sd10.wav b/addon/SD/drm/sd10.wav new file mode 100644 index 0000000..038becb Binary files /dev/null and b/addon/SD/drm/sd10.wav differ diff --git a/addon/SD/drm/sd11.wav b/addon/SD/drm/sd11.wav new file mode 100644 index 0000000..7e689ec Binary files /dev/null and b/addon/SD/drm/sd11.wav differ diff --git a/addon/SD/drm/sd12.wav b/addon/SD/drm/sd12.wav new file mode 100644 index 0000000..90c7863 Binary files /dev/null and b/addon/SD/drm/sd12.wav differ diff --git a/addon/SD/drm/sd13.wav b/addon/SD/drm/sd13.wav new file mode 100644 index 0000000..826d539 Binary files /dev/null and b/addon/SD/drm/sd13.wav differ diff --git a/addon/SD/drm/sd14.wav b/addon/SD/drm/sd14.wav new file mode 100644 index 0000000..d598284 Binary files /dev/null and b/addon/SD/drm/sd14.wav differ diff --git a/addon/SD/drm/sd15.wav b/addon/SD/drm/sd15.wav new file mode 100644 index 0000000..98eca67 Binary files /dev/null and b/addon/SD/drm/sd15.wav differ diff --git a/doc/convert_wav2raw.txt b/doc/convert_wav2raw.txt new file mode 100644 index 0000000..f9781fd --- /dev/null +++ b/doc/convert_wav2raw.txt @@ -0,0 +1,11 @@ +Convert WAV to RAW: +for i in *.wav +do + sox $i -c 1 -b 16 -L `basename $i .wav`.raw +done + +Convert RAW to WAV: +for i in *.raw +do + sox -r 44100 -c 1 -b 16 -L -e signed $i `basename $i .raw`.wav +done diff --git a/drums.h b/drums.h index 1a67715..0fb91cc 100644 --- a/drums.h +++ b/drums.h @@ -49,7 +49,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_BASS, MIDI_C3, - "/drm/bd01.raw", + "/drm/bd01.wav", "B", 0.0, 0.8, @@ -59,7 +59,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HANDCLAP, MIDI_CIS3, - "/drm/cp02.raw", + "/drm/cp02.wav", "C", -0.4, 0.6, @@ -69,7 +69,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_SNARE, MIDI_D3, - "/drm/sd15.raw", + "/drm/sd15.wav", "S", 0.2, 0.6, @@ -79,7 +79,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HIHAT, MIDI_FIS3, - "/drm/hh01.raw", + "/drm/hh01.wav", "h", 0.8, 0.2, @@ -89,7 +89,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HIHAT, MIDI_GIS3, - "/drm/hh02.raw", + "/drm/hh02.wav", "h", 0.8, 0.2, @@ -99,7 +99,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HIHAT, MIDI_AIS3, - "/drm/oh02.raw", + "/drm/oh02.wav", "H", 0.8, 0.2, @@ -109,7 +109,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_LOWTOM, MIDI_G3, - "/drm/lt01.raw", + "/drm/lt01.wav", "T", -0.7, 0.8, @@ -119,7 +119,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HIGHTOM, MIDI_A3, - "/drm/ht01.raw", + "/drm/ht01.wav", "T", -0.5, 0.8, @@ -129,7 +129,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_RIDE, MIDI_CIS4, - "/drm/rd01.raw", + "/drm/rd01.wav", "R", -0.6, 0.3, @@ -139,7 +139,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_RIDE, MIDI_DIS4, - "/drm/rd02.raw", + "/drm/rd02.wav", "R", -0.6, 0.3, @@ -149,9 +149,9 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_BASS, MIDI_C5, - "/drm/PHKick1.raw", + "/drm/PHKick1.wav", "B", - 0.0, + -1.0, 0.9, 0.0, 0.0 @@ -159,9 +159,9 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HANDCLAP, MIDI_DIS5, - "/drm/808Clap1.raw", + "/drm/808Clap1.wav", "C", - 0.0, + 1.0, 0.9, 0.0, 0.4 @@ -169,7 +169,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_SNARE, MIDI_CIS5, - "/drm/808RimS1.raw", + "/drm/808RimS1.wav", "R", -0.3, 0.5, @@ -179,9 +179,9 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { { DRUM_HIHAT, MIDI_FIS5, - "/drm/808HHCL1.raw", + "/drm/808HHCL1.wav", "H", - 0.4, + 1.0, 0.6, 0.0, 0.0