I find myself always googling this and it takes forever to find the answer. I don’t know how to change the sample rate of Supercollider.
The help file for ServerOptions clearly has:
.sampleRate
.samplerRate = value
The preferred sample rate. If non-nil the server app will attempt to set the sample rate of the hardware. The hardware has to support the sample rate that you choose.
Yet when I enter
ServerOptions.sampleRate
I get:
ERROR: Message 'sampleRate' not understood.
How do I do this? And how do I remember how to do this? It happens every few months and I go crazy trying to figure it out.
Hi Brian,
I’m not sure how I can help you to remember it, but I use s.options.sampleRate = 48000 before boot
I think the error is because ServerOptions.sampleRate is calling a function on … nothing? ServerOptions.new.sampleRate = 48000 would work (since it creates an object with .new), but doesn’t set the ServerOptions of the default server (can be done with s.options = ServerOptions.new.sampleRate…).
Anyway, I think someone on the forum can elaborate on this, but for now I hope my suggested line will do the job.
ServerOptions.sampleRate returns an error and that’s normal.
When doing this, you are invoking a class method. And the ServerOptions class as no such class method. If you look carefully the documentation you’ll see that samplerate is an instance method.
So first, you’ve got to retrieve a ServerOptions instance.
If you want to change the current config you need to retrieve the current set of options with s.options.
So to set sample rate you should do:
s.options.sampleRate = 44100
And reboot the server
As per documentation of the Server class:
.options
.options = value
Get or set this Server’s ServerOptions object. Changes to options only take effect when the server is rebooted.
Theres a distinction between a class “ServerOptions” and an instance “a ServerOptions”.
To change the options for the server stored in s you send messages to that Server’s Server options instance (s.options). It can be convenient to store the instance in another variable (o=s.options). Interpret o.dump to see all the options. Reboot the server after changing.
You can query the options of remote servers too, for example by sending messages to their ServerOptions instances.
ServerOptions.devices sends the message \devices to the class ServerOptions not any particular Server’s ServerOptions instance.