Mit der Zielsetzung einen Sinuston beliebiger Frequenz zu erzeugen habe ich ein Programm erstellt.
Code: Alles auswählen
def sineWave(samplingRate):
sinFrequency = np.arange(samplingRate)*int(fField.get())
nbrSinValues = sinFrequency/samplingRate
sinRaw = np.sin((2*Pi)*nbrSinValues)
sinWave = sinRaw.astype(np.float32)
sinWave = sinWave * volume
return sinWave
def callback(in_data, frame_count, time_info, status):
data = sineWave(samplingRate)
return ( data, pyaudio.paContinue)
def streamOn():
stream = p.open(format=pyaudio.paFloat32,
channels=1,
rate=samplingRate,
output=True,
start=True,
stream_callback=callback,
frames_per_buffer = samplingRate)
Sobald ich channels auf 2 setzte, wird der callback ungültig, der stream spielt nur einmal den Frame-Puffer und bricht dann ab.
Gruss
Christoph