Generators

Commonly used generators such as oscillators, phasor (i.e. positive sawtooth) and others. This list will grow a bit over time.

oscil is sine wave oscillator, phasor is a sawtooth wave that can also be used as a periodic phase signal, noise is white noise and sample plays back a "sample".

Synth.oscilFunction
oscil(m :: Union{Real,Signal}, f :: Union{Real,Signal}, p :: Union{Real,Signal}; phase = 0.0)

A "oscil" is a sinusoidal oscillator whose frequency and amplitude can be varied ("modulated") over time. The f argument is expected to be a frequency in Hz units. m determines the amplitude and p the phase in unit range. The phase named argument is a number in the range [0.0,1.0] determining the starting phase within the cycle. It is added to the overall phase evolution as a constant so that oscil can be used for a sine wave with 0.0 as the phase and as a cosine wave with 0.5 as the phase. This lets us do both FM and PM using the same unit.

Design

An earlier approach was to have the second argument be a phasor. However, the phasor argument always ended up being passed as phasor(freq) and so it made sense to fold the frequency into oscil as the main control. This made for a simpler use of oscil, though a tad less general. So essentially oscil(m, f) is equivalent to oscil_v1(m, phasor(f)) where oscil_v1 was the previous version.

source
Synth.phasorFunction
phasor(f :: Real, phi0 = 0.0)
phasor(f :: Signal, phi0 = 0.0)

A "phasor" is a signal that goes from 0.0 to 1.0 linearly and then loops back to 0.0. This is useful in a number of contexts including wavetable synthesis where the phasor can be used to lookup the wavetable.

source
Synth.sawFunction
saw(f :: Union{Real,Signal}, phi0::Float64 = 0.0)

A protected sawtooth wave (See protect)

source
Synth.triFunction
tri(f :: Union{Real,Signal}, phi0::Float64 = 0.0)

A protected triangular wave (See protect)

source
Synth.sqFunction
sq(f :: Union{Real,Signal}, phi0::Float64 = 0.0)

A protected square wave (See protect). This is perhaps the harshest of them with a small possibility of aliasing, so the q factor for this is twice the usual.

source
Synth.noiseFunction
noise(rng :: AbstractRNG, amp :: Signal)
noise(rng :: AbstractRNG, amp :: Real = 1.0f0)
noise(amp :: Signal)
noise(amp :: Real = 1.0f0)

Amplitude modulatable white noise generator.

source
noise(rng :: AbstractRNG, amp :: Signal)
noise(rng :: AbstractRNG, amp :: Real = 1.0f0)
noise(amp :: Signal)
noise(amp :: Real = 1.0f0)

Amplitude modulatable white noise generator.

source
noise(rng :: AbstractRNG, amp :: Signal)
noise(rng :: AbstractRNG, amp :: Real = 1.0f0)
noise(amp :: Signal)
noise(amp :: Real = 1.0f0)

Amplitude modulatable white noise generator.

source
noise(rng :: AbstractRNG, amp :: Signal)
noise(rng :: AbstractRNG, amp :: Real = 1.0f0)
noise(amp :: Signal)
noise(amp :: Real = 1.0f0)

Amplitude modulatable white noise generator.

source
Synth.sampleFunction
sample(samples :: Vector{Float32}; looping = false, loopto = 1.0) 
sample(filename :: AbstractString; looping = false, loopto = 1.0, samplingrate=48000.0, selstart=0.0, selend=Inf)

Produces a sampled signal which samples from the given array as a source. It starts from the beginning and goes on until the end of the array, but can be asked to loop back to a specified point after that.

  • The loopto argument is specified relative (i.e. scaled) to the length of the samples vector. So if you want to jump back to the middle, you give 0.5 as the loopto value.
  • The selstart and selend keyword arguments can be used to slice into the sound sample, with the default covering the entire file.

If the sample rate of the file is different from the selected samplingrate, the loaded samples will be converted to the given rate (uses DSP.resample).

To make slicing into large files efficient, files are loaded once and cached. This cache is looked up (based on the file name) every time a slice is needed.

source
sample(name :: Symbol) :: Sample

Retrieve named sample. The retrieved sample will have the same looping settings as the stored sample, but not its running state.

source
Synth.registerFunction
register(name :: Symbol, s :: Sample)

Associates the given name with the given sample so it can be retrieved using sample(::String).

source
register(name :: Symbol, wt :: Vector{Float32})
register(name :: Symbol, wt :: Wavetable)

Associates the given wave table with the given name so it can be retrieved using wavetable(::String).

source