Load and run an .rb file at sonic pi boot

Hi there :slight_smile:
Premised that I’m a sonicPi noob and I’m poorly skilled in programming…
I’ve started using Siaflab’s Petal, a port of Tidal Cycles, and i would like to load it at every boot of sonic pi
Is it possible to add somewhere the startup command "require MYPATH/Petal.rb?

Hi LucioBT
There are two solution you can try. The easiest one is simply to paste the code you want into one of the Sonic Pi buffers: you have 0 to 9 to choose from. The code will be loaded there automatically each time you start Sonic Pi, although it will not run, until you select the buffer and run it.

The second method uses the file init.rb which you can find in the folder .sonic-pi in your home directory. This contains the store for the buffers, plus the file init.rb
Code placed within this file is automatically run when Sonic Pi boots.


I’ve just located the Patel examples and inserting a line like

require "~/petal-1.2.0/petal.rb"

in it does exactly what you want. (I installed petal-1.2.0 in my home folder)


thanks robin, i’ve added the code to init.rb :slight_smile:

NP. Thank you for reminding me about petal. I’ve spent the afternoon playing with it. It is really cool!
for anyone else wantint to try it out site is

as discussed in this thread you can put the require line in init.rb so it is set up for you aotumatically when you start Sonic Pi.

1 Like

:slight_smile: I’ve copied almost all my sample set inside the petal-dirt samples folder… wow!