Dateien hochladen nach „“

pull/77/head
positionhigh 3 years ago
parent 56dba40ad0
commit 9be7b8967c
  1. 194
      dexed_sd.cpp
  2. 44
      sequencer.cpp

@ -837,104 +837,7 @@ bool load_sd_seq_drumsettings_json(uint8_t number)
} }
} }
AudioInterrupts();
return (false);
}
bool load_sd_seq_voicesettings_json(uint8_t number)
{
uint8_t bank[MAX_DEXED];
uint8_t voice[MAX_DEXED];
if (number < 0)
return (false);
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
char filename[FILENAME_LEN];
sprintf(filename, "/%s/%s%d-v.json", SEQ_CONFIG_PATH, SEQ_CONFIG_NAME, number);
// first check if file exists...
AudioNoInterrupts();
if (SD.exists(filename))
{
// ... and if: load
#ifdef DEBUG
Serial.print(F("Found Sequencer configuration ["));
Serial.print(filename);
Serial.println(F("]... loading..."));
#endif
json = SD.open(filename);
if (json)
{
deserializeJson(data_json, json);
json.close();
AudioInterrupts();
//check_configuration_fx();
#ifdef DEBUG
Serial.println(F("Read JSON data:"));
serializeJsonPretty(data_json, Serial);
Serial.println();
#endif
for (uint8_t i = 0; i < MAX_DEXED; i++)
{
bank[i] = data_json["bank"][i];
voice[i] = data_json["voice"][i];
configuration.fx.reverb_send[i] = data_json["rev_send"][i];
configuration.dexed[i].midi_channel = data_json["midi_ch"][i];
configuration.dexed[i].sound_intensity = data_json["vol"][i];
configuration.dexed[i].transpose = data_json["v_trans"][i];
}
/*
configuration.fx.reverb_roomsize = data_json["rev_roomsize"];
configuration.fx.reverb_damping = data_json["rev_damping"];
configuration.fx.reverb_lowpass = data_json["rev_lowpass"];
configuration.fx.reverb_lodamp = data_json["rev_lodamp"];
configuration.fx.reverb_hidamp = data_json["rev_hidamp"];
configuration.fx.reverb_diffusion = data_json["rev_diffusion"];
configuration.fx.reverb_level = data_json["rev_level"];
configuration.fx.eq_bass = data_json["eq_bass"];
configuration.fx.eq_treble = data_json["eq_treble"]; */
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
load_sd_voice(bank[i], voice[i], i);
MicroDexed[i]->doRefreshVoice();
MicroDexed[i]->panic();
}
seq_tempo_ms = 60000000 / seq_bpm / 4;
timer1.begin(sequencer, seq_tempo_ms / 2, false);
//set_fx_params();
return (true);
}
#ifdef DEBUG
else
{
Serial.print(F("E : Cannot open "));
Serial.print(filename);
Serial.println(F(" on SD."));
}
}
else
{
Serial.print(F("No "));
Serial.print(filename);
Serial.println(F(" available."));
#endif
}
}
AudioInterrupts();
return (false); return (false);
} }
@ -980,74 +883,7 @@ bool save_sd_seq_drumsettings_json(uint8_t number)
return (true); return (true);
} }
json.close(); json.close();
}
else
{
#ifdef DEBUG
Serial.print(F("E : Cannot open "));
Serial.print(filename);
Serial.println(F(" on SD."));
#endif
}
AudioInterrupts();
return (false);
}
bool save_sd_seq_voicesettings_json(uint8_t number)
{
char filename[FILENAME_LEN];
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
sprintf(filename, "/%s/%s%d-v.json", SEQ_CONFIG_PATH, SEQ_CONFIG_NAME, number);
#ifdef DEBUG
Serial.print(F("Saving sequencer voice config "));
Serial.print(number);
Serial.print(F(" to "));
Serial.println(filename);
#endif
AudioNoInterrupts();
json = SD.open(filename, FILE_WRITE);
if (json)
{
for (uint8_t i = 0; i < MAX_DEXED; i++)
{
data_json["bank"][i] = configuration.performance.bank[i];
data_json["voice"][i] = configuration.performance.voice[i];
data_json["rev_send"][i] = configuration.fx.reverb_send[i];
data_json["midi_ch"][i] = configuration.dexed[i].midi_channel;
data_json["vol"][i] = configuration.dexed[i].sound_intensity;
data_json["v_trans"][i] = configuration.dexed[i].transpose;
}
/*
data_json["rev_roomsize"] = configuration.fx.reverb_roomsize;
data_json["rev_damping"] = configuration.fx.reverb_damping;
data_json["rev_lowpass"] = configuration.fx.reverb_lowpass;
data_json["rev_lodamp"] = configuration.fx.reverb_lodamp;
data_json["rev_hidamp"] = configuration.fx.reverb_hidamp;
data_json["rev_diffusion"] = configuration.fx.reverb_diffusion;
data_json["rev_level"] = configuration.fx.reverb_level;
data_json["eq_bass"] = configuration.fx.eq_bass;
data_json["eq_treble"] = configuration.fx.eq_treble; */
#ifdef DEBUG
Serial.println(F("Write JSON data:"));
serializeJsonPretty(data_json, Serial);
Serial.println();
#endif
serializeJsonPretty(data_json, json);
json.close();
AudioInterrupts(); AudioInterrupts();
return (true);
}
json.close();
} }
else else
{ {
@ -1057,7 +893,6 @@ bool save_sd_seq_voicesettings_json(uint8_t number)
Serial.println(F(" on SD.")); Serial.println(F(" on SD."));
#endif #endif
} }
AudioInterrupts();
return (false); return (false);
} }
@ -1067,23 +902,8 @@ bool save_sd_seq_json(uint8_t seq_number)
int count = 0; int count = 0;
seq_number = constrain(seq_number, 0, 99); seq_number = constrain(seq_number, 0, 99);
save_sd_seq_drumsettings_json(seq_number);
save_sd_seq_voicesettings_json(seq_number);
if (sd_card > 0) if (sd_card > 0)
{ {
sprintf(filename, "/%s/%s%d.json", SEQ_CONFIG_PATH, SEQ_CONFIG_NAME, seq_number);
AudioNoInterrupts();
if (SD.exists(filename)) {
Serial.println("Remove");
Serial.print(filename);
SD.remove(filename);
}
AudioInterrupts();
File json; File json;
sprintf(filename, "/%s/%s%d.json", SEQ_CONFIG_PATH, SEQ_CONFIG_NAME, seq_number); sprintf(filename, "/%s/%s%d.json", SEQ_CONFIG_PATH, SEQ_CONFIG_NAME, seq_number);
@ -1175,11 +995,11 @@ bool save_sd_seq_json(uint8_t seq_number)
#endif #endif
serializeJsonPretty(data_json, json); serializeJsonPretty(data_json, json);
json.close(); json.close();
AudioInterrupts();
return (true); return (true);
} }
json.close(); json.close();
AudioInterrupts();
} }
else else
{ {
@ -1189,7 +1009,6 @@ bool save_sd_seq_json(uint8_t seq_number)
Serial.println(F(" on SD.")); Serial.println(F(" on SD."));
#endif #endif
} }
AudioInterrupts();
return (false); return (false);
} }
@ -1201,9 +1020,6 @@ bool load_sd_seq_json(uint8_t seq_number)
seq_number = constrain(seq_number, 0, 99); seq_number = constrain(seq_number, 0, 99);
load_sd_seq_drumsettings_json(seq_number);
load_sd_seq_voicesettings_json(seq_number);
if (sd_card > 0) if (sd_card > 0)
{ {
File json; File json;
@ -1227,9 +1043,7 @@ bool load_sd_seq_json(uint8_t seq_number)
deserializeJson(data_json, json); deserializeJson(data_json, json);
json.close(); json.close();
AudioInterrupts();
//check_configuration_fx();
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Read JSON data:")); Serial.println(F("Read JSON data:"));
@ -1292,9 +1106,9 @@ bool load_sd_seq_json(uint8_t seq_number)
seq_oct_shift = data_json["seq_oct_shift"]; seq_oct_shift = data_json["seq_oct_shift"];
seq_element_shift = data_json["seq_element_shift"]; seq_element_shift = data_json["seq_element_shift"];
//set_fx_params();
return (true); return (true);
} }
#ifdef DEBUG #ifdef DEBUG
else else
@ -1312,8 +1126,6 @@ bool load_sd_seq_json(uint8_t seq_number)
#endif #endif
} }
} }
AudioInterrupts();
return (false); return (false);
} }

