mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Shouldn't pass np.int16 to pyaudio stream.write(), must convert to Python bytes. Working OK now
This commit is contained in:
parent
64b7582913
commit
8fcf882767
|
@ -68,7 +68,7 @@ if AUDIO_OUTPUT_DEVICE != -1:
|
||||||
rate=AUDIO_SAMPLE_RATE_TX,
|
rate=AUDIO_SAMPLE_RATE_TX,
|
||||||
frames_per_buffer=AUDIO_FRAMES_PER_BUFFER, #n_nom_modem_samples
|
frames_per_buffer=AUDIO_FRAMES_PER_BUFFER, #n_nom_modem_samples
|
||||||
output=True,
|
output=True,
|
||||||
output_device_index=AUDIO_OUTPUT_DEVICE,
|
output_device_index=AUDIO_OUTPUT_DEVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,16 +139,16 @@ for i in range(1,N_BURSTS+1):
|
||||||
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*2)
|
mod_out_silence = create_string_buffer(samples_delay*2)
|
||||||
txbuffer += bytes(mod_out_silence)
|
txbuffer += bytes(mod_out_silence)
|
||||||
print(f"samples_delay: {samples_delay} DELAY_BETWEEN_BURSTS: {DELAY_BETWEEN_BURSTS}", file=sys.stderr)
|
#print(f"samples_delay: {samples_delay} DELAY_BETWEEN_BURSTS: {DELAY_BETWEEN_BURSTS}", file=sys.stderr)
|
||||||
|
|
||||||
# resample up to 48k
|
# resample up to 48k (resampler works on np.int16)
|
||||||
x = np.frombuffer(txbuffer, dtype=np.int16)
|
x = np.frombuffer(txbuffer, dtype=np.int16)
|
||||||
txbuffer_48k = resampler.resample8_to_48(x)
|
txbuffer_48k = resampler.resample8_to_48(x)
|
||||||
print(len(txbuffer), len(x), len(txbuffer_48k), file=sys.stderr)
|
|
||||||
|
|
||||||
# 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 != -1:
|
if AUDIO_OUTPUT_DEVICE != -1:
|
||||||
stream_tx.write(txbuffer_48k)
|
# Gotcha: we have to convert from np.int16 to Python "bytes"
|
||||||
|
stream_tx.write(txbuffer_48k.tobytes())
|
||||||
else:
|
else:
|
||||||
# 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_48k)
|
sys.stdout.buffer.write(txbuffer_48k)
|
||||||
|
|
Loading…
Reference in a new issue