TuningFork.Listener (TuningForkSpeaker v0.1.11)

Copy Markdown View Source

Plays raw signed 16-bit little-endian PCM arriving on a TCP port through this machine's speaker, one connection after another — the far end of TuningFork.Sink.Tcp over an ssh tunnel.

{:ok, listener} = TuningFork.Listener.start_link(port: 5000)

Each connection opens the sink afresh and closes it when the connection ends; the next connection is accepted then. Audio that has arrived faster than it can play — a burst while the device was opening, a stall on the link — is dropped down to :max_lag_ms, so what is heard stays that close to what was sent.

Options

  • :port — the TCP port to listen on; 0 picks a free one and port/1 tells which. Required
  • :ip — the interface to listen on. Default {127, 0, 0, 1}, this machine only
  • :rate, :channels — the PCM format. Default 44_100 and 2
  • :sink — the TuningFork.Sink to play through, as module or {module, opts}. Default TuningFork.Sink.Speaker
  • :max_lag_ms — the most audio kept waiting to play. Default 100
  • :name — a registered name. Default: none

Summary

Functions

Returns a specification to start this module under a supervisor.

The port being listened on.

Start listening.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

port(listener)

@spec port(GenServer.server()) :: :inet.port_number()

The port being listened on.

start_link(opts \\ [])

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

Start listening.