Re: Lightweight OpenAL Python Wrapper

@8
Yes, absolutely. You can position a player at the same location as the listener, which would play it without rolloff or panning applied.

@9
Hm, digging into the bindings of the wrapper it seems that the listeners position is set by alListener3f, which expects 3 values, but that the orientation is set with alListenerfv which expects a pointer to a ctypes float array. The C based example code in the OpenAL documentation puts it like this:

ALfloat listenerOri[]={0.0,0.0,-1.0, 0.0,1.0,0.0}; 

// Orientation ... 
alListenerfv(AL_ORIENTATION,listenerOri); 

So, the Python equivalent might look something like this:

test = [1.456,1.54,1.88, 0.4,2.23,0.1]
test = ctypes.pointer((ctypes.c_float * len(test))(*test))

al.alListenerfv(al.AL_ORIENTATION,test[0])

I haven't had the opportunity to test this out though, so grain of salt and all that.

The actual handler classes included in it don't have all the features implemented, it actually disables source relative in the player by default but didn't have the function to change that, oops. I've cleaned it up a bit and fixed some of the python 3 bugs, and put in a source relative toggle setting. I might go over it a bit later to make the handler classes more feature complete for the listener and player cone orientation settings and such. Note that the OpenAL32.dll version packed with it is the 32 bit version, if your running 64 bit python you'll need to grab the 64 bit version from OpenAL-Soft.

@10
I haven't played around much with ogg, but it should be possible to decode it with something like [PyOgg] and pass it to an OpenAL buffer for playback. I might play around more with that later and see how it goes.

EDIT:
I've messed around a bit more with PyOgg and managed to successfully load and playback an ogg file with OpenAL, its seems fairly straight forward. What you do is load the ogg file, then use a custom BufferSound() object and pass the ogg's data into it, then load it into a player like any other audio file, i'm currently using a sample sound off wikipedia [here]. Example:

from openal import *
import pyogg
import time

class Example(object):
    def __init__(self):
    #load listener
        self.listener = Listener()
    #load ogg file
        tmp = pyogg.VorbisFile("Example.ogg")

        self.buffer = BufferSound()
    #set channels, bitrate, and samplerate
        self.buffer.configure(tmp.channels, self.buffer.bitrate, tmp.frequency)
    #load audio data
        self.buffer.load(tmp.buffer)

    #load sound player
        self.player = Player()
    #load sound into player
        self.player.add(self.buffer)
    #set rolloff factor
        self.player.rolloff = 0.01
    #play sound
        self.player.play()
    #give time for the sound to play
        time.sleep(6)
    #stop player
        self.player.stop()

    #clean up resources
        self.player.delete()
        self.buffer.delete()
        self.listener.delete()

Example()

In this case, the bitrate doesn't seem to be in the vorbis data, so I just pass the channels and sample rate, use the buffers existing bitrate, then load the data and play it.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : NicklasMCHD 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 : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : NicklasMCHD 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 : 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 : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector

Reply via email to