bastibe / PySoundCard

PySoundCard is an audio library based on PortAudio, CFFI and NumPy
BSD 3-Clause "New" or "Revised" License
87 stars 9 forks source link

playing 1D matrices does not play stereo #50

Closed bastibe closed 9 years ago

mgeier commented 9 years ago

This depends on the host API.

Which one are you talking about?

For example ALSA does what you apparently want, JACK doesn't.

bastibe commented 9 years ago

This bug has been introduced in 820a916e291ad104609cb3d95c00b87f53d35183 (by me) and has been broken ever since.

The original code did not call tile on 1D arrays.

By the way, the original code also used asmatrix to make a 1D sequence into a 2D array. This is wrong. Numpy matrices are 2D arrays that overload mathematical operators to do matrix math. In contrast, atleast_2d promotes 1D arrays to two dimensions, but mathematical operators still work element-wise.

Some of my students actually need this fixed, so I'd appreciate a quick merge.

mgeier commented 9 years ago

Sure, merge away!

To me, this is dead code anyway. Once we have a high-level interface (play(), rec() and playrec(), see #19) we can remove all the "intelligent" broadcasting in write() (see #15).

In the meantime, you could give your students the hint to use the "playrec" branch; that's what I did to mine: http://nbviewer.ipython.org/github/spatialaudio/communication-acoustics-exercises/blob/master/intro.ipynb#Listening-to-the-Signal.