Raspberry Pi

Introduction

Raspberry PiAs of April 2013, L2Ork is proudly supporting Raspberry Pi (RPi) platform. Below are instructions on how to get started, including how to remotely connect to RPi and share its own internet connection with RPi, as well as a collection of external resources with additional information. While it is perfectly reasonable to use RPi independently by connecting it to its own screen, mouse, keyboard, and the internet connection, the instructions below focus on an alternative setup where RPi is running headless. This means we will connect to it via the laptop, use laptop’s keyboard, touchpad, screen, and speakers, and share laptop’s internet connection to allow RPi access to the internet.

The following tutorial should not take more than 5-10 minutes assuming you have a fast internet connection and have the following hardware/software handy:

  • One laptop with Ubuntu 12.04 (or newer) with at least 1 USB, 1 ethernet port, and a working wireless internet connection
  • One Raspberry Pi (RPi) with USB power cable and an ethernet (network) cable
  • One SD Card with PdPi Raspbian image installed on it

For additional information on how to install the said Raspbian pdpi image that includes a number of audio-related optimizations, visit pdpi website.

Instructions

Step 1: Connecting to RPi

First we will connect to RPi, so that we can reconfigure its settings to better fit our specific needs as well as set up internet connection sharing to install software libraries necessary to run Pd-L2Ork, and eventually Pd-L2Ork itself.

1. On your laptop configure a new ethernet network connection with a static IP of 192.168.1.1.

How?

Network Manager Disable WirelessMake sure that your laptop has its wireless internet disabled to prevent confusion between the two network interfaces (wireless an wired). Do so by disabling “Enable Wireless” option in the Network Manager top-panel menu accessible by clicking on the top-panel network icon.

Network Manager Edit ConnectionsNext, open Network Connections window by clicking on “Edit Connections…” option in the Network Manager top-panel menu.

Create ConnectionIn the Network Connections menu select “Wired” tab and then click on “Add.”

Create Temporary RPi Connection 1st StepCreate Temporary RPi Connection 2nd StepCreate a temporary RPi network connection with appropriate settings.

Why?

By default, RPi’s IP address (as per pdpi website) is 192.168.1.2 and so we want to ensure that our laptop is within the same “domain” to be able to see RPi on its network. Given that this is a common IP address for local area network (LAN), we need to make sure that the laptop is not already connected to such a network using its wireless connection. Otherwise, computer may be confused as to which connection it needs to use to access RPi’s IP address.

2. Connect the RPi and laptop using ethernet cable and power it via USB port

How?

RPi SD CardBefore connecting anything, make sure that your SD Card is properly seated inside RPi.

Connecting RPi to ComputerUsing a generic ethernet cable connect the RPi ethernet port with that of your laptop. Similarly, using a micro-USB cable connect RPi micro-USB port with one of laptop’s USB ports to provide power the RPi.

RPi LEDsOnce RPi is powered and booted you should get all 4 LEDs lighting up (one red, two green, and one yellow, with ACT LED occasionally blinking, showing CPU activity). Please note booting RPi may take up to a minute.

Why?

RPi requires power to run. Laptop’s USB port typically provides adequate power for RPi, thus allowing for greater mobility. Similarly, we need RPi to be networked with the laptop so that we can access, configure, and eventually use it remotely without the need for a separate monitor, keyboard, mouse, etc.

3. Open Terminal application and login remotely into RPi using secure shell (ssh)

How?

Copy following code and paste it into terminal:

ssh pi@192.168.1.2

When prompted, enter RPi password which is 3.14159 and you should be in.

Why?

Remote login allows us to connect to RPi and configure it. This is important as we will need to allow RPi to share laptop’s internet connection, as well as install necessary software in order to be able to run Pd-L2Ork. We use ssh (secure shell) that allows to securely communicate with RPi and eventually view its desktop over the network.

Step 2: Getting RPi on the Internet

Given that we also may need to download additional packages from the internet, we will also set up our laptop used to connect to RPi to share its internet connection with RPi. To do this we will need to reconfigure RPi static IP and set up a special ethernet connection between the laptop/computer and RPi.

1. Change RPi’s static IP address to 10.42.0.10

How?

We will alter RPi’s static IP address, so that once we set up the internet connection sharing on the laptop (which by default in Ubuntu generates 10.42.0.* IP address range), RPi remains within the same domain as the laptop. To do this, we need to edit the /etc/network/interfaces file. Since this is a system file, we will do so by using sudo command that will temporarily grant us administrative privileges:

sudo gedit /etc/network/interfaces

You may be asked sudo password, which should be the same as the RPi login password. Now find the following line:

iface eth0 inet static

and change contents below it as follows:

netmask 255.255.255.0
address 10.42.0.10
gateway 10.42.0.1

Then, save the file. Once you’ve edited and saved the file, reboot RPi for the network changes to be updated.

sudo shutdown -r now

Upon rebooting, you will not be able to connect to RPi and this ok because RPi now has a new IP address that places it into a different domain. Next, we will reconfigure our laptop’s network connection so that it can once again connect to RPi.

Why?

We need to reconfigure RPi’s static IP address so that it falls within the range that will be visible to our laptop once we enable internet connection sharing (a.k.a. network bridge). This way, RPi will be able to access the internet by first going through the laptop and then through its wireless connection. We will use this connection to retrieve software libraries Pd-L2Ork relies upon. Please note that we can use any IP address that falls in the range between 10.42.0.2 and 10.42.0.255 (10.42.0.1 is reserved for the laptop). In this tutorial we chose 10.42.0.10 that may be a bit easier to remember.

Key commands used in this step are sudo, gedit, and reboot. sudo command grants us “superuser” or administrator access, so that we can alter important system files as well as order computer remotely to reboot. gedit command starts Gnome text editor.

2. Set up new internet sharing connection

How?

Network Manager Edit ConnectionsNavigate back to the Network Manager top-panel menu and reenable wireless connection. Wait for the wireless connection to come back online and then click on “Edit Connections…”

Create ConnectionIn the Network Connections window, delete the old temporary connection we created earlier–we won’t be needing this anymore. Then, add a new connection by clicking on the “Add” button.

Create RPi Shared ConnectionCreate RPi Shared Connection IPv4 TabWe’ll call the new connection “Raspberry Pi Shared Connection.” On the IPv4 tab make sure to select “Shared to other computers” method. Also make sure that the “Require IPv4 adressing for this connection to complete” option. Save the newly created connection.

Connect to RPi Shared ConnectionIn the Network Manager top-panel menu click on the Raspberry Pi Shared Connection and wait a few moments for the Network Manager to indicate that the connection is active. We are now ready to reconnect to RPi using its new IP address.

Why?

Doing so will allow us to bridge laptop’s internet connection to RPi so that internet data can freely flow from wireless over ethernet to RPi and back. This will enable us to install the necessary libraries Pd-L2Ork relies upon, and eventually Pd-L2Ork itself.

Step 3: Install Pd-L2Ork and supporting libraries

By now we should be ready to begin installing software. First we will connect to RPi’s newfound IP address.

1. Connect to RPi via ssh using new IP address

How?

Once again, we use ssh, but this time we also pass it a “-X” flag that allows us to view applications started on RPi on laptop’s screen.

ssh -X pi@10.42.0.10

When prompted, enter password which is 3.14159.

Why?

Doing so will allow you to access RPi and configure it properly for use with Pd-L2Ork.

2. Make sure you are able to access the internet

How?

ping -c 3 l2ork.music.vt.edu

If everyting works ok, you should be getting output similar to the one below:

…icmp_req=2 ttl=48 time=124 ms

Why?

We need to make sure your internet connection is working before instructing RPi to install new software, as the software will have to be retrieved from the internet. ping command sends a simple signal to a desired address and lets us know how long it has taken for a signal to return to us. This is arguably the simplest way one can make sure that they are indeed connected to the internet. Otherwise, the signal will never reach our desired destination resulting in an error.

3. Install software libraries Pd-L2Ork depends on

How?

Enter following commands to install libraries Pd-L2Ork depends on. Once again, we will use “sudo” command to install libraries system-wide. The installation may take several minutes or even longer depending on the speed of your connection.

sudo apt-get install bison flex automake qjackctl tcl-dev tk-dev libasound2-dev libjack-jackd2-dev libtool libbluetooth-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libmagick++-dev libftgl-dev libgmerlin-dev libgmerlin-avdec-dev libavifile-0.7-dev libmpeg3-dev libquicktime-dev libv4l-dev libraw1394-dev libdc1394-22-dev libfftw3-dev libvorbis-dev ladspa-sdk dssi-dev tap-plugins ladspa-foo-plugins invada-studio-plugins-ladspa blepvco swh-plugins mcp-plugins cmt blop slv2-jack omins ubuntustudio-audio-plugins rev-plugins libslv2-dev dssi-utils vco-plugins wah-plugins fil-plugins mda-lv2 libmp3lame-dev libspeex-dev libgsl0-dev portaudio19-dev python-dev libsmpeg0 libjpeg62 tkpng flite1-dev libgsm1-dev libfftw3-dev libgtk2.0-dev subversion git libstk0-dev libsndobj-dev libfluidsynth-dev x-ttcidfont-conf defoma tclxapian

Why?

