Pages: [1]   Go Down
Author Topic: USB MIDI driver working for UNO. Turn your UNO into a MIDI device.  (Read 3196 times)
0 Members and 1 Guest are viewing this topic.
Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got a USB MIDI device driver working for the UNO's atmega8u2.  Just flash it onto the atmega8u2 using dfu-programmer or flip and your UNO becomes a USB MIDI device.  I've tested it with GarageBand and it seems to be working well.

Details, firmware hex files, source, and an example sketch are available from http://hunt.net.nz/users/darran/.

Cheers,
Darran.
Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are doing great work here. Can I do this with the normal IDE to or do I need special tools (I'm on win 7 )

Do you also intend to implement an USB printer? 
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Brazil
Offline Offline
God Member
*****
Karma: 3
Posts: 616
Wusik Dot Com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's great news, thank you so much, check my sig for the project I'm working on.  smiley-mr-green

Wk
Logged


Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow that's an awesome project!  Looks like you're close to having the first PCB-based version up and running.  Really impressive.
Logged


Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are doing great work here. Can I do this with the normal IDE to or do I need special tools (I'm on win 7 )

Do you also intend to implement an USB printer? 


You should be able to use flip to load the firmware in windows: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886
You'll need to put the UNO into DFU mode and then use flip.  You can put it into DFU mode just by connecting two wires as seen here: http://arduino.cc/forum/index.php/topic,52447.msg374201.html#msg374201; hold wire 1 on the pad, touch wire 2 to the left side of the capacitor for a second or so, remove wire 2, remove wire 1 and the UNO will be in DFU mode ready to upload new firmware. Unplug the USB cable and plug it back in and the UNO will appear as a MIDI device. Note that you can't load sketches when the MIDI firmware is loaded, you have to go through the process again and upload Arduino-usbserial.hex before loading you sketch with the Arduino IDE.

Regarding a USB printer driver, I have a feeling that the firmware would be too large for the 4KB of flash space that's available on the atmega8u2.  I'm curious as to what you would do with your Arduino if it could be a printer device?
Logged


Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've updated the MIDI driver to be bi-directional so now it can also receive MIDI messages from the host.  The new firmware, source, and demo sketch is available from Arduino hacking.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



What Im doing wrong? 

Scenario 1: If I use arduinos MIDI lib , I get "pitchbend" 8/16 - 16/16 as a result in ableton
Scenario 2: if I dont use MIDI lib I get "CC notes" from 1-127 i ableton

(If I have any HEX outside "0xB0 - 0xBF" neither of scenerios works)





#include <usbDevices.h>

#define numPots 6  // numer of pots
#define b 1        // this is the delta needed in

unsigned int currentPot[6] = {0,0,0,0,0,0};   
unsigned int pot[6] = {0,0,0,0,0,0};
byte controlChange = 0xBC; //0xB0 or 176

void setup() {
 usb.init(midi);
 // MIDI.begin();
 //Serial.begin(31250);
}                         
void loop() {
  for(unsigned char i=0; i<numPots; i++) {
    currentPot = analogRead(i) / 8;   
    if(abs(currentPot-pot) > b) {
      sendMidi(controlChange, i+1, currentPot);
      pot = currentPot;
    }
  }
}

void sendMidi(byte controlChange, unsigned int controlNum, int val) {
//MIDI.sendControlChange(controlNum, val);
 
Serial.write(controlChange);
Serial.write(controlNum);
Serial.write(val);
  // Serial.write(unsigned char(controlChange));
  //   Serial.write(unsigned char(controlNum));
  //     Serial.write(unsigned char(val));
  }
 
 

 
 



* traktor2.jpg (1220.92 KB, 1320x1956 - viewed 23 times.)
Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Great code!
Logged

My website: http://ried.cl

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I know it look redic now,   I took it from this forum somewere and rewrote it some.
regarding all the unsigned ints and stuff i just tested out everything because i cant get it to work.
Im pretty new to coding so I really need help smiley 
can you help?
Logged

Pages: [1]   Go Up
Jump to: