Go Down

Topic: MIDI Serial Port (Read 4765 times) previous topic - next topic

OzGrant

G'day,
Is it possible to use NewSoftSerial so that another pin(port) for the MIDI signal in the MIDI library is used.
Tks


Is it possible to use NewSoftSerial so that another pin(port) for the MIDI signal in the MIDI library is used.


Is there a MIDI library? And don't you only use port 1 (TX) port for outputting MIDI? What port would you rather use?
http://twoguysonebit.blogspot.com/
http://guitarduino.blogspot.com/

robtillaart


Looking at the NewSoftSerial.cpp file it has an entry for 31250 baud in its tables which is IIRC the MIDI speed. Start/stop/parity bits unkown.


Rob Tillaart

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

OzGrant

Not sure if I explained my problem correctly.
The MIDI library uses digital pins 0 & 1 and I want to use pins 8 & 9.
The command MIDI.begin() does not give you the option of altering the serial port, and am hoping that NewSoftSerial library can be used to achieve this.
Can this be done.

robtillaart

Do you have an URL to the MIDI library to peek into the code?
Rob Tillaart

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

Grumpy_Mike

Quote
The MIDI library uses digital pins 0 & 1

Yes that is because it uses the hardware serial connections. To make the library use the softwa  serial routines you will have to hack it so that all the references to the serial port now refer to the software serial commands.

OzGrant

Rob,
Am using theV2.5  MIDI library from the playground http://www.arduino.cc/playground/Main/MIDILibrary.
Will now start to look at how to hack it.

OzGrant

Is it possible to use pin 1 (TX) to communicate with the USB and Pin 0 (Rx) to accept MIDI inputs.
That way I can use to use the existing MIDI library.
I need to use the USB port to send the MIDI date so that I can read it on the PC.

Grumpy_Mike

Quote
Is it possible to use pin 1 (TX) to communicate with the USB and Pin 0 (Rx) to accept MIDI inputs.
That way I can use to use the existing MIDI library.

No you can't run the hardware at different baud rates.

robtillaart

@OzGrant
Had a quick view in the midilib and somewhere in the top of the CPP file there is    #define UART Serial    which is used through the code as Serial port.

Quick hack:
- include the NSS library,
- declare an instance of NSS e.g. MidiSerial
- do a global search/replace of UART with MidiSerial

Better:
- accept param TX and RX in the constructor (default 0 & 1 to be BW compatible)
- if 0 and 1 => use hardware serial
- if other pinnr's => use NSS


Rob Tillaart

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

OzGrant

Rob,
Yup found that declare, so will give it a shot. Haven't done this level of program altering in a library, so it should be interesting.
Thanks for the pointer.

nickvd

I haven't really dug into the code, but I am using the Midi library (notice that it is not all-caps) from here: http://timothytwillman.com/itp_blog/?page_id=240

You initialize the class using:
Code: [Select]
Midi midi(Serial);

So it should be as simple as passing in your nss object to the midi constructor...

(i also find this midi library much more versatile for midi-input)..

OzGrant

Timothy,
Looks like your MIDI Lib is what I'm after.
Down loaded it (the tgz extension ended up as a .tar) but my winzip ver 14.5 gave me the msg
"Error reading header after processing 0 entries"
Does this mean WinZip does not do tar files or is something else required.
Grant

nickvd

I used izarc without issues... it's free and imo better than winzip

OzGrant

Tks Nick (got the name correct this time)
Downloaded the Lib Ok and unzipped with IzArc.
So will now see if I can use the other port.

Go Up