Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 8 months ago.
Problem with USB Midi
Hey everyone,
I am working on this project with USBMidi to send midi commands such as (Note on or Note off, etc) to fruityloops. However my code doesn't work and I can't figure out why. Basically what I am doing for now is use only one button to send a note to fruityloops. The weird thing is that fruityloops detect the mbed but doesn't react to it.
thx in advance.
Here is my code:
usb midi fruityloops
#include "mbed.h" #include "USBMIDI.h" #include "DebounceIn.h" USBMIDI midi; DigitalOut myled(LED1); DebounceIn pb(p8); // SPST Pushbutton demo using internal PullUp function // no external PullUp resistor needed // Pushbutton from P8 to GND. int main() { myled = 0; int prevstatus = 1; int pressed = 0; pb.mode(PullUp); wait(.001); while(1) { switch(pb) { default: break; case 0: if(pressed == 0 && prevstatus == 1) { myled = 1; midi.write(MIDIMessage::NoteOn(69)); wait(0.1); ++pressed; prevstatus = pb; } break; case 1: if(prevstatus == 0) { myled = 0; midi.write(MIDIMessage::NoteOff(69)); wait(0.1); prevstatus = 1; pressed = 0; } break; } } }
Hi, have you tried the hello world example? Are you sure that in your code the midi.write() is called? Can you try with Battery to see if you have the same behavior?
Sam
posted by Samuel Mokrani 09 Mar 2013Hello sam, The hello world example works perfectly on fruityloops. And why would using a battery be different? And how can I figure out if the midi.write() is send or not? Thank you for your reply.
posted by Kazii kaz 09 Mar 2013Hi, no Battery is just another MIDI software. But as the hello world example is working, no need to test it :) To be sure that you are sending the notes, start from the hello world example and add little by little additional code. you can use printf to test if you enter in the "case" of your "switch" Sam
posted by Samuel Mokrani 09 Mar 2013Hi sam, I have just tested my own code that I posted above and I changed the pin 8 to pin 20 and it works!! For some reason pin 8 is causing a problem because when I push the button connected to pin 8, my mbed goes to shortcircuit. But pin 20 works perfectly. Perhaps there is a flaw in the hardware?
posted by Kazii kaz 09 Mar 2013