TuningFork.Wave (TuningFork v0.1.11)

Copy Markdown View Source

Oscillators, as functions from phase (0.0 to 1.0 over one cycle) to amplitude (-1.0 to 1.0).

TuningFork.Wave.sample(:sine, 0.25)

Summary

Functions

One sample of white noise, from -1.0 to 1.0, and the seed for the next. The same seed always gives the same sequence.

One sample of shape at phase, with no band limiting.

One sample of shape at phase, band limited for a phase step of step per sample.

A seed for noise/1, from any term.

Types

seed()

@type seed() :: integer()

shape()

@type shape() :: :sine | :square | :saw | :triangle

Functions

noise(seed)

@spec noise(seed()) :: {float(), seed()}

One sample of white noise, from -1.0 to 1.0, and the seed for the next. The same seed always gives the same sequence.

sample(shape, phase)

@spec sample(shape(), float()) :: float()

One sample of shape at phase, with no band limiting.

phase is a position in the cycle from 0.0 to 1.0. The result runs -1.0 to 1.0.

sample(atom, phase, step)

@spec sample(shape(), float(), float()) :: float()

One sample of shape at phase, band limited for a phase step of step per sample.

step is freq / rate. A step of 0.0 gives the raw shape. :sine and :triangle ignore step.

seed(term)

@spec seed(term()) :: seed()

A seed for noise/1, from any term.