FAQ
Hello list,

Here's a little Python toy I've been hacking on, as I thought it might
amuse some of you. [1] Python 3.1+ (not sure about 3.0)

It's a package called 'audiogen' which includes bindings to libao for
portable audio output and some functions/classes/... for generating
audio. It grew from the idea that code like this would be neat:

def sinewave(arguments go here):
wavetable = # generate sinusoid waveform
while True:
yield wavetable

or even something like this:

def eric_idle(arguments do here):
for note in (Do, Re, Mi):
yield plucked_string(note)
yield pause(beats=2)

Generalised a bit to allow for stereo / multi-channel output, plus some
decorators, and you get pyaudiogen. Some examples and all the code is on
bitbucket [1]. For good measure, here's the sine wave function sketched
above as real, working, code:

@wave_gen(channels=1) # mono output
def sinusoid(freq, amp, srate : 'rate'):
from math import sin, pi
wavelength = srate // freq
wavetable = wave.from_float(amp*sin(2 * pi * x / wavelength)
for x in range(int(wavelength)))
while True:
yield (wavetable,)


Suggestions welcomed!

-- Thomas


[1] <URL:http://bitbucket.org/jollybox/pyaudiogen>

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 15, '10 at 8:36p
activeJun 15, '10 at 8:36p
posts1
users1
websitepython.org

1 user in discussion

Thomas Jollans: 1 post

People

Translate

site design / logo © 2022 Grokbase