Coding a Custom Step Sequencer

I have been wanting to code my own customer step sequencer for a while. A couple of weeks ago I finally dived in to the project. I knew I wanted to use a lightweight scripting language for the project an started out with Python. But after trying out a couple of Midi libraries I got frustrated and switched to Ruby with UniMidi.

UniMidi actually works pretty well, and I was able to write a fairly complete 8 track step sequencer for my Novation LaunchPad Mini in about 20 hours. The source code is available on github.  I also made a track where I used this sequencer to control my Volca Sample, and it worked out great.

Last week I decided to take things a bit further and ordered a Novation LaunchControl from Thomann. I figured this controller would be perfect fit for my needs: The silicon pads can be used to mute/unmute the 8 tracks and the 2 x 8 knobs can be set to control volume and pan of the corresponding Volca Sample channels (I’m actually using the right output on the Volca Sample as an effect send, so the pan knob acts as dry/wet balance).

I made another track with this setup and it worked out great… I will be needing a second LaunchControl for my Volca Beats before long. Or maybe I should get hold of some silicon pads and build a more customised midi controller…

I hit some snags with my Ruby/UniMidi setup though. Things work reasonably well as long as I sync to an external clock, but I have not been able to implement a 100% stable internal clock with the Ruby Sleep() function. The internal clock works OK most of the time, but sometimes the tempo drops by maybe 10% for 20 seconds or so… probably because some background task kicks in on my MacBook.

I really want to take this project further and eventually I hope to build a complete sequencer for my hardware setup. While playing around with Ruby and UniMidi has been fun, it is clear to me that I will need another platform to reach this goal.

I initially discounted Max/MSP because I really dislike visual programming languages. I spend my days developing software professionally and I like to write code in a text editor. But after doing some more research, I realised that Max actually has a javascript object and that it is possible to create extensions if you want and this has put me at ease.  At least I will have an alternative to huge canvases with a million visual objects and connections.

I’m still not sure if I want to go with live Max for Live or a “pure” Max setup for this project, but I will be doing some research.

Korg Volca Sync Issues and How to Solve Them

Ever since I got my Korg Volcas (all 4 of them) I have been struggling with timing issues. The units sync up fine most of the time, but sometimes one of them skip a step or two when I press play and gets out of time with the other units.

At first, I thought the problem only occurred when I sync the Volcas to my computer via MIDI, and suspicion immediately fell on my home made MIDI Thru Box. I later discovered that the same thing also happens sometimes when I use only Volcas with sync cables, so I started doing some research.

It turns out that the sync problems were caused by my mono audio cables! When using mono cables (or a stereo cable plugged into a mono input), one of the audio channels is shorted to ground and this somehow interferes with the sync circuits of the Volcas.


The solution was straight forward – I took some minijack stereo cables I had lying around, got out my wire cutters and snipped one of the 2 wires in each cable. I covered up the cut with electrical tape to provide isolation and avoid pops when I touch the cable.

I haven’t had any sync issues since and this solution also allows me to plug the Volcas into the balanced inputs on my Scarlet audio interface without having the two stereo channels cancel each other out.

Live Perfromance with 4 x Korg Volca and Waldorf Rocket

I recently watched an interesting video with Saytek on how he does his live performances and got a few ideas for my own.

I started out by creating kick, bass and pad loops in Reason, and imported them into Ableton Live as clips. I then created additional parts with the internal sequencers on the Volca Bass, Beats and Sample and used Ableton Live to sequence the Volca Keys and Waldorf Rocket. I love the  Volca Keys but the internal sequencer is pretty useless in my opinion.

All the hardware synths go into Ableton Live for real-time FX processing and mixing (no multi tracking was involved). I set up the Korg nanoKontrol to control volume on the kick and a couple of other tracks, to be able to fade them in and out.

I played around with the parts for a while and set up a few scenes in Live to outline the arrangement. I maximized the width of the master track in Live and typed in notes along with the scene names to guide me during the performance – a cool trick I picked up from the Saytek video. I mapped one of the buttons on the nanoKontrol to “Scene Up” in Live and used it switch scenes during the performance.

All in all I think the setup worked out pretty well. The notes really did help me bring more structure to the performance but they are also somewhat constraining. I will probably not use performance notes moving forward – I prefer to improvise… after all, making good electronic music is all about fortunate accidents!

DIY Mixer and Effects for my Korg Volcas

