midi converter / change incoming midi data

hello there,
i'm new to this forum — and glad to be here.

i am trying to build a sort of midi-converter, which takes incoming midi data (notes and/or channels) and transforms them into other data. see my sketch as for what i mean.

what i'm trying to achieve is to trigger a drum-set (audio to midi) and change the chords / notes this drum-set plays. on my audio-to-midi converter i can assign each incoming audio signal (via piezo mic) a note value. this again i pass on to a synthesizer. my current restriction is, that each drum can only be assigned one note value, which means in order to change to notes my drum-set is "playing", i need to reconfigure the converter. the idea i basic: i'd like to pinch a converter-box between the (midi-)output of the converter and my synthesizer/sound-generator. this converter is to change the incoming data / notes as played on a connected midi-keyboard, and thus output the new notes.

any idea? is this actually achievable with arduino?
thanks a ton!

If you have suitable hardware (a couple of optocouplers) it should be achievable.

I have a sketch here that reads MIDI in:

Code here:

http://forum.arduino.cc/index.php/topic,100382.0.html

Instead of outputting to serial, you could output the MIDI again, with modifications.

is this actually achievable with arduino?

Yes it is quite easy.
What you need is a look up table. This is just an array.
The index of the array ( the position of an entry in the array ) is the note you want to intercept, the contents of the array is the note number you want to map it to.
Then read in a note on or off message on say channel 1. Then run the note number through the array and output it on channel 9 percussion.

awesome guys! thanks so much.. i'll be digging in to your tips and most probably come back with a load of questions (because i'm quite a beginner).

< very motivated!

edit: before i start — one more essencial question. is it theoretically possible to remap the played notes in an order from low to high? lets say, example:

drum-set / audio-to-midi is configured as bassdrum=C1, snare=D1, tom=E1 ...etc, but obviously not necessarily played in this order (also, sometimes strokes will be played simultaneously)

my input-keyboard plays lets say F3, H4, C2.
can this input be distributed so that the lowest note is mapped to the lowest note of my drumset (ie bassdrum C1)?

and, additionally:
would i be using standard midi in-out schematics (as found here http://forum.arduino.cc/index.php/topic,22447.0.html),
but build 2 midi-inputs and one output? one input for the actual triggered notes and one for the notes played be the keyboard?

but build 2 midi-inputs

The Arduino Uno has only one serial port so having two inputs is problematic. You might get some success with using the software bit banging emulator softwareSerial ( part of the IDE ) but I am not sure if this will work at MIDI speeds.

I do not fully understand what you need two inputs, can you not route the triggers through the MIDI TRU on the keyboard?

ok. that means as for the following:

1 ) my drumtrigger is running on MIDI CH2, e.g. transmits a NOTE C2
2 ) -> going to the THRU-port of my keyboard (keyboard running on MIDI CH1)
3 ) -> keyboard plays NOTE D3
4 ) -> the OUT-port of my keyboard transmits CH2, NOTE C2 (from drumtrigger) + CH1, NOTE D3 (from keyboard)
5 ) -> all this is passed into my "converter-box"
6 ) -> converter-box reassembles the midi message as a mix of drumtrigger and keyboard.
7 ) -> sends the new note-value (from keyboard) with the note-on from the drum-trigger
8 ) -> this new message is received by the synth (last in line) on MIDI CH2

(is this understanding correct? --> http://img703.imageshack.us/img703/1595/4dqx.jpg)

the crucial point is, that i don't want the synth to react to the stroke of the keyboard, only to the stroke of the drum, obviously using the note-value of the keyboard.

the crucial point is, that i don't want the synth to react to the stroke of the keyboard,

So what do you want the keyboard to trigger?

only to the stroke of the drum, obviously using the note-value of the keyboard.

Are you saying that you want to disregard the note that the drum sends and send a mapped value from the last keyboard note when the drum machine sends anything?
If so that is still on with an arduino but I don't see how in practice you will play this.

So what do you want the keyboard to trigger?

it's a hardware synthesizer (dsi prophet), running on midi channel2.
(i edited my latest post — check this image :slight_smile: ImageShack - Best place for all of your image hosting and image sharing needs)

Are you saying that you want to disregard the note that the drum sends and send a mapped value from the last keyboard note when the drum machine sends anything? If so that is still on with an arduino but I don't see how in practice you will play this.

this is correct. to explain in detail: one person plays an (acoustic) drum-set — this is triggered and outputs midi on channel2, unfortunately every trigger i know of outputs fixed note-values.
another person "interferes" the midi-signal, changing the note-values received from the drum-set. new note-values are sent to the synth, although the note-on / "stroke" is still determined by the drumset.

OK - you might want to edit that last post so your reply is not in the quote box.

Yes it is possible to do this with an arduino. You simply store the mapped note from the keyboard on every note on message and output it (send a note on message on channel 9) when you get the drum trigger note on message. Being on different channels you should e able to separate them easily.

Does someone know of a sketch to make arduino change mididata received from a USB MIDI Keyboard which is connected to the arduino via the USB host shield (available on the arduino ADK rev3) instead of a midi-cable?

I've built a MIDI mapper with the midi library. I'll see if I can find it. You should look into an Alesis Trigger IO. You can hook up triggers to it and set each trigger to a diff note. Then use the arduino to map to whatever. That's what I did.

https://github.com/deseipel/Arduino/blob/master/KORGES1_Control

There's my code for mapping noteOn values to other events. Cheers