(R)Pianophone v0.2

The R(Pianophone) has been upgraded since last year (see http://antoine.villeret.free.fr/?p=427).
Here is the version 0.2 :
(R)Pianophone v0.2
It has a nice 16×2 LCD screen and two push buttons.
The LCD displays Pd patches available on the SDcard and you can go up and down in the list thanks to the buttons.
I also added a USB sound card : ESI UGM96 with 2 inputs (mic and hi-Z) and 2 outputs.

The LCD is a Midas I²C device connected to the Pi through GPIO.
A small command line tool writes on the LCD.

The two buttons are matrixed with the keypad and scanned in an infinite while loop.
When a patch is selected, its name is send through OSC to a main Pd patch and the patch is loaded.

To update the patches on the SDcard, just plug a USB key with some Pd stuff and all patches will be available on the (R)Pianophone.

The USB sound card makes me crazy because of lots of issues.
First I have to disable the ethernet chip to get audio input through USB with this command :
dhclient -r # release DCHP
echo -n "1-1.1:1.0" | sudo tee /sys/bus/usb/drivers/smsc95xx/unbind #disable the cheap

I also need to downgrade to the firmware revision of April 26, 2013.
sudo rpi-update 994e46341bd190ef4ce6ee011e3f9fb8173e2bbf
With the up-to-date firmware, I only got crakles when I disable the ethernet chip (and my USB keyboard goes crazy too…).

Moreover, as the analog synth emulation is eating a lot of CPU, I have to disable the audio input in this patch and to re-enable it the others.
This is done inside Pd by sending those messages to pd :
audio-dialog 2 0 0 0 2 0 0 0 2 0 0 0 2 0 0 0 48000 10 -1 64 to enable
and
audio-dialog 2 0 0 0 -2 0 0 0 2 0 0 0 2 0 0 0 48000 10 -1 64 to disable.
But those messages are not portables. I depends on the alsa configuration. You may find out which command to send by looking to tcl -> pd communication.
To do so, just put a [r pd] connected to a [print] somewhere in your patch and look to the Pd’s console when clicking on “Apply” in the Alsa configuration dialog.

One more thing, is that I got crackles when Pd is loaded directly from /etc/rc.local and I don’t know why…
But a workaround is to start Pd from /home/pi/.bashrc script instead.
It’s a bit crapy since Pd launches every time the pi user logs in and thus several Pd can be loaded at the same time.
But I can’t find a better way to avoid crakles…