I have been playing around with my Korg Volcas for a while now and I think they are really great. I thoroughly enjoy the immediate, “hands-on” music making experience I get from a small table-top setup.

I still use Ableton Live for mixing and effects though, which is less than ideal. What I really want is to bypass the computer all together – no DAW, only “real”, tactile gear. I see a lot of people on YouTube using small 4 way mono mixers, perhaps with a stomp box or two, but I find that approach a bit too simplistic for my needs. With only a few sound sources to work with I think it is really important to have something interesting going on in the stereo field, at least for the type of “down tempo” music that I like to make. I also need a good selection of delay, reverb and chorus type effects to create ambience and interesting textures.

I have been looking at the Eventide and Strymon guitar pedals which sound fantastic and would probably work great for me. Unfortunately they are also pretty expensive, and I have not been able to find a small form factor stereo mixer that suits my needs.

So, I started looking around for schematics online, thinking that I might build this stuff myself. The mixer is pretty straight forward, since what I want is really just 5-6 stereo channels with volume controls, a master volume control and nothing else. There are also a ton of DIY guitar pedal designs out there which could be adapted for my needs – this will require a bit of work though. Guitar pedals tend to work best on stuff that occupy the mid-range frequencies (such as… guitars) and almost all the DIY designs out there are mono only. Being powered by 9V DC most guitar pedals handle -10 dBv signals just fine (such as those from the Volcas) but impedance can be an issue, especially on the outputs.

Some of the more interesting and best sounding guitar pedal designs I have found are based on old school analog “brigade bucket delays” commonly referred to as BBDs. Most of these chips are out of production and horribly expensive but I found one company that still manufacture BBD chips and sell them at reasonable prices. I have done the math and figure I should be able to make at least 3-4 true analog stereo reverb/delay/chorus type effects for the price of a single Eventide/Strymon box. Plus I get to build them myself, which is fun, interesting and infinitely more satisfying than just forking over your hard earned cash to buy the same stuff as everyone else.

I have already done some work on the mixer and a couple of effects and will be posting about this soon, so stay tuned!

Ambient House Track: Detour #1

I did a new track tonight with my “tabletop” hardware synths going into Ableton Live. I used a LaunchPad to bring in Ableton Live parts and a nanoKontrol2 to control the Ableton Live mixer and effects.

I recorded a live performance of about 8:30 minutes to multiple tracks in Ableton Live which I then edited down to the final 5:43 minutes. Nothing was added in the editing process – I basically just cut out the boring parts, rearranged the drums a bit and fixed the levels in a couple of places.

Detour #01 setup

Gear used on this track:

  • Waldorf Rocket
  • Korg Volca Keys
  • Korg Volca Bass
  • Korg nanoKontrol2
  • Novation LaunchPad Mini
  • mda ePiano (free plugin)
  • TAL-U-No-62 (free plugin)
  • Ableton Live instruments and FX

Test-Driven Development for Arduino on Windows 7

Arduino UnoWhen I first started programming micro-processors in C, I felt like I had stepped into a time machine that took me back to my early teenage years where I spent long nights learning how to write simple programs on the C64.  But alas, after a few nostalgic programming sessions I found myself falling out of love with of procedures, modules and global variables all over again and started looking for ways to apply some of the things I have learned about software development over the last 30 years or so.

Figuring out how to use basic C++ for embedded development helped me leap about ten years ahead in time to my early twenties, where I started learning about object oriented programming in Java. But I still found micro-controller development to be slow, messy and error prone and I missed the rigour and predictability I have achieved in my programming in recent years by applying TDD. jgade

So I started looking for information on how to write unit tests for micro-controller code and quickly came across James W. Greenings book “Test-Driven Development for Embedded C”, which convinced me I was on to something.

Although the book is choke full of good information, it is pretty sketchy on how to set up a development environment for embedded TDD, as is the documentation for CppUTest — the authors C/C++ unit testing framework of choice. And since I have never done much C/C++ development and have no prior experience with GCC, it took me a while to figure out how to set up a decent development environment on my Windows 7 PC.

I set up the environment for the Arduino because I am working on an project for this board at the moment. However, the unit testing tool chain is completely independent from the Arduino tool chain, so it should be a simple matter to adapt this setup to other boards and micro-controllers.

Step 1: Install Sublime Text with Stino

