Open bactone opened 3 years ago
while I found it's because the output level is too small, if i change the code outdata[:] = indata to outdata[:] = 5*indata, then i can hear the playback sound, thanks
@bactone please post code in a ```
environment so it is formatted in a readable way.
The way you want to specify the audio device and further parameters is probably more like this. Also see the documentation for Stream for further parameters.
import sounddevice as sd
DEVICE = "ASIO Fireface USB" # according to `sd.query_devices()`
SAMPLERATE = 44100 # Hz
CHANNELS = [1, 1]
BLOCKSIZE = 1024 # samples
DURATION = 5.5 # seconds
def callback(indata, outdata, frames, time, status):
if status:
print(status)
outdata[:] = indata
print(sd.query_devices())
with sd.Stream(
samplerate=SAMPLERATE,
blocksize=BLOCKSIZE,
device=DEVICE,
channels=CHANNELS,
callback=callback,
):
sd.sleep(int(DURATION * 1000))
I don't know what your hardware or intended use case is. But the outdata[:] = 5*indata
is of course a matter of signal amplification. That depends on what your respective levels of the audio hardware is (where there might be different ways of how they are set or influenced when using a ASIO vs. a non-ASIO driver on Windows for the same audio interface ... maybe).
@HaHeho thanks for your answer
hi, I have been running the callback example given at the web tutorial, https://python-sounddevice.readthedocs.io/en/0.4.1/usage.html#callback-streams, if use the default setting of devices, It works, however if i change the default device, i can't hear the voice played back, the revised code is given as:
so my question is, how to set the device, channel, and other paramters for callback and stream? thanks