Sunday, October 4, 2009

Homemade guitar looper with Arduino

Introduction

Here is how to produce pedalboard for electric guitar. The idea is to connect pedals to the Arduino, and to use them to control a software of sound processing in Pure Data. Here I show you the example of a looper, but one can be also made a rack of effects without problem.

A video of the looper in action is available here :

 

First of all, something you must understand: our pedals break up into two parts: the controls part and the sound part. The control part is composed of:
  • several pedals (footswitch, pedals of expression).
  • Arduino to connect them to the PC.
  • a driver: here it is about a Pure Data patch, which allows to use easily what Arduino sends to us.
The sound part:
  • an electric guitar.
  • a sound card which one connects it.
  • the software which treats the sound: here, it is thus about a Pure Data patch.
The pedalboard are thus used only to control a software of sound treatment.

Electronic part



Overall picture


As it there is seen, my pedalboard is composed of (from left to right):
  • an expression pedal: it is connected on a catch RCA.
  • a footswitch with 2 switches: it is connected on a catch stereo jack
  • finally, 2 switches which leaves in mono jack.
The assembly is simple: first, get the jacks catch which correspond to the pedals. Then, connect them on a small circuit which one even manufactures oneself. The idea, it is that each switch will be crossed by a 5 volts supply, provided by Arduino. Then, depending on the pedal state, the power is on (or off). With the pedal of expression, it is only a potard, which will modulate the power supply sent by Arduino.

Each pedal must thus be connected to the alim 5V provided by Arduino on the one hand, and to the mass of the other. Just put a resistance between the pedal and the mass: it is about a resistance of pulling. And here, connect the pines digital (or analogical for the pedal of expression) of Arduino, knowing the tensoin there and thus knowing if the pedal were actuated.

Close-up on the circuit


A close-up to see the circuit, but which does not show large thing.


 

 Electric diagram


Small diagram which shows that it is very simple.






Data-processing part


Code embedded on Arduino


Now that the assembly is made, we must write the short piece of code which one will embark on Arduino to manage all that.

Here also it is very simple: only the role of Arduino is to know the values of each switch (open/closed, 0/1) and of the potar (value between 0 and 1), and to send these data to the computer .

This code, one writes it with the kit of development provided with Arduino. For the communication between the chart and the ordi, one uses the lib Firmata, provided with the SDK.


See link below for the source code.


Comments on this code


Thus of course, this code corresponds precisely to the assembly which I carried out. But it is very easy to adapt to any assembly of the same style.

The use of the variables '' prev_… '' makes it possible to send data only when one of the values changes. As long as one does not touch with any pedal, the chart doesn't send anything. That avoids flood on USB port, and to tire the chart unnecessarily.


Pure Data Part


Driver Pure Data


Well. All the part with Arduino is made. It is now necessary to make communicate our chart with Pure Data. For that, I used Pduino. It is a Pure Data object which is interfaced with Arduino. It requires to have used the lib Firmata on the embedded code.

Available at this address: http://at.or.at/hans/pd/objects.html
Once one manages to make communicate our Arduino with Pure Dated, one can start to program a small driver. It only handle simple tasks:
  • to establish the communication with Arduino.
  • to recalibrate what the expression pedal gives us to obtain a value between 0 and 1.
  • to make sure that the switches give well until one waits.
  • to send the values wanted thanks to send objects, so we can use them in others patches.
The Pure Data driver for the pedals is in the zip file (see following section), under the name arduino-driver-0-0-5.pd.

The looper


From there, one made all the part controls pedals. Remain the sound part. I will not extend too much on this part, which does not relate to really any more Arduino.

I only give the 2 Pure Data patches I made and use in the youtube movie :
  • looper-0-0-3.pd It acts of an object which carries out a loop of the input signal. One controls it by messages:
    • start: start the recording of the loop.
    • stop: stop the recording of the loop.
    • toggle: start to play the loop, or asks him to stop as soon as it arrives at the end.
    • kill: immediately stop the loop, and reset the looper. I.e. one can't call back the loop with toggle anymore.
    • float: one can also send a float. That is used to force the size of the loop to a multiple of this value. If X is sent, the loop will be forced with the one of the following sizes: X/4, X/2, X, 2X, 4X. But what for?? That is used when one has several loopers in parallels, so that the loops remain synchronized.
  • looper-test-3.pd This patch uses the precedent. It makes it possible to use 4 loops in parallels. The expression pedals makes it possible to control the volume of the loops. One of the switches is dedicated to change loop. The 3 others are used to control the looper.
The 3 Pure Data patches are there:
http://www.arduino.cc/playground/uploads/Projets/guitarlooper-pd-objects


Note: I am a very occasional user of Pure Data (the last time that I served myself it of it was y' is 2 years old well), then if y' has people who know well and throw an eye with my patches, it can make them odd. I just made a point of preventing. I used quite ugly tricks, but I did not know how to do them differently.

Conclusion


The interest of this is multiple:
  • the price: my pedals cost me about 100 euros by counting the carriage costs.
  • flexibility: so tomorrow I need to add an unspecified pedal, I just add it on my assembly and they is good. No need to buy a new whole pedalboard.
  • an infinity of applications: from the moment you're used to Pure Data, you can work your sound of guitar as you wants, and can control it as you want, since you choose what the pedals do. Thus the possibilities are enormous for people impassioned, and who have free time. 

Edit 2014

A new version of the source code is available on Gitlab for those interested:
https://gitlab.com/elboulangero/looper


9 comments:

  1. I can't open your link to the pd patches... what application am I opening it with? are these suppose to be patches? What operating system are they intended for?

    ReplyDelete
  2. if i use new switches they have to be on/on or on/off type?also can i use a pot if i don't have an expr pedal?

    ReplyDelete
  3. Your Pd patches are quite logically structured. Do you know if they work in libpd?

    In your Arduino code there is no need for the delay(10) function call. Delay turns off interrupts in the MCU and basically bricks your Arduino until the delay() function returns. If you want to sample inputs less frequently you can keep a last_millis register and sample the input at a specified rate.

    ReplyDelete
  4. How do I get in contact with you man ?

    molina8@gmail.com

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Bonjour et bravo pour ton projet,

    Je vois que l'article n'est pas tout récent et j'espère que tu verras mon message. Je suis très intéressé pour reproduire ce que tu as fait mais les choses ont changé au niveau d'Arduino et Puredata sous Linux, ce qui me pose des problèmes.

    Tout d'abord, au niveau d'Arduino je recevais des erreurs du style «WProgram.h aucun fichier de ce type». J'ai vu qu'il suffisait de remplacer les «WProgram.h» par des «Arduino.h». Ensuite, la vérification plantait en me disait que «BYTE n'est pas défini dans cette portée». J'ai vu que l'utilsation des fonctions a changé et qu'il suffit d'enlever l'argument BYTE. J'ai alors pu vérifier et téléverser sans problème.

    En fait le réel souci vient de Puredata. J'ai vu que tu as fait un script «Launch.sh». Malheureusement celui n'est plus utilisable : je reçois l'erreur «pd-extended: not found». J'ai en effet cru comprendre que cette librairie n'est plus utilisée !

    Aurais-tu une solution à me proposer ?

    Merci d'avance et encore bravo,

    Lucas

    PS : Dans la vidéo que tu as mis sur Youtube, es-tu sous Linux ? Utilises-tu Guitarix, Rakarrak ou uniquement Puredata ?

    ReplyDelete
  7. Can I do it with only 1 mono switch??? Waiting for ana answer on my question///

    ReplyDelete
  8. Totally awesome. I'd love to make one of these. Anyone who speaks English that got this working?

    ReplyDelete
  9. Will it work on an acoustic guitar ??

    ReplyDelete

About Me

french version here : http://www.arduino.cc/playground/Projets/LooperPourGuitare