Gast
#805854
Hallo,
sorry, ich steh wirklich an. ich versuche mit Peter Fleury's UART Lib
Midi Daten in einem Array zu speichern. mich interessieren Sysex cmds,
mit denen ich einen status setze und NoteOn/Off, die dann je nach eben
genannten statusbits weiterverarbeitet werden.
irgendwie funktioniert mein code nicht. mittels debug-noteOn (eine idee
von mir einen ton unterschiedlicher höhe in verschiedenen subprocedures
auszugeben) hat auch nix gebracht. offenbar hakts bei der
zusammenstellung der midi commandos.
die idee:
loop(unendlich)
ist das zeichen ein sysex oder noteon oder noteoff
speichere es in array an pos 0
ist das zeichen nur midi daten
erhöhe index im array und speichere das zeichen im array
ist das cmd ein noteon/off und sind alle datenbytes (=2) angekommen
bearbeite noteon/off
ist das cmd ein sysex und sind alle datenbytes (immer 6) da
bearbeiter sysex
endloop
kann mir jemand helfen??
mein hauptprogramm:
int main(void) {
u08 c; // currently received Byte
u08 byteCount; // number of Bytes received
u08 cmdType; // type of the midi command
u08 chan; // midi channel
u08 mididata[5]={0};// midi command collector
// ------------ INITIALISATION ---------------------
hw_init();
c=NONE;
byteCount = 0;
cmdType=NONE;
chan=NONE;
for(;;) {
// -------- CHECK IF UART 1 MIDI DATA IS INCOMMING ----------
c = (unsigned char)uart1_getc(); // c is int not byte!
if ( c & UART_NO_DATA ) {
;
}
else { // interpret midi stuff
if (c & 0x080) { // is it a command?
if ((c & MIDI_SYSEX) || (c & MIDI_NOTEON) || (c & MIDI_NOTEOFF))
{
byteCount=0;
mididata[0] = c;
}
if (c & MIDI_EOX) {
byteCount++;
//do not handle midi EOX
}
}
else { // normal midi data received
byteCount++;
mididata[byteCount] = c; // add incomming data
} // if myByte - else
} // if c & uartnodata - else
// -------- INTERPRET MIDI STUFF ---------------------------
if (byteCount==2) {
if (mididata[0] & MIDI_NOTEON) handle_NOTE(mididata);
if (mididata[0] & MIDI_NOTEOFF) handle_NOTE(mididata);
/*debug
if ((mididata[0] & MIDI_CHANNEL_MASK)==0) {
// add 1 to channel and send it back
uart1_putc(mididata[0]+1);
uart1_putc(mididata[1]);
uart1_putc(mididata[2]);
}debug*/
}
if (byteCount==5) {
if (mididata[0] & MIDI_SYSEX) handle_SYSEX(mididata);
}
} // for
// ------------- MAIN LOOP END -------------------------
} //void main