Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save MIDI Channel assignments to tuning slots #116

Open
wants to merge 3 commits into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,464 changes: 11,464 additions & 0 deletions builds/digigurdy-baz-3.0.0a-REV3-LED-MORE-SWELL.ino.TEENSY41.hex

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,30 @@ const int TPOSE_UP_INDEX = num_keys - 1;
/// @details This is intended to be the bottom second key from the right.
const int TPOSE_DN_INDEX = num_keys - 3;

/// @brief The MIDI channel of the "Hi Melody" string.
/// @details Default is MIDI channel 1.
const int MIDI_HI_CHANNEL = 1;

/// @brief The MIDI channel of the "Low Melody" string.
/// @details Default is MIDI channel 2.
const int MIDI_LO_CHANNEL = 2;

/// @brief The MIDI channel of the "Trompette" string.
/// @details Default is MIDI channel 3.
const int MIDI_TR_CHANNEL = 3;

/// @brief The MIDI channel of the "Drone" string.
/// @details Default is MIDI channel 4.
const int MIDI_DR_CHANNEL = 4;

/// @brief The MIDI channel of the "Buzz" string.
/// @details Default is MIDI channel 5.
const int MIDI_BZ_CHANNEL = 5;

/// @brief The MIDI channel of the "Key Click" string.
/// @details Default is MIDI channel 6.
const int MIDI_KC_CHANNEL = 6;


// These are less-commonly-changed options:

Expand Down
12 changes: 6 additions & 6 deletions digigurdy-baz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ void setup() {
};
#endif

mystring = new GurdyString(1, Note(g4), "Hi Melody", EEPROM.read(EEPROM_SEC_OUT));
mylowstring = new GurdyString(2, Note(g3), "Low Melody", EEPROM.read(EEPROM_SEC_OUT));
mytromp = new GurdyString(3, Note(c3), "Trompette", EEPROM.read(EEPROM_SEC_OUT));
mydrone = new GurdyString(4, Note(c2), "Drone", EEPROM.read(EEPROM_SEC_OUT));
mybuzz = new GurdyString(5,Note(c3), "Buzz", EEPROM.read(EEPROM_SEC_OUT));
mykeyclick = new GurdyString(6, Note(b5), "Key Click", EEPROM.read(EEPROM_SEC_OUT));
mystring = new GurdyString(MIDI_HI_CHANNEL, Note(g4), "Hi Melody", EEPROM.read(EEPROM_SEC_OUT));
mylowstring = new GurdyString(MIDI_LO_CHANNEL, Note(g3), "Low Melody", EEPROM.read(EEPROM_SEC_OUT));
mytromp = new GurdyString(MIDI_TR_CHANNEL, Note(c3), "Trompette", EEPROM.read(EEPROM_SEC_OUT));
mydrone = new GurdyString(MIDI_DR_CHANNEL, Note(c2), "Drone", EEPROM.read(EEPROM_SEC_OUT));
mybuzz = new GurdyString(MIDI_BZ_CHANNEL, Note(c3), "Buzz", EEPROM.read(EEPROM_SEC_OUT));
mykeyclick = new GurdyString(MIDI_KC_CHANNEL, Note(b5), "Key Click", EEPROM.read(EEPROM_SEC_OUT));

