4 Replies - 900 Views - Last Post: 11 April 2016 - 04:59 AM Rate Topic: -----

#1 civral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-March 16

Python 3D sound with openAL

Posted 09 April 2016 - 02:32 PM

Hi guys,
I am experimenting with 3D sound and python.
I came across openAL, and i think it is a great library for 3D sound.
Tried some code from documentation, but it I have some problems with it.

from openal.loaders import load_wav_file
from openal.audio import *

sink = SoundSink()   
listener = SoundListener()
listener.position = (0, 0, 0)
listener.velocity = (0, 0, 0)
listener.orientation = (0, 0, -1, 0, 1, 0)
source = SoundSource()
wavsound = load_wav_file("test.wav")
source.queue(wavsound)
SoundSink.play(source)



and this is my error:

Quote

TypeError: play() missing 1 required positional argument: 'sources'


Is This A Good Question/Topic? 0
  • +

Replies To: Python 3D sound with openAL

#2 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Python 3D sound with openAL

Posted 09 April 2016 - 03:49 PM

Shouldn't you be calling play() on the instance, not the class itself?

# Not
SoundSink.play(source)

# But rather
sink.play(source)


Was This Post Helpful? 0
  • +
  • -

#3 civral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-March 16

Re: Python 3D sound with openAL

Posted 10 April 2016 - 01:11 PM

No, this does not help.
If I play it like that:

sink.play(source)


the error is:

Quote

openal.audio.OpenALError: 'Invalid context'

Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Python 3D sound with openAL

Posted 10 April 2016 - 02:55 PM

That is improvement, mate. Not all errors are equal. Now, at least, you are getting a specific OpenAL error, instead of a generic Python TypeError.

Now you just need to figure out why the 'context' is 'invalid'. I don't know this library, but just skimming the docs Google found for me, it talks about how to set different contexts. You may want to try that, see if it changes anything.
Was This Post Helpful? 0
  • +
  • -

#5 civral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-March 16

Re: Python 3D sound with openAL

Posted 11 April 2016 - 04:59 AM

So i got it to execute, but it does not play the sound with desired effect

sink = SoundSink()   
listener = SoundListener()
SoundSink.activate(sink)
listener.position = (0, 0, 0)
listener.velocity = (0, 0, 0)
listener.orientation = (0, 0, -1, 0, 1, 0)
source = SoundSource()
wavsound = load_wav_file("test.wav")
source.queue(wavsound)
#SoundSink.play(source)
sink.play(source)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1