Sound programming: Tone production in Python?
andrew at indranet.co.nz
Thu Jan 23 01:09:24 CET 2003
sndarray just gives you a way to access raw sample data. If you want to
make tones, calculate a sine wave with the right period, amplitude and
zero-offset (which will depend on the output format and sample rate), and
use sndarray to play it.
It would help to know better what you want to do, as messing with audio can
pretty quickly get out of python's performance envelope. As such, you
might be better sticking to controlling something external (like a
--On Wednesday, January 22, 2003 15:41:10 -0500 Joseph Blaylock
<blaylock at indiana.edu> wrote:
> I've been searching around the 'net for information on sound programming
> in Python, particularly tutorials, etc., but the outlook appears to be
> pretty bleak. There's a lot of stuff about playing back
> previously-sampled audio files, but I haven't found anything about making
> music or (especially) generating raw tones.
> For example, if I wanted to generate a tone of 200 hertz and a tone of 205
> hertz on audio channels 0 and 1, respectively, for a duration of two
> seconds, how might I accomplish this? Pygame's sndarray module looks
> promising, but seems a bit light on it's documentation, especially of a
> tutorial nature.
> So: can anybody tell me a sure-fire way to generate tones from Python?
> Bonus points for sticking to packages that are in Debian unstable, or
> part of the basic distribution. And further, can anybody provide me
> pointers to more generalized sound/music programming resources for
> Python, especially of a tutorial nature?
More information about the Python-list