if (EEPROM.read(EEPROM_SEC_OUT) > 0) {
mystring->setTrackLoops();
Expand Down
14 changes: 10 additions & 4 deletions eeprom_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
// If you end up burning out one of the memory locations, you can shift them around
// by redefining the assingments here.

// The slots below should be arranged so that they are at least 20 apart. This is
// The slots below should be arranged so that they are at least 25 apart. This is
// to provide room for future upgrades. There may be two more channels later, as well
// as a second value (volume) for each channel.
//
// Teensy3.5 has 4096 bytes of EEPROM, so there's lots of room here.
static const int EEPROM_SLOT1 = 0;
static const int EEPROM_SLOT2 = 20;
static const int EEPROM_SLOT3 = 40;
static const int EEPROM_SLOT4 = 60;
static const int EEPROM_SLOT2 = 25;
static const int EEPROM_SLOT3 = 50;
static const int EEPROM_SLOT4 = 75;

// These define what the values are within the "slots". You'd add this to one of the
// SLOTs above to get the actual address in EEPROM.
Expand All @@ -37,6 +37,12 @@ static const int EEPROM_LOW_MEL_GROS = 14;
static const int EEPROM_TROMP_GROS = 15;
static const int EEPROM_DRONE_GROS = 16;
static const int EEPROM_BUZZ_GROS = 17;
static const int EEPROM_HI_MEL_CHAN = 18;
static const int EEPROM_LO_MEL_CHAN = 19;
static const int EEPROM_DRONE_CHAN = 20;
static const int EEPROM_TROMP_CHAN = 21;
static const int EEPROM_BUZZ_CHAN = 22;
static const int EEPROM_KEYCLICK_CHAN = 23;

// This int saves the play screen type. 0 = note + staff, 1 = note only;
static const int EEPROM_DISPLY_TYPE = 100;
Expand Down
12 changes: 12 additions & 0 deletions gurdystring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ int GurdyString::getVolume() {
return midi_volume;
};

/// @brief Sets a new channel for this string.
/// @param vol The new MIDI channel for this string. 1-16.
void GurdyString::setChannel(int cha) {
midi_channel = cha;
};

/// @brief Returns the string's MIDI channel.
/// @return The string's volume, 1-16
int GurdyString::getChannel() {
return midi_channel;
};

/// @brief Mutes/unmutes the string.
/// @param mute True = mute, false = unmute
/// @note While muted, soundOn/Off events do nothing. This exists for programming ease (calling sounOn() on all strings without checking if they are muted).
Expand Down
2 changes: 2 additions & 0 deletions gurdystring.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class GurdyString {
void setOpenNote(int new_note);
void setVolume(int vol);
int getVolume();
void setChannel(int cha);
int getChannel();
void setMute(bool mute);
bool getMute();
bool isPlaying();
Expand Down
16 changes: 15 additions & 1 deletion load_tunings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ void load_saved_tunings(int slot_num) {
value = EEPROM.read(slot + EEPROM_KEYCLICK_VOL);
mykeyclick->setVolume(value);

// MIDI Channels
value = EEPROM.read(slot + EEPROM_HI_MEL_CHAN);
mystring->setChannel(value);
value = EEPROM.read(slot + EEPROM_LO_MEL_CHAN);
mylowstring->setChannel(value);
value = EEPROM.read(slot + EEPROM_DRONE_CHAN);
mydrone->setChannel(value);
value = EEPROM.read(slot + EEPROM_TROMP_CHAN);
mytromp->setChannel(value);
value = EEPROM.read(slot + EEPROM_BUZZ_CHAN);
mybuzz->setChannel(value);
value = EEPROM.read(slot + EEPROM_KEYCLICK_CHAN);
mykeyclick->setChannel(value);

// Gros Modes
mystring->setGrosMode(EEPROM.read(slot + EEPROM_HI_MEL_GROS));
mylowstring->setGrosMode(EEPROM.read(slot + EEPROM_LOW_MEL_GROS));
Expand Down Expand Up @@ -175,4 +189,4 @@ void signal_scene_change(int scene_idx) {
// 0 = Do nothing
// While this should be 0, if there is bad data we'll just ignore it and do nothing.
}
};
};
6 changes: 6 additions & 0 deletions pause_screens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ void save_tunings(int slot) {
EEPROM.write(slot + EEPROM_TROMP_GROS, mytromp->getGrosMode());
EEPROM.write(slot + EEPROM_DRONE_GROS, mydrone->getGrosMode());
EEPROM.write(slot + EEPROM_BUZZ_GROS, mybuzz->getGrosMode());
EEPROM.write(slot + EEPROM_HI_MEL_CHAN, mystring->getChannel());
EEPROM.write(slot + EEPROM_LO_MEL_CHAN, mylowstring->getChannel());
EEPROM.write(slot + EEPROM_DRONE_CHAN, mydrone->getChannel());
EEPROM.write(slot + EEPROM_TROMP_CHAN, mytromp->getChannel());
EEPROM.write(slot + EEPROM_BUZZ_CHAN, mybuzz->getChannel());
EEPROM.write(slot + EEPROM_KEYCLICK_CHAN, mykeyclick->getChannel());

};

Expand Down
106 changes: 100 additions & 6 deletions tuning_screens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
/// @warning These functions are hardcoded to expect certain string objects to exist.
/// @{

/// @brief Prompts the user to choose between the primary tunining options: guided tuinings, manual tunings, volume control.
/// @brief Prompts the user to choose between the primary tunining options: guided tuinings, manual tunings, volume control, MIDI channel assignment.
/// @return True if an option was chosen, false otherwise.
bool tuning() {

bool done = false;
while (!done) {

if (use_solfege == 0) {
print_menu_4("Tuning Menu", "G/C, Guided", "D/G, Guided", "Manual Setup", "Volume Control");
print_menu_5("Tuning Menu", "G/C, Guided", "D/G, Guided", "Manual Setup", "Volume Control", "MIDI Channels");
} else if (use_solfege == 1) {
print_menu_4("Tuning Menu", "Sol/Do, Guided", "Re/Sol, Guided", "Manual Setup", "Volume Control");
print_menu_5("Tuning Menu", "Sol/Do, Guided", "Re/Sol, Guided", "Manual Setup", "Volume Control", "MIDI Channels");
} else {
print_menu_4("Tuning Menu", "G/C (Sol/Do), Guided", "D/G (Re/Sol), Guided", "Manual Setup", "Volume Control");
print_menu_5("Tuning Menu", "G/C (Sol/Do), Guided", "D/G (Re/Sol), Guided", "Manual Setup", "Volume Control", "MIDI Channels");
};
delay(150);

Expand All @@ -42,7 +42,9 @@ bool tuning() {
manual_tuning_screen();
} else if (my4Button->wasPressed()) {
volume_screen();
} else if (my5Button->wasPressed() || myXButton->wasPressed()) {
} else if (my5Button->wasPressed()) {
channel_screen();
} else if (myXButton->wasPressed()) {
return false;
} else if (my6Button->wasPressed()) {
cool_kids_screen();
Expand Down Expand Up @@ -413,6 +415,98 @@ void change_volume_screen(GurdyString *this_string) {
};
};

// This screen allows the user to make manual changes to each string's MIDI channel assignment.

/// @brief Promts the user to choose a string to change the MIDI channel of.
void channel_screen() {

while (true) {

print_menu_6("MIDI Channel",
String("Hi Melody - ") + mystring->getChannel(),
String("Low Melody - ") + mylowstring->getChannel(),
String("Trompette - ") + mytromp->getChannel(),
String("Drone - ") + mydrone->getChannel(),
String("Buzz - ") + mybuzz->getChannel(),
String("Key Click - ") + mykeyclick->getChannel());
delay(150);

// Check the 1 and 2 buttons
my1Button->update();
my2Button->update();
my3Button->update();
my4Button->update();
my5Button->update();
my6Button->update();
myXButton->update();

if (my1Button->wasPressed()) {
change_channel_screen(mystring);

} else if (my2Button->wasPressed()) {
change_channel_screen(mylowstring);

} else if (my3Button->wasPressed()) {
change_channel_screen(mytromp);

} else if (my4Button->wasPressed()) {
change_channel_screen(mydrone);

} else if (my5Button->wasPressed()) {
change_channel_screen(mybuzz);

} else if (my6Button->wasPressed()) {
change_channel_screen(mykeyclick);

} else if (myXButton->wasPressed()) {
return;
};
};

return;
};

/// @brief Prompts the user to adjust the volume of the given string.
/// @param this_string The GurdyString object to adjust the volume of
void change_channel_screen(GurdyString *this_string) {
bool done = false;
int new_cha = this_string->getChannel();
delay(300);
while (!done) {

print_value_selection("MIDI Channel - " + this_string->getName(), new_cha);

my1Button->update();
my2Button->update();
myXButton->update();

if (my1Button->wasPressed()) {
if (new_cha > 1) {
new_cha -= 1;
delay(300);
};
} else if (my1Button->beingPressed()) {
if (new_cha > 1) {
new_cha -= 1;
delay(100);
};
} else if (my2Button->wasPressed()) {
if (new_cha < 16) {
new_cha += 1;
delay(300);
};
} else if (my2Button->beingPressed()) {
if (new_cha < 16) {
new_cha += 1;
delay(100);
};
} else if (myXButton->wasPressed()) {
this_string->setChannel(new_cha);
done = true;
};
};
};

/// @brief Prompts the user to add additional tones to each string (and buzz).
/// @details This is a "hidden" feature.
void cool_kids_screen() {
Expand Down Expand Up @@ -477,4 +571,4 @@ void cool_kids_screen() {
};

return;
};
};
3 changes: 3 additions & 0 deletions tuning_screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ void tune_string_screen(GurdyString *this_string);
void volume_screen();
void change_volume_screen(GurdyString *this_string);

void channel_screen();
void change_channel_screen(GurdyString *this_string);

void cool_kids_screen();
#endif