Hello/please help -
I've gotten my data structures and logic together, but I'm new at C.
Been reading a lot of arduino/C documentation/manuals/books/tutorials. . .
. . . I'm stuck.
I was under the impression that I could "include" libraries,
that would define/declare functions that I could use in my code.
but I'm getting these errors:
mono_notes_chord_key____sketch_jan16a.ino: In function 'void handleControlChange(byte, byte, byte)':
mono_notes_chord_key____sketch_jan16a:75: error: 'sendPitchBend' was not declared in this scope
mono_notes_chord_key____sketch_jan16a.ino: In function 'void handleNoteOn(byte, byte, byte)':
mono_notes_chord_key____sketch_jan16a:84: error: 'sendPitchBend' was not declared in this scope
mono_notes_chord_key____sketch_jan16a:85: error: 'sendNoteOn' was not declared in this scope
mono_notes_chord_key____sketch_jan16a.ino: In function 'void handleNoteOff(byte, byte, byte)':
mono_notes_chord_key____sketch_jan16a:89: error: 'sendNoteOff' was not declared in this scope
So, I must be missing something
I only need to read all 16 channels of noteons, and 2 controlchanges on 1 channel.
I feel like the midi input callbacks are setup correctly (at least they aren't giving me errors).
But the midi output functions (I only need to send noteons, noteoffs, and pitchbends)
I've done wrong somehow.
Here's the code thus far:
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
byte IncomingSongRoot = 0;
byte SongRootShift = 0;
byte IncomingChordRoot = 0;
byte IncomingNoteType [16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
byte ScaleDegree [12] = {0,0,1,1,1,0,1,0,0,1,1,2};
byte SemitoneOffset [12] = {0,0,2,2,4,5,4,7,7,9,9,11};
double PitchGrid [3][12] = {
{0,-1,-2,1,0,2,1,0,-1,-2,2,1},
{0,-1,-2,0,-1,2,1,0,-1,-2,2,1},
{0,-1,-2,0,2,1,0,-1,-2,-1,2,1},
};
byte ChordRootShift = 0;
byte ChordType = 0;
byte ChordRoot = 0;
MIDI_CREATE_DEFAULT_INSTANCE();
void handleControlChange(byte channel, byte number, byte value) {
if (channel == 16) {
if (number == 14) {
IncomingSongRoot = value % 12;
SongRootShift = (12 - IncomingSongRoot) % 12;
}
if (number == 15) {
IncomingChordRoot = value % 12;
}
if ((number == 14) || (number == 15)) {
byte ChordLookup = (IncomingChordRoot + SongRootShift) % 12;
ChordType = ScaleDegree [ChordLookup];
ChordRoot = (SemitoneOffset [ChordLookup] + IncomingSongRoot) % 12;
ChordRootShift = (12 - ChordRoot) % 12;
for (byte ChnCount = 0; ChnCount<16; ++ChnCount) {
byte NoteShift = (ChordRootShift + IncomingNoteType [ChnCount]) % 12;
double BendAmount = PitchGrid [ChordType][NoteShift];
sendPitchBend(BendAmount, ChnCount);
}
}
}
}
void handleNoteOn(byte channel, byte pitch, byte velocity) {
byte NoteIn = pitch % 12;
byte NoteShift = (ChordRootShift + NoteIn) % 12;
double BendAmount = PitchGrid [ChordType][NoteShift];
sendPitchBend(BendAmount, channel);
sendNoteOn(pitch, velocity, channel);
IncomingNoteType [channel] = NoteIn;
}
void handleNoteOff(byte channel, byte pitch, byte velocity) {
sendNoteOff(pitch, velocity, channel);
}
// -----------------------------------------------------------------------------
void setup()
{
MIDI.setHandleNoteOn(handleNoteOn);
MIDI.setHandleNoteOff(handleNoteOff);
MIDI.setHandleControlChange(handleControlChange);
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.turnThruOff();
// ----------------------------find out how to turn off running status
}
void loop()
{
MIDI.read();
}
apologies if this should be in the "programming questions" sub-forum