One world's music, synthesised once for every session in it: a Cauldron2D.Audio
cued from the world's own state, its PCM sent to every subscriber as
{:cauldron_shared_pcm, chunk}.
shared = Cauldron2D.Net.Audio.Shared.fetch(world, MyGame.Client, %{rate: 44_100, channels: 2})
:ok = Cauldron2D.Net.Audio.Shared.subscribe(shared)fetch/3 finds the world's stage or starts it. The cue is the game's cue/2 of the
view its Cauldron2D.Game.view/2 gives for the id :audio, read from a snapshot
every two seconds; a game whose view/2 cannot answer for an id that is not a
player gets no music from a shared stage. A subscriber is watched; the stage stops a
few seconds after its last subscriber is gone, and with the world. A rate change
from Cauldron2D.Net.Audio restarts the stage at the new rate.
Summary
Functions
Returns a specification to start this module under a supervisor.
The shared stage of world for game in format, started if it is not running.
Have the calling process sent the music; it is watched, and its going counts.
How many processes are sent the music.
Stop being sent the music.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec fetch(pid(), module(), %{rate: pos_integer(), channels: 1 | 2}) :: pid()
The shared stage of world for game in format, started if it is not running.
@spec subscribe(pid()) :: :ok
Have the calling process sent the music; it is watched, and its going counts.
@spec subscribers(pid()) :: non_neg_integer()
How many processes are sent the music.
@spec unsubscribe(pid()) :: :ok
Stop being sent the music.