instruments = ['piano', 'pretty_bell']
define :albert do | num: 1, a: 0, d: 0.5, s:0.5, r:0.5, amp: 1, c:80 |
puts instruments[num-1]
use_synth instruments[num-1]
use_synth_defaults attack: a, decay: d, sustain: s, release: r, amp: amp, cutoff: c
end
albert
play :c4
Error setting Thread Local - value must be immutable. Got: "piano" for :sonic_pi_mod_sound_current_synth_name
could somebody explain what is it immutable ?
i guess that once a variable is set to a value, this value can’t be changed. Right ?
So why this error ?
Thanks
Are you starting Sonic Pi in a non-standard way? I think Sonic Pi starts Ruby with the --enable-frozen-string-literal option enabled, so if you start it yourself without that option it could lead to this error.
If you use symbols instead, I think it should work (i.e. instruments = [:piano, :pretty_bell])
thank you @emlyn if i use symbols it works.
For information, i start sonicpi the standard way under ubuntu 18.04.3. I do not use the latest version of 3.2 dev.
Under spi 3.1 under windows 10, the list way works. By the way, the spi 3.2dev version for windows is available for patreons or not yet ?
It looks like that option is only enabled on Mac and Windows (link). I guess you’ll just have to use symbols (or try building it yourself with the option enabled, but there may well be a reason it’s not already enabled).