Sonic Pi v4.0 "Link" is now available for macOS and Windows

Version 4.0.0 ‘Link’

6th July, 2022

Get ready to Jam with v4 of Sonic Pi.

In this release, the internal timing algorithms have been completely refactored to enable them to link to a new global metronome. The GUI now features a new metronome panel which will let you dynamically change the BPM of your code whilst it is running. You can also use the new “Tap Tempo” button to click out a tempo and Sonic Pi will automatically shift to play in time with your taps. Additionally, you can link the metronome with other versions of Sonic Pi running on other computers connected to the same network (wifi or ethernet). This means it is now possible to gather some laptops together to form an ensemble or turn a whole classroom of computers into an orchestra of live coders - and for everyone to be in time with each other. You can even dynamically change the BPM for everyone on the network whilst code is running on everyone’s computers independently and everything maintains synchronised and in time. It’s a real jam.

Finally, you’re not limited to syncing tempo with other copies of Sonic Pi. The new global metronome is built on top of a wonderful piece of technology called Link which was developed and open sourced by Ableton who also make Live and Push, both widely used by professional musicians and also automatically sync using Link. Additionally there are also over 200 other apps or hardware products that also sync with Link. Sonic Pi can therefore now automatically jam with any of these with just a click of a button. It’s so exciting to imagine the new kinds of bands and collaborations that are going to be possible with this new timing system.

There’s also a large number of other improvements and fixes within this release that together combine to form the most powerful and exciting release of Sonic Pi yet. See below for a full breakdown of visible changes.

This release would not have been possible without the huge number of fabulous contributors that have been involved. Key contributions have been a huge refactoring of our GUI by Chris Maughan, the wrapping of Link as an Erlang NIF by Luis Lloret and the tireless and constant attention to detail by Ethan Crawford. Thanks so much to you all. Thanks also to José Valim for financially supporting development during a tricky period. José is the creator of the programming language Elixir which is now integrated into the internals of Sonic Pi. Elixir opens up a rich world of exciting opportunities within Sonic Pi which we have already started exploring with earnest. Expect exciting things for the future and consider becoming a Patreon supporter to automatically get access to all upcoming BETAs…

Finally, we would love for you all to extend a warm welcome to the latest member of the Sonic Pi Core Team: Lily Foster. She brings a huge depth of Linux knowledge to the team and we’re terrifically excited to have her on board.

Now, go and get your Live Coded Jam On!

Breaking Changes

  • The default BPM is now set to the new global Link metronome. This is set to 60 by default, so on the surface the behaviour will appear identical. However, if you change the Link metronome BPM using the GUI or the new fn set_link_bpm! it will change the BPM for all threads dynamically. Previous behaviour (a static BPM of 60 unlinked to the global metronome) can be obtained by starting your code with use_bpm 60.
  • Previously it was possible that the onset: option for sample silently ignored the last onset of a given sample. This has now been fixed. Some samples may therefore have an additional onset index which won’t affect any code using earlier indexes but will affect code which uses indexes larger than the number of onsets (and therefore relying on the index wrapping behaviour).
  • The Minecraft Pi Edition API has been removed (all mc_ fns). Minecraft Pi Edition appears to no longer ship on Raspberry Pi OS and the Pi Edition API is not the same as the standard Minecraft API.

New

  • Support for Ableton Link. This enables you to synchronise the tempo of Sonic Pi running on multiple computers connected on the same network. It will also enable automatic BPM synchronisation with music production tools such as Ableton Live, VJ tools such as Resolume, DJ hardware such as the MPC and many compatible iPad music apps. For a full list see: https://www.ableton.com/link/products/,,
  • New :link option to fn use_bpm. This enables Link mode for the current thread which automatically syncs the BPM to the Link metronome (which also syncs it with all other Link-capable apps running on any computer connected to the local (wired or wifi) network.
  • New fn link which sets the BPM to a new :link mode and also waits until the start of the next bar (as determined by Link) before continuing. This lets you automatically sync tempo and beat phase in one command.
  • New fn link_sync which sets the BPM to a new :link mode, waits for the Link session to be playing and also waits until the start of the next bar (as determined by Link) before continuing. This lets you automatically “arm” Sonic Pi to sync tempo and beat phase and wait for an external “play” command from another Link device - such as Ableton Live.
  • New fn set_link_bpm! to change the BPM/tempo of the Link metronome (and simultaneously change the tempo of all connected Link-capable apps on the network).
  • New fn current_random_source which returns the current random number source kind (see use_random_source).
  • New fn load_synthdef which lets you load a single synthdef file.
  • load_synthdefs now loads both directories and single files (by dispatching to load_synthdef where necessary).

Synths & FX

  • New synth :winwood_lead - a lead synth inspired by the Winwood songs from the early 80s.
  • New synth :bass_foundation - a soft bass synth inspired by the sounds of the 80s.
  • New synth :bass_highend - an addition to the :bass_foundation synth inspired by the sounds of the 80s.

Examples

  • New Algomancer example - Blockgame coded by DJ_Dave.
  • New Sorcerer example - Lorezzed.

GUI

  • Preference pane is now an overlay which hovers over the main window. This means that opening and closing it does not inadvertantly modify a carefully chosen layout e.g. for a performance.
  • New preference option to show and hide the pane titles such as Scope, Log, Cues, Context, Help, etc.
  • New preference option to hide the menubar when in fullscreen mode (Windows and Linux only as this behaviour is standard on macOS).
  • New preference option for enabling audio inputs (now disabled by default). Modifying this setting requires a reboot to take effect.
  • New preference option for selecting the default language translation. Modifying this setting requires a reboot to take effect.
  • Preferences now show audio hardware information such as connected input/out devices, sample rate, block size etc. The amount of information displayed varies by platform.
  • New GUI controls for interacting with the new Link Metronome. You can connect/disconnect to the network (to share tempo with others), change the tempo (in BPM) and tap out a new tempo.
  • Increase width of panel dividers and highlight on mouse hover.
  • Highlight scrollbars and preference checkbox descriptions on mouse hover.
  • Scrollbars now have rounded edges.
  • Teach autocompletion about random source choices: :white, :light_pink, :pink, etc.
  • Improve syntax indentation.
  • Improvements for Arabic, Catalan, Chinese (Simplified), Dutch, Estonian, French, German, Italian, Japanese, Korean, Persian, Polish, Portuguese (Brazil), Russian, Sinhala, Spanish, Swedish, Ukranian.
  • Introduced new translations for Basque, Gaelic.

Improvements

  • Many minor documentation fixes and improvements.
  • When running on Raspberry Pi, Sonic Pi connects to PulseAudio by default.
  • The scheduling accuracy of outgoing OSC and MIDI messages is improved on Windows.
  • Optimise midi_clock_beat.
  • note_range can now handle both increasing and decreasing note ranges.
  • No longer connect to the input sound device on macOS by default - this also means audio input/output rate mismatches no longer cause boot issues on macOS by default.
  • SuperCollider audio server boot issues are now immediately detected and reported as a specific issue to the user alongside the full scsynth log file.

Bugfixes

  • Improve robustness of outgoing OSC messages in the case where an outgoing hostname is malformed and can’t be resolved.
  • Synths :dull_bell and :pretty_bell now properly free themselves when they finish playing, which now means the resources they consumed are also properly freed.
  • Indexing into an empty ring no longer causes a divide by zero error.
  • No longer attempt to increase audio server priority on Windows which causes booting errors in some cases.
  • Fixed encoding issues when saving/loading files containing non-ascii characters on Windows.
  • range no longer loops infinitely with a step size of 0. Instead it now throws an error.
  • In some circumstances having the lissajous visualiser visible caused the GUI to crash on startup. This has now been addressed.
  • Stop thread hanging when passing 0 as the first argument to spread. Now just returns a ring of false values.

Releases

macOS x64 (10.15 Catalina and higher)
Link Sonic-Pi-for-Mac-x64-v4.0.0.dmg
Size 128M
MD5 5b2173ebd300df01441b19274af2723c
SHA256 c33327eccf940863ec35ad4c9954b4c66a91add17b7a84f259cfd936af8815c7
Windows
Link Sonic-Pi-for-Win-x64-v4.0.0.msi
Size 201M
MD5 2defc02210941cb89a577f3b02490714
SHA256 14b00a7b7eddca2b237de7a8eaf4241b68984a3b96ada43f8d0e3b6f8053b6e2
14 Likes

Bravo for this new version @samaaron and for your enthusiasm! Gonna try right now !

1 Like

This alone makes it worth the price of admission.

1 Like

Congratulations! Great work on the Link feature!

Hi again !

I just tried this new version with Ableton Live Intro it’s pretty cool and so easy to set ! no headache :slight_smile:
You can set the tempo from sonic pi and Ableton follows but it works also if you vary the tempo from Ableton Live.

I tried with two instances of sonic pi 4 on 2 different pc in the same network : works like a charm.

image

A lot of fun here ! Thanks again Sam !

a little question : does sonic pi handle the start and stop button of ableton live intro ?

For now, i play with that

# usage de link

use_midi_defaults port: "cable-loop-midi_5"
use_midi_logging true

link_sync 4,1

in_thread do
  loop do
    midi :c2, channel: 1
    sleep 1
    midi :d2, channel: 1
    sleep 1
  end
end

in_thread do
  loop do
    midi :f2, channel: 1
    sleep 0.5
    midi :fs2, channel: 1
    sleep 0.5
  end
end

at [8, 16] do
  4.times do
    midi (scale :c3, :major).tick, channel:2
    sleep 0.25
  end
end

at [0, 8, 16, 24] do
  8.times do
    midi (scale :c3, :acem_asiran).pick, channel:3, sustain: rrand(0.1, 1)
    sleep 0.25
  end
end

  1. i launch in Ableton
  2. then i run in sonic pi. If i stop in sonic pi, then run again it will wait for a measure of 4, and start playing again.

See if link_sync helps :slight_smile:

Can you provide an example of syncing two live_loops running on two different computers on the same local network? I can get both live_loops to respond to tempo changes but not to start with each other in the normal way I’d do it with the sync: "/live_loop/drums" function for example.

Try starting each buffer with link :slight_smile:

2 Likes

Hi there,

Just to add that thanks to @lilyinstarlight, the latest version in the repo is easy to build on ubuntu 22.04.
Thanks a lot !

Nicolas

One technique I have used if you don’t have or want to use Live to provide a start signal, is to use the fact that every time you click the metronome link button (which toggles on/off) a cue of the form /link/num-peers is sent to all machines. It sends the number of currently linked peers as a number. I use this at the start of the program on each computer to be linked.

#set_audio_latency! 50 #optional adjustable command may be necessary
link
live_loop :start do
  n = sync "/link/num-peers"
  if n[0]==1 #set to number of machines being linked -1
    cue :go
  end
end
sync :go
#remainder of program follows
#for example
live_loop :test do
  play 72,release: 0.2
  sleep 0.5
end

Adjust the link if n[0] == 1 so that then number is 1 LESS than the total number of computers involved i.ee the number of peers e.g. for 2 computers it will be 1, for three it will be 2

turn the link metronome ON for all machines except one, and run the program on ALL the machines. Then click the link on the remaining machine and they will all start playing together.
If all the machines are identical they should all have the same audio latency. If they are not, you may have to add lines like
set_audio_latency! 50
to adjust the latency for the machines. This is quite a slow process. First listen to see which machine is slowest. Then run that machine with one other at a time, and delay the audio of the faster machine using a positive number for the delay, until the notes sync together. You can press run each time to update the audio delay.
repeat until all machines are syncing.

Although SP only responds to the /link/start command sent from Live when you press the transport play button which can be used to trigger link_sync, you can also utilise the /link/stop cue which is sent when the transport stop button is pressed.
Here is a simple program which sounds only when the transport is running.

link
set :run,false
live_loop :start do
  use_real_time
  sync "/link/start"
  set :run,true
end
live_loop :stop do
  use_real_time
  sync "/link/stop"
  set :run,false
end
live_loop :react do
  use_real_time
  if get(:run)
    play scale(:c4,:minor_pentatonic,num_octaves: 2).choose, release: 0.5
  end
  sleep 1
end
1 Like

Hello and thank you very much for a modernized and feature enriched new version of Sonic PI.
I believe it is an exceptionally remarkable kind of beautifull rock in the landscape of truly free open source electronic
music / sound exploration and composition tools.

Anyway you add in the announcement also
improvements for german (language).

But after my installation today on a current windows 10 64 bit system
(21H2, Build : 19044.1806, Windows Feature Experience Pack 120.2212.4180.0)
of the current Sonic-Pi-for-Win-x64-v4-0-1.msi from Sonic Pi - The Live Coding Music Synth for Everyone (sonic-pi.net)

I do not have any german interface nor help any longer and
the preferences dialog
claims that Sonic Pi hasn’t been translated to German yet.

Is this true? SP 3.3.1 did have a german menu and
help system.

So why did you possibly “remove” german language now?

I even do not see the possibility to switch back to the
possibly rudimentary german translation that existed
for SP 3.3.1.

There semms to be an german translations file
“…\Program Files\Sonic Pi\app\gui\qt\build\Release\translations\qt_de.qm”
in the translations directory. It is btw with 208 KByte the largest file in this directory.

So what is this all about?

Could you please give some insight?

Thank you.

Hi @Buce - this appears to unfortunately be a bug. Translations have been much improved and nothing has been removed. However, it seems something went awry in the build process.

I’ll look into it and create a new release once I’ve figured out what’s going on here.

Until then, apologies.

Hi again @Buce - I believe I’ve found the issue. It’s during the build step on both macOS and Windows and I can’t believe I didn’t notice this until now. It even slipped through all the BETAs and nobody else noticed either! Ooops!

I’ll be releasing v4.0.2 in the next day or so fixing this. Thanks so much for spotting and reporting this issue.

Another problem on windows with the new SP release seems to be a relatively small text size in menues
and no scalling of text size if I increase the systems
text size.
I am not sure if i am focusing on a thing that was not different before. But to me the current menu text size
seems to be quite small and it does not scale up
if I change the systems text size.

Maybe you have a look at this as well.

Thank you very much.

Apologies, but Sonic Pi’s GUI is not currently scalable. If someone would like to look into this I’d be happy to support them, but it’s not currently at the top of my TODO list.

Hi @Buce - please download v4.0.2 - this release contains translations: Release Relink · sonic-pi-net/sonic-pi (github.com)

Hi … was it not possible(before SP 4.0.3) to change the size(up- or down-splitting) of
the error-output window below the buffers or at least change the font-size of it?

To move the error-window to another place like help- and scope/Oszilloskop/visualizer-window
would also be not that bad.

Thanks