Pd-L2Ork depends on these libraries. They provide signal processing tools (e.g. audio, video, 3D, etc.) as well as graphic user interface (GUI) toolkits Pd-L2Ork needs to interact with the user. apt-get command is like a centralized install system that knows file locations of  thousands of different software packages. Think of it as an app store for Linux where everything is free. Running this command allows system to install requested software packages provided the computer has internet connection.

4. Install Pd-L2Ork

How?

Following is a direct link to the latest version of Pd-L2Ork for the RPi platform.

Download Pd-L2Ork

Given we cannot open a browser (yet) on RPi, the easiest way to download the said package onto RPi via ssh is to copy the link above and use the following command:

wget <paste-copied-link-here>

This will download the latest version of the Pd-L2Ork deb installer. Once the download is complete, type following command to install Pd-L2Ork:

sudo dpkg -i pd-l2ork*deb

NB: If you happen to have more than one Pd-L2Ork deb installer in the folder where you downloaded the latest deb installer, you may need to substitute full file name instead of pd-l2ork*deb.

At this point you should be ready to run Pd-L2Ork on RPi. To test this, type:

pd-l2ork -version

You should get the output similar to the one below:

Pd-l2ork version 20130530
compiled 15:58:16 May 28 2013

At this point you should be ready to run Pd-L2Ork because in step 3 we connected to RPi using “-X” flag that allows us to view applications we wish to run on RPi on laptop’s screen. Therefore typing pd-l2ork in the terminal will open it on the RPi and yet be visible on our laptop’s screen. While this may suffice for power users, beginners may prefer to access RPi’s entire desktop. In the optional Step 4 below we will investigate setting up remote X session so that we can do exactly that.

If you wish to display applications on laptop’s desktop session (rather than viewing the entire RPi desktop) you may skip immediately to step 5. The advantage of viewing only Pd-L2Ork rather than the entire RPi’s Desktop on laptop’s screen is that the networked session will require less CPU resources to “project” on the laptop screen. A potential disadvantage is the difficulty distinguishing applications that are currently running on the laptop vs. those that are networked via ssh.

Why?

This step will install Pd-L2Ork software on RPi which is likely the main reason you’re following this tutorial ;-) dpkg command is a tool designed to install software packaged in deb format. You can think of it as a manual version of the apt-get tool we used earlier.

Step 4 (optional): Configure Remote Desktop Access to RPi

Accessing entire RPi desktop has some additional benefits, one of which includes ability to use Pd-L2Ork icons in the Application Menu that pre-configure various settings at startup and ensure that Pd-L2Ork requires minimal set up from a user.

1. Exit the current ssh session with RPi

How?

Type following command in the terminal:

exit

Why?

We will temporarily disconnect from RPi so that we can configure laptop to display RPi’s desktop.

2. Set up secondary X server on the laptop and reconnect to RPi

How?

Start a new X server session.

IMPORTANT! Please note that once you run the command below your screen will turn all black with the exception of one windowless white terminal located in the top-left corner. This is because your laptop will automatically switch you to the newly created (and currently empty) X (Desktop) session that will be accessible at any time by pressing CTRL+ALT+F8. However, at this point, we want to return back to our primary desktop to finish our configuration. We do so by pressing CTRL+ALT+F7.
sudo xinit -- :1

Once you press CTRL+ALT+F7, you will be back on your primary X (Desktop) session. Press CTRL+z to stop the newly created X session and then type following to background it, so that you can continue using the terminal (otherwise terminal will be unresponsive until the new X session is exited):

bg

Why?

We need to start a new X session that will display RPi’s desktop over network. Doing so will render terminal unresponsive until the current running program is backgrounded. For this reason we use bg (background) command to free-up the terminal so that we can issue other commands to it. Apart from sudo we used before, other commands used in this step include xinit that is responsible for starting a new X session. We pass it a –:1 flag to instruct computer to start a new session on a new virtual display, so that it does not clash with the existing laptop X session.

3. Set up secondary X server on the laptop and reconnect to RPi

How?

Press CTRL+ALT+F7 to return to your primary desktop (X) session. Once there, type the following command in the terminal:

DISPLAY=:1 ssh -X pi@10.42.0.10 lxsession

Raspberry Pi DesktopWhen prompted, enter RPi password (3.14159) and once logged in, leave the terminal open for as long as you wish to maintain remote connection with RPi and switch to the new X (Desktop) session by pressing CTRL+ALT+F8. You should be greeted with the following desktop image. And voila! You are now using RPi through your laptop. With the exception of audio output, everything you do on RPi will be presented to you using laptop resources. You can always listen to audio output by plugging in speakers or headphones directly into RPi audio out connector.

