Several fixes for new drum configuration.

dev
Holger Wirtz 2 years ago
parent a88fba68f1
commit 1de59e5568
  1. 35
      MicroDexed.ino
  2. 162
      addon/SD/PERFORMANCE/0/drums.json
  3. 240038
      addon/tools/drumset.h
  4. 14
      dexed_sd.cpp
  5. 20
      drumset.h

@ -984,42 +984,45 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
if (inNumber == configuration.drums.midinote[d]) { if (inNumber == configuration.drums.midinote[d]) {
uint8_t slot = drum_get_slot(drum_config[d].drum_class); uint8_t slot = drum_get_slot(drum_config[d].drum_class);
float pan = mapfloat(configuration.drums.pan[d], -127.0, 127.0, 0.0, 1.0); float pan = mapfloat(configuration.drums.pan[d], -127.0, 127.0, 0.0, 1.0);
float reverb_send = configuration.drums.reverb_send[d] / 100.0f;
//drum_mixer_r.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); float vol_min = configuration.drums.vol_min[d] / 100.0f;
//drum_mixer_l.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); float vol_max = configuration.drums.vol_max[d] / 100.0f;
drum_mixer_r.gain(slot, (1.0 - pan) * mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max));
drum_mixer_l.gain(slot, pan * mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max)); //drum_mixer_r.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min/100.0f, configuration.drums.vol_max[d]/100.0f)));
//drum_mixer_l.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min/100.0f, configuration.drums.vol_max[d]/100.0f)));
drum_mixer_r.gain(slot, (1.0 - pan) * mapfloat(inVelocity, 0, 127, vol_min, vol_max));
drum_mixer_l.gain(slot, pan * mapfloat(inVelocity, 0, 127, vol_min, vol_max));
#ifdef USE_FX #ifdef USE_FX
//drum_reverb_send_mixer_r.gain(slot, (1.0 - pan) * volume_transform(drum_config[d].reverb_send)); //drum_reverb_send_mixer_r.gain(slot, (1.0 - pan) * volume_transform(reverb_send));
//drum_reverb_send_mixer_l.gain(slot, pan * volume_transform(drum_config[d].reverb_send)); //drum_reverb_send_mixer_l.gain(slot, pan * volume_transform(reverb_send));
drum_reverb_send_mixer_r.gain(slot, (1.0 - pan) * drum_config[d].reverb_send); drum_reverb_send_mixer_r.gain(slot, (1.0 - pan) * reverb_send);
drum_reverb_send_mixer_l.gain(slot, pan * drum_config[d].reverb_send); drum_reverb_send_mixer_l.gain(slot, pan * reverb_send);
#endif #endif
if (drum_config[d].drum_data != NULL && drum_config[d].len > 0) { if (drum_config[d].drum_data != NULL && drum_config[d].len > 0) {
if (configuration.drums.pitch[d] != 0) { if (configuration.drums.pitch[d] != 0) {
Drum[slot]->enableInterpolation(true); Drum[slot]->enableInterpolation(true);
Drum[slot]->setPlaybackRate(configuration.drum.pitch[d] / 10.0f); Drum[slot]->setPlaybackRate(configuration.drums.pitch[d] / 100.0f);
} }
Drum[slot]->playRaw((int16_t*)drum_config[d].drum_data, drum_config[d].len, 1); Drum[slot]->playRaw((int16_t*)drum_config[d].drum_data, drum_config[d].len, 1);
#ifdef DEBUG #ifdef DEBUG
Serial.printf("Playing sample [%s][%c%c] on slot [%d] main volume [%d]: drum_data=%p, len=%d\n", drum_config[d].name, drum_config[d].shortname[0], drum_config[d].shortname[1], slot, configuration.drums.main_vol, drum_config[d].drum_data, drum_config[d].len); Serial.printf(PSTR("Playing sample [%s][%c%c] on slot [%d] main volume [%d]: drum_data=%p, len=%d\n"), drum_config[d].name, drum_config[d].shortname[0], drum_config[d].shortname[1], slot, configuration.drums.main_vol, drum_config[d].drum_data, drum_config[d].len);
#endif
}
#ifdef DEBUG
Serial.print(F("Drum Slot [")); Serial.print(F("Drum Slot ["));
Serial.print(slot); Serial.print(slot);
Serial.print(F("]: Velocity=")); Serial.print(F("]: Velocity="));
Serial.print(mapfloat(inVelocity, 0, 127, configuration.drums.vol_min[d], configuration.drums.vol_max[d]), 2); Serial.print(mapfloat(inVelocity, 0, 127, vol_min, vol_max), 2);
Serial.print(F(" Pan=")); Serial.print(F(" Pan="));
Serial.print(pan, 2); Serial.print(pan, 2);
Serial.print(F(" ReverbSend=")); Serial.print(F(" ReverbSend="));
Serial.println(drum_config[d].reverb_send, 2); Serial.println(reverb_send, 2);
Serial.print(F(" Pitch="));
Serial.println(configuration.drums.pitch[d] / 10.0f, 1);
#endif #endif
break; break;
} }
} }
} }
}
#endif #endif
} }

