so im trying to transfer these "canvas notes" onto my system "finalfinal" and - talkMIDI not declared in thisscope- keeps popping up. they're identical as far as im concerned but the first compiles while the second doesnt. What am i missing?
//======Canvas_Notes
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
byte note = 0; //The MIDI note value to be played
byte resetMIDI = 4; //Tied to VS1053 Reset line
byte ledPin = 13; //MIDI traffic inidicator
int instrument = 0;
int OUP(int note){
int result;
result = note + 12;
return result;
}
//Plays a note X (one) octives lower than selected note
int ODN(int note){
int result;
result = note - 12;
return result;
}
const int C = 60;
const int D = 62;
const int E = 64;
const int F = 65;
const int G = 67;
const int A = 69;
const int B = 71;
const int Cs = 61;
const int Df = 61;
const int Ds = 63;
const int Ef = 63;
const int Fs = 66;
const int Gf = 66;
const int Gs = 68;
const int Af = 68;
const int As = 70;
const int Bf = 70;
int attack_velocity = 120; //Attack velocity of notes-- AFFECTS VOLUME
int release_velocity = 60; //Release velocity of notes
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
//Setup soft serial for MIDI control
mySerial.begin(31250);
//Reset the VS1053
pinMode(resetMIDI, OUTPUT);
digitalWrite(resetMIDI, LOW);
delay(100);
digitalWrite(resetMIDI, HIGH);
delay(100);
talkMIDI(0xB0, 0x07, 120); //0xB0 is channel message, set channel volume to near max (127)
// INSTRUMENT SELECTION FUNCTIONS:::: (call this value before you play your notes)
//Oboe
talkMIDI(0xC0, 69, 0);
}
void loop() {
// put your main code here, to run repeatedly:
O1();
}
void O1(){
play(OUP(F),2);
play(OUP(D),.5);
play(OUP(E),.5);
//digitalWrite(solenoidPin,LOW); //Drops Ball
play(OUP(D),.5);
play(OUP(C),.5);
}
/void O2(){
play(OUP(B),1);
play(OUP(B),.5);
play(OUP(D),.5);
play(OUP(C),1);
digitalWrite(solenoidPin,LOW); //Drops Ball
play(OUP(C),.5);
play(OUP(D),.5);
}
void O3(){
play(OUP(E),1);
play(OUP(C),1);
play(A,.5);
play(B,.5);
digitalWrite(solenoidPin,LOW); //Drops Ball
play(OUP(C),1);
}
void O4(){
play(OUP(D),.5);
play(OUP(C),.5);
play(B,.5);
play(As,.5);
//Hand Programed as ball drops mid note
noteOn(0, F, attack_velocity);
delay(500);
digitalWrite(solenoidPin,LOW); //Drops Ball
delay(500);
noteOff(0, F, release_velocity);
}
void O5(){
play(F,1);
play(B,1);
play(B,1);
digitalWrite(solenoidPin,LOW); //Drops Ball
play(G,1);
}
void O6(){
play(A,1);
play(OUP(E),1);
play(A,.5);
play(B,.5);
digitalWrite(solenoidPin,LOW); //Drops Ball
play(C,1);
}/
//This should play a bunch of different instruments depending on what order you’re in. So the first Oboe would upload O1, second would upload O2, etc. Then you can use this to drop the ball.
//ASSOCIATED FUNCTIONS______
//plays note of specified duration and value.
void play(int note, float pause){
noteOn(0, note, attack_velocity);
delay(pause*500);
noteOff(0, note, release_velocity);
}
//Send a MIDI note-on message. Like pressing a piano key
//channel ranges from 0-15
void noteOn(byte channel, byte note, byte attack_velocity) {
talkMIDI( (0x90 | channel), note, attack_velocity);
}
//Send a MIDI note-off message. Like releasing a piano key
void noteOff(byte channel, byte note, byte release_velocity) {
talkMIDI( (0x80 | channel), note, release_velocity);
}
//Plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that data values are less than 127
void talkMIDI(byte cmd, byte data1, byte data2) {
digitalWrite(ledPin, HIGH);
mySerial.write(cmd);
mySerial.write(data1);
//Some commands only have one data byte. All cmds less than 0xBn have 2 data bytes
//(sort of: MIDI Communication Protocol)
if( (cmd & 0xF0) <= 0xB0)
mySerial.write(data2);
digitalWrite(ledPin, LOW);
}
canvas_notes.ino (3.69 KB)
finalfinal.ino (6.23 KB)