Skip to content

feat(source): add a source@v1 capture client (sendspin source) - #270

Draft
rudyberends wants to merge 1 commit into
Sendspin:mainfrom
rudyberends:feat/source-v1
Draft

feat(source): add a source@v1 capture client (sendspin source)#270
rudyberends wants to merge 1 commit into
Sendspin:mainfrom
rudyberends:feat/source-v1

Conversation

@rudyberends

Copy link
Copy Markdown

Adds a sendspin source command: run as a Sendspin source client that captures audio from a local input (line-in/microphone) or a synthetic sine test tone, encodes it (PCM, FLAC, or Opus via PyAV), and streams it to a server, which mixes and distributes it to players.

Implements the client side of the source@v1 role (Sendspin/spec#105).

Depends on Sendspin/aiosendspin#286 (the source@v1 protocol + client SDK). The aiosendspin version pin here must be bumped to the release that includes it before this can merge — hence draft.

Supersedes #123, which targeted the earlier input_stream/* proposal.

What's added

  • source_utils.py: SourceEncoder (PyAV; PCM passthrough / FLAC / Opus, exposing the raw codec header) + an RMS level meter
  • source_stream.py: SourceStreamer — capture loop (sounddevice line-in or sine tone), server-driven start/stop, optional line-sense reporting; stamps each frame with its capture time
  • cli.py: sendspin source subcommand and sendspin audio-devices inputs listing
  • audio_devices.py: input-device enumeration
  • settings.py: SourceSettings persistence (settings-source.json)
  • README.md: source-mode documentation

Capture is 16-bit; the server handles decode/resample/mix. The server is the sole initiator of streaming (a source stays idle until told to start). A device may run both source and player; it never plays its captured input locally.

Testing

  • ruff + mypy clean; pytest: 155 passed (13 new, incl. a cross-repo round-trip: encode with the CLI encoder then decode with the aiosendspin server decoder, for PCM/FLAC/Opus).
  • End-to-end over a real websocket: a source+player client streams a sine tone through a server and receives it back (PCM/FLAC/Opus).

Add a 'sendspin source' command that runs a source client: capture audio
from a local input (line-in/microphone) or a sine test tone, encode it
(PCM, FLAC, or Opus via PyAV), and stream it to a server, which mixes and
distributes it to players. The server controls when the source streams.

- source_utils: PyAV SourceEncoder (exposes raw codec header) + RMS level
- source_stream: SourceStreamer capture loop (sounddevice / sine), server
  start/stop handling, optional line-sense signal reporting
- cli: 'source' subcommand and 'audio-devices inputs' listing
- audio_devices: input-device enumeration
- settings: SourceSettings persistence (settings-source.json)
- README: source mode documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant