Manuel Guerrero Escobar
Published © LGPL

POP: Programmable Open Pedal

This is a stompbox guitar pedal built around C.H.I.P. board. With three modes of programmable operations, infinite applications in a box.

AdvancedFull instructions providedOver 1 day2,019
POP: Programmable Open Pedal

Things used in this project

Hardware components

Linear Regulator (7805)
Linear Regulator (7805)
×1
C.H.I.P.
C.H.I.P.
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
1590BBBK case
×1

Software apps and online services

jack server
invada lv2 plugins
mod-host

Story

Read more

Schematics

General schematics (Fritzing file)

General schematics (PNG)

Hqjwtx0bboohvl3xgokq

Bill Of Materials

List of components needed

Code

mod-host commands file for 3chorus effect

snippets
Commands to be executed by mod-host software in order to launch a 3chorus effect using an lv2 plugin
add http://drobilla.net/plugins/fomp/triple_chorus 0
connect system:capture_1 effect_0:in
connect a2j_bridge:capture mod-host:midi_in
connect effect_0:out1 mod-host:monitor-in_1
param_set 0 delay 0.1 
param_set 0 mod_freq_1 1
param_set 0 mod_amp_1 1
param_set 0 mod_freq_2 1
param_set 0 mod_amp_2 2
midi_map 0 mod_amp_2 129 3 0 10

script for managing reset button and leds

SH
This script is executed in background, so when you press the red button for a short time, it resets the unit, and if you press it for longer, it shuts it down.
#!/bin/sh

# Kernel 4.3
# 408 - LED
# 409 - S1
# 410 - S2
# 411 - B1 ROJO -> RESET/SHUTDOWN
# 412 - B2 

mode=$1
mode_orig=$mode

while [ 1 ]
do
   sleep 1
   v411=`cat /sys/class/gpio/gpio411/value`
   v409=`cat /sys/class/gpio/gpio409/value`
   v410=`cat /sys/class/gpio/gpio410/value`
   v412=`cat /sys/class/gpio/gpio412/value`

   # echo $v411
   if [ $v411 -eq 1 ]
   then
      amixer -c 0 cset numid=7 off
      sleep 5
      v411=`cat /sys/class/gpio/gpio411/value`
      if [ $v411 -eq 1 ]
      then
         shutdown -h 0
      else
         shutdown -r 0
      fi
      while [ 1 ]
      do
	sleep 1
        echo 1 > /sys/class/gpio/gpio408/value
        sleep 1
	echo 0 > /sys/class/gpio/gpio408/value
      done
   fi
   if [ $v411 -eq 1 ]
   then
      # Black button pressed
      echo "Black button " >> /var/log/pop.log
   fi
   if [ "$v409" -eq 1 ] && [ "$v410" -eq 0 ]
   then
      mode=mnt
   elif [ "$v409" -eq 1 ] && [ "$v410" -eq 1 ]
   then
      mode=p2
   elif [ "$v409" -eq 0 ] && [ "$v410" -eq 1 ]
   then
      mode=p1
   fi
   if [ "$mode" = "p1" ]
   then
      pop_script="pop_p1.sh"
   fi
   if [ "$mode" = "p2" ]   
   then
      pop_script="pop_p2.sh"
   fi
   if [ "$mode" = "mnt" ]
   then
      pop_script="pop_mnt.sh"
   fi

   if [ "$mode" != "$mode_orig" ]
   then
      mode_orig=$mode
      echo 1 > /sys/class/gpio/gpio408/value
      killall jackd
      killall mod-host
      killall a2jmidi_bridge
      /sbin/runuser -l chip /home/chip/${pop_script} >> /var/log/pop.log 2>&1 &
   fi 
done

script for initializing pedal

SH
It is launched when booting the unit, and depending on switch position, executes a different script
#!/bin/sh
set -x
# Kernel 4.3
# 408 - LED
# 409 - S1 - posición abajo
# 410 - S2 - posición arriba
# 411 - B1 ROJO -> RESET/SHUTDOWN
# 412 - B2 NEGRO

