keyboard shortcuts

MacBook Pro mid-2015 keyboard after some hard use of the cmd key. My habits shining through.

The left side shift and the three up/down/right arrow keys also have this nice transparency look. But strangely enough the left arrow key must not have been used much.

pd on raspberry pi

Here is a quick tutorial on how to install and run Pure Data headless on a Raspberry Pi. The instructions assume you want to start with a new clean [Raspbian] system image and do it all from scratch.
The instructions also assume you have a Raspberry model B, an USB soundcard like Terratec's Aureon Dual USB and an ethernet cable with internet access (just connect the ethernet cable between your RPi and your home router).
What you get after following the below tutorial is a SD card with a Pd patch that automatically starts when the RPi is booted.

* Put the Raspbian image onto a +4Gb SD card (it is easily done with balenaEtcher).
* On newer versions of Rasbian, activate SSH by creating an empty file called 'ssh' directly on the SD card
* Insert the SD card+ethernet+usbsoundcard and power up the RPi
* Open the terminal application on your laptop and type...
$ ssh pi@raspberrypi.local #log in from laptop. Password is 'raspberry'. (See notes below if fail)

$ sudo raspi-config #run this on the RPi and do the following system configurations
* Select expand filesystem (only needed on Wheezy and older versions of Raspbian)
* Change user password
* Optionally lower the GPU memory under advanced / memory split
* Select finish and reboot

$ ssh pi@raspberrypi.local #log in again from laptop with your new password
$ sudo apt-get update #on the RPi. Check for new updates
$ sudo apt-get upgrade #update any old packages
$ sudo apt-get dist-upgrade #update the distribution

//--Test sound
$ lsusb #should list the USB soundcard
$ aplay -l #should also list the soundcard
$ sudo speaker-test -t sine -c 2 -Ddefault:CARD=Device #should sound if headphones connected. Stop with ctrl+c
# Note: this assume that your usb soundcard name is Device - check what aplay and edit the CARD= in the line above if needed.

//--Install Pd
$ sudo apt-get install puredata #download and install Pure Data + required packages

//--Test Pd patches
Copy the following two example Pd patches (or download the attachments below) and save them on your laptop (here assume on the desktop). To copy Pd patches just paste the cryptic text into a plain text editor and save with .pd file extension.


#N canvas 1068 88 450 300 10;
#X obj 238 159 dac~;
#X obj 235 73 osc~ 400;
#X obj 289 73 osc~ 404;
#X msg 126 154 \; pd dsp 1;
#X obj 126 83 loadbang;
#X obj 126 123 del 100;
#X text 42 122 important ->;
#X obj 238 111 *~ 0.2;
#X obj 280 111 *~ 0.2;
#X connect 1 0 7 0;
#X connect 2 0 8 0;
#X connect 4 0 5 0;
#X connect 5 0 3 0;
#X connect 7 0 0 0;
#X connect 8 0 0 1;


#N canvas 1068 88 450 300 10;
#X obj 238 230 dac~;
#X msg 126 154 \; pd dsp 1;
#X obj 126 83 loadbang;
#X obj 126 123 del 100;
#X text 42 122 important ->;
#X obj 238 24 adc~;
#X obj 238 53 delwrite~ del1 500;
#X obj 238 123 delread~ del1 500;
#X obj 259 80 delwrite~ del2 750;
#X obj 280 144 delread~ del2 750;
#X obj 238 182 *~ 0.2;
#X obj 280 182 *~ 0.2;
#X connect 2 0 3 0;
#X connect 3 0 1 0;
#X connect 5 0 6 0;
#X connect 5 1 8 0;
#X connect 7 0 10 0;
#X connect 9 0 11 0;
#X connect 10 0 0 0;
#X connect 11 0 0 1;

//--Copy Pd files to RPi
$ exit #log out from the RPi
# run the two lines below on your laptop to copy the two example patches to your RPi. (This is also how you can transfer more Pd patches later on.)
$ scp ~/Desktop/testsines.pd pi@raspberrypi.local:/home/pi/
$ scp ~/Desktop/testmic.pd pi@raspberrypi.local:/home/pi/

//--Run Pure Data
$ ssh pi@raspberrypi.local #log in from laptop again
$ pd -stderr -nogui -verbose -audiodev 4 testsines.pd #stop with ctrl+c
# Note: if no sound test with different audiodev - 4 is usually the USB soundcard
$ pd -stderr -nogui -verbose -audiodev 4 testmic.pd #stop with ctrl+c
# Note: you will need to connect headphones or speakers for the first example to work. And some kind of audio input (e.g. electret mic or line-in from MP3 player) for the second example patch to work.

$ nano autostart.sh #creates a new file. Copy the two lines below into this new file.

pd -nogui -audiodev 4 /home/pi/testsines.pd

# save and exit with ctrl+o, return, ctrl+x
$ chmod +x autostart.sh #make the autostart.sh file executable
$ crontab -e #and add at the end...

@reboot /bin/bash /home/pi/autostart.sh

# again save and exit with ctrl+o, return, ctrl+x
$ sudo reboot #restarts the RPi. After booting the sine tones patch should have started automatically.

$ ssh pi@raspberrypi.local #log in from laptop once more
$ sudo pkill pd #stop Pd
$ sudo halt -p #turn off the RPi safely

* If you cannot log in and you get ssh: Could not resolve hostname raspberrypi.local, you might need to replace raspberrypi.local with the exact IP address of the RPi (e.g. ssh pi@ The exact address will vary and can be found in your router setup.
* Note: if you get WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! then run the command $ ssh-keygen -R raspberrypi.local to reset the SSH key.
* When ready with everything and you have the correct Pd patch autostarting you can [physically] lock the SD card. This will put it in no-write mode and possibly prolong its life (specially if you cut the power without properly turning off the system with sudo halt)
* If you experience audio dropouts you might try the suggestions here... wiki.linuxaudio.org/wiki/raspberrypi. Most important force USB1.1 and set CPU governor to performance mode.
* If you get ALSA output error Device or resource busy when trying to start Pd, then delay the ';pd dsp 1' message in your Pd patch with about 100 milliseconds.
* To remove the autostart just delete the file autostart.sh and go into cron again and remove the last line you added with crontab -e

update 160109: also works great on a Raspberry Pi 2 with 2015-11-21-raspbian-jessie.img
update 180102: updated for 2017-11-29-raspbian-stretch.img and 2017-11-29-raspbian-stretch-lite.img

Binary Data testsines.pd370 bytes
Binary Data testmic.pd522 bytes

nato to jitter bridge object - for peace and understanding

clean-up #31:

31jan 2003 I released two MaxMSP objects that could convert video from Jitter to nato and back. Jitter is the official library for doing video and graphics in MaxMSP. But before that was nato, or more precisely Nato.0+55+3d. Nato was a totally amazing piece of software and with it you could do similar things as with Jitter. It was mac OS9 only but super poetic and unique in all kinds of ways. I used it a lot for my live video works (klipp av tours, vj-ing etc) and played my last gig using it as late as 2007 (at club Maria in Berlin). I still miss playing with it.

The binary OS9 objects themselves have been available for download since 2003 from here, but I never released the C source code.
As I wasn't so good with C back then, it took weeks for me to reverse engineer the nato video format. Lots of trial-and-error using Metrowerk's CodeWarrior.

Releasing the objects to the public was scary. I risked loosing my software license. n.n., the author of nato, was notorious for humiliating and threatening nato users online. And even terminating licenses if one said the wrong thing in public. One of the replies I got after the release was "!m go!ng 2 eat u". See http://plot.bek.no/pipermail/55/2003-March.txt. And another one was this. Luckily my license didn't stop working.

File f0.jit2n2.c6.38 KB
File f0.n22jit.c7.79 KB

under the hood changes 2

Updating this blog to Drupal 7. It is quite different from version 6 and things will be a bit chaotic for a while. Sorry that some content here will be unavailable for a few days.

update 130607: fixed the layout and sound files should play again.

analog video in/out on a recent macbook pro

For a project I needed to take in and send out realtime analog (composite) video. Analog video input has always been a problem, but on recent laptops Apple even removed the video output via DVI adapter option (i.e. there is no displayport to video/S-video adapter).
So after experimenting and going through some old hardware I had laying around, I found a solution using two devices that I last used around 10 years ago.

* dfg1394 bus powered S-video/composite video to uncompressed firewire converter from The Imaging Source (firewire version not longer available).
* mac osx drivers for the dfg1394 from Outcastsoft. Works with MaxMSPJitter etc.
* an old TView Gold scanconverter from Focus enhancements. Used in combo with a 5V power from USB hack and a displayport to VGA adapter.

why share?

We all know how fantastic the open-source movement is. How wonderful it is with all these people that distribute their code, schematics, data, ideas etc. for free and in such a spirit of openness. We gain so much from it and it is all really great.

But seen from the contributor's point of view, one could ask the questions: why share your hard-earned knowledge? What are the benefits and why spend a lot of time helping unknown people - often without even a thanks in return? Why give away code that you care about and that have taken lots of effort and hours to write - for free? Is it for personal fame? Is it the communal spirit or some political beliefs? Or the lack of interested commercial companies?

My personal and perhaps slightly provocative answer is that I share because of egoism / self-interest. I found that by making something public, I force myself to write more reusable and understandable code. Publicising means I will proof-read, add comments and help-files and perhaps cross platform support. Sharing also makes me reluctant to drastic change and help fixate things like interface, protocol and functionality. So after uploading code, I feel responsible to maintain it for the future throughout system and program upgrades - whether other people depend on it or not. It is the knowledge that someone _might be using it that is enough to put in that little extra effort and spend a few additional hours.
So for me as an independent software developer / artist, open-source is mainly a vehicle for caring about my own work. And it is the simple act of making it open and public that is so extremely helpful for me.

Of course this is not the only reason. It is a great pleasure to see code I have written being helpful in other people's work, get feedback from users and see my ideas being developed a lot further by other artists. I also enjoy helping out where ever I can, passing on knowledge from people I in turn learned from. And being a frequent contributor in various communities do generate paid work in the form of workshops, concerts, programming jobs and technical support.
But again - the main reason I share is a selfish, practical and simple one: I write better code because I distribute it.


Subscribe to RSS - other