Sonic Pi

Hi, I just bumped into Sonic Pi project and I am wondering if it would be possible to integrate it into Zynthian. I would use external hdmi display for it, but it would be cool if Sonic Pi could be used as a separate layer on Zynthian.

3 Likes

I think Mr @C0d3man has something to say about … :wink:

Sonic-Pi uses supercollider-server (scsynth) as backend and sends messages via OSC. sonic-pi seems to be “only” the frontend. IMHO: first there is a scsynth-engine needed.

Hmmmmm… I have to think about that. Sounds easy… but who will know?

1 Like

Hi @pavel @jofemodo

I tried to add sonic-pi from the buster-repo (apt-get install sonic-pi) but there were problems getting sonic-pi running. So I decided to write my own recipe:

install_supercollider.sh (927 Bytes)
install_osmid.sh (167 Bytes)
install_sonic-pi.sh (891 Bytes)

After some changes I got the binary of sonic-pi running, but there are some problems with starting background services (seems to be a problem with a path: the start script (/zynthian/zynthian-sw/plugins/sonic-pi/app/gui/qt/rp-app-bin) seems to look at /usr instead of /zynthian/zynthian-sw/plugins/sonic-pi/).

Has anyone an idea what is going wrong?

[EDIT] Ok, I found that running “cd /zynthian/zynthian-sw/plugins/sonic-pi/app/gui/qt/build && sonic-pi” starts scsynth in the background - but after that, nothing happens… have to check the files in /root/.sonic-pi/log

[EDIT2] Maybe this is also necessary:

mkdir -p /usr/lib/SuperCollider/plugins
ln -s /usr/local/share/SuperCollider /usr/lib/SuperCollider/plugins/

Regards, Holger

1 Like

Ok, got sonic-pi/supercollider/sc3-plugins running (all from github)! :smile:

The build scripts are here:

install_supercollider.sh
install_osmid.sh
install_sonic-pi.sh

(maybe you have to run apt update before starting any script)

After installation you have to login via ssh (ssh -X root@zynthian.local) and start sonic-pi by typing:

/zynthian/zynthian-sw/plugins/sonic-pi/app/gui/qt/build/sonic-pi

If everything works, Zynthian engine code for supercollider and sonic-pi could be created.

Regards, Holger

P.S.: Thanks @jofemodo for the autoconnector! sonic-pi works without problems after starting :smiley:

4 Likes

HI @pavel,

I have tried to find some sonic-pi code which does “something” usable, like a drum pattern or a MIDI-synth - but found nothing. Do you have an idea where to find such code?

Regards, Holger

There are some examples here: http://sonic-pi.net/#examples

in_thread do
  use_synth :fm
  sleep 2
  loop do
    28.times do
       sample :drum_bass_hard, amp: 0.8
       sleep 0.25
       play :e2, release: 0.2
       sample :elec_cymbal, rate: 12, amp: 0.6
       sleep 0.25
     end
     sleep 4
   end
 end

 use_synth :tb303
 with_fx :reverb do |rev|
   loop do
     control rev, mix: rrand(0, 0.3)
     with_fx :slicer, phase: 0.125 do
       sample :ambi_lunar_land, sustain: 0, release: 8, amp: 2
     end

     control rev, mix: rrand(0, 0.6)
     r = rrand(0.05, 0.3)
     64.times do
       play chord(:e3, :minor).choose, release: r, cutoff: rrand(50, 90), amp: 0.5
       sleep 0.125
     end

     control rev, mix: rrand(0, 0.6)
     r = rrand(0.1, 0.2)
     with_synth :prophet do
       32.times do
         sleep 0.125
         play chord(:a3, :m7).choose, release: r, cutoff: rrand(40, 130), amp: 0.7
       end
     end

     control rev, mix: rrand(0, 0.6)
     r = rrand(0.05, 0.3)
     32.times do
       play chord(:e3, :minor).choose, release: r, cutoff: rrand(110, 130), amp: 0.4
       sleep 0.125
     end

     control rev, mix: rrand(0, 0.6)
     with_fx :echo, phase: 0.25, decay: 8 do
       16.times do
         play chord([:e2, :e3, :e4].choose, :m7).choose, release: 0.05, cutoff: rrand(50, 129), amp: 0.5
         sleep 0.125
       end
     end
   end
 end

Hi @ll,

there is a cool tool available for Sonic-Pi: sonic-pi-tool. With this tool you can start/stop the server and send ready-to-play scripts to the server from command line. No need for the GUI! So a sonic-pi-engine is much more easier to implement.

Here is the recipe for my installation:

cd $ZYNTHIAN_PLUGINS_SRC_DIR
sudo apt-get install -y --no-install-recommends cargo
git clone https://github.com/lpil/sonic-pi-tool.git
cd sonic-pi-tool
cargo install --git https://github.com/lpil/sonic-pi-tool/ --force
ln -s /root/.cargo/bin/sonic-pi-tool /usr/local/bin/
mkdir -p /usr/lib/sonic-pi
ln -s /home/pi/zynthian-sw/plugins/sonic-pi/app/server/ruby /usr/lib/sonic-pi/server
cd $ZYNTHIAN_PLUGINS_SRC_DIR

For testing, login via ssh zynthian.local and fire up:

sonic-pi-tool start-server >/dev/null 2>&1 # or with debug output: sonic-pi-tool start-server

and in another ssh-session:

echo "play :C4" | sonic-pi-tool eval-stdin

or

sonic-pi-tool eval-file path/to/code.rb

Have fun!

Regards, Holger

1 Like