mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
added time measurement
writing to stdout seems to be really slow after the first run...
This commit is contained in:
parent
e79aa0b457
commit
cd8f522f85
|
@ -48,10 +48,10 @@ if AUDIO_OUTPUT_DEVICE != 0:
|
||||||
output_device_index=AUDIO_OUTPUT_DEVICE,
|
output_device_index=AUDIO_OUTPUT_DEVICE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
modes = [14,10,12]
|
modes = [14,10,12]
|
||||||
for m in modes:
|
for m in modes:
|
||||||
|
|
||||||
|
|
||||||
freedv = cast(codec2.api.freedv_open(m), c_void_p)
|
freedv = cast(codec2.api.freedv_open(m), c_void_p)
|
||||||
|
|
||||||
n_tx_modem_samples = codec2.api.freedv_get_n_tx_modem_samples(freedv)
|
n_tx_modem_samples = codec2.api.freedv_get_n_tx_modem_samples(freedv)
|
||||||
|
@ -102,7 +102,8 @@ for m in modes:
|
||||||
samples_delay = int(MODEM_SAMPLE_RATE*DELAY_BETWEEN_BURSTS)
|
samples_delay = int(MODEM_SAMPLE_RATE*DELAY_BETWEEN_BURSTS)
|
||||||
mod_out_silence = create_string_buffer(samples_delay)
|
mod_out_silence = create_string_buffer(samples_delay)
|
||||||
txbuffer += bytes(mod_out_silence)
|
txbuffer += bytes(mod_out_silence)
|
||||||
|
|
||||||
|
|
||||||
# check if we want to use an audio device or stdout
|
# check if we want to use an audio device or stdout
|
||||||
if AUDIO_OUTPUT_DEVICE != 0:
|
if AUDIO_OUTPUT_DEVICE != 0:
|
||||||
|
|
||||||
|
@ -111,12 +112,22 @@ for m in modes:
|
||||||
stream_tx.write(audio[0])
|
stream_tx.write(audio[0])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
# this test needs a lot of time, so we are having a look at times...
|
||||||
|
starttime = time.time()
|
||||||
|
|
||||||
# print data to terminal for piping the output to other programs
|
# print data to terminal for piping the output to other programs
|
||||||
sys.stdout.buffer.write(txbuffer)
|
sys.stdout.buffer.write(txbuffer)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
# and at least print the needed time to see which time we needed
|
||||||
|
timeneeded = time.time()-starttime
|
||||||
|
print(f"time: {timeneeded}", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
# and at last check if we had an openend pyaudio instance and close it
|
# and at last check if we had an openend pyaudio instance and close it
|
||||||
if AUDIO_OUTPUT_DEVICE != 0:
|
if AUDIO_OUTPUT_DEVICE != 0:
|
||||||
stream_tx.close()
|
stream_tx.close()
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue