Added bank loading (banks have to be organized in _one_ sysex file per

directory (named like the bank number), e.g. 5/ROM1B.SYX).
pull/4/head
Holger Wirtz 7 years ago
parent 95c783fab6
commit 09f4b3463e
  1. 9
      MicroDexed.ino
  2. 2
      config.h
  3. 49
      dexed_sysex.cpp
  4. 4
      dexed_sysex.h

@ -45,6 +45,8 @@ AudioControlSGTL5000 sgtl5000_1; //xy=507,403
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI); MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
Dexed* dexed = new Dexed(SAMPLE_RATE); Dexed* dexed = new Dexed(SAMPLE_RATE);
bool sd_card_available = false; bool sd_card_available = false;
uint8_t bank = DEFAULT_SYSEXBANK;
#ifdef MASTER_KEY_MIDI #ifdef MASTER_KEY_MIDI
bool master_key_enabled = false; bool master_key_enabled = false;
#endif #endif
@ -107,7 +109,7 @@ void setup()
#endif #endif
// load default SYSEX data // load default SYSEX data
load_sysex(DEFAULT_SYSEXFILE, DEFAULT_SYSEXSOUND); load_sysex(bank, DEFAULT_SYSEXSOUND);
#ifdef DEBUG #ifdef DEBUG
show_patch(); show_patch();
@ -277,16 +279,13 @@ bool handle_master_key(uint8_t data)
{ {
int8_t num = num_key_base_c(data); int8_t num = num_key_base_c(data);
Serial.print(F("Key->Number: "));
Serial.println(num);
if (num > 0) if (num > 0)
{ {
// a white key! // a white key!
num = num - 1 + (((data - MASTER_NUM1) / 12) * 7); num = num - 1 + (((data - MASTER_NUM1) / 12) * 7);
if (num <= 32) if (num <= 32)
{ {
if (!load_sysex(DEFAULT_SYSEXFILE, num)) if (!load_sysex(bank, num))
{ {
Serial.print(F("E: cannot load voice number ")); Serial.print(F("E: cannot load voice number "));
Serial.println(num, DEC); Serial.println(num, DEC);

@ -40,7 +40,7 @@
#define MAX_NOTES 16 #define MAX_NOTES 16
#define AUDIO_MEM 2 #define AUDIO_MEM 2
#define DEFAULT_SYSEXFILE "RITCH0~2.SYX" #define DEFAULT_SYSEXBANK 5
#define DEFAULT_SYSEXSOUND 0 #define DEFAULT_SYSEXSOUND 0
#define MASTER_KEY_MIDI 84 // C6 #define MASTER_KEY_MIDI 84 // C6

@ -30,16 +30,23 @@
#include "dexed_sysex.h" #include "dexed_sysex.h"
#include "config.h" #include "config.h"
bool load_sysex(char *name, uint8_t voice_number) bool load_sysex(uint8_t bank, uint8_t voice_number)
{ {
File root; File root;
bool found = false; bool found = false;
voice_number %= 32; voice_number %= 32;
bank %= 10;
if (sd_card_available) if (sd_card_available)
{ {
root = SD.open("/"); char bankdir[3];
bankdir[0] = '/';
bankdir[2] = '\0';
itoa(bank, &bankdir[1], 10);
root = SD.open(bankdir);
if (!root) if (!root)
{ {
Serial.println(F("E: Cannot open main dir from SD.")); Serial.println(F("E: Cannot open main dir from SD."));
@ -57,19 +64,23 @@ bool load_sysex(char *name, uint8_t voice_number)
{ {
if (!entry.isDirectory()) if (!entry.isDirectory())
{ {
if (strcmp(name, entry.name()) == 0) uint8_t data[128];
found = true;
if (get_sysex_voice(bankdir, entry, voice_number, data))
{ {
uint8_t data[128]; char n[11];
strncpy(n, (char*)&data[118], 10);
found = true; Serial.print("<");
if (get_sysex_voice(entry, voice_number, data)) Serial.print(entry.name());
return (dexed->loadSysexVoice(data)); Serial.print("|'");
else Serial.print(n);
Serial.println(F("E: Cannot load voice data")); Serial.println("'>");
entry.close(); return (dexed->loadSysexVoice(data));
break;
} }
else
Serial.println(F("E: Cannot load voice data"));
entry.close(); entry.close();
break;
} }
} }
} }
@ -80,18 +91,23 @@ bool load_sysex(char *name, uint8_t voice_number)
return (false); return (false);
} }
bool get_sysex_voice(File sysex, uint8_t voice_number, uint8_t* data) bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data)
{ {
File file; File file;
uint16_t i, n; uint16_t i, n;
uint32_t calc_checksum = 0; uint32_t calc_checksum = 0;
char sysex_file[20];
strcpy(sysex_file, dir);
strcat(sysex_file, "/");
strcat(sysex_file, sysex.name());
if (sysex.size() != 4104) // check sysex size if (sysex.size() != 4104) // check sysex size
{ {
Serial.println(F("E: SysEx file size wrong.")); Serial.println(F("E: SysEx file size wrong."));
return (false); return (false);
} }
if (file = SD.open(sysex.name())) if (file = SD.open(sysex_file))
{ {
if (file.read() != 0xf0) // check sysex start-byte if (file.read() != 0xf0) // check sysex start-byte
{ {
@ -135,5 +151,10 @@ bool get_sysex_voice(File sysex, uint8_t voice_number, uint8_t* data)
return (false); return (false);
} }
} }
else
{
Serial.print(F("Cannot open "));
Serial.println(sysex.name());
}
return (true); return (true);
} }

@ -25,6 +25,6 @@
extern bool sd_card_available; extern bool sd_card_available;
extern Dexed* dexed; extern Dexed* dexed;
bool load_sysex(char *name, uint8_t voice_number); bool load_sysex(uint8_t bank, uint8_t voice_number);
bool get_sysex_voice(File sysex, uint8_t voice_number, uint8_t* data); bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data);

Loading…
Cancel
Save