[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] playing a pure tone from Numeric array



I am trying to use pygame to create sound arrays with Numeric.  When I
try and play the sound, no sound comes out.  Here is what I am doing:

    from Numeric import *
    from pygame import mixer, sndarray, time

    mixer.init(22050, 16, 0)

    phi = arange(44100) / 4.0
    s = sin(phi).astype(Int16)
    snd = sndarray.make_sound(s)
    snd.play()

    while mixer.get_busy():
        time.wait(200)

I don't think it is a problem with my setup or soundcard, because I
can use pygame to play wav files, as in

    from pygame import mixer, time

    mixer.init(22050, 8, 0) 
    sound = mixer.Sound('heile.wav')
    sound.play()

    while mixer.get_busy():
        time.wait(200)

Any advice on what I am doing wrong in my array example?

Thanks,
John Hunter

pygame-1.5.6
Numeric 23
Python 2.2.2 (#2, May  6 2003, 12:00:14)
[GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2