[Tutor] newbie "sound" question

Galen O'Neil goneil@scu.edu
09 Oct 2002 23:02:16 -0700


On Wed, 2002-10-09 at 21:25, udigom wrote:
> Hi all! Thanks for allowing me to join, lurk, and learn.
> 
> I am very new to python, and I have dl'ed the proper files and have had some
> basic experience with IDLE, etc.
> 
> I am curious-- I have duplicated the hello world.py, and some other
> exercises-- Is it possible to create sounds in .py files? If so, could one
> of you kind people provide me with a simple basic source code so that I can
> learn from it?


If you want to play sounds then you should check out pygame.
www.pygame.org

Make sure you get the examples, there is one called sound.py that is
pretty simple.

#load the sound    
file = os.path.join('data', 'secosmic_lo.wav')
sound = mixer.Sound(file)


#start playing
print 'Playing Sound...'
channel = sound.play()


#poll until finished
while channel.get_busy(): #still playing
    print '  ...still going...'
    time.wait(1000)
print '...Finished'