@ -69,14 +69,14 @@
], ],
"pitch": [ "pitch": [
0, 0,
1.2, 12,
0, 0,
0, 0,
0, 0,
1.1, 11,
1.3, 13,
0, 0,
1.4, 14,
0, 0,
0, 0,
0, 0,
@ -91,10 +91,10 @@
0, 0,
0, 0,
0, 0,
1, 10,
0, 0,
1, 10,
0.9, 9,
0, 0,
0, 0,
0, 0,
@ -106,7 +106,7 @@
0, 0,
0, 0,
0, 0,
1.427136, 142,
0, 0,
0, 0,
0, 0,
@ -266,69 +266,69 @@
0 0
], ],
"vol_max": [ "vol_max": [
1, 100,
1, 100,
0.7, 70,
1, 100,
0.7, 70,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
1, 100,
0.75, 75,
0.56, 56,
1, 100,
1, 100,
1, 100,
0.79, 79,
0.73, 73,
1, 100,
0.89, 89,
0.74, 74,
0.93, 93,
1, 100,
1, 100,
0.86, 86,
0.74, 74,
0.9, 90,
0.9, 90,
0.8, 80,
0.8, 80,
0.77, 77,
0.8, 80,
0.8, 80,
0.83, 83,
1, 100,
0.78, 78,
0.88, 88,
0.9, 90,
0.94, 94,
0.9, 90,
0.9, 90,
0.9, 90,
0.8, 80,
0.9, 90,
0.9, 90,
1, 100,
1, 100,
0, 100,
0, 100,
0, 100,
0, 100,
0, 100,
0, 100,
0, 100,
0.8, 80,
0 0
], ],
"vol_min": [ "vol_min": [
@ -418,36 +418,36 @@
0, 0,
0, 0,
0, 0,
0.52, 52,
0.59, 59,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0.34, 34,
0, 0,
0.65, 65,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0.53, 53,
0, 0,
0, 0,
0, 0,
0, 0,
0.2, 20,
0, 0,
0, 0,
0.52, 52,
0.25, 25,
0.66, 66,
0, 0,
0, 0,
0.69, 69,
0, 0,
0, 0,
0, 0,

File diff suppressed because it is too large Load Diff

@ -416,7 +416,7 @@ bool load_sd_drumsettings_json(uint8_t number) {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Found drums configuration [")); Serial.print(F("Found drums configuration ["));
Serial.print(filename); Serial.print(filename);
Serial.println(F("]... loading...")); Serial.println(F("]... loading"));
#endif #endif
json = SD.open(filename); json = SD.open(filename);
if (json) { if (json) {
@ -491,12 +491,12 @@ bool save_sd_drumsettings_json(uint8_t number) {
data_json["midi_channel"] = configuration.drums.midi_channel; data_json["midi_channel"] = configuration.drums.midi_channel;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) {
data_json["note"][i] = drum_config[i].midinote; data_json["note"][i] = configuration.drums.midinote[i];
data_json["pitch"][i] = drum_config[i].pitch; data_json["pitch"][i] = configuration.drums.pitch[i];
data_json["pan"][i] = drum_config[i].pan; data_json["pan"][i] = configuration.drums.pan[i];
data_json["vol_max"][i] = drum_config[i].vol_max; data_json["vol_max"][i] = configuration.drums.vol_max[i];
data_json["vol_min"][i] = drum_config[i].vol_min; data_json["vol_min"][i] = configuration.drums.vol_min[i];
data_json["reverb_send"][i] = drum_config[i].reverb_send; data_json["reverb_send"][i] = configuration.drums.reverb_send[i];
} }
#if defined(DEBUG) && defined(DEBUG_SHOW_JSON) #if defined(DEBUG) && defined(DEBUG_SHOW_JSON)

@ -1,6 +1,22 @@
#pragma once #pragma once
#include "drums.h" #include <Arduino.h>
typedef struct drum_config_s {
uint8_t drum_class; // Type of drum
uint8_t midinote; // Triggered by note
char name[DRUM_NAME_LEN];
const uint8_t* drum_data;
char shortname[2]; // 1 char name for sequencer
uint32_t len; // number of elements in drum_data
float32_t pitch; // variable pitch per note for sequencer
float32_t pan; // Panorama (-1.0 - +1.0)
float32_t vol_max; // max. Volume (0.0 - 1.0)
float32_t vol_min; // min. Volume (0.0 - 1.0, should be <= vol_max)
float32_t reverb_send; // how much signal to send to the reverb (0.0 - 1.0)
} drum_config_t;
enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM, DRUM_PERCUSSION, DRUM_POLY};
// Converted from Clap808.wav, length = 7744 bytes // Converted from Clap808.wav, length = 7744 bytes
PROGMEM const uint8_t DRUM_Clap808[] = { PROGMEM const uint8_t DRUM_Clap808[] = {
@ -239201,7 +239217,7 @@ PROGMEM const uint8_t DRUM_Vl1hbeep[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
drum_config_t drum_config[NUM_DRUMSET_CONFIG] = PROGMEM const drum_config_t drum_config[NUM_DRUMSET_CONFIG] =
{ {
{ {
DRUM_BASS, DRUM_BASS,

Loading…
Cancel
Save