TuningFork (TuningFork v0.1.11)

Copy Markdown View Source

Sound synthesised on the BEAM: play a TuningFork.Voice on a TuningFork.Stage.

{:ok, _pid} = TuningFork.Stage.start_link(sink: TuningFork.Sink.Speaker)
TuningFork.play(TuningFork.Voice.new(shape: :sine, freq: 440.0))

Summary

Functions

Whether this machine can play sound.

Sound a voice on the stage registered as TuningFork.Stage.

Render a voice to signed 16-bit little-endian PCM without playing it.

Start a stage under tuning_fork's own DynamicSupervisor.

Functions

available?()

@spec available?() :: boolean()

Whether this machine can play sound.

Asked of TuningFork.Sink.Speaker, and false when the tuning_fork_speaker package is not installed.

play(voice)

@spec play(TuningFork.Voice.t()) :: :ok

Sound a voice on the stage registered as TuningFork.Stage.

Returns immediately; the voice is rendered inside the stage.

render(voice, rate \\ 44100, channels \\ 2)

@spec render(TuningFork.Voice.t(), pos_integer(), pos_integer()) :: binary()

Render a voice to signed 16-bit little-endian PCM without playing it.

rate is samples per second and channels is 1 for mono or 2 for stereo. Stereo applies the voice's :pan.

start_stage(opts \\ [])

@spec start_stage(keyword()) :: DynamicSupervisor.on_start_child()

Start a stage under tuning_fork's own DynamicSupervisor.

opts are TuningFork.Stage.start_link/1's options. The stage is not linked to the caller.