Midi direct via USB?

Hi, does anyone know if it's possible to get the Arduino to send midi directly to an application on my Mac avoiding the need for a MIDI to USB box? Can I use the USB driver chip on the board to do this? I'm using Isadora to recieve MIDI.

i think it should be possible. i'm not sure yet though if you can use the onboard ftdi usb chip or if you need another chip or none at all.

here's the specification for usb midi devices:
http://www.usb.org/developers/devclass_docs/midi10.pdf

search google for "usb midi atmega8", at least it has been done by one guy.

generally speaking it is possible to develop "native" usb devices using an atmega8. there are many different starting points on the web but i just didn't find the time yet. look for "AVRusb" as another example for such projects.

if you want to start on this, i'd be happy to assist. for now, i'm stuck with the innards of a midiman usb-midi adapter. i'd me more than happy with an arduino solution.

//best , kuk

yeah i've got this up and running.

you will need to download the Roland to Serial to MIDI Driver from their website - sorry I don't have the link offhand but I googled it fairly quickly.

Next, you will have to edit the FTDI drivers that come with arduino so that you can run the serial port at 31250 bps. You will need to make a few changes to FTDIPORT.inf

Look for [FtdiPort232.NT.HW.AddReg] and change the the second line below to the one that i've got here.

HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,60,00,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00

This will map 38400 bps to 31250 which you need for MIDI communication. Whenever windows thinks it's running the port at 38400, the driver will actually run it at 31250. Use Serial.begin(31250) in your code.

Reinstall the arduino FTDI drivers, install the Roland drivers, and VOILA!

EDIT: whooooppppsss sorry just reread that you are using mac... I think a similar Roland driver exists, as for the FTDI driver mods, not so sure how you would go about it. It works on XP so there may be hope!

this sounds good.

just to make sure i understand:
your arduino is sending midi data via serial at 31250 bps.
you needed to hack the ftdi driver to allow that bit rate.

the roland application just takes the data from the (ftdi)serial port and creates a virtual midi-in on your pc?

i tried similar things with the Gee Three StealtPort application on a mac. it creates a virtual midi port, and lets you chose a serial port for the data. it didn't work though. i guess the ftdi driver on the mac doesn't support 31250 neither.

anyone has an idea how to hack the mac-driver for the ftdi?

still HID-midi would be much more comfortable though, as we not need to install any drivers on any OS.

Maybe someone familiar with processing can create some kind of a general serial-to-midi application.
That way we would have a cross-platform solution.

but anyway, really nice work and it sure gives hope.

//kuk

this sounds good.

just to make sure i understand:
your arduino is sending midi data via serial at 31250 bps.
you needed to hack the ftdi driver to allow that bit rate.

exactly. I went to the FTDI website and looked up info on custom serial baud rates. There was a good outline of how to change the .INF settings to get the 31250 at FTDI Knowledgebase I had a quick look through but could not find anything on how to change the MAC drivers around.

The reason that the StealthPort application wont work is probably the same reason that I originally couldn't get the Roland Serial to MIDI driver to work - that is that the com port would not support 31250. If the Mac OS driver is anything like the windows driver, you would only have to change 2 bytes in some config file to get the driver going at the right baud rate. My bets would be on hacking the driver to get the raight baud rate and running the extra serial to midi driver. I am not sure how you would go about folding a HID-midi driver into the FTDI drivers, but I bet it would be a real pain.

yeah i've got this up and running... Reinstall the arduino FTDI drivers, install the Roland drivers, and VOILA!

I've reinstalled the FTDI drivers and installed the Roland driver, but I hear nothing when outputting MIDI from the Arduino. XP > Control Panel > Sounds and Audio Devices > Audio > Midi music playback > Roland Serial MIDI Out A, still nothing... :frowning: any ideas?

ok, i did a little research on a mac solution.

we don't have an .inf files ofr the driver, but still there is readable file inside sytem/library/extensions/FTDIUSBSerialDriver.kext.

you have to right-click that file and select "show package content".

the file named "info.plist" is an xml-like file which lists all available Baud Rates and much more.

i didnn't really understand the structure of the doument but added 31250 for midi support.

the block now looks like this:

<dict>
                        <key>BaudRates</key>
                        <dict>
                              <key>B115200</key>
                              <integer>57600</integer>
                              <key>B1200</key>
                              <integer>57600</integer>
                              <key>B19200</key>
                              <integer>57600</integer>
                              <key>B230400</key>
                              <integer>57600</integer>
                              <key>B2400</key>
                              <integer>57600</integer>
                              <key>B300</key>
                              <integer>57600</integer>
                              <key>B31250</key>
                              <integer>57600</integer>
                              <key>B38400</key>
                              <integer>57600</integer>
                              <key>B4800</key>
                              <integer>57600</integer>
                              <key>B57600</key>
                              <integer>57600</integer>
                              <key>B600</key>
                              <integer>57600</integer>
                              <key>B9600</key>
                              <integer>57600</integer>
                        </dict>
                  </dict>

the driver still works as normal. still i get no results with the geethree midi to serial tool, which is the same i think as the roland drivers.

i didn't yet find a way to prove that my changes to info.plist had any effect at all. no serial tool i know of offers 31.250 as a baudrate. anyone hay an idea how to go on?

as for the Roland serial-to-midi driver on your pc... did you have to select between "fast mode" and "standard 1MHz"? which one did you chose?

i asked a question over at the AVR-USB forum.
http://forums.obdev.at/viewtopic.php?p=679#679
it seems not too easy to offer HID-midi-support on arduino :frowning: at least for me. so i hope i can get this solution to work.

//kuk

(edited a typo)

yeah i've got this up and running... Reinstall the arduino FTDI drivers, install the Roland drivers, and VOILA!

I've reinstalled the FTDI drivers and installed the Roland driver, but I hear nothing when outputting MIDI from the Arduino. XP > Control Panel > Sounds and Audio Devices > Audio > Midi music playback > Roland Serial MIDI Out A, still nothing... :frowning: any ideas?

ok well first you should have the MIDI Music Playback set to Windows midi player - what you are attempting to do is send MIDI data TO arudino instead of receiving it.

To actually get some sounds, you will need some sort of program that caputres MIDI data and does something with it. To make some computer music, you will need use a program like Cubase or Ableton or even just a simple VST instrument. From a program like that, choose to input MIDI data from the Roland MIDI device, then the switches or whatever on the Arduino will be able to control the software.

ok, i did a little research on a mac solution.

we don't have an .inf files ofr the driver, but still there is readable file inside sytem/library/extensions/FTDIUSBSerialDriver.kext.

Humm looking at the file you changed, I can't see it having the same effect. What you are setting in the .inf file are some divisors that calculate a baud rate based on a reference frequency. I'd email FTDI and ask about setting a custom baud rate with the mac drivers, if it can be done they are the best people to ask.

erik

Look for [FtdiPort232.NT.HW.AddReg] and change the the second line below to the one that i've got here.

HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,60,00,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00

Which second line do you mean exctly?

1[FtdiPort232.NT.HW.AddReg]
2 HKR,,"UpperFilters",0x00010000,"serenum"
3;HKR,,"ConfigData",1,01,00,3F,3F,10,27,88,13,C4,09,E2,04,71,02,38,41,9c,80,4E,C0,34,00,1A,00,0D,00,06,40,0 3,80,00,00,d0,80
4 HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,60,00,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00

And the roland serial to usb is this the right vesrsion:RSDRV31W2K.ZIP???

thanxx

I can't get Windows to use the Arduino version of ftdiport.inf that I've changed; it insists on using the XP version in oem5.inf.

Any tips to force Windows to use my version? Is there a place in the registry I can just add the MIDI baud rate?

