Raspberry Pi Video Synthesizer

I’ve been working on a Raspberry Pi video synthesizer that is coded in Python running on two Raspberry Pi computers. Each Pi runs a Python script to access the camera module controls and video effects. Each Pi’s camera is pointed at the other Pi’s video monitor to create a feedback loop. OSC commands provide remote control and are sent to each Pi from a max patch running on a laptop. More documentation with sound is on the way. For now enjoy the footage

Raspberry Pi Speakers running Pd

I built these Raspberry pi Speakers using mono amplifier boards from Sparkfun, 8 ohm speakers from All Electronics, a few components and some wood from my garage I have made four WIFI speaker boxes for Raspberry Pi based audio projects. Each speaker box has a Raspberry Pi in the back that runs a Pure Data audio patch. The Pure Data audio patch is controlled via OSC through a WIFI dongle on the Pi. The speaker is powered via the Pi’s 3.3 volt GPIO pin and ground.

Raspberry Pi Speakers

Networked Raspberry Pis and Pure Data

This past Spring I have been tinkering with the Raspberry Pi computers. They are pretty amazing considering that they only cost about $40. The two areas I have been researching have been running Pure Data networked between three Pis and setting up stand-alone HD video players for use in galleries and kiosks. Here’s a demo video of three Pis networked together, running Pure Data, and being controlled via a laptop with Pure Data and a Korg Nano controller.

Raspberry Pi – Gallery Video Player

This tutorial will turn your Raspberry Pi into a simple video player. The Raspberry Pi will automatically begin playing a folder of video files when it starts. The files in the folder will randomly repeat until the script is stopped or the Pi is turned off. To see a demonstration video please go here.The following instructions assume you are logged in to your Pi from a remote computer.

Create a folder and copy video files to your Pi

To create a new folder named videos for your video files type:

mkdir videos

To move into the newly created videos directory type:

cd videos

Open a new “local” terminal window. You’ll run the next command on the “local” terminal and not the terminal window connected to your Pi
To copy a folder of video files from your laptop’s desktop to your Pi type :

scp /Users/[your username]/Desktop/[folder name>]/* pi@[your Pi's ip address]:/home/pi/videos

The command looked like this on my computer:

scp /Users/dwingus/Desktop/vids/* pi@10.0.1.9:/home/pi/videos

Type your Pi’s password, press return and wait for videos to transfer. The next step is to create a shell script using the nano text editor.

Shell Script to play videos in a folder

Log in to your Pi. and type:

sudo nano playseries

Copy the following into the Nano text editor:

#!/bin/bash
if [ x"$1" = x"help" -o x"$1" = x"--help" -o x"$1" = x"-help" ];then
echo "Usage: playseries [folder path]"
echo "Audio mode can be either 'hdmi' or 'local'."
echo "Folder path is the full path to folder full of video files."
echo "This script will try to play all files in the video folder regardless of file type"
exit
fi
while true
do
for file in $2/*
do
omxplayer -o $1 $file
done
done

 

Save the script file by typing control-x
Make the script executable by typing:

sudo chmod +x playseries

Move the file to the /usr/bin folder by typing:

sudo mv playseries /usr/bin

 

Running the script

The script follows the format:

[scriptname] [audio-output] [path_to_directory]

To run the script using the HDMI audio out type:

playseries hdmi /home/pi/videos

To run the script using the local audio out type:

playseries local /home/pi/videos

Blanking the Pi's screen between video files

You'll notice when you run the script that OmxPlayer pauses between video files and there is text that is displayed on the video monitor. To eliminate the text you need to basically tell the Pi to make the screen black.
To fix this edit the file here:

sudo nano /etc/kbd/config


In the config file change "BLANK TIME" to a value of 2 and save the file
Then restart your Pi by typing:

sudo reboot

Automatic Login and Running the Script on Boot

To get your Raspberry Pi to automatically login when booted and to call the playseries script complete the following steps:
- Type:

sudo nano /etc/inittab

- Scroll to the line: #1:2345:respawn:/sbin/getty 115299 tty1 and put a # in front of it to comment out the line of code
- Add a new line underneath:

1:2345:respawn:/bin/login -f pi tty1/dev/tty1 2>&1

- Save the file. This will make your Pi automatically login when booted.
- To start the playseries script automatically on boot edit your .bash_profile file by typing:

sudo nano ~/.bash_profile

- Add the following line to the file:

playseries local /home/pi/videos

- Save the file. Commands located in the .bash_profile file will be executed when the Pi boots
- To reboot your pi type

sudo reboot

Raspberry Pi Workshop at Machine Project

Raspberry Pi workshop

I will be teaching a two day Raspberry Pi workshop at Machine Project on Wednesday, March March 12th and Monday, March 17th 2014. The workshop will focus on using the Raspberry Pi camera module with an emphasis on capturing time lapse videos.

The first class session will focus on getting the Raspberry Pi set up, learning the commands for the HD camera board and preparing a time lapse video capture script using the Python programming language. For homework, each student will shoot a time lapse video of their choice.

In the second class meeting we will cover how to convert the time lapse images into a video file for presentation. Each student will then show their time lapse video to the class. As time permits we will also cover modifications for the time lapse script, capturing video files to disk and using the pi camera board’s image effects remotely as a realtime “Video Synth.” We’ll also demonstrate a pan and tilt servo controller for the camera board.

You can register for the class using this link

Raspberry Pi Streaming Video using NC and MPlayer

Raspberry Pi Streaming Video

Here are some instructions to get a Raspberry Pi streaming video using NC and MPlayer This method looks the best and has the least amount of latency.

Install HomeBrew and MPlayer
HomeBrew is a package installer for Os X. You will install this on your laptop and not the RPI. Installing HomeBrew will allow you to easily install MPlayer. It will also allow you to use additional unix commands that are not included in a standard Os X install.
1. Go here: http://brew.sh
2. Scroll to the very bottom of the page and follow the “Install Homebrew” instructions.
3. The first thing to do after installing HomeBrew is to type into command line: brew doctor
4. Type the following to install MPlayer: brew install mplayer

Commands to start streaming
You will need to have two terminal windows open on your laptop. One will be for the RPI and the other will be a local terminal. Start MPlayer on the local terminal. It will listen for the video stream from the RPI. MPlayer should always be started first.The video stream on the RPI will be started using raspivid which pipes the video output to NC.

on the mac terminal : nc -l 5001 | mplayer -fps 31 -cache 1024 –
on the Raspberry Pi : raspivid -t 0 -o – | nc [ ip address ] [port number]
looks like: raspivid -t 0 -o – | nc 172.20.121.152 5001

Now, if only we can figure out a way to get this nice looking, low latency video into Jitter!

Raspberry Pi – Installing Pure Data

Run the following commands on your Raspberry Pi to install Pd-Extended. Make sure you are connected to the internet.
1. sudo pico /etc/apt/sources.list
2. put this line in the file and save: deb http://apt.puredata.info/releases wheezy main
3. sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-key 9f0fe587374bbe81
4. sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-key D63D3D09C39F5EEB
5. sudo apt-get update
6. sudo apt-get install pd-extended

You can run Pd-Extended using the Rasberry Pi Gui –

1. type start x on the command line to start the RPI GUI
2. In the start menu in the bottom left look for Pd-Extended and open it
3. command / will start the audio

or you can run Pd-extended remotely with the following command. you’ll need to upload a working Pd patch to the Pi.

pd -nogui /home/pi/

change “youfile.pd” to be the name of the Pd file you would like to run.

My command looked like this:

pd-extended -nogui /home/pi/pd/pi1-osc.pd

Use the 1/8th inch stereo audio port on your Pi in order to hear the sound via a sound system. If your Pi is connected to a HDMI video monitor then the sound will default through the video monitor’s speakers.

Raspberry Pi – TimeLapse Video

Here are instructions for capturing and compiling a time-lapse video using a Raspberry Pi and the PiCamera module.

Upload and edit the time-lapse video script

1. Connect to your pi via the terminal :

ssh pi@10.0.1.17

change the IP address to match your Pi

2. Create a 'scripts' directory in your home folder of your pi:

mkdir scripts

3. Open a new terminal window to work locally on your laptop. Put the time-lapse Python script on your desktop.

4. On your laptop terminal type the following to upload the time lapse python script to your pi:

scp /Users/dwingus/Desktop/TL.py pi@10.0.1.17:/home/pi/scripts

Change "dwingus" to your laptops username and change the IP address to match your Pi

5. You can edit the TL.py to change the filenames or the speed at which images are captured.

sudo nano TL.py

Make your changes and then save the file.

Stream the video feed from your Pi to your laptop to setup the camera

You will need to install two applications on your laptop to make this step work. You will install HomeBrew and MPlayer

HomeBrew is a package installer for Os X. Installing HomeBrew will allow you to easily install MPlayer. It will also allow you to use additional unix commands that are not included in a standard Os X install.
1. Go here: http://brew.sh
2. Scroll to the very bottom of the page and follow the "Install Homebrew" instructions.
3. The first thing to do after installing HomeBrew is to type into command line:

brew doctor

4. Type the following to install MPlayer

brew install mplayer

You will need to have two terminal windows open on your laptop. One will be for the Pi and the other will be a local terminal. Start MPlayer on the local terminal. It will listen for the video stream from the Pi. MPlayer should always be started first. The video stream on the RPI will be started using raspivid which pipes the video output to NC.

You will need to know your laptops IP address in order to send a video stream to it. To do so go to System Preferences / Network and make note of the IP address. You will need it in the following steps.

on the mac terminal type the following command:

 nc -l 5001 | mplayer -fps 31 -cache 1024 - 

This starts MPlayer and has it wait for an incoming video stream.

on the Pi terminal type the following command:

raspivid -t 0 -o - | nc [ ip address ] [port number] 

My command looked like this:

 raspivid -t 0 -o - | nc 172.20.121.152 5001 

This starts the Raspivid and pipes its output to your laptop. You should now see the video stream from the Pi Camera in MPlayer on your laptop. This will allow you to adjust the PiCamera remotely in order to setup a nice shot for capturing a time-lapse video.

Running the Python time-lapse script
Once you have setup a nice shot do the following to start capturing images:

Start the time-lapse python script with the following command:

sudo python /home/pi/scripts/TL.py

This will start the image capturing sequence. The script will automatically create a new time-lapse folder with a time stamp in the folder name. It will then start saving JPG files into the folder. There will be many JPG files! You may need a bigger SD card!

To have the script start immediately on boot:

sudo nano /home/pi/.bash_profile

Put the following in the bottom of the .bash_profile file:

python /home/pi/scripts/TL.py

Save the file and reboot

Compiling the JPG files into a time-lapse MP4 movie

Navigate to the time-lapse folder and list the file names into a text file.

sudo ls *.jpg > stills.txt

Run apt-update on the Pi to update all of the library packages

sudo apt-get update

Install a program called mencoder

sudo apt-get install mencoder

Navigate to the time-lapse folder containing your JPG files and run the following command to create a movie file

mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=24 mf://@stills.txt

This will take a while depending on how many images there are to process. Once the process is complete you should see a file called timelapse.avi in the folder.

To play the movie:

omxplayer -o hdmi timelapse.avi

Raspberry Pi – HD video player demo

The video below demonstrates using a Raspberry Pi micro-computer as a standalone, high-definition video player for use in museums, galleries or any space equipped with an HDMI capable flatscreen monitor or projector. The RPI provides an inexpensive alternative to using a laptop, Mac Mini, or DVD player for the display of high definition content by video-artists, film-makers, and photographers. I’ve written a script which makes the system extremely easy for anyone to use. Simply connect the RPI to a video display with a HDMI cable and power up the RPI. Once the RPI boots, it will immediately play and loop a series of files stored in a folder designated by the user. It will run for days without a hitch.

With an additional usb WIFI stick attached to the RPI, a user can remotely connect and change what files play or upload additional content. In addition, the RPI uses an SD card for its file system providing easy backup capability and a simple way to exchange content. The script I’ve written uses the RPI’s stock system resources and does not rely on third party code which would require download, installation and future updates.

I will be teaching a workshop on the RPI HD video player at Machine Project in Los Angeles on August 20th and 22nd, 2013. Details about the workshop will be available soon.

Gramophone review of In the Beginning

I recently came across a review in Gramophone Magazine of David Rosenboom’s In the Beginning double CD set that I recorded and mixed last summer for New World Records. The reviewer complemented the sound quality which makes me happy considering the amount of work that went into the project!

“In the Beginning II, for example, is an exploration by Rosenboom of an overwhelming, embryonic dread, with uneasy Indian harmonies and a splendid gong – an audiophile demo piece for low electronic bass”

“The studio recordings made since 2009 at the California Institute of the Arts vividly document the new sounds possible with configurations such as eight trombones (all played by Mike Svoboda) or a keyboard and two oranges, are complimented by live performances from 1979 and 1980 with Don Buchla’s 300 Series Electric Music Box.”