Cauldron2D.Net.Audio (Cauldron2D.Net v0.1.3)

Copy Markdown View Source

The server's sound policy: what every session's sound costs it.

Cauldron2D.Net.Audio.set(music: :arena, sfx: :personal)
Cauldron2D.Net.Audio.set(music: :dynamic)
Cauldron2D.Net.Audio.policy()

Music

  • :personal — every session synthesises its own music, cued by its own view. Default
  • :arena — one stage a world (Cauldron2D.Net.Audio.Shared), cued by the world's state, its music mixed under each session's own effects
  • :static — every session plays the first section it is cued and no other, rendered once a node and looped (Cauldron2D.Audio with static_music: true): the music is a resource, not a performance, and costs a copy a chunk
  • :dynamic — personal, at a rate the node's load sets: 44 100 Hz while the schedulers are under 30% busy, 22 050 Hz once they pass 60%, each held for thirty seconds at least. A session whose rate changes restarts its audio and tells its browser
  • :off — no music

Effects

  • :personal — each session's own, placed against its listener. Default
  • :off — none

A session that asks for no sound (join param audio: false) gets none whatever the policy. :rate (default 44 100) caps the rate any session gets; a session asking for less gets what it asked. format/1 answers what a session gets for what it asked; subscribe/0 has the calling process told {:cauldron_audio_rate, rate} when the rate changes.

Summary

Functions

What a session gets for the format it asked, :off for no sound asked.

The policy in force.

The rate sessions get now: the policy's, lowered by the governor under :dynamic music.

Set the policy: :music, :sfx and :rate; what is not given goes back to its default.

Have the calling process told {:cauldron_audio_rate, rate} whenever the rate changes.

Types

format()

@type format() :: %{rate: pos_integer(), channels: 1 | 2} | :off

music()

@type music() :: :personal | :arena | :dynamic | :static | :off

policy()

@type policy() :: %{music: music(), sfx: sfx(), rate: pos_integer()}

sfx()

@type sfx() :: :personal | :off

Functions

format(arg1)

@spec format(%{rate: pos_integer(), channels: 1 | 2} | :off | nil) :: format()

What a session gets for the format it asked, :off for no sound asked.

policy()

@spec policy() :: policy()

The policy in force.

rate()

@spec rate() :: pos_integer()

The rate sessions get now: the policy's, lowered by the governor under :dynamic music.

set(opts)

@spec set(keyword()) :: :ok

Set the policy: :music, :sfx and :rate; what is not given goes back to its default.

subscribe()

@spec subscribe() :: :ok

Have the calling process told {:cauldron_audio_rate, rate} whenever the rate changes.