If you already have a good text editor for Arduino development, you can skip this step. However, if you are still using the standard Arduino editor, I strongly recommend that you give Sublime Text a try.

  1. Download Sublime Text 2 and install
  2. If you have not already done so, grab the Arudino software and install that as well
  3. Open Sublime Text
  4. Click the Preferences > Browse Packages… menu to open an explorer window
  5. Browse up one level and then open the Installed Packages folder
  6. Download Package Control.sublime-package and copy it into the Installed Packages folder
  7. Restart Sublime Text
  8. Click the menu Preferences->Package Control
  9. Type package control install and select Package Control: Install Package
  10. Type arduino and select Arduino-like IDE

You should now see an Arduino menu in Sublime Text.

Step 2: Set up the Example Project

Time to get hold of the arduino-tdd-example project and take your new development environment for a spin:

  1. Open the arduino-tdd-example repository on GitHub and download the zip file
  2. Unzip the project under your  Cygwin home folder (mine is c:\cygwin\home\Rasmus in the windows file system)
  3. Open the helloword.ino file in Sublime Text
  4. Click the menu Arduino > Preferences > Select Arduino Application Folder and select the Arduino folder on your system (e.g. c:\program files\arduino)
  5. Click Arduino > Arduino AVR Boards and select the board you are using
  6. Press Ctrl+Alt+V to compile the sketch

Next, try to upload the sketch to your Arduino:

  1. Connect your Arduino board to your PC
  2. Click the menu Arduino > Serial Port and select the Arduino COM port
  3. Click the menu Arduino > Serial Monitor > Baudrate and select 9600 (this is what the example project uses)
  4. Press Ctrl+Alt+M to start the serial monitor
  5. Press Ctrl+Alt+U to upload the sketch to you Arduino

When the sketch has finished uploading, you should see a Hello world! message in the serial monitor.

Step 3: Install Cygwin and CppUTest

It is possible to use CppUTest with a number of tool chains but the simplest solution is probably to use Cygwin.

  1. Start the latest installer from the Cygwin website
  2. On the packages screen, choose to install all devel packages (they are around 500 MB, so the installation might take a while… some mirrors are faster that others though!)
  3. Once the installation is complete, locate and open your Cygwin home directory in Windows Explorer (e.g c:\cygwin\home\Rasmus)
  4. Download the latest release of CppUTest from the GitHub repository (I used version 3.6)
  5. Unpack the CppUTest folder cpputest-x.y to your Cygwin home directory (the x.y suffix is the version number you are using)
  6. Open the Cygwin terminal
  7. Type cd cpputest-x.y to open the CppUtest folder
  8. Type mkdir build_dir; cd build_dir
  9. Type cmake ..
  10. Type make
  11. Finally, type make check to run the CppUTest tests

All tests should pass.

Step 4: Run the Example Unit Tests

  1. In the cygwin prompt, navigate top the arduino-tdd-example project folder (use /cygdrive/c to access the c: drive in the windows file system)
  2. Type make to run build and run CppUTest

And that all there is to it. Now go write some tests for your Arduino projects!

DIY Breakout Boards for Prototyping

I have been prototyping a drum machine on breadboards lately and found it difficult to make some components sit well in the boards, especially potentiometers and jack sockets.

Although I had carefully selected components that would fit in a breadboard, I was experiencing annoying issues with unreliable connections. I even had components falling out of the boards when I was moving them around (I am the proud father of a very curious 2-year old boy and need to store my prototypes on a high shelf when I’m not working on them).

I decided to solve this problem once and for all and spent an evening designing and building a couple of simple breakout boards for my project, using Olivier Gillet’s breadboard friends as inspiration.

Prototyping breakout boards

The breakout boards work just as I had hoped. They sit really tight on top of the breadboards and the connections are 100% reliable.

I also picked up on Olivier’s idea of using jumpers to set default connections – e.g. connecting the sleeve of the jack socket to ground and bridging tip and ring so that only a single wire is needed to incorporate the socket in a circuit in “mono mode”. This approach not only saves time but also reduces the number of wires in my prototype, making it easier to work with.

I really recommend this approach, even for fairly simple prototypes: What worth doing is usually worth doing well – especially in engineering projects.

You could use strip board for your own designs as long as the power rails on your breadboard match “standard” dimensions – this is not the case with all boards. If you enjoy etching your own circuit boards like I do, that’s obviously the way to go – you can grab my Eagle files on GitHub and use them as a starting point for your own designs.