Files
ISR/config.example.ini
T
adminandClaude Opus 5 1541110ffb refactor: collapse the single-implementation backend abstraction, fix device resolution
isr.py carried a plugin architecture — AudioBackend ABC, a _backend_classes
registry, _discover_backends, available_backends/get_backend, a
preferred_backend config knob — for exactly one implementation. It was
also the source of three real bugs:

* find_device() returned None before reaching the ALSA PCM-name fallback
  whenever `arecord -l` enumerated nothing, so the documented
  `device = shared_mic` (dsnoop from asound.conf) case failed outright on
  any host with no hardware card. The fallback is the whole point: those
  PCMs never appear in `arecord -l`.

* `device = monitor` could never resolve. ALSA has no generic monitor
  source and list_devices hardcoded is_monitor=False, so the keyword —
  advertised in config.example.ini as the "EASY" way to capture system
  audio — only ever produced "device not found". Removed; it is a
  PulseAudio idea that outlived the PulseAudio backend.

* list_all_devices() deduplicated by lowercased name "in case a device
  appears in multiple backends". With one backend what it actually did
  was delete the second of two identical USB cards. Dedup dropped.

find_device() now always returns a device, so _resolve_device's
unreachable "Available devices:" error is gone; an unknown spec is
passed to ALSA verbatim and logged. AudioDevice loses backend/
is_monitor plus channels/sample_rate — the latter were hardcoded 2/44100
and only ever printed by --list-devices, i.e. numbers with no bearing on
what gets recorded.

--list-devices now says outright that it lists hardware cards only, which
is where the shared_mic confusion started.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 20:28:30 +02:00

145 lines
4.7 KiB
INI

# ISR - Audio Recorder Configuration
# Supports multiple recording sources: Icecast streams and soundcards
#
# Configuration sections:
# [general] - Shared settings for all sources (optional)
# [sourcename] - One section per recording source (name is your choice)
#
# Each source section must have 'type' set to either 'stream' or 'soundcard'
# =============================================================================
# GENERAL SETTINGS (optional - can be overridden per source)
# =============================================================================
[general]
# Output directory for recordings (will be created if it doesn't exist)
output_directory = recordings
# Duration in minutes after which to split into a new file
split_minutes = 60
# Recording filenames are fixed as <YYYYMMDD>_<HHMMSS>.<ext> (the start time,
# e.g. 20241216_143000.flac). This is not configurable: the web UI parses the
# start time back out of the filename to show the date and to name cut clips
# with real wall-clock times.
# Maximum number of connection/recording retry attempts before giving up
max_retries = 10
# Delay in seconds between retry attempts
retry_delay_seconds = 5
# Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL
log_level = INFO
# Log file location
log_file = recorder.log
# =============================================================================
# EXAMPLE: ICECAST STREAM SOURCE
# =============================================================================
[mystream]
# Source type (required): stream or soundcard
type = stream
# Stream URL (required for stream type)
url = http://example.com:8000/stream
# Authentication (optional - leave empty for public streams)
username =
password =
# Audio format: auto (detect from stream), mp3, ogg, aac, flac, opus
format = auto
# Override general settings for this source (optional):
# output_directory = recordings/streams
# split_minutes = 30
# =============================================================================
# EXAMPLE: SOUNDCARD SOURCE (Linux)
# =============================================================================
# Uncomment and configure to record from a soundcard
#
# [stereo_mix]
# type = soundcard
#
# # Device selection (use one of these methods):
# # device = default - Use system default input device
# # device = <name> - Match device by partial name (e.g., "Stereo Mix")
# # device = <id> - Use exact device ID from --list-devices
# # device = <pcm> - Any ALSA PCM name from asound.conf (e.g. shared_mic);
# # these never show up in --list-devices but work anyway
# #
# # To list available devices, run: python isr.py --list-devices
# device = default
#
# # Sample rate in Hz (common: 44100, 48000, 96000)
# sample_rate = 44100
#
# # Number of audio channels (1 = mono, 2 = stereo)
# channels = 2
#
# # Output format: wav, flac
# format = wav
#
# # Override general settings for this source (optional):
# # output_directory = recordings/soundcard
# # split_minutes = 60
# =============================================================================
# MULTIPLE SOURCES EXAMPLE
# =============================================================================
# You can define as many sources as you want. Each will record simultaneously.
#
# [radio_station_1]
# type = stream
# url = http://radio1.example.com:8000/live
# format = auto
#
# [radio_station_2]
# type = stream
# url = http://radio2.example.com:8000/live
# format = auto
#
# [system_audio]
# type = soundcard
# device = Stereo Mix
# sample_rate = 48000
# channels = 2
# format = flac
# =============================================================================
# SOUNDCARD TIPS (Linux / Raspberry Pi)
# =============================================================================
# ISR uses ALSA (arecord) for soundcard recording. arecord is pre-installed
# on Raspberry Pi OS and most Linux distros (package: alsa-utils).
#
# Run: python isr.py --list-devices (or: arecord -l) to list devices.
#
# Specify a device by ALSA hardware ID from --list-devices:
# [usb_mic]
# type = soundcard
# device = hw:1,0
# sample_rate = 44100
# channels = 2
# format = flac
#
# SHARING A DEVICE WITH ANOTHER APP (e.g. darkice):
# ALSA hw: devices are exclusive — only one process can open them at a time.
# Use the dsnoop virtual device defined in asound.conf to share the hardware:
#
# 1. sudo cp asound.conf /etc/asound.conf (once, on the host)
# 2. Change the other app (darkice etc.) to use device "shared_mic" too
# 3. Use device = shared_mic in ISR config (docker-compose.yml mounts asound.conf automatically)
#
# [usb_mic_shared]
# type = soundcard
# device = shared_mic
# sample_rate = 48000
# channels = 2
# format = flac