Add demo content selector for 1 kHz test tone option
Adds a selectbox in Demo mode UI to choose between program material and a 1 kHz test tone. Includes test tone WAV files at 16/24/48 kHz sample rates. The server detects and persists the demo content type based on the selected audio source files.
This commit is contained in:
@@ -322,6 +322,17 @@ if audio_mode == "Demo":
|
||||
disabled=is_streaming,
|
||||
help="Select the demo stream configuration."
|
||||
)
|
||||
demo_content_options = ["Program material", "1 kHz test tone"]
|
||||
saved_demo_content = saved_settings.get('demo_content', 'Program material')
|
||||
if saved_demo_content not in demo_content_options:
|
||||
saved_demo_content = 'Program material'
|
||||
demo_content = st.selectbox(
|
||||
"Demo Content",
|
||||
demo_content_options,
|
||||
index=demo_content_options.index(saved_demo_content),
|
||||
disabled=is_streaming,
|
||||
help="Select whether demo streams use program audio files or a continuous 1 kHz test tone."
|
||||
)
|
||||
# Stream password and flags (same as USB/AES67)
|
||||
saved_pwd = saved_settings.get('stream_password', '') or ''
|
||||
stream_passwort = st.text_input(
|
||||
@@ -1508,9 +1519,13 @@ if start_stream:
|
||||
bigs1 = []
|
||||
for i in range(demo_cfg['streams']):
|
||||
cfg_cls, lang = lang_cfgs[i % len(lang_cfgs)]
|
||||
if demo_content == "1 kHz test tone":
|
||||
source_file = f'../testdata/test_tone_1k_{int(q["rate"]/1000)}kHz_mono.wav'
|
||||
else:
|
||||
source_file = f'../testdata/wave_particle_5min_{lang}_{int(q["rate"]/1000)}kHz_mono.wav'
|
||||
bigs1.append(cfg_cls(
|
||||
code=(stream_passwort.strip() or None),
|
||||
audio_source=f'file:../testdata/wave_particle_5min_{lang}_{int(q["rate"]/1000)}kHz_mono.wav',
|
||||
audio_source=f'file:{source_file}',
|
||||
iso_que_len=32,
|
||||
sampling_frequency=q['rate'],
|
||||
octets_per_frame=q['octets'],
|
||||
|
||||
@@ -528,6 +528,13 @@ async def init_radio(transport: str, conf: auracast_config.AuracastConfigGroup,
|
||||
demo_count = sum(1 for big in conf.bigs if isinstance(big.audio_source, str) and big.audio_source.startswith('file:'))
|
||||
demo_rate = int(conf.auracast_sampling_rate_hz or 0)
|
||||
demo_type = None
|
||||
demo_sources = [
|
||||
str(b.audio_source)
|
||||
for b in conf.bigs
|
||||
if isinstance(b.audio_source, str) and b.audio_source.startswith('file:')
|
||||
]
|
||||
is_demo_tone = bool(demo_sources) and all('test_tone_1k_' in src for src in demo_sources)
|
||||
demo_content = '1 kHz test tone' if is_demo_tone else 'Program material'
|
||||
if demo_count > 0 and demo_rate > 0:
|
||||
if demo_rate in (48000, 24000, 16000):
|
||||
demo_type = f"{demo_count} × {demo_rate//1000}kHz"
|
||||
@@ -554,8 +561,9 @@ async def init_radio(transport: str, conf: auracast_config.AuracastConfigGroup,
|
||||
'big_random_addresses': [getattr(big, 'random_address', DEFAULT_RANDOM_ADDRESS) for big in conf.bigs],
|
||||
'demo_total_streams': demo_count,
|
||||
'demo_stream_type': demo_type,
|
||||
'demo_content': demo_content,
|
||||
'is_streaming': auto_started,
|
||||
'demo_sources': [str(b.audio_source) for b in conf.bigs if isinstance(b.audio_source, str) and b.audio_source.startswith('file:')],
|
||||
'demo_sources': demo_sources,
|
||||
}
|
||||
return mc, persisted
|
||||
except HTTPException:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user