waiting for buffer

it seems we need to wait a little bit for our modulation data. There are some moments where audio output is stuck a little bit. Maybe python is sometimes faster than the buffer allocation or its a threading problem
This commit is contained in:
dj2ls 2021-12-26 18:41:43 +01:00
parent 88a0628b53
commit 3501b4f952
3 changed files with 7 additions and 5 deletions

View file

@ -646,7 +646,6 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
}
// BEACON STATE
console.log(arg.beacon_state)
if (arg.beacon_state == 'True') {
document.getElementById("startBeacon").className = "btn btn-success spinner-grow"
document.getElementById("startBeacon").disabled = true

View file

@ -617,6 +617,8 @@ def burst_rpt_received(data_in):
def open_dc_and_transmit(data_out, mode, n_frames_per_burst):
global DATA_CHANNEL_READY_FOR_DATA
static.TNC_STATE = 'BUSY'
asyncio.run(arq_open_data_channel(mode))
# wait until data channel is open

View file

@ -242,8 +242,9 @@ class RF():
# write preamble to txbuffer
codec2.api.freedv_rawdatapreambletx(freedv, mod_out_preamble)
time.sleep(0.01)
txbuffer += bytes(mod_out_preamble)
# create modulaton for n frames in list
for n in range(0,len(frames)):
@ -259,19 +260,19 @@ class RF():
data = (ctypes.c_ubyte * bytes_per_frame).from_buffer_copy(buffer)
codec2.api.freedv_rawdatatx(freedv,mod_out,data) # modulate DATA and save it into mod_out pointer
time.sleep(0.01)
txbuffer += bytes(mod_out)
# append postamble to txbuffer
codec2.api.freedv_rawdatapostambletx(freedv, mod_out_postamble)
txbuffer += bytes(mod_out_postamble)
time.sleep(0.01)
# add delay to end of frames
samples_delay = int(self.MODEM_SAMPLE_RATE*(repeat_delay/1000))
mod_out_silence = create_string_buffer(samples_delay*2)
txbuffer += bytes(mod_out_silence)
time.sleep(0.01)
# resample up to 48k (resampler works on np.int16)
x = np.frombuffer(txbuffer, dtype=np.int16)