Changing Sample Rate

Hi, hoping you’re having a good day (=

I was wondering if any of you know if there’s a way to configure the sample rate from inside Sonic Pi, because it isn’t implementing the preferences from SuperCollider which are:

(
s.doWhenBooted({
	
	s.sync;
	o = Server.default.options;
	o.inDevice_("ASIO : MOTU M Series");
	o.outDevice_("ASIO : MOTU M Series");
	s.options.numInputBusChannels = 8 ;
	s.options.numOutputBusChannels = 4;
	o.sampleRate_("48000");
	
	s.sync;
	Server.local.options.memSize = 2.pow(20);
	Server.internal.options.memSize = 2.pow(20);
	Server.default.reboot;

	s.sync;
}););

when I run:

puts scsynth_info

Sonic Pi dump:

{run: 1, time: 0.0}
 └─ (map sample_rate:         44100.0,
         sample_dur:          2.2675736545352265e-05,
         radians_per_sample:  0.00014247585204429924,
         control_rate:        689.0625,
         control_dur:         0.001451247138902545,
         subsample_offset:    0.0,
         num_output_busses:   16.0,
         num_input_busses:    16.0,
         num_audio_busses:    1024.0,
         num_control_busses:  16384.0,
         num_buffers:         4096.0)

So what I want is to change the sample rate, but I haven’t had any success.

Running on Windows 10 version 22H2

Thank you in advance, looking forward to hearing from you!

look in the file [user home folder] > .sonic-pi > config > audio-settings.toml

edit the file and look for the setting
# sound_card_sample_rate = 44100
remove the # and change the rate to 48000 giving
sound_card_sample_rate = 48000

Of course the sound card you you mus be capable of 48000 and you may have to look at the Device properties of your output device and at the additional device properties advanced tab to check this. If for example this is set to 44100, then Sonic Pi will appear to play (you will see output on the scope) but you won’t hear anything. Conversely if it is set to 48000 and you use the default /toml file setting Sonic Pi will use 41000 and you will still hear OK as it will sync to the lower setting.

Note if you change device settings like this you will have to restart Sonic Pi to pick up the new valuew, as Supercollider negotiates these once on startup.

One final point. If you have a default input device active then it must be set to the same rate as scsynth requires this. You can switch off audio input if necessary on the Sonic Pi Audio preferences panel. (It is off be default initiallly) so that playback will still work if this is not the case.