Arduino Forum

Products => Arduino Due => Topic started by: gpud on May 02, 2014, 07:04 pm

Title: Transmitting midi noteon and ccs using Serial1 (Tx pin19) to Processing
Post by: gpud on May 02, 2014, 07:04 pm
hi - i'm doing my first DUE project so am a very novice newbie building a sensor controlled granular synth (in Processing) via midi.

The midi i'm sending is only control change (mapped sensor values) and midi noteons (switches) to Processing (using rwmidi) i am not using a midi library in arduino (1.5.3). I have a midi DIN --> USB converter connector and am transmitting from TX1 pin 19.

First, do i have to define/declare pin 19 in my sketch, or is that handled internally by using Serial1? if so, what syntax would i use, and would i need to declare the TX and RX pins (18, 19) even if i'm only transmitting?

my second query relates to the start bit and stop bit. Can i simply setup Serial1 with:
#Serial1.begin(31250);
and then send the data in the correct channel message format or do i need to use:
#Serial1.begin(SPEED, CONFIG);
to set it up. ie config: sets data, parity, and stop bits.

I have read in the begin() info that the default is  8 data bits, no parity, one stop bit (SERIAL_8N1) as opposed to midi with Start bit, 8 data bits, Stop bit (10bits).

If i need to configure Serial1 - would i write this?:
#Serial1.begin(31250, 18N1);



Thank you for your time
Title: Re: Transmitting midi noteon and ccs using Serial1 (Tx pin19) to Processing
Post by: Grumpy_Mike on May 02, 2014, 07:10 pm
Quote
I have read in the begin() info that the default is  8 data bits, no parity, one stop bit (SERIAL_8N1) as opposed to midi with Start bit, 8 data bits, Stop bit (10bits).

Those two are the same, as the start bit is always present itis sometimes omitted.

How are you going to get the output of serial1 into processing? It is not attached to the serial USB converter.
Title: Re: Transmitting midi noteon and ccs using Serial1 (Tx pin19) to Processing
Post by: gpud on May 04, 2014, 04:01 pm
thank you for your response and for clarification of the config -
can i use Serial1 with the Hairless midi serial bridge ? (i'm going to check out Hairless now)

or can i first use the Serial monitor to calibrate a sensor (mpu9150), turn off the monitor and then plug in the midi to pin 1 and carry on using serial with midi --> USB cable, without having to recompile?
Title: Re: Transmitting midi noteon and ccs using Serial1 (Tx pin19) to Processing
Post by: Grumpy_Mike on May 04, 2014, 11:53 pm
Quote
can i use Serial1 with the Hairless midi serial bridge ?

Yes providing you can get that signal into your computer. You will need a TTL serial to USB cable to do this.

Quote
and then plug in the midi to pin 1 and carry on using serial with midi

If the MIDI you speak of is MIDI hardware and you have a MIDI interface on your computer then yes.

Serial1 is not connected to your computer if you do not make special provisions to connect it. The built in USB to serial only works with Serial, no other port.
Title: Re: Transmitting midi noteon and ccs using Serial1 (Tx pin19) to Processing
Post by: gpud on May 08, 2014, 04:42 pm
thankyou - yes - i can now see the midi coming through on the midi monitor - i'm having a few issues with controlling the controlchange data - getting it to only send when it changes rather than continuously send and i seem to have some conflict with control change data sending noteoffs  -  reckon it's  my code structure and perhaps some hardware interferences (it's very busy breadboard) ..... more likely my code -  but hopefullly nothing that a bit of grafting wont solve!!