diff --git a/UI.hpp b/UI.hpp index 195ef66..81bc84c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4075,10 +4075,14 @@ void UI_func_drum_pitch(uint8_t param) { { midi_learn_mode = true; + memset(tmp_name, ' ', 8); + tmp_name[8] = '\0'; + strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name)); + display.setCursor(0, 0); display.print(F("Drums Pitch")); display.setCursor(1, 1); - display.print(drum_config[active_sample].name); + display.print(tmp_name); display.setCursor(LCD_cols - 5, 1); snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); display.print(tmp_val); @@ -4090,19 +4094,23 @@ void UI_func_drum_pitch(uint8_t param) { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) { if (display_name == true) { - active_sample = constrain(++active_sample, 0, NUM_DRUMSET_CONFIG - 1); - display.setCursor(LCD_cols - 5, 1); - snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); - display.print(tmp_val); + if (active_sample < NUM_DRUMSET_CONFIG - 2) { + active_sample++; + display.setCursor(LCD_cols - 5, 1); + snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); + display.print(tmp_val); + } } else { configuration.drums.pitch[active_sample] = constrain(configuration.drums.pitch[active_sample] + ENCODER[ENC_L].speed(), DRUMS_PITCH_MIN, DRUMS_PITCH_MAX); } } else if (LCDML.BT_checkUp()) { if (display_name == true) { - active_sample = constrain(--active_sample, 0, NUM_DRUMSET_CONFIG - 1); - display.setCursor(LCD_cols - 5, 1); - snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); - display.print(tmp_val); + if (active_sample > 0) { + active_sample--; + display.setCursor(LCD_cols - 5, 1); + snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); + display.print(tmp_val); + } } else { configuration.drums.pitch[active_sample] = constrain(configuration.drums.pitch[active_sample] - ENCODER[ENC_L].speed(), DRUMS_PITCH_MIN, DRUMS_PITCH_MAX); } @@ -4113,8 +4121,12 @@ void UI_func_drum_pitch(uint8_t param) { #ifdef DEBUG Serial.printf("Pitch for active_sample=%d [%s]\n", active_sample, drum_config[active_sample].name); #endif + memset(tmp_name, ' ', 8); + tmp_name[8] = '\0'; + strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name)); + display.setCursor(1, 1); - display.print(drum_config[active_sample].name); + display.print(tmp_name); display.setCursor(LCD_cols - 5, 1); snprintf_P(tmp_val, sizeof(tmp_val), PSTR("%4.1f"), configuration.drums.pitch[active_sample] / 10.0); display.print(tmp_val); diff --git a/addon/tools/drumset.cfg2 b/addon/tools/drumset.cfg2 new file mode 100644 index 0000000..986e251 --- /dev/null +++ b/addon/tools/drumset.cfg2 @@ -0,0 +1,2 @@ +# class, midinote, name, shortname, pitch, p_offset, pan, vol_max, vol_min, reverb_send, filename +DRUM_BASS, MIDI_F2, S_loTom_1, B, 1.0, 0.0, 0.8, 0.0, 0.0, S_loTom_1.wav diff --git a/addon/tools/wav2c.sh b/addon/tools/wav2c.sh index 5595cf0..f9ba5f8 100755 --- a/addon/tools/wav2c.sh +++ b/addon/tools/wav2c.sh @@ -16,6 +16,7 @@ DRUMS_H="${TMP}/drums.h" MAX_NUM_DRUMSET_CONFIG=71 # ARDUINO_TEENSY41 #MAX_NUM_DRUMSET_CONFIG=40 # ARDUINO_TEENSY40 #MAX_NUM_DRUMSET_CONFIG=19 # ... +NUM_DRUMSET=0 function cleanexit() { @@ -87,6 +88,7 @@ then fi mkdir -p "${TMP}" +rm -f "${DRUMSET_H}" cat >> "${DRUMSET_H}" << EOF #pragma once @@ -188,6 +190,8 @@ do fi echo "};" >> "${DRUMSET_H}" + NUM_DRUMSET=`expr "${NUM_DRUMSET_CONFIG}" + 1` + converted_files["${sample['filename']}"]="${sample['c_name']},${sample['len']}" else sample['c_name']=`echo ${converted_files[${sample['filename']}]} | cut -d"," -f1` diff --git a/drumset.h b/drumset.h index 0c6f51b..4455785 100644 --- a/drumset.h +++ b/drumset.h @@ -239217,7 +239217,7 @@ PROGMEM const uint8_t DRUM_Vl1hbeep[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -PROGMEM const drum_config_t drum_config[NUM_DRUMSET_CONFIG] = +const drum_config_t drum_config[NUM_DRUMSET_CONFIG] = { { DRUM_BASS,