python - Play square wave SciPy and PyAudio -


i'm trying play square waves generated using scipy pyaudio error

typeerror: len() of unsized object

which kind of strange because square wave object should have size, right?

rate = 48000 p = pyaudio.pyaudio() stream = p.open(format = pyaudio.paint16,             channels = 2,             rate = rate,             output = true) # ... inside loop     wav = signal.square(2*math.pi*freq*t)     wav = wav.astype(np.int16)     stream.write(wav) # crash here 

the crash happens on first iteration of loop, suppose loop not problem.

i same error. however, omitting information, assume these imports:

import pyaudio import math import numpy np scipy import signal 

and that

freq = 440 

it looks variable iterating t , it's scalar. might have reasons this, don't think how scipy.signal meant work. if use vector t instead:

t = np.linspace(0, 2) 

then signal.square(...) , stream.write(wav.astype(np.int16)) work without problems.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -