Go Down

Topic: Arduino MIDI output (With USB-Midi Cable)? (Read 450 times) previous topic - next topic

ajraycakn

Hello Friends,
I recently bought a USB-to-MIDI cable for an audio project.

I uploaded a few basic example sketches off the web, in an attempt simply to get an output from the board to FL Studio. Unfortunately, I don't seem to be getting a correct output. As seen in attached image, FL recognises the USB cable as an interface,  and even senses some kind of signal (Note C0, 64 Velocity - NOT the note I'm trying to output).

I'm also attached the basic circuit I'm using. I'm using a MIDI Jack Input on the breadboard. (220ohm resistor, and I'm definitely using the correct pins, in case the schematic looks off)

Any suggestions or corrections for simply getting a MIDI output from my board to FL through the USB-MIDI cable?



For reference, I just used the MIDI tutorial code;

void setup() {
  // Set MIDI baud rate:
  Serial.begin(31250);
}

void loop() {
  // play notes from F#-0 (0x1E) to F#-5 (0x5A):
  for (int note = 0x1E; note < 0x5A; note ++) {
    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0x45);
    delay(100);
    //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);
    delay(100);
  }
}

// plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that
// data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
}



I'm aware I'm only using one resistor where the guide suggests two, but I've found others have gotten away with using just one on the 5V wire... I imagine the problem isn't being caused by that.

Any help is appreciated :)

ajraycakn

Guess my FL screenshot didn't upload :(

Anyway, I'm sure I'm not the first person to use a USB-MIDI cable for an Arduino. Just wondering how I can get output from the board, to FL.

Grumpy_Mike

#2
Dec 04, 2018, 08:36 am Last Edit: Dec 04, 2018, 08:37 am by Grumpy_Mike
Quote
NOT the note I'm trying to output).
So what is the note you are trying to output?
I would suggest that a delay of 0.1 seconds between notes is a bit high try dropping that to 0.5 second.

Just try the one note and see what you get.

If you are getting note and velocity messages nearly right it could be a speed miss match between your Arduino and PC. Is it a real Arduino or a clone?

Has it got a crystal or a resonator co trolling the clock.

Please read the how to use this forum sticky post so you use code tags correctly so the code is not mangled like yours has been. Or use the copy for forum option in the IDE for pasting code.

ajraycakn

#3
Dec 04, 2018, 12:11 pm Last Edit: Dec 04, 2018, 12:16 pm by ajraycakn
If you are getting note and velocity messages nearly right it could be a speed miss match between your Arduino and PC. Is it a real Arduino or a clone?
Has it got a crystal or a resonator co trolling the clock.

I'm using a genuine Mega 2560 board.   The note's I'm trying to output is a simple C4-C5 scale.

Another sketch half worked. It output most of the notes right, then jumped to extremely high notes (D13 or something).     The main sketch I'm using (works for others) simply outputs C0 :(

ajraycakn

I've decided to just use Virtual porting. The cable seems temperamental and it saves space in the circuit I guess. Just downloaded hairless MIDI, changed Serial Rate to 115200, turned on IAC Bus and its working fine in FL.

Thanks for help :)

Grumpy_Mike

Glad you got it going, those leads are sometimes temperamental.

Go Up