mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Autoformat all MIDI examples
This commit is contained in:
parent
45eddcf2db
commit
ce7c93a281
5 changed files with 118 additions and 118 deletions
60
examples/USBH_MIDI/USBH_MIDI_dump/USBH_MIDI_dump.ino
Executable file → Normal file
60
examples/USBH_MIDI/USBH_MIDI_dump/USBH_MIDI_dump.ino
Executable file → Normal file
|
@ -36,7 +36,7 @@ void setup()
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (Usb.Init() == -1...
|
}//if (Usb.Init() == -1...
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ void loop()
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
t1 = micros();
|
||||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
|
@ -58,41 +58,41 @@ void loop()
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
void MIDI_poll()
|
void MIDI_poll()
|
||||||
{
|
{
|
||||||
char buf[20];
|
char buf[20];
|
||||||
uint8_t bufMidi[64];
|
uint8_t bufMidi[64];
|
||||||
uint16_t rcvd;
|
uint16_t rcvd;
|
||||||
|
|
||||||
if(Midi.vid != vid || Midi.pid != pid){
|
if (Midi.vid != vid || Midi.pid != pid) {
|
||||||
sprintf(buf, "VID:%04X, PID:%04X", Midi.vid, Midi.pid);
|
sprintf(buf, "VID:%04X, PID:%04X", Midi.vid, Midi.pid);
|
||||||
Serial.println(buf);
|
Serial.println(buf);
|
||||||
vid = Midi.vid;
|
vid = Midi.vid;
|
||||||
pid = Midi.pid;
|
pid = Midi.pid;
|
||||||
}
|
}
|
||||||
if(Midi.RecvData( &rcvd, bufMidi) == 0 ){
|
if (Midi.RecvData( &rcvd, bufMidi) == 0 ) {
|
||||||
sprintf(buf, "%08X: ", millis());
|
sprintf(buf, "%08X: ", millis());
|
||||||
Serial.print(buf);
|
Serial.print(buf);
|
||||||
Serial.print(rcvd);
|
Serial.print(rcvd);
|
||||||
Serial.print(':');
|
Serial.print(':');
|
||||||
for(int i=0; i<64; i++){
|
for (int i = 0; i < 64; i++) {
|
||||||
sprintf(buf, " %02X", bufMidi[i]);
|
sprintf(buf, " %02X", bufMidi[i]);
|
||||||
Serial.print(buf);
|
Serial.print(buf);
|
||||||
}
|
|
||||||
Serial.println("");
|
|
||||||
}
|
}
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay time (max 16383 us)
|
// Delay time (max 16383 us)
|
||||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||||
{
|
{
|
||||||
unsigned long t3;
|
unsigned long t3;
|
||||||
|
|
||||||
if( t1 > t2 ){
|
if ( t1 > t2 ) {
|
||||||
t3 = (4294967295 - t1 + t2);
|
t3 = (4294967295 - t1 + t2);
|
||||||
}else{
|
} else {
|
||||||
t3 = t2 - t1;
|
t3 = t2 - t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( t3 < delayTime ){
|
if ( t3 < delayTime ) {
|
||||||
delayMicroseconds(delayTime - t3);
|
delayMicroseconds(delayTime - t3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
examples/USBH_MIDI/USB_MIDI_converter/USB_MIDI_converter.ino
Executable file → Normal file
38
examples/USBH_MIDI/USB_MIDI_converter/USB_MIDI_converter.ino
Executable file → Normal file
|
@ -42,7 +42,7 @@ void setup()
|
||||||
_MIDI_SERIAL_PORT.begin(31250);
|
_MIDI_SERIAL_PORT.begin(31250);
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (Usb.Init() == -1...
|
}//if (Usb.Init() == -1...
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ void loop()
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
t1 = micros();
|
||||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
|
@ -64,29 +64,29 @@ void loop()
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
void MIDI_poll()
|
void MIDI_poll()
|
||||||
{
|
{
|
||||||
byte outBuf[ 3 ];
|
byte outBuf[ 3 ];
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if( (size=Midi.RecvData(outBuf)) > 0 ){
|
if ( (size = Midi.RecvData(outBuf)) > 0 ) {
|
||||||
//MIDI Output
|
//MIDI Output
|
||||||
_MIDI_SERIAL_PORT.write(outBuf, size);
|
_MIDI_SERIAL_PORT.write(outBuf, size);
|
||||||
}
|
}
|
||||||
}while(size>0);
|
} while (size > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay time (max 16383 us)
|
// Delay time (max 16383 us)
|
||||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||||
{
|
{
|
||||||
unsigned long t3;
|
unsigned long t3;
|
||||||
|
|
||||||
if( t1 > t2 ){
|
if ( t1 > t2 ) {
|
||||||
t3 = (4294967295 - t1 + t2);
|
t3 = (4294967295 - t1 + t2);
|
||||||
}else{
|
} else {
|
||||||
t3 = t2 - t1;
|
t3 = t2 - t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( t3 < delayTime ){
|
if ( t3 < delayTime ) {
|
||||||
delayMicroseconds(delayTime - t3);
|
delayMicroseconds(delayTime - t3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
50
examples/USBH_MIDI/USB_MIDI_converter_multi/USB_MIDI_converter_multi.ino
Executable file → Normal file
50
examples/USBH_MIDI/USB_MIDI_converter_multi/USB_MIDI_converter_multi.ino
Executable file → Normal file
|
@ -44,7 +44,7 @@ void setup()
|
||||||
_MIDI_SERIAL_PORT.begin(31250);
|
_MIDI_SERIAL_PORT.begin(31250);
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (Usb.Init() == -1...
|
}//if (Usb.Init() == -1...
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void loop()
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
t1 = micros();
|
||||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
|
@ -66,35 +66,35 @@ void loop()
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
void MIDI_poll()
|
void MIDI_poll()
|
||||||
{
|
{
|
||||||
byte outBuf[ 3 ];
|
byte outBuf[ 3 ];
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if( (size=Midi1.RecvData(outBuf)) > 0 ){
|
if ( (size = Midi1.RecvData(outBuf)) > 0 ) {
|
||||||
//MIDI Output
|
//MIDI Output
|
||||||
_MIDI_SERIAL_PORT.write(outBuf, size);
|
_MIDI_SERIAL_PORT.write(outBuf, size);
|
||||||
}
|
}
|
||||||
}while(size>0);
|
} while (size > 0);
|
||||||
do {
|
do {
|
||||||
if( (size=Midi2.RecvData(outBuf)) > 0 ){
|
if ( (size = Midi2.RecvData(outBuf)) > 0 ) {
|
||||||
//MIDI Output
|
//MIDI Output
|
||||||
_MIDI_SERIAL_PORT.write(outBuf, size);
|
_MIDI_SERIAL_PORT.write(outBuf, size);
|
||||||
}
|
}
|
||||||
}while(size>0);
|
} while (size > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay time (max 16383 us)
|
// Delay time (max 16383 us)
|
||||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||||
{
|
{
|
||||||
unsigned long t3;
|
unsigned long t3;
|
||||||
|
|
||||||
if( t1 > t2 ){
|
if ( t1 > t2 ) {
|
||||||
t3 = (4294967295 - t1 + t2);
|
t3 = (4294967295 - t1 + t2);
|
||||||
}else{
|
} else {
|
||||||
t3 = t2 - t1;
|
t3 = t2 - t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( t3 < delayTime ){
|
if ( t3 < delayTime ) {
|
||||||
delayMicroseconds(delayTime - t3);
|
delayMicroseconds(delayTime - t3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
52
examples/USBH_MIDI/bidrectional_converter/bidrectional_converter.ino
Executable file → Normal file
52
examples/USBH_MIDI/bidrectional_converter/bidrectional_converter.ino
Executable file → Normal file
|
@ -50,7 +50,7 @@ void setup()
|
||||||
MIDI.begin(MIDI_CHANNEL_OMNI);
|
MIDI.begin(MIDI_CHANNEL_OMNI);
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (Usb.Init() == -1...
|
}//if (Usb.Init() == -1...
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
}
|
}
|
||||||
|
@ -62,19 +62,19 @@ void loop()
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
t1 = micros();
|
||||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
if (MIDI.read()) {
|
if (MIDI.read()) {
|
||||||
msg[0] = MIDI.getType();
|
msg[0] = MIDI.getType();
|
||||||
if( msg[0] == 0xf0 ) { //SysEX
|
if ( msg[0] == 0xf0 ) { //SysEX
|
||||||
//TODO
|
//TODO
|
||||||
//SysEx implementation is not yet.
|
//SysEx implementation is not yet.
|
||||||
}else{
|
} else {
|
||||||
msg[1] = MIDI.getData1();
|
msg[1] = MIDI.getData1();
|
||||||
msg[2] = MIDI.getData2();
|
msg[2] = MIDI.getData2();
|
||||||
Midi.SendData(msg, 0);
|
Midi.SendData(msg, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//delay(1ms)
|
//delay(1ms)
|
||||||
|
@ -84,27 +84,27 @@ void loop()
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
void MIDI_poll()
|
void MIDI_poll()
|
||||||
{
|
{
|
||||||
byte outBuf[ 3 ];
|
byte outBuf[ 3 ];
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
|
|
||||||
if( (size=Midi.RecvData(outBuf)) > 0 ){
|
if ( (size = Midi.RecvData(outBuf)) > 0 ) {
|
||||||
//MIDI Output
|
//MIDI Output
|
||||||
_MIDI_SERIAL_PORT.write(outBuf, size);
|
_MIDI_SERIAL_PORT.write(outBuf, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay time (max 16383 us)
|
// Delay time (max 16383 us)
|
||||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||||
{
|
{
|
||||||
unsigned long t3;
|
unsigned long t3;
|
||||||
|
|
||||||
if( t1 > t2 ){
|
if ( t1 > t2 ) {
|
||||||
t3 = (4294967295 - t1 + t2);
|
t3 = (4294967295 - t1 + t2);
|
||||||
}else{
|
} else {
|
||||||
t3 = t2 - t1;
|
t3 = t2 - t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( t3 < delayTime ){
|
if ( t3 < delayTime ) {
|
||||||
delayMicroseconds(delayTime - t3);
|
delayMicroseconds(delayTime - t3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
examples/USBH_MIDI/eVY1_sample/eVY1_sample.ino
Executable file → Normal file
36
examples/USBH_MIDI/eVY1_sample/eVY1_sample.ino
Executable file → Normal file
|
@ -24,13 +24,13 @@ void noteOn(uint8_t note);
|
||||||
void noteOff(uint8_t note);
|
void noteOff(uint8_t note);
|
||||||
|
|
||||||
uint16_t pid, vid;
|
uint16_t pid, vid;
|
||||||
uint8_t exdata[] ={
|
uint8_t exdata[] = {
|
||||||
0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10,
|
0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10,
|
||||||
'k',' ','o',',', //Ko
|
'k', ' ', 'o', ',', //Ko
|
||||||
'N','\\',',', //N
|
'N', '\\', ',', //N
|
||||||
'J',' ', 'i', ',', //Ni
|
'J', ' ', 'i', ',', //Ni
|
||||||
't','S',' ','i',',',//Chi
|
't', 'S', ' ', 'i', ',', //Chi
|
||||||
'w',' ','a', //Wa
|
'w', ' ', 'a', //Wa
|
||||||
0x00, 0xf7
|
0x00, 0xf7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void setup()
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
while(1); //halt
|
while (1); //halt
|
||||||
}//if (Usb.Init() == -1...
|
}//if (Usb.Init() == -1...
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void setup()
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
noteOn(0x3f);
|
noteOn(0x3f);
|
||||||
|
@ -61,15 +61,15 @@ void loop()
|
||||||
// Poll USB MIDI Controler
|
// Poll USB MIDI Controler
|
||||||
void MIDI_poll()
|
void MIDI_poll()
|
||||||
{
|
{
|
||||||
byte inBuf[ 3 ];
|
byte inBuf[ 3 ];
|
||||||
|
|
||||||
//first call?
|
//first call?
|
||||||
if(Midi.vid != vid || Midi.pid != pid){
|
if (Midi.vid != vid || Midi.pid != pid) {
|
||||||
vid = Midi.vid; pid = Midi.pid;
|
vid = Midi.vid; pid = Midi.pid;
|
||||||
Midi.SendSysEx(exdata, sizeof(exdata));
|
Midi.SendSysEx(exdata, sizeof(exdata));
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
uint8_t size = Midi.RecvData(inBuf);
|
uint8_t size = Midi.RecvData(inBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//note On
|
//note On
|
||||||
|
|
Loading…
Reference in a new issue