Files
ISR/config.example.ini
admin e67e27f047 fix: share soundcard between darkice and ISR via ALSA dsnoop
hw:0,0 is an exclusive ALSA device — darkice holding it caused arecord
to fail silently (stderr was /dev/null), leaving all recordings at 0 bytes
with no errors in the log.

asound.conf: defines a dsnoop virtual device 'shared_mic' that opens
hw:0,0 once and lets multiple processes capture simultaneously.

docker-compose.yml: mount asound.conf into the container as
/etc/asound.conf; add ipc: host so the container shares the host IPC
namespace (dsnoop uses System V shared memory which does not cross the
container IPC boundary without this).

config.example.ini: document the dsnoop setup and shared-device pattern.
README, CLAUDE.md: document the full setup procedure.
2026-04-26 14:21:31 +02:00

163 lines
5.1 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
# Filename pattern with strftime format codes
# Examples:
# %Y%m%d_%H%M%S -> 20241216_143000.ext
# recording_%Y-%m-%d_%H%M -> recording_2024-12-16_1430.ext
# %Y/%m/%d/audio_%H%M%S -> 2024/12/16/audio_143000.ext (creates subdirs)
# Common codes: %Y=year, %m=month, %d=day, %H=hour, %M=minute, %S=second
filename_pattern = %Y%m%d_%H%M%S
# 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
# filename_pattern = mystream_%Y%m%d_%H%M%S
# =============================================================================
# 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 = monitor - Auto-select first monitor/loopback source (for system audio)
# # device = <name> - Match device by partial name (e.g., "Stereo Mix")
# # device = <id> - Use exact device ID from --list-devices
# #
# # To list available devices, run: python isr.py --list-devices
# device = default
#
# # Audio backend (only 'alsa' is supported):
# # backend = alsa
#
# # 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
# # filename_pattern = soundcard_%Y%m%d_%H%M%S
# =============================================================================
# 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
# filename_pattern = radio1_%Y%m%d_%H%M%S
#
# [radio_station_2]
# type = stream
# url = http://radio2.example.com:8000/live
# format = auto
# filename_pattern = radio2_%Y%m%d_%H%M%S
#
# [system_audio]
# type = soundcard
# device = Stereo Mix
# sample_rate = 48000
# channels = 2
# format = flac
# filename_pattern = system_%Y%m%d_%H%M%S
# =============================================================================
# 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.
#
# EASY: Use the "monitor" keyword to capture system/loopback audio:
# [system_audio]
# type = soundcard
# device = monitor
# format = wav
#
# MANUAL: Specify a device by ALSA hardware ID from --list-devices:
# [usb_mic]
# type = soundcard
# device = hw:1,0
# backend = alsa
# 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
# backend = alsa
# sample_rate = 48000
# channels = 2
# format = flac