Thanks!

Any tips to force Windows to use my version? Is there a place in the registry I can just add the MIDI baud rate?

Try somewhere under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS... there you'll find the ConfigData binary key.

Thanks. I don't know if it would be the same for all XP installations, but I made a .reg file people could use. Just paste this into a file, name it "foo.reg" (or whatever) and double-click it to merge it into the registry. (USE AT OWN RISK! REG HACKS CAN KILL YOUR INSTALLATION!!!! BACKUP YOUR REGISTRY FIRST!!!!)

---paste below---

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS\VID_0403+PID_6001+A4001drJA\0000\Device Parameters]
"PortName"="COM4"
"PollingPeriod"=dword:00000000
"ConfigData"=hex:11,00,3f,3f,10,27,00,00,88,13,00,00,c4,09,00,00,e2,04,00,00,
71,02,00,00,38,41,00,00,9c,80,00,00,60,00,00,00,34,00,00,00,1a,00,00,00,0d,
00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,d0,80,00,00
"MinReadTimeout"=dword:00000000
"MinWriteTimeout"=dword:00000000
"LatencyTimer"=dword:00000010

---paste above---

Ok tried installing everything as per in this thread but no luck on midi via usb yet :frowning:
I noticed in that the FtdiPort232.NT.HW.AddReg trick seems to be pointing to port 232. But I've installed on com3 - is that a problem.
I hate to sound lame but I can't find an answer anywhere. Help appreciated :slight_smile:

// The switch is on Arduino pin 10:
#define switchPin 2
// Middle C (MIDI note value 60) is the lowest note we'll play:
#define middleC 60
// Indicator LED:
#define LEDpin 4

// Variables:
char note = 1; // The MIDI note value to be played
int AnalogValue = 0; // value from the analog input
int lastNotePlayed = 0; // note turned on when you press the switch
int lastSwitchState = 0; // state of the switch during previous time through the main loop
int currentSwitchState = 0;

void setup() {
// set the states of the I/O pins:
pinMode(switchPin, INPUT);
pinMode(LEDpin, OUTPUT);
// Set MIDI baud rate:
Serial.begin(31250);
blink(3);
}

void loop() {
// My potentiometer gave a range from 0 to 1023:
AnalogValue = analogRead(0);
// convert to a range from 0 to 127:
note = AnalogValue/8;
currentSwitchState = digitalRead(switchPin);
// Check to see that the switch is pressed:
if (currentSwitchState == 1) {
// check to see that the switch wasn't pressed last time
// through the main loop:
if (lastSwitchState == 0) {
// set the note value based on the analog value, plus a couple octaves:
// note = note + 60;
// start a note playing:
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
digitalWrite(LEDpin, HIGH);
}
}
else { // if the switch is not pressed:
// but the switch was pressed last time through the main loop:
if (lastSwitchState == 1) {
// stop the last note played:
noteOn(0x90, lastNotePlayed, 0x00);
digitalWrite(LEDpin, LOW);
}
}

// save the state of the switch for next time
// through the main loop:
lastSwitchState = currentSwitchState;
}

// 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(char cmd, char data1, char data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}

// Blinks an LED 3 times
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(LEDpin, HIGH);
delay(100);
digitalWrite(LEDpin, LOW);
delay(100);
}
}

Has anyone actually gotten any iteration of this to work in OSX?

Or does anyone know of anyone working on a driver solution specifically for the Arduino MIDI crowd?

bump.

Has anyone actually gotten any iteration of this to work in OSX?
Or does anyone know of anyone working on a driver solution specifically for the Arduino MIDI crowd?

No, i haven't, but how hard would this be to code arduino-usb-midi driver ourselves?
let's throw together our crazy ideas and URLs to maybe have a solution within the next couple of years. this thread has been here for long enough.

What do we want?

  • use an arduino board as a (generic) USB-midi device on OS X. That means you hook the board to an USB port on your computer and it shows up as midi-input and output ports as any other USB-Midi device does. most important to me: the board/controller is usb powered.

How do we get there?

I can think of 3 solutions to get there, (which for sure will exist in the near future anyways, but we want it now), so:

SOLUTION A:

  • something like AVR-USB http://www.obdev.at/products/avrusb/index.html
    Arduino is programmed to communicate directly via USB (no FTDI chip in between). It reports itself as a generic midi device and the computer's operation system uses a standard driver.

pro: no installation on computers necessary. arduino device works out of the box on most computers.
contra: a little out of my scope yet, and i'm doubtful if such a AVR-USB-arduino could do much input reading besides doing USB. an extra atmega could be needed.

SOLUTION B:

  • a hacked, or redone FTDI-driver to enable midi baud rate like it has been done on windows PCs. then use a roland midi serial driver to emulate midi ports.

pro: i don't know. it didn't work for me and i got bored because of...
...contra: hacking a driver to be able to use the board with a propietary software, made this unattractive to me. the roland driver seems quite old as well

SOLUTION C:

  • an inbetween application like serial proxy server. Create virtual midi ports and act as a relay between any serial device (arduino board in our case) and MIDI. the baord can send midi messages at any baud rate.

pro: relatively straight forward. debugging friendly, because of flexible baud rate. arduino compatible , no extra atmega or FTDi hack.
contra: installation/configuration necessary on any new computer (only affects people who often switch computers or want to give away controllers to more unsavvy users)

i tend to SOLUTION C, with a nice interface to setup port names. Maybe someone of you knows a good starting point. i tried doing it with processing, but midi on OS X requires a library, which does not work with out of the box Java on OS X. as i have a working solution (midiman usb adapter) i gave up on that. Java would be cool, but since i'm also interested in building native cocoa apps, i'm thinking of going that way. but i couldnt yet find the right documents at the apple developers site or any open source project that uses midi.

anyone?

i tend to SOLUTION C, with a nice interface to setup port names. Maybe someone of you knows a good starting point. i tried doing it with processing, but midi on OS X requires a library, which does not work with out of the box Java on OS X. as i have a working solution (midiman usb adapter) i gave up on that. Java would be cool, but since i'm also interested in building native cocoa apps, i'm thinking of going that way. but i couldnt yet find the right documents at the apple developers site or any open source project that uses midi.

anyone?

I choose this solution too, between Isadora and arduino on a mac, as to drive 3 stepper motor. I send Midi from Isadora to Max/msp (good serial analysis, easy management of integer/hexa/bytes), Max send it via serial to arduino, working well, the same in return with sensor on Arduino, sended easely via serial to max, translated to midi and sended to Isadora. I would prefere OSC but serial and OSC in Isadora are really poorly implemented.

anyone?

well, after reading your post for the third time now, i still must say i just don't get it!
but the good thing is that, now, since i have posted something here in this thread,
i'm authorized to send PMs.

thumbs up ... daniel!

I choose this solution too, between Isadora and arduino on a mac, as to drive 3 stepper motor. I send Midi from Isadora to Max/msp (good serial analysis, easy management of integer/hexa/bytes), Max send it via serial to arduino, working well, the same in return with sensor on Arduino, sended easely via serial to max, translated to midi and sended to Isadora. I would prefere OSC but serial and OSC in Isadora are really poorly implemented.

aah. that sounds like an easy solution for now.
no Max/MSP experience here. but wouldn't it be possible to do a serial-to-midi converter patch in Max and share this (legally)? I don't know what kind of data you're sending from max to arduino, but i'd like to keep the format of the data as it is. I mean that the max patch needs not to do any kind of interpreting of the midi-data. just pass every byte from serial to the midi port and the other way around. Is this what you're doing, or do you know if it would be hard to accomplish?

(and BTW: hello daniel78)

kuk