Generating Tones With Python

John O'Hagan research at johnohagan.com
Mon May 18 02:33:03 EDT 2009


On Mon, 18 May 2009, Adam Gaskins wrote:
> I am pretty sure this shouldn't be as hard as I'm making it to be, but
> how does one go about generating tones of specific frequency, volume, and
> L/R pan? I've been digging around the internet for info, and found a few
> examples. One was with gstreamer, but I can't find much in the
> documentation to explain how to do this. Also some people said to use
> tksnack snack, but the one example I found to do this didn't do  anything
> on my machine, no error or sounds. I'd like this to be cross platform,
> but at this point I just want to do it any way I can.
[...]

I've done this using the subprocess module to call the sox program (which has 
a built-in synth to generate customisable tones, and can play sound files) or 
using the socket module to send control messages to a running instance of the 
fluidsynth program (which can generate sound using soundfonts). The former is 
very simple, the latter is very responsive to quick changes. I think both 
programs are cross-platform.

HTH,

John



More information about the Python-list mailing list