Cauldron2D.Net.Sound (Cauldron2D.Net v0.1.3)

Copy Markdown View Source

Plays the PCM a Cauldron2D.Net.Link.Socket delivers through this machine's speaker, in a process of its own so the writes never hold up whoever draws.

{:ok, sound} = Cauldron2D.Net.Sound.start_link()
Cauldron2D.Net.Sound.play(sound, chunk)

Options: :sink, the TuningFork.Sink module (default TuningFork.Sink.Speaker); :rate and :channels (default 44100 and 2). The sink opens on the first chunk; format/3 sets the rate and channels the next chunks come in, reopening it.

Summary

Functions

Returns a specification to start this module under a supervisor.

The rate and channels the chunks come in from now on.

Queue a chunk of signed 16-bit little-endian PCM.

Start the player.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

format(sound, rate, channels)

@spec format(GenServer.server(), pos_integer(), 1 | 2) :: :ok

The rate and channels the chunks come in from now on.

play(sound, chunk)

@spec play(GenServer.server(), binary()) :: :ok

Queue a chunk of signed 16-bit little-endian PCM.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Start the player.