Sonic Pi Sample Rate

Hello,

I’m sorry if this has been asked or is elsewhere on the forum. I looked but didn’t find. I’m wondering what the audio sample rate and bit depth is by default (and whether or not it is adjustable). I looked up things on SuperCollider and it seems there are options - just wondering which were chosen for SP.

I’m running on a Mac (for now).

Thanks,
Isaac

Hi @Hypostatic,

I can talk at least a little about sample rate. @samaaron might know a little more about it, but from, what I understand, Sonic Pi’s default sample rates are just whatever SuperCollider (scsynth) boots with.
You can alter the values that scsynth uses, but how you do so will depend on whether you are prepared to work with a self-compiled bleeding edge version of Sonic Pi, wait for the next beta or release version, or use an existing release version.

If you are prepared to build a bleeding edge version from source, or wait for the next beta or release version, then there have been recent changes in the ruby code to customise the boot up settings that are sent to scsynth.
The relevant change is here: https://github.com/samaaron/sonic-pi/commit/41ceedc0508de59b62064083262dda451f5a48cc.

If you have a version with this change in it, then the file to edit is settings.json - which is in your .sonic-pi folder. That folder will be in your home directory unless you have specified that it be stored somewhere else using the SONIC_PI_HOME environment variable.
Happy to talk about editing settings.json more if that is the path you decide to go down.

On the other hand, if you wish to use a current release version, then the best option is to just use the Audio MIDI Setup app on your Mac to edit the sample rate of your default input and output devices before booting Sonic Pi. (Which need to be identical if you wish to use sound input in Sonic Pi on a Mac).

Bit rate I am not so sure about - all I can really tell you about that is that for example when I use the recording function in Sonic Pi on my Mac here, it outputs a wav file in 32 bit float format.

1 Like

Hi, just to verify what @ethancrawford has already said:

  • For live audio Sonic Pi currently uses your computer’s default sound card and settings. So if your default sound card is set to 48khz @ 16 bits, then this is the rate and bit depth Sonic Pi will use for the audio.
  • For wav recordings, Sonic Pi defaults to a bit depth of 16 which can be modified with set_recording_bit_depth!.
3 Likes

Thank you @ethancrawford, and @samaaron for the details! I sort of assumed it might use what the driver/interface was set too, but didn’t want to find out the hard way that it was somehow hard coded. My music partner and I usually use at least 48k, 24bit when stemming etc, and I didn’t want to go down a path where I couldn’t get to at least that.

I’ve been compiling for Linux on another laptop. As I had just pulled the latest from the repo the other day, I may have the changes allowing for customizable boot. I’ll give the .json config a look through. Thanks for that info as well.

You guys are on it! I’m still learning a lot, but the features and UI/UX of this are amazing. Perfectly minimal and easy to use, with lots of power and options behind the scenes. Thanks for your work!

3 Likes

If you want to be sure what Sonic Pi is using bit rate and depth wise, just run the following:

puts scsynth_info

and you’ll see something like the following:

{run: 4, time: 0.0}
 └─ (map sample_rate:         48000.0,
         sample_dur:          2.0833333110203966e-05,
         radians_per_sample:  0.0001308996870648116,
         control_rate:        750.0,
         control_dur:         0.0013333333190530539,
         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)

Just to clarify, bit depth doesn’t mean much in SuperCollider land as it uses floats which will be either 32 or 64 bit. It will only matter when it is manipulated by the audio card or when it is saved to a wav file.

That all makes complete sense. I’m not worried about it. I think it comes down to my continual thinking that Sonic Pi is too good to be true :slight_smile:

Running the new 3.3.0 Beta on Linux right as of yesterday.

2 Likes