Pages: [1]   Go Down
Author Topic: coding midi seriel output?  (Read 1687 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm currently working on a drum module using the arduino.
Setup will be something like
piezoelectric sensors -> arduino -> code doing its thing -> serial to midi converter -> virtual midi on the pc -> reaper (with digidrums vsti for the drum sounds) -> to speaker or headphones from the computer.

I've been messing with the sensors trying to figure how to get it to work with arduino (somewhat new to this stuff) , I've tested it with a few differnt sensors connected to analog pins 0-3 (with a 1 Mohm resistor in parallel, as this seems to be a pretty standard setup from other examples I've found), and they output to pins 6, 9, 10, 11 connected to LEDS. So far so good: I've managed to get it take the input data(0-1023 range if i read taht correctly for analog pins), convert to scale for output (0-255), so depending on how hard i hit the sensor, determines the brightness.
Now that I've got some type of velocity data going, I think I can start working on the midi output. I've been searching around the forums and internet, and there's some code I've found that does this (like the drumkit kit from spikenzilabs) but I'm not sure I really understand how it works.

It appears, from the samples I've seen, that I will need to do a serial.print to get the data to the pc, which makes sense, I'm just not sure how to make it so it will be read as a midi output. From what I've read about midis, theres 3 or 4 pieces of info(?): [tells it to turn on or off][midi channel 0-15][the note][velocity].
Do I just do 4 serial.write lines into my loop?
such as
serial.write (turnon)    //tells it to turn on
serial.write (9)          // example of channel
serial.write (C#)      // example of a note that will be assigned to a drum sound in reaper
serial.write (100)      // example of a velocity reading from 0-127, which seems to be the scale midi works. of course I'm sure this will be stored as a variable instead of just straight up digits.

If this is close to what I want, how will it determine which midi note to 'turnon' since that piece of info seems to come before the note (c# as the example) Is there a way to output the serialwrite data as just one command, instead of having it go in that order?
Any help or reference would be appreciated. Hope these questions make some kind  of sense, if not just ask and I'll be more than happy to try and make things a little clearer.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a look at http://www.midi.org/techspecs/midimessages.php

Note-on messages are channel based, and require three bytes. The first contains the Note-on message and the channel, the second is the note number and the third is the velocity. You can't send 'C#'. For note numbers, look at http://www.midimountain.com/midi/midi_note_numbers.html
Logged

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

thanks that helps make alot more sense on how they turn on specific channels to use.

So the message for turn on channel 11 would be 10011011?
I know that the code is converted to binary when it's sent to the arduino, but are we able to code in binary itself?

Does the specific note need to be converted to hexadecimal first?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 626
Posts: 34152
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So the message for turn on channel 11 would be 10011011?
No you don't turn on a channel in MIDI you turn on a note and that note is on a channel.

Quote
I know that the code is converted to binary when it's sent to the arduino
The code is not converted it is never in anything other than binary.

Quote
but are we able to code in binary itself?
We can't code in anything else when it comes down to it.

Quote
Does the specific note need to be converted to hexadecimal first
You are not getting the hang of this, any number is just a binary bit pattern nothing needs to be converted to anything. You can express that binary bit pattern as a hex number a decimal number or a binary number it is still the same bit pattern.

Look at some examples with real MIDI input and output to get the idea about messages.
For receiving MIDI see:-
http://www.thebox.myzen.co.uk/Hardware/Glockenspiel.html
for sending MIDI see:-
http://www.thebox.myzen.co.uk/Hardware/Pendulum.html
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Love the glockenspiel. Were you the Mike that wrote the Beeb bodybuilding course in The Micro User? I read all of those, I think.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 626
Posts: 34152
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep guilty the same one.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool. I think my beeb is still in my parents loft. Must try and find it sometime.
Logged

Offline Offline
Sr. Member
****
Karma: 8
Posts: 250
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

well, i don't really know if this will help you or not, but it cannot harm to take a look.

I have been trying to build a kind of MIDI Xilophone.
i am following the plans from here:
http://www.jdeboi.com/portfolio/electronics.html
In that page you can also find the code she used for it.

I am really just starting with electronics and also this Xilophone project is really in the beggining (and it is my first!!  smiley-grin  ).
I have hooked up one of the Piezo Disks (plus all the 5v, ground, anal and digit pins) to try it out.
Once i got some reading on the Serial Monitor i started looking into some Serial to MIDI converter.
There on the link above there is also a link for S2Midi converter.

I have been trying it but i am not sure it is working properlly.

I manage to open Ableton Live and to get Midi In Signal, but still i cannot assign the piezo disk to any thing. The signal coming in is always changing each time i "press" the disk.
Sometimes it shows as PitchBend2, some as PitchBend6...  it always changes (but it seems to be always some kind of pitch bend).

Can it be that it is because i have only ONE of the disks plugged in?
What is the "Digital MIDI" thing you talk about?
After the Serial do Midi converter do we still need something before the actual "music software"?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 626
Posts: 34152
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can it be that it is because i have only ONE of the disks plugged in?
It could be. Make sure that those resistors are fitted even if the sensors are not. This will prevent the input from floating and giving you random values when the nonexistent sensors are scanned.
Logged

Offline Offline
Sr. Member
****
Karma: 8
Posts: 250
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, i'll give it a go tomorrow!  =)
Logged

Pages: [1]   Go Up
Jump to: