Hi Folks,
I need your help once again.
As indicated in the title, I would like to display the scale name of the chosen scale, e.g. "Amaj0", and the note being played, e.g. "A6", on my LC-Display.
Up to now I get the chosen Scale displayed as number between 0 and 19 (20 Scales to choose from) but I only get the first letter of the Scale_Name displayed, e.g. "A", instead of "Amaj0".
1) How do I get the complete Scale_Name of the Scale which has been chosen, e.g. "Amaj0", displayed on my LCD?
In the second row of my LCD I get the note being played displayed as number (according to my scales the numbers range from 57 to 119).
2) How can I get the actual note_name, e.g. "A6", from the const char arrays displayed?
I still have problems here connecting the int values given from the potis (A0, and A1)and the const char arrays to display the note names themselves.
Any ideas?
Thanks for your help in advance and Happy New Years Celebrations to all of you,
Marl
I need your help once again.
As indicated in the title, I would like to display the scale name of the chosen scale, e.g. "Amaj0", and the note being played, e.g. "A6", on my LC-Display.
Up to now I get the chosen Scale displayed as number between 0 and 19 (20 Scales to choose from) but I only get the first letter of the Scale_Name displayed, e.g. "A", instead of "Amaj0".
1) How do I get the complete Scale_Name of the Scale which has been chosen, e.g. "Amaj0", displayed on my LCD?
In the second row of my LCD I get the note being played displayed as number (according to my scales the numbers range from 57 to 119).
2) How can I get the actual note_name, e.g. "A6", from the const char arrays displayed?
Code:
// include the library code:
#include <LiquidCrystal.h>
#include <MIDI.h>
int const numPins = 2; // number of analog inputs
int analogPins[] = {
0,1 // which analog pins to use
};
// the MIDI channel number to send messages
const int channel = 1;
int theNote;
int OldNote = 0;
// *********************************
// SCALE INFORMATION:
// *********************************
// *** A Major *** COUNT: 0
const int Amaj0[] = {57,59,61,62,64,66,68,69};
const char *Amaj0_Names[] = {"A6", "B6", "C#6", "C6", "E6", "F#6", "G#6", "A7"};
// *** A Major 1*** COUNT: 1
const int Amaj1[] = {69,71,73,74,76,78,80,81};
const char *Amaj1_Names[] = {"A7", "B7", "C#7", "C7", "E7", "F#7", "G#7", "A8"};
// *** B Major *** COUNT: 2
const int Bmaj0[] = {59,61,63,64,66,68,70,71};
const char *Bmaj0_Names[] = {"B6", "C#6", "D#6", "E6", "F#6", "G#6", "A#7", "B7"};
// *** B Major 1*** COUNT: 3
const int Bmaj1[] = {71,73,75,76,78,80,82,83};
const char *Bmaj1_Names[] = {"B7", "C#7", "D#7", "E7", "F#7", "G#7", "A#8", "B8"};
// *** C Major *** COUNT: 4
const int Cmaj0[] = {60,62,64,65,67,69,71,72};
const char *Cmaj0_Names[] = {"C6", "D6", "E6", "F6", "G6", "A7", "B7", "C7"};
// *** C Major 1 *** COUNT: 5
const int Cmaj1[] = {72,74,76,77,79,81,83,84};
const char *Cmaj1__Names[] = {"C7", "D7", "E7", "F7", "G7", "A8", "B8", "C8"};
// *** D Major *** COUNT: 6
const int Dmaj0[] = {62,64,66,67,69,71,73,74};
const char *Dmaj0_Names[] = {"D6", "E6", "F#6", "G6", "A7", "B7", "C#7", "D7"};
// *** D Major 1*** COUNT: 7
const int Dmaj1[] = {74,76,78,79,81,83,85,86};
const char *Dmaj1_Names[] = {"D7", "E7", "F#7", "G7", "A8", "B8", "C#8", "D8"};
// *** E Major *** COUNT: 8
const int Emaj0[] = {64,66,68,69,71,73,75,76};
const char *Emaj0_Names[] = {"E6", "F#6", "G#6", "A7", "B7", "C#7", "D#7", "E7"};
// *** E Major 1*** COUNT: 9
const int Emaj1[] = {76,78,80,81,83,85,87,88};
const char *Emaj1_Names[] = {"E7", "F#7", "G#7", "A8", "B8", "C#8", "D#8", "E8"};
// *** F Major *** COUNT: 10
const int Fmaj0[] = {65,67,69,70,72,74,76,77};
const char *Fmaj0_Names[] = {"F6", "G6", "A7", "A#7", "C7", "D7", "E7", "F7"};
// *** F Major 1*** COUNT: 11
const int Fmaj1[] = {77,79,81,82,84,86,88,89};
const char *Fmaj1_Names[] = {"F7", "G7", "A8", "A#8", "C8", "D8", "E8", "F8"};
// *** G Major *** COUNT: 12
const int Gmaj0[] = {55,57,59,60,62,64,66,67};
const char *Gmaj0_Names[] = {"G5", "A6", "B6", "C6", "D6", "E6", "F#6", "G6"};
// *** G Major 1*** COUNT: 13
const int Gmaj1[] = {67,69,71,72,74,76,78,79};
const char *Gmaj1_Names[] = {"G6", "A7", "B7", "C7", "D7", "E7", "F#7", "G7"};
// *** G Mixolydian*** COUNT: 14
const int Gmix[] = {81,83,84,86,88,89,79,81};
const char *Gmix_Names[] = {"A8", "B8", "C8", "D8", "E8", "F8", "G7", "A8"};
// *** Pentatonic*** COUNT: 15
const int Pent[] = {0,2,4,7,9};
const char *Pent_Names[] = {"C", "D", "E", "G", "A"};
// *** Pentatonic 8*** COUNT: 16
const int Pent8[] = {84,86,88,91,93};
const char *Pent8_Names[] = {"C8", "D8", "E8", "G8", "A9"};
// *** Blues*** COUNT: 17
const int Blue[] = {0,2,3,4,5,7,9,10,11};
const char *Blue_Names[] = {"C", "D", "D#", "E", "F", "G", "A2", "A#2","B2"};
// *** Bluz 10*** COUNT: 18
const int Bluz[] = {108,110,111,112,113,115,117,118,119};
const char *Bluz_Names[] = {"C10", "D10", "D#10", "E10", "F10", "G10", "A11", "A#11","B11"};
// *** Phrygian 5*** COUNT: 19
const int Phry5[] = {48,49,51,53,55,56,58};
const char *Phry5_Names[] = {"C5", "C#5", "D#5", "F5", "G5", "G#5", "A#6"};
// **********************************************
// ******* END OF SCALE INFORMATION ********
// **********************************************
const int *Scales[] = {Amaj0, Amaj1, Bmaj0, Bmaj1, Cmaj0, Cmaj1, Dmaj0, Dmaj1, Emaj0, Emaj1, Fmaj0, Fmaj1, Gmaj0, Gmaj1, Gmix, Pent, Pent8, Blue, Bluz, Phry5};
const int ScaleLength[] = {8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 5, 9, 9, 7};
const char *Scale_Names[] = {"Amaj0_Names", "Amaj1_Names", "Bmaj0_Names", "Bmaj1_Names", "Cmaj0_Names", "Cmaj1_Names", "Dmaj0_Names", "Dmaj1_Names", "Emaj0_Names", "Emaj1_Names", "Fmaj0_Names", "Fmaj1_Names", "Gmaj0_Names", "Gmaj1_Names", "Gmix_Names", "Pent_Names", "Pent8_Names", "Blue_Names", "Bluz_Names", "Phry5_Names"};
const char *Scales_Names[] = {"Amaj0", "Amaj1", "Bmaj0", "Bmaj1", "Cmaj0", "Cmaj1", "Dmaj0", "Dmaj1", "Emaj0", "Emaj1", "Fmaj0", "Fmaj1", "Gmaj0", "Gmaj1", "Gmix", "Pent", "Pent8", "Blue", "Bluz", "Phry5"};
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12,11,5,4,3,2);
void setup() {
// put your setup code here, to run once:
MIDI.begin();
Serial.begin(31250);
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// include reverse switch
pinMode(16, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
// The pot on A1 selects which of the 20 scales we pull notes from
int whichScale = (analogRead(A1) * 20) / 1024;
const int *theChosenScale = Scales[whichScale];
int theChosenScalesLength = ScaleLength[whichScale];
char theChosenScaleName = (*Scales_Names[whichScale]);
// The pot on A0 selects a note from the chosen scale
int whichNoteOfScale = (analogRead(A0) * theChosenScalesLength) / 1024;
// If the switch is set to reverse, reverse the direction of the sequence
if (digitalRead(16) == HIGH) {
const int theNote = theChosenScale[((theChosenScalesLength - 1) - whichNoteOfScale)];
lcd.setCursor(6, 1);
//print that the Scale is in reverse mode
lcd.print("Reverse");
lcd.setCursor(0, 0);
lcd.print(whichScale);
lcd.setCursor(6, 0);
lcd.print(theChosenScaleName);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the note being played:
lcd.print(theNote);
} else {
const int theNote = theChosenScale[whichNoteOfScale];
lcd.setCursor(6, 1);
//print that the Scale is in normal mode
lcd.print("Normal ");
lcd.setCursor(0, 0);
lcd.print(whichScale);
lcd.setCursor(6, 0);
lcd.print(theChosenScaleName);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the note being played:
lcd.print(theNote);
}
if (theNote != OldNote) {
MIDI.sendNoteOn(theNote, 127, channel);
Serial.println(theNote);
}
else {
MIDI.sendNoteOff(theNote, 127, channel);
}
OldNote = theNote;
}
Any ideas?
Thanks for your help in advance and Happy New Years Celebrations to all of you,
Marl