other

pd on raspberry pi

here is a quick tutorial on how to install and run puredata 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 cable to your router).
what you get after following the below tutorial is a sdcard with a pd patch that automatically starts when the pi is booted.

update 160109: also works great on a raspberrypi2 with 2015-11-21-raspbian-jessie.img

//--preparations:
* put the raspbian image (2014-12-24-wheezy-raspbian.img) onto a +4gb card (on osx it is easily done with PiFiller).
* insert the sdcard+ethernet+usbsoundcard and power up the rpi
* open the terminal application on your laptop and type...
$ ssh pi@raspberrypi.local #log in from laptop with pi/raspberry (see notes below if fail)

//--setup
$ sudo raspi-config #run this on the rpi and do the following system configurations
* select expand filesystem
* 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
$ sudo apt-get update #on the rpi. check for new updates
$ sudo apt-get upgrade #update any old packages

//--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 puredata + 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.

//--testsines.pd

#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;

//--testmic.pd

#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 puredata
$ ssh pi@raspberrypi.local #log in from laptop again
$ pd -stderr -nogui -verbose -audiodev 4 testsines.pd #stop with ctrl+c
$ 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.

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

#!/bin/bash
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
$ sudo 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.

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

//--notes
* 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@192.168.1.51). 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... http://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 sudo crontab -e

AttachmentSize
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 max objects that could convert video from jitter to nato and back. jitter is the official library for doing video and graphics in max/msp. 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 osc9 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 metrowerks 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://www.bek.no/pipermail/55/2003-March.txt. and another one was this. luckily my license didn't stop working.

AttachmentSize
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 10years ago.

* dfg1394 bus powered s-video/composite video to uncompressed firewire converter from imagingsource (firewire version not longer available).
* mac osx drivers for the dfg1394 from outcastsoft. works with max/jitter 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.

f0blog hacked

sorry this place got hacked and someone overwrote all my media files (snd, pic, vid). i'm travelling atm and it will be a few more weeks until i can access the backup files and restore the archive.
071022 update: ok everything should now be back in place.
071028 update: and now updated to drupal 5.3

Pages

Subscribe to RSS - other