I'm using pyaudio in a school project and I'm trying to get the sound to play on only one speaker at a time. My code is like this:
import pyaudio
p = pyaudio.PyAduio()
def play_wave(stream, wave):
chunks = []
chunks.append(wave)
chunk = concatenate(chunks)*0.1
stream.write(chunk.astype(np.float32).tostring())
def play_sound(freq, t, A=0.2):
wave, A = wavefunc(t, freq, A=A)
S = sigmoid(t)
wave = wave*S
stream = p.open(channels=1, rate=44100, format=pyaudio.paFloat32, output=True)
play_wave(stream,wave)
stream.close()
where wavefunc just generates a wave.
Does anybody know what to do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…