Fixing drum filename handling.

Adding drums and sequencer to T_3.6 menus.
pull/61/head
Holger Wirtz 3 years ago
parent 853895222e
commit ee10414a03
  1. 11
      MicroDexed.ino
  2. 28
      UI.hpp
  3. 32
      UI_FX.h
  4. 4
      UI_FX_T4.h
  5. 4
      UI_NO_FX.h
  6. 1
      config.h
  7. 17
      drums.cpp

@ -112,7 +112,7 @@ AudioMixer8 drum_reverb_send_mixer_l;
//AudioConnection patchCord[] = { //AudioConnection patchCord[] = {
// {wavetable[0], 0, mixer[0], 0}, {wavetable[1], 0, mixer[0], 1}, {wavetable[2], 0, mixer[0], 2}, {wavetable[3], 0, mixer[0], 3}, {mixer[0], 0, mixer[TOTAL_MIXERS - 2], 0}, // {wavetable[0], 0, mixer[0], 0}, {wavetable[1], 0, mixer[0], 1}, {wavetable[2], 0, mixer[0], 2}, {wavetable[3], 0, mixer[0], 3}, {mixer[0], 0, mixer[TOTAL_MIXERS - 2], 0},
// Audio chain tail // Audio chain tail
#if defined(USE_FX) #if defined(USE_FX)
#ifdef USE_PLATEREVERB #ifdef USE_PLATEREVERB
@ -521,7 +521,7 @@ void setup()
} }
else else
{ {
strcpy(drumset_name,"StdDrums"); strcpy(drumset_name, "StdDrums");
num_drums = read_drum_config(drumset_name); num_drums = read_drum_config(drumset_name);
check_and_create_directories(); check_and_create_directories();
@ -776,7 +776,12 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
drum_mixer_l.gain(slot, 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_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_reverb_send_mixer_l.gain(slot, fsin * pseudo_log_curve(drum_config[d].reverb_send));
Drum[slot]->play(drum_config[d].filename);
char f[DRUM_CFG_GILENAME_LEN];
strcpy(f, drum_config[d].filename);
strcat(f, ".wav");
Drum[slot]->play(f);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Drum ")); Serial.print(F("Drum "));

@ -314,6 +314,8 @@ void UI_func_drum_main_volume(uint8_t param);
void UI_func_drum_volume(uint8_t param); void UI_func_drum_volume(uint8_t param);
void UI_func_drum_pan(uint8_t param); void UI_func_drum_pan(uint8_t param);
char* basename(const char* filename);
char* strip_extension(char* filename);
// normal menu // normal menu
LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change) LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change)
@ -3613,8 +3615,7 @@ void UI_func_drum_reverb_send(uint8_t param)
sprintf(displayname, "%02d", activesample); sprintf(displayname, "%02d", activesample);
lcd.print(displayname); lcd.print(displayname);
lcd.setCursor(4, 1); lcd.setCursor(4, 1);
strncpy(displayname, drum_config[activesample].filename + 6 + strlen(drumset_name), 7); lcd.print(basename(drum_config[activesample].filename));
lcd.print(displayname);
sprintf(displayname, "%03d", (int)(drum_config[activesample].reverb_send * 100) ); sprintf(displayname, "%03d", (int)(drum_config[activesample].reverb_send * 100) );
lcd.setCursor(12, 1); lcd.setCursor(12, 1);
lcd.print(displayname); lcd.print(displayname);
@ -3641,7 +3642,7 @@ void UI_func_drum_reverb_send(uint8_t param)
void UI_func_drum_main_volume(uint8_t param) void UI_func_drum_main_volume(uint8_t param)
{ {
; ;
} }
void UI_func_drum_volume(uint8_t param) void UI_func_drum_volume(uint8_t param)
@ -3702,8 +3703,7 @@ void UI_func_drum_volume(uint8_t param)
sprintf(displayname, "%02d", activesample); sprintf(displayname, "%02d", activesample);
lcd.print(displayname); lcd.print(displayname);
lcd.setCursor(4, 1); lcd.setCursor(4, 1);
strncpy(displayname, drum_config[activesample].filename + 6+ strlen(drumset_name), 7); lcd.print(basename(drum_config[activesample].filename));
lcd.print(displayname);
sprintf(displayname, "%03d", (int)(drum_config[activesample].vol_max * 100) ); sprintf(displayname, "%03d", (int)(drum_config[activesample].vol_max * 100) );
lcd.setCursor(12, 1); lcd.setCursor(12, 1);
lcd.print(displayname); lcd.print(displayname);
@ -3791,8 +3791,7 @@ void UI_func_drum_pan(uint8_t param)
sprintf(displayname, "%02d", activesample); sprintf(displayname, "%02d", activesample);
lcd.print(displayname); lcd.print(displayname);
lcd.setCursor(4, 1); lcd.setCursor(4, 1);
strncpy(displayname, drum_config[activesample].filename + 6 + strlen(drumset_name), 7); lcd.print(basename(drum_config[activesample].filename));
lcd.print(displayname);
sprintf(displayname, "%+f", drum_config[activesample].pan); sprintf(displayname, "%+f", drum_config[activesample].pan);
lcd.setCursor(12, 1); lcd.setCursor(12, 1);
lcd.print(displayname); lcd.print(displayname);
@ -3935,17 +3934,13 @@ void UI_func_seq_lenght(uint8_t param)
void UI_func_sequencer(uint8_t param) void UI_func_sequencer(uint8_t param)
{ {
char displayname[8]={0,0,0,0,0,0,0,0};
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
encoderDir[ENC_R].reset(); encoderDir[ENC_R].reset();
seq_note_in = 0; seq_note_in = 0;
// setup function // setup function
lcd.setCursor(1, 0); lcd.setCursor(1, 0);
strncpy(displayname, drum_config[activesample].filename + 6 + strlen(drumset_name), 6); lcd.print(basename(drum_config[activesample].filename));
lcd.print(displayname);
lcd.setCursor(9, 0); lcd.setCursor(9, 0);
if (seq_running == false && seq_recording == false) if (seq_running == false && seq_recording == false)
{ {
@ -4067,8 +4062,7 @@ void UI_func_sequencer(uint8_t param)
if (activesample < num_drums) { if (activesample < num_drums) {
lcd.setCursor(1, 0); lcd.setCursor(1, 0);
strncpy(displayname, drum_config[activesample].filename + 6 + strlen(drumset_name), 6); lcd.print(basename(drum_config[activesample].filename));
lcd.print(displayname);
} else if (activesample == num_drums) { } else if (activesample == num_drums) {
lcd.setCursor(1, 0); lcd.setCursor(1, 0);
lcd.print("EMPTY "); lcd.print("EMPTY ");
@ -7293,5 +7287,11 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id)
} }
} }
char* basename(const char* filename)
{
char* p = strrchr (filename, '/');
return p ? p + 1 : (char *) filename;
}
#endif #endif
#endif #endif

@ -109,14 +109,26 @@ LCDML_add(75, LCDML_0_3, 5, "MIDI", NULL);
LCDML_add(76, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); LCDML_add(76, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank);
LCDML_add(77, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); LCDML_add(77, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank);
LCDML_add(78, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); LCDML_add(78, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice);
LCDML_add(79, LCDML_0, 4, "Sequencer", UI_func_sequencer); LCDML_add(79, LCDML_0, 4, "Drums", NULL);
LCDML_add(80, LCDML_0, 5, "Pattern Chain", UI_func_seq_pat_chain); LCDML_add(80, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume);
LCDML_add(81, LCDML_0, 6, "System", NULL); LCDML_add(81, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume);
LCDML_add(82, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); LCDML_add(82, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan);
LCDML_add(83, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); LCDML_add(83, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send);
LCDML_add(84, LCDML_0_6, 3, "Favorites", UI_func_favorites); LCDML_add(84, LCDML_0, 5, "Sequencer", NULL);
LCDML_add(85, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset); LCDML_add(85, LCDML_0_5, 1, "Sequencer", UI_func_sequencer);
LCDML_add(86, LCDML_0, 6, "Info", UI_func_information); LCDML_add(86, LCDML_0_5, 2, "Pattern Chain", UI_func_seq_pat_chain);
LCDML_addAdvanced(87, LCDML_0, 7, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); LCDML_add(87, LCDML_0_5, 3, "Seq. Length", UI_func_seq_lenght);
#define _LCDML_DISP_cnt 87 LCDML_add(88, LCDML_0_5, 4, "Tempo", NULL);
LCDML_add(89, LCDML_0_5, 5, "L.Transp.Key", UI_func_seq_live_transpose_oct);
LCDML_add(90, LCDML_0_5, 6, "L.Trp.Offset", NULL);
LCDML_add(91, LCDML_0_5, 7, "Pattern load", NULL);
LCDML_add(92, LCDML_0_5, 8, "Pattern save", NULL);
LCDML_add(93, LCDML_0, 6, "System", NULL);
LCDML_add(94, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono);
LCDML_add(95, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru);
LCDML_add(96, LCDML_0_6, 3, "Favorites", UI_func_favorites);
LCDML_add(97, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset);
LCDML_add(98, LCDML_0, 7, "Info", UI_func_information);
LCDML_addAdvanced(99, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default);
#define _LCDML_DISP_cnt 99
#endif #endif

@ -112,12 +112,12 @@ LCDML_add(78, LCDML_0_3, 5, "MIDI", NULL);
LCDML_add(79, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); LCDML_add(79, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank);
LCDML_add(80, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); LCDML_add(80, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank);
LCDML_add(81, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); LCDML_add(81, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice);
LCDML_add(82, LCDML_0, 4, "Drum Settings", NULL); LCDML_add(82, LCDML_0, 4, "Drums", NULL);
LCDML_add(83, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume); LCDML_add(83, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume);
LCDML_add(84, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); LCDML_add(84, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume);
LCDML_add(85, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); LCDML_add(85, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan);
LCDML_add(86, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); LCDML_add(86, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send);
LCDML_add(87, LCDML_0, 5, "Sequencer Set.", NULL); LCDML_add(87, LCDML_0, 5, "Sequencer", NULL);
LCDML_add(88, LCDML_0_5, 1, "Sequencer", UI_func_sequencer); LCDML_add(88, LCDML_0_5, 1, "Sequencer", UI_func_sequencer);
LCDML_add(89, LCDML_0_5, 2, "Pattern Chain", UI_func_seq_pat_chain); LCDML_add(89, LCDML_0_5, 2, "Pattern Chain", UI_func_seq_pat_chain);
LCDML_add(90, LCDML_0_5, 3, "Seq. Length", UI_func_seq_lenght); LCDML_add(90, LCDML_0_5, 3, "Seq. Length", UI_func_seq_lenght);

@ -85,11 +85,11 @@ LCDML_add(51, LCDML_0_2, 4, "MIDI", NULL);
LCDML_add(52, LCDML_0_2_4, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); LCDML_add(52, LCDML_0_2_4, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank);
LCDML_add(53, LCDML_0_2_4, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); LCDML_add(53, LCDML_0_2_4, 2, "MIDI Snd Bank", UI_func_sysex_send_bank);
LCDML_add(54, LCDML_0_2_4, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); LCDML_add(54, LCDML_0_2_4, 3, "MIDI Snd Voice", UI_func_sysex_send_voice);
LCDML_add(55, LCDML_0, 3, "Drum Settings", NULL); LCDML_add(55, LCDML_0, 3, "Drum", NULL);
LCDML_add(56, LCDML_0_3, 1, "Drums Main Vol", UI_func_drum_main_volume); LCDML_add(56, LCDML_0_3, 1, "Drums Main Vol", UI_func_drum_main_volume);
LCDML_add(57, LCDML_0_3, 2, "Drum Volumes", UI_func_drum_volume); LCDML_add(57, LCDML_0_3, 2, "Drum Volumes", UI_func_drum_volume);
LCDML_add(58, LCDML_0_3, 3, "Drum Pan", UI_func_drum_pan); LCDML_add(58, LCDML_0_3, 3, "Drum Pan", UI_func_drum_pan);
LCDML_add(59, LCDML_0, 4, "Sequencer Set.", NULL); LCDML_add(59, LCDML_0, 4, "Sequencer", NULL);
LCDML_add(60, LCDML_0_4, 1, "Sequencer", UI_func_sequencer); LCDML_add(60, LCDML_0_4, 1, "Sequencer", UI_func_sequencer);
LCDML_add(61, LCDML_0_4, 2, "Pattern Chain", UI_func_seq_pat_chain); LCDML_add(61, LCDML_0_4, 2, "Pattern Chain", UI_func_seq_pat_chain);
LCDML_add(62, LCDML_0_4, 3, "Seq. Length", NULL); LCDML_add(62, LCDML_0_4, 3, "Seq. Length", NULL);

@ -281,6 +281,7 @@
#define BANK_NAME_LEN 11 // 10 (plus '\0') #define BANK_NAME_LEN 11 // 10 (plus '\0')
#define VOICE_NAME_LEN 12 // 11 (plus '\0') #define VOICE_NAME_LEN 12 // 11 (plus '\0')
#define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN
#define DRUM_CFG_GILENAME_LEN 42
#define FX_CONFIG_PATH "FXCFG" #define FX_CONFIG_PATH "FXCFG"
#define FX_CONFIG_NAME "FXCFG" #define FX_CONFIG_NAME "FXCFG"

@ -89,12 +89,17 @@ uint8_t read_drum_config(const char* drumset)
sprintf(ds, "/DRM/%s", drumset); sprintf(ds, "/DRM/%s", drumset);
for (JsonPair kv : root) for (JsonPair kv : root)
{ {
sprintf(drum_config[drum].filename, "%s/%s.wav", ds, kv.key().c_str()); sprintf(drum_config[drum].filename, "%s/%s", ds, kv.key().c_str());
if (!SD.exists(drum_config[drum].filename))
char f[DRUM_CFG_GILENAME_LEN];
strcpy(f, drum_config[drum].filename);
strcat(f, ".wav");
if (!SD.exists(f))
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Cannot find WAV file [")); Serial.print(F("Cannot find WAV file ["));
Serial.print(drum_config[drum].filename); Serial.print(f);
Serial.println(F("]")); Serial.println(F("]"));
#endif #endif
continue; continue;
@ -259,7 +264,7 @@ uint8_t read_drum_config(const char* drumset)
Serial.print(F("midinote = ")); Serial.print(F("midinote = "));
Serial.println(drum_config[drum].midinote, DEC); Serial.println(drum_config[drum].midinote, DEC);
Serial.print(F("filename = ")); Serial.print(F("filename = "));
Serial.println(drum_config[drum].filename); Serial.println(f);
Serial.print(F("shortname = ")); Serial.print(F("shortname = "));
Serial.println(drum_config[drum].shortname); Serial.println(drum_config[drum].shortname);
Serial.print(F("pan = ")); Serial.print(F("pan = "));
@ -283,7 +288,7 @@ uint8_t read_drum_config(const char* drumset)
drum_config[drum].vol_max = 0.0; drum_config[drum].vol_max = 0.0;
drum_config[drum].vol_min = 0.0; drum_config[drum].vol_min = 0.0;
drum_config[drum].reverb_send = 0.0; drum_config[drum].reverb_send = 0.0;
return (drum); return (drum);
} }

Loading…
Cancel
Save