pyalsaaudio icon indicating copy to clipboard operation
pyalsaaudio copied to clipboard

play sine on either left or right

Open GOBish opened this issue 6 years ago • 2 comments

Hi, I'm trying to generate a sine wave and play it on either the left channel or right channel. I have been experimenting with the isine code, thank you very much for providing that. Could you possibly give an example of how I could achieve this? Also, to implement the isine code I have been using "from isine import change" but then I need a sleep function to get it to play for any time. Is this how it is intended to be used or am I doing it wrong? Thanks!

GOBish avatar Sep 16 '18 03:09 GOBish

These might be of interest to you:

https://github.com/ttm/mass https://github.com/ttm/music

kfrncs avatar Sep 18 '18 20:09 kfrncs

To play data on just one channel, you could open a stereo device and set the data for one channel to 0 - typically the data for stereo is interleaved (LRLR off the top of my head). The size of your data and its interpretation depend on the format, though.

The default format is PCM_FORMAT_S16_LE. So you could use struct.pack('hh', 0, v) to construct a single frame.

larsimmisch avatar Jul 13 '20 20:07 larsimmisch

this question is moderately related to the sine example failing to work as advertised, see #42.

other than that, i think we can close this as "resolved support question".

ossilator avatar Feb 01 '24 21:02 ossilator