echo 408 > /sys/class/gpio/export 
echo out > /sys/class/gpio/gpio408/direction
echo 1 > /sys/class/gpio/gpio408/value
echo 409 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio409/direction
echo 410 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio409/direction
echo 411 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio409/direction
echo 412 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio409/direction

v409=`cat /sys/class/gpio/gpio409/value`
v410=`cat /sys/class/gpio/gpio410/value`
echo $v409
echo $v410

# 408=1 409=0 -> Mantenimiento, switch abajo
# 408=1 409=1 -> Switch enmedio
# 408=0 409=1 -> Switch arriba

if [ "$v409" -eq 1 ] && [ "$v410" -eq 0 ] 
then
   mode=mnt
elif [ "$v409" -eq 1 ] && [ "$v410" -eq 1 ]
then 
   mode=p2 
elif [ "$v409" -eq 0 ] && [ "$v410" -eq 1 ]
then 
   mode=p1
fi   
echo $mode

if [ "$mode" != "mnt" ]
then
   echo "iface wlan0 inet manual" > /etc/network/interfaces
else
   :> /etc/network/interfaces   
fi

/usr/local/bin/pop_loop.sh $mode &

if [ "$mode" = "p1" ] 
then
    pop_script="pop_p1.sh"
fi
if [ "$mode" = "p2" ]    
then
    pop_script="pop_p2.sh"
fi
if [ "$mode" = "mnt" ]
then
    pop_script="pop_mnt.sh"
fi
date >> /var/log/pop.log
echo 1 > /sys/class/gpio/gpio408/value
chmod 777 /sys/class/gpio/gpio408/value
/sbin/runuser -l chip /home/chip/${pop_script} >> /var/log/pop.log 2>&1 &

mod-host commands for a delay effect

snippets
add http://invadarecords.com/plugins/lv2/delay/mono 0
connect system:capture_1 effect_0:in
connect midi_controller:capture mod-host:midi_in
connect effect_0:outL mod-host:monitor-in_1
connect system:capture_1 system:playback_1
param_set 0 delay1 0.2
param_set 0 fb1 25
midi_map 0 delay1 0 0 0 2
midi_map 0 delay2 0 1 0 2
midi_map 0 fb1 0 16 0 133
midi_map 0 fb2 0 17 0 133
midi_map 0 vol1 0 2 0 100
midi_map 0 vol2 0 3 0 100

script for launching audio software - P1

SH
script that is run when switch is in position 1 (up)
#!/bin/sh
sudo rmmod snd_usb_audio
sudo rmmod snd_usbmidi_lib
sudo rmmod snd_rawmidi

sudo insmod ./snd-seq-device.ko
sudo insmod ./snd-seq.ko
sudo insmod ./snd-rawmidi.ko
sudo insmod ./snd-seq-midi-event.ko
sudo insmod ./snd-seq-midi.ko
sudo insmod ./snd-usbmidi-lib.ko
sudo insmod ./snd-usb-audio.ko
amixer -c 0 cset numid=7 on
sleep 4
/usr/local/bin/jackd -P70 -R -t2000 -dalsa -dhw:0 -r48000 -p256 -n3 -S -s -i 1 -o 1  &
sleep 2
a2jmidi_bridge midi_controller  &
sleep 2
aconnect 20:0 129:0
aconnect 20:0 128:0
cd /home/chip/lv2
/usr/local/bin/led_on.sh
./mod-host.sh delay

script for launching audio software - P2

SH
#!/bin/sh
sudo rmmod snd_usb_audio
sudo rmmod snd_usbmidi_lib
sudo rmmod snd_rawmidi

sudo insmod ./snd-seq-device.ko
sudo insmod ./snd-seq.ko
sudo insmod ./snd-rawmidi.ko
sudo insmod ./snd-seq-midi-event.ko
sudo insmod ./snd-seq-midi.ko
sudo insmod ./snd-usbmidi-lib.ko
sudo insmod ./snd-usb-audio.ko
amixer -c 0 cset numid=7 on
sleep 4
/usr/local/bin/jackd -P70 -R -t2000 -dalsa -dhw:0 -r48000 -p256 -n3 -S -s -i 1 -o 1  &
sleep 2
a2jmidi_bridge midi_controller &
sleep 2
aconnect 20:0 129:0
aconnect 20:0 128:0
cd /home/chip/lv2
/usr/local/bin/led_on.sh
./mod-host.sh compressor

script for launching audio software - P2 (alternative for supercollider)

SH
Script run in position 2 (middle) for launching a supercollider effect
#!/bin/sh
sudo rmmod snd_usb_audio
sudo rmmod snd_usbmidi_lib
sudo rmmod snd_rawmidi

sudo insmod ./snd-seq-device.ko
sudo insmod ./snd-seq.ko
sudo insmod ./snd-rawmidi.ko
sudo insmod ./snd-seq-midi-event.ko
sudo insmod ./snd-seq-midi.ko
sudo insmod ./snd-usbmidi-lib.ko
sudo insmod ./snd-usb-audio.ko
amixer -c 0 cset numid=7 on
sleep 4
/usr/local/bin/jackd -R -t1000 -dalsa -dhw:0 -r48000 -p256 -n2 -S -s &
#sleep 3
#a2jmidi_bridge midi_controller & 
#sleep 3
#aconnect 20:0 128:0
sleep 2
mkfifo /tmp/sc.fifi
cat /tmp/sc.fifi | sclang -D /home/chip/patch.sc &

script for launching audio software - MNT

SH
Script that is run when switch is in position MNT (down)
#!/bin/sh
sudo rmmod snd_usb_audio
sudo rmmod snd_usbmidi_lib
sudo rmmod snd_rawmidi

sudo insmod ./snd-seq-device.ko
sudo insmod ./snd-seq.ko
sudo insmod ./snd-rawmidi.ko
sudo insmod ./snd-seq-midi-event.ko
sudo insmod ./snd-seq-midi.ko
sudo insmod ./snd-usbmidi-lib.ko
sudo insmod ./snd-usb-audio.ko
amixer -c 0 cset numid=7 on
sleep 4
/usr/local/bin/jackd -P70 -R -t2000 -dalsa -dhw:0 -r48000 -p256 -n3 -S -s -i 1 -o 1  &
sleep 2
a2jmidi_bridge midi_controller  &
sleep 2
aconnect 20:0 129:0
aconnect 20:0 128:0
cd /home/chip/lv2
/usr/local/bin/led_on.sh
./mod-host.sh reverb

Supercollider effect example

SH
supercollider code for an tremolo-delay effect. There are several synths defined that are not finally connected, but can be used by modifying the sc file. Supercollider has to be compiled from source in order to work on CHIP board.
(

s.waitForBoot(
{

SynthDef("octaver",{ arg out=0, in=0, octdown=1, octup=1, wet=1, gate=1;
    var input,efx,mixed, up, down;
    input = SoundIn.ar(in, 1);
	up = PitchShift.ar(input,0.1,2,0,0.004);
	down = PitchShift.ar(input,0.1,0.5,0,0.004);
	mixed = input + wet*gate*octup*up + wet*gate*octup*down;
	Out.ar([out, out+1], mixed);
}).load(s);

SynthDef("phaser",{ arg out=0, in=0, rate=1, range=2, wet=1, gate=1;
    var input, fft, fft2, shifted, mixed;
    input = SoundIn.ar(in, 1);
    fft = FFT(LocalBuf(2048), input);
	fft2 = FFT(LocalBuf(2048), input);
    shifted = PV_PhaseShift(
			fft,
			pi*range*LFPar.kr(
					rate,
					0,
					1,
					0),
			1
			);
	mixed = wet*gate*2*IFFT(fft2) + IFFT(shifted);
	Out.ar([out, out+1], mixed);
}).load(s);

SynthDef("reverb", { arg out=0, in=0, wet=1, gate=1 ;
	// in and env come from the wrapper.
	var input, dsig, mixed, local;
	input = SoundIn.ar(in, 1);
    local = LocalIn.ar(1);
	16.do({ local = AllpassC.ar(input + local, 0.04, Rand(0.001,0.04), 3)});
	mixed = input + gate*wet*local;
	LocalOut.ar(mixed);
	Out.ar([out, out+1], mixed);
}).load(s);


SynthDef("tremolo",{ arg out=0, in=0, rate=1, wet=1, gate=1;
    var input,efx,mixed;
    input = SoundIn.ar(in, 1);
	efx = gate*input*LFPar.kr(rate,0,wet,0);
	mixed = 0.5*input + 0.5*efx;
	Out.ar([out, out+1], mixed);
}).load(s);


SynthDef("delay", { arg out=0, in=0, wet=1, gate=1, delay=0.5, fdbk=0.0, decay=0.0 ;

	var input, maxdelay, dsig, mixed, local;
    maxdelay = 1.0;
    input = In.ar(in, 1);
    local = LocalIn.ar(1);
    dsig = AllpassL.ar( // the delay (you could use AllpassC (put 0 in decay))
        input + (local * fdbk),
        maxdelay * 2,
        delay * maxdelay,
        decay);
    mixed = 0.5*input + 0.5*gate*wet*dsig;
    LocalOut.ar(mixed);
    Out.ar([out, out+1], mixed);
}).load(s);

SynthDef("level",{ arg out=0, in=0, v=1, tone=1200;
    var input,level,mixed;
    input = In.ar(in, 1);
	level = v*BBandPass.ar(input,tone+100, 3);
	Out.ar([out, out+1], level);
}).load(s);

c = Synth.new("tremolo", [\in, 0], addAction:\addToHead);
c.set(\wet, 0.8);
c.set(\gate, 1);
c.set(\rate, 3.5);

e = Synth.after(c,"delay", [\in, 0]);
e.set(\delay, 0.2);
e.set(\fdbk, 0.10);
e.set(\decay, 0.30);
e.set(\wet, 0.80);
e.set(\gate, 1);



MIDIIn.connectAll;


MIDIdef.cc(\reverbbypass, {arg value; value.postln; if (value == 0,
			{ "Reverb off".postln;
				c.set(\gate,0);
			},
			{ "Reverb on".postln;
				c.set(\gate,1);
			}
		)},32);

MIDIdef.cc(\tremolowet, {arg value; c.set(\wet, value/127);value.postln},16);
MIDIdef.cc(\tremolorate, {arg value; c.set(\wet, value/10);value.postln},0);

MIDIdef.cc(\delaybypass, {arg value; value.postln; if (value == 0,
			{ "Delay off".postln;
				e.set(\gate,0);
			},
			{ "Delay on".postln;
				e.set(\gate,1);
			}
		)},37);
MIDIdef.cc(\delaytime, {arg value; e.set(\delay, value/10);value.postln},21);
MIDIdef.cc(\delayfb, {arg value; e.set(\fdbk, value/10);value.postln},22);
MIDIdef.cc(\delaywet, {arg value; e.set(\wet, value/10);value.postln},5);
//MIDIdef.cc(\delaydecay, {arg value; e.set(\decay, value/10);value.postln},6);


})

)

LED on script

SH
Script for setting the green led to on
#!/bin/sh
echo 0 > /sys/class/gpio/gpio408/value

GITHUB repository

Visit or clone this repository for latest code

Credits

Manuel Guerrero Escobar

Manuel Guerrero Escobar

1 project • 1 follower
I am a professional engineer and amateur musician.

Comments