fix non precoded wav file playing; use 5min wave particle lecture as demo
This commit is contained in:
@@ -78,23 +78,32 @@ class AuracastBigConfigFra(AuracastBigConfig):
|
|||||||
name: str = 'Auditoire A'
|
name: str = 'Auditoire A'
|
||||||
language: str ='fra'
|
language: str ='fra'
|
||||||
program_info: str = 'Auditoire FR'
|
program_info: str = 'Auditoire FR'
|
||||||
audio_source: str = 'file:./testdata/announcement_fr.wav'
|
audio_source: str = 'file:./testdata/wave_particle_5min_fr.wav'
|
||||||
|
|
||||||
class AuracastBigConfigSpa(AuracastBigConfig):
|
class AuracastBigConfigSpa(AuracastBigConfig):
|
||||||
id: int =12345
|
id: int =12345
|
||||||
random_address: str = 'F4:F1:F2:F3:F4:F5'
|
random_address: str = 'F4:F1:F2:F3:F4:F5'
|
||||||
name: str = 'Broadcast3'
|
name: str = 'Auditorio A'
|
||||||
language: str ='spa'
|
language: str ='spa'
|
||||||
program_info: str = 'Announcements Spanish'
|
program_info: str = 'Auditorio ES'
|
||||||
audio_source: str = 'file:./testdata/announcement_es.wav'
|
audio_source: str = 'file:./testdata/wave_particle_5min_es.wav'
|
||||||
|
|
||||||
class AuracastBigConfigIta(AuracastBigConfig):
|
class AuracastBigConfigIta(AuracastBigConfig):
|
||||||
id: int =1234567
|
id: int =1234567
|
||||||
random_address: str = 'F5:F1:F2:F3:F4:F5'
|
random_address: str = 'F5:F1:F2:F3:F4:F5'
|
||||||
name: str = 'Broadcast4'
|
name: str = 'Aula A'
|
||||||
language: str ='ita'
|
language: str ='ita'
|
||||||
program_info: str = 'Announcements Italian'
|
program_info: str = 'Aula IT'
|
||||||
audio_source: str = 'file:./testdata/announcement_it.wav'
|
audio_source: str = 'file:./testdata/wave_particle_5min_it.wav'
|
||||||
|
|
||||||
|
|
||||||
|
class AuracastBigConfigPol(AuracastBigConfig):
|
||||||
|
id: int =12345678
|
||||||
|
random_address: str = 'F6:F1:F2:F3:F4:F5'
|
||||||
|
name: str = 'Sala Wykładowa'
|
||||||
|
language: str ='pol'
|
||||||
|
program_info: str = 'Sala Wykładowa PL'
|
||||||
|
audio_source: str = 'file:./testdata/wave_particle_5min_pl.wav'
|
||||||
|
|
||||||
|
|
||||||
class AuracastConfigGroup(AuracastGlobalConfig):
|
class AuracastConfigGroup(AuracastGlobalConfig):
|
||||||
|
|||||||
@@ -520,28 +520,29 @@ class Streamer():
|
|||||||
|
|
||||||
if pcm_format.channels != 1:
|
if pcm_format.channels != 1:
|
||||||
logging.info("Input device provides %d channels – will down-mix to mono for LC3", pcm_format.channels)
|
logging.info("Input device provides %d channels – will down-mix to mono for LC3", pcm_format.channels)
|
||||||
if pcm_format.sample_type == audio_io.PcmFormat.SampleType.INT16:
|
if pcm_format.sample_type == audio_io.PcmFormat.SampleType.INT16:
|
||||||
pcm_bit_depth = 16
|
pcm_bit_depth = 16
|
||||||
elif pcm_format.sample_type == audio_io.PcmFormat.SampleType.FLOAT32:
|
elif pcm_format.sample_type == audio_io.PcmFormat.SampleType.FLOAT32:
|
||||||
pcm_bit_depth = None
|
pcm_bit_depth = None
|
||||||
else:
|
else:
|
||||||
logging.error("Only INT16 and FLOAT32 sample types are supported")
|
logging.error("Only INT16 and FLOAT32 sample types are supported")
|
||||||
return
|
return
|
||||||
encoder = lc3.Encoder(
|
|
||||||
frame_duration_us=global_config.frame_duration_us,
|
encoder = lc3.Encoder(
|
||||||
sample_rate_hz=global_config.auracast_sampling_rate_hz,
|
frame_duration_us=global_config.frame_duration_us,
|
||||||
num_channels=1,
|
sample_rate_hz=global_config.auracast_sampling_rate_hz,
|
||||||
input_sample_rate_hz=pcm_format.sample_rate,
|
num_channels=1,
|
||||||
)
|
input_sample_rate_hz=pcm_format.sample_rate,
|
||||||
lc3_frame_samples = encoder.get_frame_samples() # number of the pcm samples per lc3 frame
|
)
|
||||||
|
|
||||||
big['pcm_bit_depth'] = pcm_bit_depth
|
lc3_frame_samples = encoder.get_frame_samples() # number of the pcm samples per lc3 frame
|
||||||
big['channels'] = pcm_format.channels
|
big['pcm_bit_depth'] = pcm_bit_depth
|
||||||
big['lc3_frame_samples'] = lc3_frame_samples
|
big['channels'] = pcm_format.channels
|
||||||
big['lc3_bytes_per_frame'] = global_config.octets_per_frame
|
big['lc3_frame_samples'] = lc3_frame_samples
|
||||||
big['audio_input'] = audio_input
|
big['lc3_bytes_per_frame'] = global_config.octets_per_frame
|
||||||
big['encoder'] = encoder
|
big['audio_input'] = audio_input
|
||||||
big['precoded'] = False
|
big['encoder'] = encoder
|
||||||
|
big['precoded'] = False
|
||||||
|
|
||||||
|
|
||||||
logging.info("Streaming audio...")
|
logging.info("Streaming audio...")
|
||||||
@@ -551,7 +552,6 @@ class Streamer():
|
|||||||
while self.is_streaming:
|
while self.is_streaming:
|
||||||
stream_finished = [False for _ in range(len(bigs))]
|
stream_finished = [False for _ in range(len(bigs))]
|
||||||
for i, big in enumerate(bigs.values()):
|
for i, big in enumerate(bigs.values()):
|
||||||
|
|
||||||
if big['precoded']:# everything was already lc3 coded beforehand
|
if big['precoded']:# everything was already lc3 coded beforehand
|
||||||
lc3_frame = bytes(
|
lc3_frame = bytes(
|
||||||
itertools.islice(big['lc3_frames'], big['lc3_bytes_per_frame'])
|
itertools.islice(big['lc3_frames'], big['lc3_bytes_per_frame'])
|
||||||
@@ -642,7 +642,7 @@ if __name__ == "__main__":
|
|||||||
bigs = [
|
bigs = [
|
||||||
auracast_config.AuracastBigConfigDeu(),
|
auracast_config.AuracastBigConfigDeu(),
|
||||||
auracast_config.AuracastBigConfigEng(),
|
auracast_config.AuracastBigConfigEng(),
|
||||||
#auracast_config.AuracastBigConfigFra(),
|
auracast_config.AuracastBigConfigFra(),
|
||||||
#auracast_config.AuracastBigConfigEs(),
|
#auracast_config.AuracastBigConfigEs(),
|
||||||
#auracast_config.AuracastBigConfigIt(),
|
#auracast_config.AuracastBigConfigIt(),
|
||||||
]
|
]
|
||||||
@@ -656,15 +656,15 @@ if __name__ == "__main__":
|
|||||||
#config.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001057705357-if02,1000000,rtscts' # transport for nrf54l15dk
|
#config.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001057705357-if02,1000000,rtscts' # transport for nrf54l15dk
|
||||||
#config.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_95A087EADB030B24-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
|
#config.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_95A087EADB030B24-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
|
||||||
#config.transport='usb:2fe3:000b' #nrf52dongle hci_usb # TODO: iso packet over usb not supported
|
#config.transport='usb:2fe3:000b' #nrf52dongle hci_usb # TODO: iso packet over usb not supported
|
||||||
# config.transport= 'auto'
|
config.transport= 'auto'
|
||||||
config.transport='serial:/dev/ttyAMA3,1000000,rtscts' # transport for raspberry pi
|
#config.transport='serial:/dev/ttyAMA3,1000000,rtscts' # transport for raspberry pi
|
||||||
|
|
||||||
# TODO: encrypted streams are not working
|
# TODO: encrypted streams are not working
|
||||||
|
|
||||||
for big in config.bigs:
|
for big in config.bigs:
|
||||||
#big.code = 'ff'*16 # returns hci/HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE_ERROR
|
#big.code = 'ff'*16 # returns hci/HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE_ERROR
|
||||||
#big.code = '78 e5 dc f1 34 ab 42 bf c1 92 ef dd 3a fd 67 ae'
|
#big.code = '78 e5 dc f1 34 ab 42 bf c1 92 ef dd 3a fd 67 ae'
|
||||||
big.precode_wav = True
|
big.precode_wav = False
|
||||||
#big.audio_source = big.audio_source.replace('.wav', '_10_16_32.lc3') #lc3 precoded files
|
#big.audio_source = big.audio_source.replace('.wav', '_10_16_32.lc3') #lc3 precoded files
|
||||||
#big.audio_source = read_lc3_file(big.audio_source) # load files in advance
|
#big.audio_source = read_lc3_file(big.audio_source) # load files in advance
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user