Download free music MP3s on genuine quality, the world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, The world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, stats, charts, biographies and concerts. stats, charts, biographies and concerts.
Sunday, October 6, 2024
Arduino Drum Trigger to MIDI
After playing with my Arduino Euclidean Gate Sequencer I started to think about how to turn that into MIDI. One option, naturally, is to add MIDI to the sequencer itself, but I thought the more versatile approach would be to build a second Arduino…
After playing with my Arduino Euclidean Gate Sequencer I started to think about how to turn that into MIDI. One option, naturally, is to add MIDI to the sequencer itself, but I thought the more versatile approach would be to build a second Arduino that took trigger pulses and turned them into MIDI drum messages. This is a project to do that.
Note: This is not a fully-fledged GATE/TRIGGER to MIDI converter - that requires more electronics to do properly, but that is discussed more below.
Warning! I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!
These are the key Arduino tutorials for the main concepts used in this project:
This is a very simplified version of the required circuit, but it shows how a MIDI module has to be wired to the Arduino and which pins are being used as inputs.
Note that any trigger inputs that are not being used should be pulled LOW to GND using a resistor. A 10K resistor should be fine for this purpose. The triggers will go active when a HIGH pulse (5V) is detected.
Adding Proper Trigger Inputs
In order to turn the inputs into a more general (i.e. you can probably plug anything into them) input, some electronics is required to do the following:
Ensure the input is pulled LOW when not in use.
Has over and under-voltage protection for the Arduino.
Has a useful impedance to meet whatever is plugged into it.
The GATE and TRIGGER circuit from my Educational DIY Synth Thing is the kind of thing that would be required, i.e. something like the following:
Note that this reverses the logic of the gate or trigger though. With this circuit a HIGH trigger becomes an active-LOW signal for the microcontroller. It is also show connected to 3V3 whereas for an Arduino Uno that would be 5V. Everything else ought to be fine however.
The Code
The code is relatively straight forward. The core aim is for something that achieves the following:
Define which MIDI voices are to be used with which Digital Input Pins
Setup(): Initialise the Digital Input pins
Loop(): FOR EACH digital input pin: IF pin goes LOW->HIGH Send corresponding MIDI NoteOn message IF pin goes HIGH->LOW Send corresponding MIDI NoteOff message
I initially thought I'd need to attempt to use pin change interrupts and Arduino direct PORT IO to ensure I didn't miss any triggers, but after measuring the timing of the main loop and finding that even with all digitalRead() calls for each digital pin, it was still running in less than 100uS. At that rate, detecting a 10mS or more pulse is easily well within reach, so I ignored the interrupt approach and stuck with a simple loop.
I've listed a number of MIDI drum notes at the start of the file. These are all General MIDI Drum map compatible values and up to six can be chosen for use with the triggers. It also defaults to sending on MIDI channel 10, the General MIDI drum/percussion channel.
In the final version, I've left a compile-time option for the trigger to be active HIGH (the default) or active LOW (e.g. for use with the "advanced" circuit described above).
Find it on GitHub here.
Closing Thoughts
In the video I've connected the triggers up directly to my Arduino Euclidean Gate Sequencer and the MIDI to my Roland TR-505, because, well, why not?
The 4/16 clock on D13 can also be seen to illuminate the onboard LED on the clock generator Arduino.
The TR-505 is fully General MIDI (it's a bit early for that) but all the above map onto something sensible in terms of its own drum map. Sounds like its working anyway!
I might build up some kind of trigger shield with the protection circuitry required to take more generic inputs and a MIDI out link.
No comments:
Post a Comment