Resample:
Filter:
Classes | Server > Abstractions

Resample : Object

Change the sample rate of a SynthDef/Synth
Source: SynthDef.sc

Description

For certain applications it is beneficial to run a Synth at a higher sample rate. Instead of increasing the sample rate of the whole Server, which could be very wasteful, you can use the Resample object inside a SynthDef to only change the sample rate of specific Synths.

For example, with a factor of 4.0, the Synth will run at four times the Server's sample rate. Keep in mind that upsampling increases the CPU usage roughly proportionally to the upsampling factor.

The resampling factor can be a constant number or it can be set dynamically via a Synth control (except for Supernova). See *new for more information.

NOTE: For technical reasons, Supernova requires a fixed resampling factor. Trying to use a Synth control results in a warning.

For example, you can use upsampling + filtering to reduce the effects of aliasing:

Class Methods

Resample.new(factor: 1.0)

Specify the resampling factor of the Synth. You should only create this once per SynthDef. Duplicate instances generate a warning and are ignored.

Arguments:

factor

the resampling factor. This can either be a constant number (e.g. 2.0) or a Synth control. With the latter, the resampling factor can be set independently for each Synth. However, it cannot be modulated after the Synth has been instantiated on the Server.

The resampling factor must be power of two. A value of 0.0 is the same as 1.0 (= no resampling).

Currently, only upsampling is supported! Any attempt at downsampling (e.g. a factor of 0.5) is ignored and results in a warning.

Discussion:

Note that the Resample object is not a UGen and there are certain restrictions on the types of arguments it accepts. In particular, you cannot use UGen expressions. (UGens are only evaluated after the Synth has been initialized. At this point, the resampling factor must have already been set.) For example, the following does not work and will throw an error:

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

.controlIndex

.controlIndex = value

.factor

.factor = value

.synthDef

.synthDef = value

.writeDef(stream)