Fyi: embedded raspberry pi, monome, gate inputs – sequencer – tutorial :)

after some more months of trial and error, i’ve compiled an up to date walkthrough for getting puredata and the grid to run from scratch on the raspberry… you can find it here: https://docs.google.com/document/d/1X6XEBOFWkDXBDxmBkIWtTUYur-g2f80m3U3KS3RrLB8/


dear all,
coming from a mac and max/msp and with no clue about electrical engineering, raspberries, pure data, github, compiling files and all the like, i was able to build myself an embedded sequencer with gate/clock input within ~4 days :slight_smile: (not meaning to brag here – just trying to encourage anyone to do the same as it’s much easier than i thought and so incredibly rewarding!).

i had massive help from dan (@dan_derks) and paul (@pxxlhxslxn) – many of the steps listed are actually copied 1:1 from their messages. others i gathered from google, electronics.stackexchange.com (a guy by the name of “Volodymyr Smotesko” was super helpful) and obviously the monome docs (thanks to brian @tehn, as always).

i put together a detailed, low level list of to-do’s for anyone who’d like to give it a shot. following these few steps is probably all you’ll need to do to get it to work.

the PD patch is roughly based on a very slimmed down version of a monome 256 sequencer i’ve been working on the past ~1.5 years. i’ll happily share it, but i’ve never managed to finish a 128-version so i am thinking it may be to exotic to drop it here. def let me know if you want the application, how ever – it’s running well and i’m hoping to make a new video of the current state sometime soon.

here’s a short clip of the (new) PD sequencer with the rPi and a little breakout-box: https://youtu.be/5BPoXEU9Nzc


1) SET UP RASPBERRY PI (3, Model B)

