What I seem to be experiencing is this:
the first 16 IF statements process the way I intend, but the 17th thru 47th don't seem to process.
My project: an UP/Down switch that sends different serial data depending on witch instance has been selected. specifically, changing patches (via MIDI) on 3 different devices. The Song Name and # are printed to an LCD for refrence. I added output to the serial monitor for troubleshooting. The LCD coding has been commented out(//) of this version because I notice no problem with the output to the LCD and I have the same issue with the output to the serial monitor. Song#'s 20 thru 45 have been omitted to save space(and your sanity).
example: switch from "song"#1(working for the weekend) to "song" #3(wild nights) should change my GR-55 to patch#26("lespaul"),change my POD to patch#97, and change my GR-30 to patch#28 in bank 10.
All the Midi switching works the way I expect it to, but only for "song"#'s 1-16. The problem is that switching up/down to/from "song"s 17-47 changes the "song" #, but does NOT send the correct MIDI signals. The signals from "song" # 16 are repeated.
As far as I can tell, the issue is with the "IF" statements, but I could be wrong(have been before, will be again).
the huge "SONGName" string array was the first way I found to print the Characters of the song name. These change with the "SONGNum" as I expect, but the variables for the MIDI data only change for "SONGNum" 1-16.
So what have I missed ?
I'm sure there are better organized ways for some of the program, and I am interested in opinions for that, but my focus is on sending the correct(or "what I expect") data out of the MIDI port.
serial monitor code
//#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
//LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
//works with song #'s from 1-50
//16 charcter names
//program change format:(patch #, MIDI channel)
//control change format:(control #, value, MIDI channel)
//GR-55 MIDI channel=1
//PodXTLive MIDI channel=2
//GR-20 MIDI channel=3
//#include <MIDI.h>
//MIDI_CREATE_DEFAULT_INSTANCE();
int GRpatchNum=0; //GR-55 patch #
int PODpatchNum=0; //PODxt patch #
int GR20patchNum=0; //GR-20 patch #
int GR20bankNum=0; //GR-20 bank #
int SONGNum=0; //song #
int startNum;
int newNum;
char* SONGName[]={"_","Work Wkend","Cud Been Me ","Wild Nights","Everlong",
"Any Way U Want","Hey Jealosy","Sweetness","Summer 69","Think Wr Alone",
"Sex On Fire","Hotel Cali","Jenny, Jenny","Paradise City","Died In UR Arms",
"Somebdy Told Me","Evrybody Talks","Lit Up","Amrcn Girl","China Grove",
"Standing There","Laid","Buttercup","Ever st Rain","Green Day","500 Mi",
"Hurt So Good","BoysOSumer","Bonjovi","Brw Eye Girl","Evrtng Abt U",
"Rebel Yell","Ballroom Blitz","FF Right 2 Party","Sweet Caroline",
"Johnny B Goode","Cold Hard Bitch","JustWhatINeeded","Runaway DelSh",
"Hands 2 Yourself","You & YR Hand","Hey Ya","Still R&R","DancingInTheDark","Dance,Dance",
"Mr.Jones","Santaria","Want U 2 Want Me"};
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT_PULLUP); //patch down button
pinMode(3, INPUT_PULLUP); //patch up button
//MIDI.begin(MIDI_CHANNEL_OMNI);
// set up the LCD's number of columns and rows:
//lcd.begin(16, 2);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
startNum=(SONGNum);
if(digitalRead(3)== LOW&&SONGNum<50){ //when patch up pressed(set"< [max song #]")
SONGNum++; //song# + 1
delay(400);
}
if(digitalRead(2)== LOW&&SONGNum>1){ //when patch down pressed
SONGNum--; //song# - 1
delay(400);
}
if (SONGNum==1){
//"working for the weekend";
GRpatchNum=28;//1C strat
PODpatchNum=81;//51
GR20patchNum=1;
GR20bankNum=0;
}
if (SONGNum==2){
//"could have been me";
GRpatchNum=28;//1C strat
PODpatchNum=110;//6E
GR20patchNum=8;//ACpiano
GR20bankNum=0;
}
if (SONGNum==3){
//"wild nights";
GRpatchNum=26;//1A E335
PODpatchNum=97;//61
GR20patchNum=28;//Perc 29
GR20bankNum=10;
}
if (SONGNum==4){
//everlong
GRpatchNum=28;//strat
PODpatchNum=113;//modern rock
}
if (SONGNum==5){
//any way want you it
GRpatchNum=27;//Lespaul
PODpatchNum=84;//80's rock lead
GR20patchNum=5;//organ
GR20bankNum=0;
}
if (SONGNum==6){
//hey jealosy
GRpatchNum=28;//strat
PODpatchNum=90;//90's drive
}
if (SONGNum==7){
//sweetness
GRpatchNum=28;//strat
PODpatchNum=114;//modern clean
GR20patchNum=8;//ACpiano
GR20bankNum=0;
}
if (SONGNum==8){
//summer of 69
GRpatchNum=28;//strat
PODpatchNum=82;//80's chorus
GR20patchNum=12;//
GR20bankNum=0;
}
if (SONGNum==9){
//i think were alone now
GRpatchNum=28;//strat
PODpatchNum=84;//80's rock lead
GR20patchNum=2;//wave lead
GR20bankNum=0;
}
if (SONGNum==10){
//sex on fire
GRpatchNum=28;//strat
PODpatchNum=109;//sexonfire clean
}
if (SONGNum==11){
//hotel california
GRpatchNum=4;//12 str acst
PODpatchNum=111;//eagles drive
}
if (SONGNum==12){
//jenny jenny
GRpatchNum=28;//strat
PODpatchNum=82;//80's chorus
}
if (SONGNum==13){
//paradise city
GRpatchNum=27;//Lespaul
PODpatchNum=86;//80's chr clean
}
if (SONGNum==14){
//died in your arms
GRpatchNum=12;//died in your arms
}
if (SONGNum==15){
//somebody told me
GRpatchNum=24;//smbdy told me
}
if (SONGNum==16){
//everybody talks
GRpatchNum=21;//cheap organ}
if (SONGNum==17){
//lit up
GRpatchNum=27;//LP
PODpatchNum=100;//MSE rmy
}
if (SONGNum==18){
//american girl
GRpatchNum=19;//12str elect
}
if (SONGNum==19){
//china grove
GRpatchNum=6;//china grove
PODpatchNum=99;// plexi LD
GR20patchNum=8;//AC Piano
GR20bankNum=0;
}
if (SONGNum==46){
//santaria
GRpatchNum=7;//rock organ
PODpatchNum=88;//90s cln
}
if (SONGNum==47){
//want u 2 want me
GRpatchNum=27;//LP
PODpatchNum=95;//70s LD
}
newNum=(SONGNum);
if (newNum!= startNum){
Serial.print("GR#");
Serial.println(GRpatchNum);
// MIDI.sendProgramChange(GRpatchNum,1);
Serial.print("POD#");
Serial.println(PODpatchNum);
//MIDI.sendProgramChange(PODpatchNum,2);
Serial.print("GR20BANK#");
Serial.println(GR20bankNum);
//MIDI.sendControlChange(0,GR20bankNum,3);
Serial.print("GR20#");
Serial.println(GR20patchNum);
Serial.print("Song: ");
Serial.println(SONGName[SONGNum]);
Serial.println(SONGNum);
//MIDI.sendProgramChange(GR20patchNum,3);
//MIDI.sendProgramChange(SONGNum,4); //turn on to display song# on midi diagnostic
//lcd.clear();
}
//lcd.setCursor(0, 0);//top line
//lcd.print(SONGName[SONGNum]);
//lcd.setCursor(0, 1);//bottm line
//lcd.print(SONGNum);
}
GR_POD__GR20change_serialmonitor.ino (7.72 KB)