Simple background sound effect playback

Jacob Kruger jacob at blindza.co.za
Wed Dec 17 14:41:40 EST 2014


Ok, trying simple code from a pygame tutorial snippet - nothing happens - just silent, but with no errors being returned:

# play a sound to the left, to the right and to the center

# import the time standard module
import time

# import the pygame module
import pygame


# start pygame
pygame.init()

# load a sound file into memory
sound = pygame.mixer.Sound("bird.ogg")

# start playing the sound
# and remember on which channel it is being played
channel = sound.play()
# set the volume of the channel
# so the sound is only heard to the left
channel.set_volume(1, 0)
# wait for 1 second
time.sleep(1)

# do the same to the right
channel = sound.play()
channel.set_volume(0, 1)
time.sleep(1)

# do the same to the center
channel = sound.play()
channel.set_volume(1, 1)
time.sleep(1)
#end code

Think this is why ignored pygame in past...<smile> - think it actually needs more than itself to be installed, or something.

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...

  ----- Original Message ----- 
  From: Ian Kelly 
  To: Python 
  Sent: Wednesday, December 17, 2014 3:49 AM
  Subject: Re: Simple background sound effect playback


  On Tue, Dec 16, 2014 at 9:57 AM, Jacob Kruger <jacob at blindza.co.za> wrote:
  >
  > Would prefer to use something free, that could work somewhat cross-platform, but, my primary target is for windows OS, and would primarily just want to be able to easily trigger playback of either .wav or .mp3 background sound effects, but, yes, would also be nice to be able to control them a little bit in terms of volume, possibly stereo panning as well as playback rate/frequency/pitch?
  >  
  > I have used something called sound_lib, as well as another one relating to a sort of windows directSound effect, but, both of them had issues when working with either py2exe or cx_freeze when it came to compiling into executable, and main thing is would like to keep it simple...<smile>
  >  
  > Suggestions?


  https://wiki.python.org/moin/Audio/


------------------------------------------------------------------------------


  -- 
  https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141217/41e7b781/attachment.html>


More information about the Python-list mailing list