Upon starting the RPi networked X session, the white terminal in the top left corner will now have window decorations. Rather than closing it, simply minimize it for the duration of your X session. Otherwise, closing the said terminal will close the entire X session.

Why?

Once again, we use the “-X” flag, followed by the lxsession command that broadcasts entire RPi desktop onto the laptop’s X session we created earlier and that can be accessed by pressing CTRL+ALT+F8.

Step 5: Run Pd-L2Ork (including K12 module) on RPi

IMPORTANT! Before starting with Pd-L2Ork, please be careful not to damage your hearing by outputting audio at maximum loudness! Despite the fact that Pd-L2Ork K12 module offers built-in features that protect against overpowering audio levels, as is the case with any programming environment, working with Pd-L2Ork can lead to unpredictable results and as such caution is advised at all times, including use of conservative audio levels.

1. Start Pd-L2Ork

How?

1. Type command into the terminal (this is the only option for those who have skipped step 4)

For regular Pd-L2Ork type:

pd-l2ork -noautopatch -rt -audiobuf 50 -inchannels 2 -outchannels 2 -alsamidi -mididev 0

For K12 module type:

pd-l2ork -k12 -noautopatch -rt -audiobuf 50 -inchannels 2 -outchannels 2 -alsamidi -mididev 0

Note the only difference between the two is the “-k12″ flag we use when we wish to run K12 version of Pd-L2Ork.

2. Navigate into RPi’s application menu and click on the Pd-L2Ork application icon (possible only if using remote X session described in optional step 4)

Start Pd-L2Ork from the RPi Application MenuOpen Application Menu by clicking on the icon in the bottom left corner of the screen, then navigate to Sound & Video sub-menu, and select the appropriate Pd-L2Ork version.

Either way, upon starting Pd-L2Ork, you will be presented with the main Pd-L2Ork window:

RPi Pd-L2Ork Main Window

Why?

When starting pd-l2ork remotely without the access to X session, we don’t have the ability to visually navigate application menus, so we use terminal to directly invoke command that would be otherwise invoked by clicking on the application icon.

2. Configure Pd-L2Ork’s Audio Setup

How?

Before we can use Pd-L2Ork we need to adjust default audio settings. This is a one-time step and once the settings have been adjusted you won’t have to go through this step again.

RPi Pd-L2Ork ALSA MenuIn the main window menu click on “Media” and then “ALSA” which stands for Advanced Linux Sound Architecture, or the backbone of audio support in Linux.

RPi Pd-L2Ork ALSA MenuA new window titled “Audio Settings” will pop up. In it, make sure to adjust delay (msec) to 50, and make sure that bcm2835 ALSA (hardware) audio device is selected both for input and output. Once done, click on “Apply,” and then “Save All Settings.” This will ensure that next time you start Pd-L2Ork, the chosen settings will be remembered. Once you’ve saved the settings, you can close the Audio Settings window.

Why?

The default settings Pd-L2Ork ships with are quite ambitious–this is what we use in L2Ork on a daily basis, but our systems have been specially tailored for this purpose. With 5ms default internal latency, systems without a custom real-time kernel (the core of an operating system) and adequate CPU power simply cannot cope with. Since RPi is considered a relatively low-powered device in terms of raw CPU power, we need to adjust settings to that they better match RPi’s capabilities.

3. Test audio

How?

Connect speakers or headphones to RPi’s 1/8″ (headphone) jack.

RPi Pd-L2Ork Test Audio and MIDIIn the main window,click on “Media” menu, and then on “Test Audio and MIDI” option.

RPi Pd-L2Ork Test Audio and Midi PatchA patch window will pop up, populated with various objects and controls. In the top left corner, below the “TEST TONES” heading click on the box that says 60 (this will bring the audio levels up) and check if you can hear the audio coming out of the headphones/speakers connected to RPi.

Why?

Before we can begin using Pd-L2Ork, we need to ensure that the audio is indeed properly configured.

Congratulations, you’re now ready to use Pd-L2Ork on RPi!

 

Compiling Pd-L2Ork for RPi from Source

IMPORTANT! Compiling is typically not for the faint of heart. You will likely need to install various dev packages in order to be able to compile Pd on your own. Therefore, before compiling make sure to install all the dev packages (or their counterparts in your respective Linux distribution) listed at the top of this page. Once ready, click on the arrow below for the step-by-step instructions

To compile Pd-L2Ork on RPi you can follow the instructions for compiling Pd-L2Ork found on the main Software page with one notable exception: after retrieving the source from the git, use -R flag for the autocompile script, like so:

./tar_em_up.sh -R

The rest should be identical. Hope this helps!

Questions? Look us up on the L2Ork-Dev public mailing list.

Share