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 was written for an older iteration (circa 2014) Raspberry Pi OS. Therefore some of steps may be different on newer releases. Please note that the goal of the provided setup is to provide parity with the L2Ork’s RPi Orchestra setup, which in part also includes the installation of the RPi version of Pd-L2Ork. Steps outlined below 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 “-Y” flag that allows us to view applications started on RPi on laptop’s screen.

ssh -Y 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 Pd-L2Ork

How?

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

Download Pd-L2Ork for RPi architecture from the Software page. The link is found in the “Download Pd-L2Ork” section under the “Complete (a.k.a. ‘Burrito Supreme’) Installer” header. Note that this link opens in a new tab to allow you to keep your position on this page.

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.

Once the install has completed, you will likely encounter errors because pd-l2ork depends on other external libraries to function. Not to worry, unless you’ve already installed such libraries for other reasons (which is unlikely), this error is expected. To correct this problem, simply type:

sudo apt-get update && sudo apt-get -f install

Once the libraries are downloaded and installed, the computer will automatically configure Pd-L2Ork and report that everything has indeed completed successfully. You should be now 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 2.16.0 (20211208-rev.d3e3d542)
compiled 15:36:14 Dec  8 2021

At this point you should be ready to run Pd-L2Ork because in step 3 we connected to RPi using “-Y” 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 that also calculates dependencies.

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 -Y 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 “-Y” 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.

If you are intending on accessing GPIO or SPI interfaces on RPi to interact with digital and analog sensors, you will need to run pd-l2ork with sudo privileges that grant you access to system devices. To do this, simply type:

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

If you are connecting to RPi via network you may also need to use the -E flag like so:

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

For K12 module simply add the -k12 flag right after the pd-l2ork command.

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. Pd-L2Ork, however, tries to make this a relatively simple 3-step process. First you will need to 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, follow the step-by-step instructions below to generate and then install the newly generated package.

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:

make all

Once the install deb package has been generated, simply follow the install instructions provided above. Hope this helps!

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

Share Button