OpenAL with Python

Viewed 291

I wanted to create some 3D sounds using OpenAl just for fun. But I noticed there wasn't a lot of support for python. The only documentation I could find was PyAl. But as a beginner, I still can't get the basic code to run below that I got from the link. It just says no Module named 'openal.' I tried installing it via pip but that does not exist either.

I looked through the documentation and it said to run python setup.py install after downloading openAL from the website. I downloaded the openAL installer and it just said installation complete. There was no setup.py file to run. I do have the OpenAL32.dll file in my Windows/System32 folder though.

So I am a little confused as to how I can start using this module in python? Are there any tutorials for openAL with python or do you have any recommendations using another language with better documentation for a beginner?

from openal import al, alc # imports all relevant AL and ALC functions
def main():
    source = al.ALuint()
    device = alc.alcOpenDevice(None)
    if not device:
        error = alc.alcGetError()
        # do something with the error, which is a ctypes value
        return -1
    # Omit error checking
    context = alc.alcCreateContext(device, None)
    alc.alcMakeContextCurrent(context)
    # Do more things
    al.alGenSources(1, source)
    al.alSourcef(source, al.AL_PITCH, 1)
    al.alSourcef(source, al.AL_GAIN, 1)
    al.alSource3f(source, al.AL_POSITION, 10, 0, 0)
    al.alSource3f(source, al.AL_VELOCITY, 0, 0, 0)
    al.alSourcei(source, al.AL_LOOPING, 1)
    al.alDeleteSources(1, source)
    alc.alcDestroyContext(context)
    alc.alcCloseDevice(device)
    return 0
if __name__ == "__main__":
    raise SystemExit(main())
0 Answers
Related