Re: I need help, again!

Like with programming languages in general, learning one can help you better understand and use others. Think of it more as gaining experience, it could prove useful in the future depending on your needs. Anyway, here's an example of Pygames mixer:

import pygame
from pygame import mixer
import sys

def Example():
#initialize pygame
    pygame.init()
#initialize sound mixer
    mixer.init()
#create display
    window = pygame.display.set_mode([640,480])
#load sound
    sound = mixer.Sound('tone5.wav')

#main update loop
    while True:
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
            #if space is pressed, play sound
                if event.key == pygame.K_SPACE:
                    sound.play()
            #if escape is pressed, quit
                if event.key == pygame.K_ESCAPE:
                    pygame.quit()
                    sys.exit(0)

    #update window
        pygame.display.update()

Example()

You can check how many instances of the sound are currently playing by using "sound.get_num_channels()", which can help you put a cap on it to prevent any overlap. You can also find the documentation for playing individual sounds and streaming sounds [here] and [here] respectively.

For OpenAL, you can download my example pack [here], but reflecting on it you don't actually need to install Pyglet to use it. What you do is take the python dependancy files: lib_openal.py, lib_alc.py, and lib_efx.py, and put them in the working directory of your script along with OpenAL32.dll, then import them. In the examples included in the OpenAL pack the imports are for a Pyglet install like so:

from pyglet.media.drivers.openal import lib_openal as al
from pyglet.media.drivers.openal import lib_alc as alc

But if the scripts are just in your working directory you can cut straight to:

import lib_openal as al
import lib_alc as alc

So when using the examples just change the imports appropriately. The examples come with OpenAL32.DLL already, but if you need to get it elsewhere or the latest version go to [OpenAL-Soft] and download the latest release, which is currently 1.19.1, unpack it and head into the /bin/x32 or /bin/x64 directories, depending. Rename either of the soft_oal.dll files to OpenAL32.dll, and copy it to your working directory with the py scripts, and you should be good to go.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector

Reply via email to