all \ code

Arduino MIDI

I made this simple project to demonstrate Arduino for my class. The code and electronics are easy enough, yet is more interesting than the typical blinking-LED projects.

This basic approach requires a computer to translate commands from the Arduino into MIDI messages which in turn control software or hardware. Fancier approaches are possible to have a self-contained Arduino which spits out MIDI directly via a wired-up MIDI connector.

Result

Trigger soft synths (software synthesisers) via Arduino-connected sensors. Buttons send MIDI note commands, and two light dependent resistors (LDRs) send continuous control data to modulate the sound.

Ingredients

  • Arduino board (I used an Uno)
  • Buttons
  • Light dependent resistors
  • 10k ohm resisters (one per button and LDR used)
  • Jumper cables
  • Some kind of a soft synth (I used a Native Instruments Reaktor patch via Maschine), ideally with MIDI learn capabilities
  • SpikenzieLabs’ Serial-MIDI Converter
  • Arduino code

Wiring it up

You’ll note that there is a very simple pattern at work for wiring up these components. To add more or less components, it is just a matter of duplicating the pattern.

Buttons are wired up to digital lines, and the two LDRs run to the analog input lines. It’s a little bit unclear in the picture, but the resistors run from the leg of the button to ground. Positioned after them in the circuit (wired underneath the resistor) is are the wires that run to the Arduino inputs. I know bugger-all about circuitry, but this seems to work.

Software set-up

You need to download and configure the Serial-MIDI Converter. One small point: the compiled version crashes for me, I run it from the Processing source instead.

The converter does the job of translating simple messages sent by the Arduino into fully-fledged MIDI messages on a virtual MIDI port. In turn, you need to then configure your synth/DAW etc to listen to that particular MIDI port. The steps required to do this varies wildly depending on what software you’re using. You should also be able to pipe the MIDI data to a hardware as well with a bit of routing magic. Make sure you close the converter whenever you want to upload a sketch to the Arduino as it locks off the serial port.

Arduino code

The Arduino code is very straightforward. If a button is pressed, a note on is sent, the Arduino waits for a bit, and then sends a note off command. The LDR input is scaled (from 0-1023) to MIDI CC range (0-127), and encoded as CC1-CC4 parameters. I’m sending each LDR value on two CC parameters just because I couldn’t seem to map a single CC on to multiple macro knobs in Maschine.

If you want to send different notes or control messages, consult the MIDI Message Table or a guide to MIDI Note Numbers and Frequencies

Compile, upload and start up the Serial-MIDI converter. Select the right ports, and then switch to your soft synth. If you’ve asked it to listen to the right MIDI ports, you should see signs of MIDI activity, and you’re off and going.

Maschine

On the Maschine side things are also quite simple. Maschine is set to receive MIDI on the virtual MIDI port, and I simply mapped some macro knobs to CCs 1-4.

Future work

Now this approach is perhaps the most simplistic of all, and there are many things that could be made better. Here are some ideas:

  • Only send CC data when range is outside of normal, or instead, only when a particular button is pressed.
  • Sending note on when a button is pressed, and only sending a note off when the button is released (debouncing issues need to be sorted too).
  • Primitive step sequencer. A simple four-step sequencer could be built with the same circuit, with each button representing a step. Press and hold the button and use the LDRs to change the step parameters (duration, velocity, note value).
  • I used simple and cheap LDRs as to control CCs, but of course this could any of the more interesting analog sensors you can hook up to an Arduino.
  • etc.

3 October 2011

Comment [2]

 

Pertelian Console

Download Pertelian Console and source

What it?

Outputs text to a Pertelian display from a file, program, command line or the web.

I wrote it because I was frustrated with the way the device rendered weather data by default:

There was lots of horrible horizontal scrolling and almost impossible to get useful weather information at a glance: one would have to wait and watch it for a minute for the right information to scroll into view.

Using PertelianConsole and a web-based PHP script which utilises Yr.no’s weather data, it now shows concise, useful weather information:

Current temperature is always shown on the top-right and otherwise shows temperature and forecast for morning, noon and night. The page alternates between today, tomorrow and the day after.

Getting started

PertelianConsole (PeCo) is a command line tool designed to be run from batch scripts or the Windows’ Scheduled Tasks service. Thus, you have to pass in options for anything to happen. The program assumes the Pertelian is connected and drivers are installed. If your display works with the bundled Pertelian app, it should work with PertelianConsole.

Example 1. XML Content

Display content from a web-based XML source, runs for three hours before automatically exiting. Content is looped every 10 seconds and the console window is hidden so it runs in the background.

PertelianConsole.exe --xml=http://thestaticvoid.net/toy/weather/weather.php?render=pertelian --runFor=3h --loopInterval=10s --fastHide

Example 2. Piped output

Shows the contents of the current directory scrolling on the display. The ‘stream’ flag is require to tell PeCo to read from the standard input. Note that input is not wrapped to fit screen width.

dir | PertelianConsole.exe --stream

Example 3. Display text from the command line

Displays “line one” on the first line, and “line two” on the second. Note the use of \n to control output. PeCo will letter-wrap text.

PertelianConsole.exe --text="line one\nline two"

Example 4. File input

Reads a text file and displays it for five minutes, showing each screenful of content for one second.

PertelianConsole.exe --file=test.txt --stayRunning=5m --scrollInterval=1s

Tips

  • To get an overview of PeCo’s options, just run it without arguments and you’ll get some help text.
  • Display is cleared and turned off when the program exits. Consider using the ‘runFor’ parameter to keep the program running.
  • See the Url in Example 1 for an example of the XML format. Alternatively refer to src/Reader.cs
  • The ‘loop’ flag continues to show the text (looping for multi-page input) for as long as the program is running

Download Pertelian Console and source

31 October 2009

 

Del.icio.us private bookmarks feed

This ugly little duckling will output a feed of your del.icio.us bookmarks, including those that aren’t shared. As far as I can gather, there’s not a way of get such a feed from del.icio.us itself without logging in first.

13 February 2008

 

Ligerator

I’ve put the Ligerator online. It’s a simple web-based tool which lets you easily generate a Microsoft Word macro to do a bunch of text replacements.

My main reason for developing it was to maintain scripts for typographic ligature replacement, for example to transform:

into:

Once you’ve set it up, you can bookmark a magic URL which allows you to return to the preset, make some changes and re-generate a new macro, or share it with someone else.

The code generated should be portable across Word versions and platforms, however I’ve only tested on Word 2007 running on Windows.

p.s., if you don’t see the difference in the two samples above, Ligerator is clearly not for you.

28 December 2007

 

DateCalc

It’s a simple little program that will tell you the time period between two dates.

Download bare executable (147KB)
No installation required, just save and run or open directly.
Doesn’t run? DateCalc requires .NET Framework 2.0 (or x64).

Usage
Just select the two dates, or paste in dates into below the calendars. Select a unit from the drop-down menu.

7 June 2007

 

 

XML

Crest
The Static Void.
Est. 2000