@ -7,6 +7,7 @@
extern LCDMenuLib2 LCDML; extern LCDMenuLib2 LCDML;
extern LiquidCrystal_I2C lcd; extern LiquidCrystal_I2C lcd;
extern config_t configuration; extern config_t configuration;
extern uint8_t drum_midi_channel;
extern void handleNoteOn(byte , byte , byte ); extern void handleNoteOn(byte , byte , byte );
extern void handleNoteOff(byte , byte , byte ); extern void handleNoteOff(byte , byte , byte );
extern void UI_func_sequencer(uint8_t); extern void UI_func_sequencer(uint8_t);
@ -38,7 +39,7 @@ void sequencer_part1(void)
if ( seq_track_type[d] == 0) { // drum track if ( seq_track_type[d] == 0) { // drum track
if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 ) if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 )
{ {
handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); handleNoteOn(drum_midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]);
} }
} }
else { else {
@ -61,15 +62,16 @@ void sequencer_part1(void)
{ {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12) + seq_arps[seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200][x], seq_chord_velocity); handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12) + seq_arps[seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200][x], seq_chord_velocity);
} }
seq_prev_note[d] = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12); seq_prev_note[d] = seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] + (seq_oct_shift * 12);
seq_prev_vel[d] = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; seq_prev_vel[d] = seq_vel[seq_patternchain[seq_chain_active_step][d]][seq_step];
} }
} }
if (seq_track_type[d] == 3) { //Arp if (seq_track_type[d] == 3) { //Arp
arp_step = 0; arp_step = 0;
arp_counter = 0; arp_counter = 0;
arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12); arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12);
if (seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200 >= 0) // if (seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200 >= 0)
arp_chord = seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200; arp_chord = seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200;
} }
} }
@ -80,23 +82,21 @@ void sequencer_part1(void)
if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) { if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) {
{ if (arp_style == 0) { //arp up { if (arp_style == 0) { //arp up
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] , seq_chord_velocity); handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step + seq_element_shift], seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] ; arp_note_prev = arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] ;
} }
else if (arp_style == 1) { //arp down else if (arp_style == 1) { //arp down
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][10 - arp_step + seq_element_shift] , seq_chord_velocity); handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift], seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][10 - arp_step + seq_element_shift] ; arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift] ;
} }
else if (arp_style == 2) { //arp up & down else if (arp_style == 2) { //arp up & down
if (seq_step < arp_lenght) { if (arp_step <= arp_lenght) {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step ], seq_chord_velocity);
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step+1] , seq_chord_velocity); arp_note_prev = arp_note + seq_arps[arp_chord][arp_step ] ;
arp_note_prev = arp_note + seq_arps[arp_chord][arp_step +1] ;
} }
else { else {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ], seq_chord_velocity);
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght*2-2 - arp_step ] , seq_chord_velocity); arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ] ;
arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght*2- - arp_step ] ;
} }
} }
else if (arp_style == 3) { //arp random else if (arp_style == 3) { //arp random
@ -118,26 +118,28 @@ void sequencer_part1(void)
} }
else else
{ {
if (arp_speed == 1) // Arp Speed 1/8 // Arp Speed 1/8
{
if (arp_counter > 1) { if (arp_counter > 1) {
arp_counter = 0; arp_counter = 0;
arp_step++; arp_step++;
} }
} }
}
if (arp_style != 2){ if (arp_style != 2) {
if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght) if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght)
{ {
arp_step = 0; arp_step = 0;
} }
} }
else if (arp_style == 1 || arp_style == 2 )
{
if (arp_lenght == 0)arp_lenght = 9;
{ }
if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght*2) if ( arp_style == 2 ) //only for up&down
{
if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght * 2)
{ {
arp_step = 0; arp_step = 0;
} }

Loading…
Cancel
Save