(more or less in dan’s words :)) »

  1. grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/1

  2. use ApplePiBaker (https://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/1) to format the SD card, or follow these instructions: http://blog.smalleycreative.com/linux/setup-a-headless-raspberry-pi-with-raspbian-jessie-on-os-x/ . usually the SD card ejects immediately after, so just pull out and put back in for the next step:

  3. make sure you execute this in Terminal afterward: touch /Volumes/boot/ssh to enable ssh in.

  4. eject SD Card, throw it into the Pi, plug into ethernet and power up!

  5. use this (http://angryip.org/download/#mac1) to find your Pi’s IP address. if you don’t connect the rPi to a (wifi-)router but directly to your mac via ethernet » turn on internet sharing on the mac. select “bridge100” in angry ip scanner (by pressing the “ip” button next to hostname). it worked for me scanning the range 192.168.2.1 - 192.168.2.255

  6. SSH into your Pi (https://www.raspberrypi.org/documentation/remote-access/ssh/unix.md). default credentials are username: pi / password: raspberry

  7. if you run into a weird error (“someone is doing something nasty”), just follow these steps: https://www.digitalocean.com/community/questions/how-can-i-get-rid-of-warning-remote-host-identification-has-changed. basically you just need to “ssh-keygen -R hostname” on the mac (replace “hostname” with the PI’s address), then reconnect

  8. after that, sudo raspi-config and Expand the Filesystem, change your password.

  9. sudo apt-get update and sudo apt-get dist-upgrade to update and upgrade!

  10. follow these VNC instructions to access a GUI over the network: https://www.raspberrypi.org/documentation/remote-access/vnc/. note: you won’t be able to run it cloud-based unless you plug in a monitor/keyboard/mouse…the setting just won’t present itself.

  11. dan’s found that running VNC with vncserver -geometry 1080x768 is the most friendly config


2) SETUP PURE DATA / PD-L2ORK / PURR DATA

note: this got me reeeeelly confused! so many weird PD versions around! :fearful: … to sum it up as i understood:

· pd-extended is dead; besides it having tons of externals pre-installed, there’s no real necessity (reason?) to use it.

· pd (vanilla) is maintained. since its new version, it has an external-manager (referred to as “deken”) implemented – you can download externals via help » find externals. the cyclone library ports loads of max objects.

· pd-l2ork (or purr data) is a different version that’s supposed to run well on rPis (if i get this right). this is the version i am using, because: there is currently no rPi build of the “mrpeach”-externals for pd-vanilla. these externals include all the OSC and UDP stuff you’ll need for the monome. i’m sure with a little more research it’d be possible to use vanilla pd, but – i’m still at the very beginning. so »

to sum it up: on my mac, i’m patching in vanilla pd using the cyclone v0.3 and mrpeach exernals. on the rPi i’m running pd-l2ork. transfering the patches from one to the other is almost seemless, but due to the fact that pd-l2ork runs cyclone v0.2 on the rPi (as apposed to v0.3 on the mac / pd vanilla), there are some small perks as for a few objects; weirdnesses such as “Uzi” needing to be spelled with a capital “U”, arguments for some objects not doing what you’d expect them to do and so on. you’ll become aware of this quite quickly. also, a cyclone v0.3 build for rPi is in the making and should be released within the next few days (https://github.com/porres/pd-cyclone/releases)

so, let’s set pd-l2ork up on the rPi:

  1. follow these instructions (probably starting at step 3): http://l2ork.music.vt.edu/main/make-your-own-l2ork/software/raspberry-pi/ – you may skip the IP stuff if your rPi is already (net)working and you should use the newest pd-l2ork build from https://github.com/agraef/purr-data/releases (so wget [newest link] – not the one stated in the doc). i used the raspbian armv7 deb file on my rPi 3 model b

  2. sudo dpkg -i pd-l2ork*deb to install … you’ll probably get errors

  3. sudo apt-get update && sudo apt-get -f install to get the missing packages

  4. run pd-l2ork -version to test if pd-l2ork is working … you should get smth like:
    $ Pd-L2Ork version 2.2.1 (20170528-rev.5bfda30)
    $ compiled 19:21:04 May 28 2017

  5. you can now start pd-l2ork via the start-menu


3) SETUP MONOME

important note: i am only able to run serialosc by executing serialoscd (with a “d” at the end). don’t know what’s up with this; maybe @tehn knows – but it appears to work this way :slight_smile: think all the following is from the docs:

  1. The first things to build are libmonome and serialosc, so you need to install their dependencies.
    sudo apt-get install git libconfuse-dev liblo-dev libudev-dev libavahi-compat-libdnssd1 libavahi-compat-libdnssd-dev
    There are no released tarballs of libmonome or serialosc yet, so you’ll have to checkout their source code from git. This is much easier than it sounds!
    mkdir git
    cd git
    git clone https://github.com/monome/libmonome.git
    git clone https://github.com/monome/serialosc.git

  2. Build libmonome first:
    cd libmonome
    ./waf configure
    ./waf
    sudo ./waf install

  3. Now build serialosc:
    cd ../serialosc
    ./waf configure (probably an error, so git submodule init && git submodule update. and then repeat step 2)
    ./waf
    sudo ./waf install

  4. Next, plug in your monome and run serialoscd from a terminal. You should see something like this:
    $ serialosc
    $ serialosc [m128-000]: connected, server running on port 18872

  5. Unplug your monome so that it saves its current configuration to ~/.config/serialosc/, including port number. Press Ctrl-C to stop serialosc.

  6. Now restart serialosc, then plug and unplug your monome to get your config saved. If you need to change any aspect of your monome, such as its rotation in 90-degree increments, edit ~/.config/serialosc/.conf. You can also set the application prefix, host, and port numbers.

note from paul, if something doesn’t work:
alright, here’s what I had to do to get it working:

  1. from the serialosc git directory, run: git checkout -b stable > git reset --hard c46a0fa5ded4ed9dff57a47d77ecb54281e2e2ea This will create a new stable branch, and point it to the 1.4 release commit.
  2. Run ./waf distclean && ./waf configure, then ./waf and sudo ./waf install as per the normal instructions
  3. Once it’s installed successfully, where the instructions say serialosc, throw a d onto the end of it: serialoscd.
  4. From here, I was able to get a device (mostly) recognized and working with a little test script
  5. I say “mostly” above because I still ran into a couple of segmentation faults when plugging the device in or unplugging it. I had to run ps aux | grep serialosc a few times to check if there were orphaned processes, and had to kill them a few times. Some combination of “plugging the grid in, and then running serialoscd” or the other way around worked.
  6. lastly, you will want to grab the pd gridstudies patches to see if it is all working!

4) AUTOBOOT INTO PD PATCHES

edit as of JULY 10: finally found out how booting works into desktop and/or command-line interface. my route may be kinda messy, but this works for me :slight_smile: here we go:

  1. sudo nano /home/pi/pdstart (to create or edit your bootscript-file)

  2. add these lines to the file
    sleep 5
    serialoscd &
    sudo pd-l2ork -nogui -mididev 1 /home/pi/...pathToYourPdFile.pd &
    mind the “&” at the end of the lines! as for “sleep 5” – you may not need that.

  3. sudo chmod 755 pdstart (for privilges)

  4. go to folder /etc/init.d/

  5. sudo nano local.autostart (create this file or edit it, if it’s there)

  6. add ALL of the following to this file:
    #! /bin/ ``### BEGIN INIT INFO
    # Provides: local.autostart
    # Required-Start: $start
    # Required-Stop: $shutdown
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Short Description
    # Description: Long Description
    ### END INIT INFO
    # Author: Name
    # run the script you created
    sh /home/pi/pdstart

  7. finally:
    sudo chmod 755 local.autostart (for priviliges)
    sudo update-rc.d local.autostart defaults (to register your local.autostart file)


5) CONFIGURE SAMBA FOR FILE SHARING

this is no necessary step, but it’s handy to have. i have my rPi connected to the local wifi and can update/upload the patches without needing to unhook it from my modular.
follow these instructions: https://www.elektronik-kompendium.de/sites/raspberry-pi/2007071.htm – notice: it’s probably enough if you only do all this for user “pi”. important: use absolute paths in smd.conf file (so smth like /home/pi/Desktop/share)


6) HARDWARE: ADDING CLOCK / GATE INPUTS TO YOUR rPI

note that this circuit only works for gates! the GPIO pins on the rPi are digital and we’re not ADC’ing. yet, it’s very doable (i’ve read you may want to use an arduino for the translation) and if anybody wants to add an instruction, that’d be cool, too! :slight_smile: you’ve got LOADS of inputs on the rPi, so the sky’s really the limit here, i think.

the circuit we’ll be using is dead simple. parts per input cost a buck including the jacks. just mind the direction you’re putting the 2N3904 in – and don’t forgot to ground your jack input (…benni :smile_cat:)

(if you want to add LEDs, too, go this route: tinyurl.com/y7dklshl // Note that R3 there must be of high value because it lowers the output voltage. You don’t want output to be too low. The LED will be inverted just as the outputs: when the input is low, the LED will be ON. R4 can be replaced with 560 Ohm for more brightness.)


7) IN PD: ACCESSING THE PINS

  1. as for the software, we’ll be using the PDwiringPi externals from https://github.com/garthz/pdwiringPi, so
    github clone https://github.com/garthz/pdwiringPi on your rPi
  2. make in this folder to build the externals
  3. point pd-l2ork to the externals (something like edit » preferences » filepaths)
  4. restart pd-l2ork and see if you can access the pins. some vague instructions and an example patch can be found over here (rather dead webspace, so i’ve pastebinned the patch here to preserve it)

note: it was necessary for me to run pd-l2ork as root (sudo pd-l2ork) for these externals to work! to get the current states of pins, you need to poll them (use a metro at a high interval – i’m doing 1ms)


that’s it! have fun! :slight_smile: (and again – suuuuper big thank you for the help i got from dan & paul <3)

37 Likes

woah, kudos for taking the time to share all of your collected knowledge with the community!!
immensely useful for anyone diving in, but especially with no prior knowledge :hushed: :ok_hand:
it really feels like a revival right now… should dust off mi pi too and join the headless club.

2 Likes

absolutely! for me as an absolute novice, this is such a neat thing to do… finally having what feels like a standalone sequencer – and even having it speak to my modular is … just … woah! :joy:

1 Like

tbh, I partly blame the excellent monome eurorack modules for the dust :smile:
but building your own stuff is really another experience. and also less expensive with something like a pi. and much more flexible. you also made it super accessible now.

1 Like

hey benniii, awesome work collating all this together! just a quick note though, the steps described in section three are not my work, but from the amazing @rknLA on the Raspberry Pi + Monome thread.

Thank you! I am totally going to use this guide.

I’ve been looking at the new Raspberry Pi Zero N for exactly this application, which given its wireless/bluetooth capabilities would require changes to certain elements of this cookbook, but not many.

Does that HARDWARE: ADDING CLOCK/GATE INPUTS work with the Bela platform or BeagleBone black?
How about schematic for outputs (gate and modulation)?

1 Like

RPi’s GPIO pins are logic gates, meaning 3.3V is high/on, whereas 0V is low/off. Bela/BBB’s pins are analog ins. They will accept any voltage from 0-4V+ And the actual voltage value can be read from the pin. You will want a summing amplifier to convert bipolar voltages to unipolar, and also to scale the range.

You can use this calculator to find the right resistor values.

1 Like

wow jason! really happy about that link – this is rocket science for me :slight_smile: … a really novice question (in line with this whole post kchkch):

am i getting it right that i simply need to adjust the values (and reproduce the circuit) on this page to convert CV also for arduino / teensy etc? i really know nothing about this stuff and am super eager to learn some more, but i’ve read that a good route to get analog voltage into the rPi is via one of these microcontrollers…

and what would happen if my input-signal over/understeps the voltages (-5/5) i’m preparing the circuit for? apparently this happens in eurorack-land?

thanks for this link, very appreciated!

I certainly can’t claim to be an expert. Just now learning about these things for the first time myself.

And that calculator leaves a ton of wiggle room, so I’m not 100% confident about the best way to use it.

But you’d want to put your input ranges into the top two fields (for eurorack that’s usually going to be -10V to +10V or -5V to +5V) and the output ranges into the next two fields (0V to +4V for Bela.io). Then you want a reference voltage. I use an IC to get this and I’ve ordered 3.3V reference voltage ICs, if I remember correctly (all this stuff is sitting next to my breadboard right now waiting for me to get around to it). Then you play with the resistor values until everything lines up. You want to choose resistor values that allow you to use simple and common resistors, so you aren’t overspending on weird resistor values.

The circuit scales voltages. So, in the example above, -10V becomes 0V and +10V becomes +4V. You can make them scale to whatever you want. Just use the values appropriate for your use case.

The consequences of getting it wrong can involve releasing the magic smoke. For example, you really don’t want negative voltages of any kind going into a Bela analog input. It will fry the board.

As for out-of-expected-range voltages, I think you can protect yourself from that using diodes. This is something I haven’t investigated as deeply yet.

this is great!!!, i just got two raspis for devel so i’ll do this for sure. I have already set up l2ork/purr I am also going to add Analog knobs and ins for them but i would love to use my monome stuff as an interface for the raspis. FUN

BTW, it is essential to run headless for any heavy lifting [SPECTRAL/FFT, Long Sampling] IMHO

@shreeswifty, any good tips / tuts for running this config headless?

@dan_derks – i’ve updated the manual for the auto-booting procedure
(as i’m so terrible with this stuff, it took me aaaages! there are like gazillion ways to boot and this is the only one that worked for me after loads of approaches)

1 Like

I really need to try this.

As I happen to only have a arduinome 8x8 at hand, I wonder, if your PD patch could be converted to run with an 8x8 grid.

Any chance to get a copy of that patch file?

sure… but it’s super chaotic and barely tested! it’s really only a quick sketch of the big one one for now, to see how PDs working for me :slight_smile:
pdpatches v04.zip (38.0 KB)

Thanks a lot, this will be quite helpful.
Some learning ahead, though.

Great!
I tried this years ago on a 1st Gen raspberry PI and some python scripts (no way that thing would run PD smooth enough) This seems like a good approach. Haven’t got a Pi lying around but trying it on a PocketCHIP. So far so got, I’ve got the crashing serialosc deamon, but if I keep retrying it eventually looks stable…

to complete the pd-l20rk i had to “apt-get install libnss3”

PD lork installed and runs, but I can’t find monome, I will try and recompile serialosc as suggested above

what’s that? :open_mouth: :face_with_raised_eyebrow: