mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
reduced audio block size
This commit is contained in:
parent
33cb040edf
commit
05bff2ff70
4 changed files with 12 additions and 10 deletions
|
@ -26,7 +26,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
# DJ2LS: 3.5 seconds is working well WITHOUT a channel busy detection delay
|
# DJ2LS: 3.5 seconds is working well WITHOUT a channel busy detection delay
|
||||||
TIMEOUT_CHANNEL_BUSY = 0
|
TIMEOUT_CHANNEL_BUSY = 0
|
||||||
TIMEOUT_CONNECT_ACK = 3.5 + TIMEOUT_CHANNEL_BUSY
|
TIMEOUT_CONNECT_ACK = 3.5 + TIMEOUT_CHANNEL_BUSY
|
||||||
TIMEOUT_TRANSFER = 2 + TIMEOUT_CHANNEL_BUSY
|
TIMEOUT_TRANSFER = 3.5 + TIMEOUT_CHANNEL_BUSY
|
||||||
TIMEOUT_STOP_ACK = 3.5 + TIMEOUT_CHANNEL_BUSY
|
TIMEOUT_STOP_ACK = 3.5 + TIMEOUT_CHANNEL_BUSY
|
||||||
|
|
||||||
STATE_TRANSITION = {
|
STATE_TRANSITION = {
|
||||||
|
|
|
@ -200,6 +200,7 @@ class Demodulator():
|
||||||
'snr': snr,
|
'snr': snr,
|
||||||
'frequency_offset': self.get_frequency_offset(freedv),
|
'frequency_offset': self.get_frequency_offset(freedv),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data_queue_received.put(item)
|
self.data_queue_received.put(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class EventManager:
|
||||||
|
|
||||||
def broadcast(self, data):
|
def broadcast(self, data):
|
||||||
for q in self.queues:
|
for q in self.queues:
|
||||||
self.logger.debug(f"Event: ", ev=data)
|
#self.logger.debug(f"Event: ", ev=data)
|
||||||
if q.qsize() > 10:
|
if q.qsize() > 10:
|
||||||
q.queue.clear()
|
q.queue.clear()
|
||||||
q.put(data)
|
q.put(data)
|
||||||
|
|
|
@ -152,7 +152,7 @@ class RF:
|
||||||
callback=self.sd_input_audio_callback,
|
callback=self.sd_input_audio_callback,
|
||||||
device=in_dev_index,
|
device=in_dev_index,
|
||||||
samplerate=self.AUDIO_SAMPLE_RATE,
|
samplerate=self.AUDIO_SAMPLE_RATE,
|
||||||
blocksize=4800,
|
blocksize=1200,
|
||||||
)
|
)
|
||||||
self.sd_input_stream.start()
|
self.sd_input_stream.start()
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class RF:
|
||||||
callback=self.sd_output_audio_callback,
|
callback=self.sd_output_audio_callback,
|
||||||
device=out_dev_index,
|
device=out_dev_index,
|
||||||
samplerate=self.AUDIO_SAMPLE_RATE,
|
samplerate=self.AUDIO_SAMPLE_RATE,
|
||||||
blocksize=4800,
|
blocksize=256,
|
||||||
)
|
)
|
||||||
self.sd_output_stream.start()
|
self.sd_output_stream.start()
|
||||||
|
|
||||||
|
@ -215,9 +215,7 @@ class RF:
|
||||||
self, mode, repeats: int, repeat_delay: int, frames: bytearray
|
self, mode, repeats: int, repeat_delay: int, frames: bytearray
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
|
||||||
|
|
||||||
self.demodulator.reset_data_sync()
|
self.demodulator.reset_data_sync()
|
||||||
|
|
||||||
# Wait for some other thread that might be transmitting
|
# Wait for some other thread that might be transmitting
|
||||||
self.states.waitForTransmission()
|
self.states.waitForTransmission()
|
||||||
self.states.setTransmitting(True)
|
self.states.setTransmitting(True)
|
||||||
|
@ -235,6 +233,8 @@ class RF:
|
||||||
else:
|
else:
|
||||||
txbuffer_out = x
|
txbuffer_out = x
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# transmit audio
|
# transmit audio
|
||||||
self.enqueue_audio_out(txbuffer_out)
|
self.enqueue_audio_out(txbuffer_out)
|
||||||
|
|
||||||
|
@ -246,11 +246,11 @@ class RF:
|
||||||
|
|
||||||
def enqueue_audio_out(self, audio_48k) -> None:
|
def enqueue_audio_out(self, audio_48k) -> None:
|
||||||
self.enqueuing_audio = True
|
self.enqueuing_audio = True
|
||||||
|
|
||||||
if not self.states.isTransmitting():
|
if not self.states.isTransmitting():
|
||||||
self.states.setTransmitting(True)
|
self.states.setTransmitting(True)
|
||||||
|
|
||||||
self.radio.set_ptt(True)
|
self.radio.set_ptt(True)
|
||||||
|
|
||||||
self.event_manager.send_ptt_change(True)
|
self.event_manager.send_ptt_change(True)
|
||||||
|
|
||||||
if self.radiocontrol in ["tci"]:
|
if self.radiocontrol in ["tci"]:
|
||||||
|
@ -259,7 +259,7 @@ class RF:
|
||||||
self.tci_module.wait_until_transmitted(audio_48k)
|
self.tci_module.wait_until_transmitted(audio_48k)
|
||||||
else:
|
else:
|
||||||
# slice audio data to needed blocklength
|
# slice audio data to needed blocklength
|
||||||
block_size = 4800
|
block_size = 256
|
||||||
pad_length = -len(audio_48k) % block_size
|
pad_length = -len(audio_48k) % block_size
|
||||||
padded_data = np.pad(audio_48k, (0, pad_length), mode='constant')
|
padded_data = np.pad(audio_48k, (0, pad_length), mode='constant')
|
||||||
sliced_audio_data = padded_data.reshape(-1, block_size)
|
sliced_audio_data = padded_data.reshape(-1, block_size)
|
||||||
|
@ -267,6 +267,7 @@ class RF:
|
||||||
for block in sliced_audio_data:
|
for block in sliced_audio_data:
|
||||||
self.audio_out_queue.put(block)
|
self.audio_out_queue.put(block)
|
||||||
|
|
||||||
|
|
||||||
self.enqueuing_audio = False
|
self.enqueuing_audio = False
|
||||||
self.states.transmitting_event.wait()
|
self.states.transmitting_event.wait()
|
||||||
|
|
||||||
|
@ -277,7 +278,7 @@ class RF:
|
||||||
|
|
||||||
def sd_output_audio_callback(self, outdata: np.ndarray, frames: int, time, status) -> None:
|
def sd_output_audio_callback(self, outdata: np.ndarray, frames: int, time, status) -> None:
|
||||||
try:
|
try:
|
||||||
if not self.audio_out_queue.empty():
|
if not self.audio_out_queue.empty() and not self.enqueuing_audio:
|
||||||
chunk = self.audio_out_queue.get_nowait()
|
chunk = self.audio_out_queue.get_nowait()
|
||||||
audio.calculate_fft(chunk, self.fft_queue, self.states)
|
audio.calculate_fft(chunk, self.fft_queue, self.states)
|
||||||
outdata[:] = chunk.reshape(outdata.shape)
|
outdata[:] = chunk.reshape(outdata.shape)
|
||||||
|
@ -285,7 +286,7 @@ class RF:
|
||||||
else:
|
else:
|
||||||
# reset transmitting state only, if we are not actively processing audio
|
# reset transmitting state only, if we are not actively processing audio
|
||||||
# for avoiding a ptt toggle state bug
|
# for avoiding a ptt toggle state bug
|
||||||
if not self.enqueuing_audio:
|
if self.audio_out_queue.empty() and not self.enqueuing_audio:
|
||||||
self.states.setTransmitting(False)
|
self.states.setTransmitting(False)
|
||||||
# Fill with zeros if the queue is empty
|
# Fill with zeros if the queue is empty
|
||||||
outdata.fill(0)
|
outdata.fill(0)
|
||||||
|
|
Loading…
Reference in a new issue