The programming Toolchain

Re-invent the wheel !

Most of the time, when i develop something for a personal project, i really like to start from scratch…It’s not about being a Linux or a command line extremist, it’s just that it allow me to really understand clearly what i’m doing.

This is one of the reason that drive my choice of not using the Arduino Integrated development environment. The other reason is that i want to program the entire project in C/C++ (which is my favorite language ) and that the Arduino IDE allow me to program in a “simplified” language which is not true C/C++.

Obviously, i made this choice after investigating what was feasible according to the basic tools available… Those research lead me to the following observation:

  • The Arduino IDE translate it’s “simplified” source code into true C/C++ during the compilation phase.
  • The Arduino IDE compilation process is based upon GNU avr-gcc which is an open source implementation of the GNU compiler collection for the AVR platform.
  • All the facility library used by Arduino are written in pure C/C++

So everything is already here to build a standard toolchain that can compile C/C++ code, use existing library (to do serial communication or MIDI processing…), and upload the program to the Arduino without a lot of pain..

Tools used:

So to summarize everything, here is what i will use to develop the software side of the MIDILooper:

  • Host computer: Raspberry PI.
  • Host OS: Raspian, a derived version of Debian compiled for the ARM architecture of the Raspberry.
  • Source Control: Git (using remote repository hosted on GitHub).
  • CMake for creating makefile allowing me to build the ArduinoCore library plus the MIDILooper program itself.
  • The GNU avr-gcc toolchain for compiling, assembling and linking my code.

So now, next step is to setup those tools and compile the Arduino Core Library !

Selected technical solution

Arduino to the rescue !!

Computer sciences and programming are great, but meeting and discussing with real people is even better !!

That’s a friend of mine that talk to me the first time about the Arduino solution.

Okay, i’m making some advertising, but you really should check out the website of his team Akwariom, they are creating amazing light control and audio technical solutions for live shows. YOU RULES DUDES !

So for those who don’t know about Arduino, in short, it’s an opensource hardware solution for creating small electronic device that can control pretty much everything ranging from stepper motor’s control, sensor data extraction to MIDI processing !

There are many variation of the Arduino platform, but the most used one is the Arduino Uno.

The Arduino Uno platform is mainly two things:

  • An hardware platform build around an Atmel AVR (ATmega328p) processor which is an 8 bit Risc microcontroller
  • A software solution that simplify the development process on this platform using a simplified programming language and several wrappers library.

As i want to develop this project in pure C/C++,  i’m going to use only the hardware platform, and develop my own tools for replacing the software solution, including the build toolchain and the wrappers library.

Arduino source code for the software solution and the wrapper library are available on GitHub:  https://github.com/arduino/Arduino

Get rid of the Hardware side !

As i’m not an hardware specialist, i’m always disappointed when it come to solder resistors… But thanks to the Arduino platform, lots of company have developed hardware extension slot (called shields) for the Arduino platform.

Among them, there is one, SparksFun that have developed an extension shield that provide all the necessary MIDI circuitry needed for reading MIDI data and sending MIDI data:

https://www.sparkfun.com/products/9598

It provide  3 MIDI connectors:

  • A MIDI IN which allow the Arduino to read MIDI data comming from an external device (in my case the Gaia SH01)
  • A MIDI OUT which allow the Arduino to send MIDI data to external device (again in my case, the GAIA SH01)
  • A MIDI THRU which is often present in MIDI powered device and which duplicate what come in the MIDI IN connector

Sounds like a great start no ? !

Nothing to solder and i like it !

Here is a picture of both the Arduino Uno and the MIDI Shield:

IMG_20131118_222544

Genesis of the project

Let’s start !

So let’s start this blog with a first post introducing the project i’m planning to create, why i’m creating it and why it sound so cool to me !

MIDILooper ? So what’s that stuff ?

Good question ! Before that, let me quickly introduce myself… I’m a computer scientist since several years. Programming stuff, analyzing code, debugging programs, this is my things ! I spend ( … nearly 🙂 … )all my days reading and writing C/C++/python code for various stuff and in various domains (Video games, CG software, embedded software…)

Beside of that i’m also (at least trying to be…) a musician. I use the following instruments

  • A Seagull S6 acoustic guitar (recorded using a Audio Technica AT 2031)
  • A Yamaha P95 Digital piano.
  • A Novation Mininova synthesizer.
  • An Akai MPC500.

All of those instruments are mixed using a Behringer Xenyx 1002 Analog mixer.

The Piano, Guitar and synthesizer are then send back to the Roland Boss RC300 Loop-station. And the output of the loop-station is also mixed down to the Xenyx mixer.

The Boss RC300 Also act as a master controller: It send tempo ticks to the MPC500 and the Novation in order to keep them in sync with what i’m playing.

In short, i can record and loop 3 separates instruments tracks on the RC300 plus one extra track coming from the MPC500.

  • Here are some pictures of this setup:

IMG_20131118_203341 IMG_20131118_203414

  • And a nice graph showing how devices are connected:

MusicSetup

So What ?

I’m very happy with the setup, but there one thing that annoy me: The 3 instruments tracks are audio track.

This is very good for piano, guitar or even voices, but for the Gaia synthesizer, it really reduce the expression potential. Let me explain:

This synthesizer have a huge amount of nobs and slider that can be tweak while playing in order to change the shape of the generated sound (for example change cutoff frequency of a low pass filter, or frequency of a LFO…)

The point is that when i record and then loop a musical phrase played on the GAIA, i cannot change the generated sound anymore. Thit is because the RC300 record the full audio data going out of the synth.
So as soon as the looped start, the sound is not generated anymore by the synth.

What i would like to do is the following:
Play a musical phrase on the GAIA, record it somewhere, loop that recorded phrase and WHILE the loop is playing, tweak nobs and sliders to change the sound played.

The theoretical solution:

Fortunately there is one theoretical solution, let me explain :
The Gaia SH01, like most of the actual synthesizer is made of 2 main “components”

  • A sound engine.
  • Controller.

The sound engine is what actually create the sound, you ask him: “Please play a C note for this amount of time, with this intensity and with this kind of sound” and he generate the sound you ear in real time. The type of generated sound depends on various settings controlled by several nobs and sliders. (The same nobs and sliders i want to tweak during a loop). Using those nobs and sliders, i can change the sound in real time, BUT, i have to tweak them WHILE i’m playing on the GAIA’s keyboard

The controller, to be simple, is the GAIA’s keyboard. When i play a note on the keyboard, a digital command is generated which contain all the informations about the played note. (But no sound, because sound is generated by the sound engine) This command is then send to the sound engine which play the specified note

Those commands are in fact MIDI commands.MIDI is a very popular standard allowing several musical devices to communicate with each others.

The Gaia have 2 MIDI plugs:

  • A MIDI OUT: All the MIDI commands generated by the keyboards are directly send to this output (in order to be send to the MIDI IN of an other instrument for example…)
  • A MIDI IN: The Gaia receive all the MIDI command send on this plug and play them directly using the sound engine.

So here is the goal of this project:
Create a small device, that can record a sequence of MIDI commands coming from an external device (the Gaia in my case), and that can send back this sequence to an other (or the same) device and loop that sequence over time.