Esempio n. 1
0
void TrashMIDI(void)
{
  long Length;
  int J;

  /* If not logging, drop out */
  if(!MIDIOut) return;
  /* Turn sound off */
  for(J=0;J<MIDI_CHANNELS;J++) NoteOff(J);
  /* End of track */
  MIDIMessage(0xFF,0x2F,0x00);
  /* Put track length in file */
  fseek(MIDIOut,0,SEEK_END);
  Length=ftell(MIDIOut)-22;
  fseek(MIDIOut,18,SEEK_SET);
  fputc((Length>>24)&0xFF,MIDIOut);
  fputc((Length>>16)&0xFF,MIDIOut);
  fputc((Length>>8)&0xFF,MIDIOut);
  fputc(Length&0xFF,MIDIOut);

  /* Done logging */
  fclose(MIDIOut);
  Logging   = MIDI_OFF;
  LastMsg   = -1;
  TickCount = 0;
  MIDIOut   = 0;
}
Esempio n. 2
0
	void sendMessage(QueueMessage *qm)
	{
		uint8_t *m = qm->getMessage();
		for (int i = 0; i < qm->getSize(); i++)
			midiOut.send(m[i]);

//		printf("MidiMessage: %x %x %x (%d)\n",m[0],m[1],m[2],qm->getSize());

		if (midiUsb.suspended)
			midiUsb.write(MIDIMessage(m, qm->getSize()));
	}
Esempio n. 3
0
bool USBMIDI::EP2_OUT_callback() {
    uint8_t buf[64];
    uint32_t len;
    readEP(EPBULK_OUT, buf, &len, 64);

    if (midi_evt != NULL) {
        for (int i=0; i<len; i+=4) {
            midi_evt(MIDIMessage(buf+i));
        }
    }

    // We reactivate the endpoint to receive next characters
    readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
    return true;
}
Esempio n. 4
0
bool USBMIDI::EPBULK_OUT_callback() {
    uint8_t buf[64];
    uint32_t len;
    readEP(EPBULK_OUT, buf, &len, 64);

    if (midi_evt != NULL) {
        for (uint32_t i=0; i<len; i+=4) {   
            uint8_t data_read;
            data_end=true;
            switch(buf[i]) {
            case 0x2:
                // Two-bytes System Common Message - undefined in USBMidi 1.0
                data_read=2;
                break;
            case 0x4:
                // SysEx start or continue
                data_end=false;
                data_read=3;
                break;
            case 0x5:
                 // Single-byte System Common Message or SysEx end with one byte
                data_read=1;
                break;
            case 0x6:
                // SysEx end with two bytes
                data_read=2;
                break;
            case 0xC:
                // Program change
                data_read=2;
                break;
            case 0xD:
                // Channel pressure
                data_read=2;
                break;      
            case 0xF:
                // Single byte
                data_read=1;
                break;    
            default:
                // Others three-bytes messages
                data_read=3;
                break;      
            } 
        
            for(uint8_t j=1;j<data_read+1;j++) {
                data[cur_data]=buf[i+j];
                cur_data++;
            }
        
            if(data_end) {
                 midi_evt(MIDIMessage(data,cur_data));
                 cur_data=0;            
            }
       }
    }

    // We reactivate the endpoint to receive next characters
    readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
    return true;
}