Audaspace and bpy in standalone

Hi everybody!

I could need some help with this. I am working with the audaspace-module, because the sound logic-bricks seem to be a bit buggy, when there are too many sounds at a time. For example the background-music suddenly stops, when the player begins to walk and so on. With audaspace this does not seem to happen.

I want to leave the sounds inside the blend-file of my game, i don´t want the sound files outside of it. To solve this, i use the bpy-module to get the sound from inside the blend. Works perfect, here you can see the code:

from bge import logic
import bpy
import aud

cont = logic.getCurrentController()
own = cont.owner

if not 'init' in own:
    own['init'] = 1
    device = aud.device()
    sound1 =["ambient.dark.loop.mp3"].factory
    own["handle1"].loop_count = -1

Everything works just fine, but when i export the game as a standalone exe, the bpy-module is not on board. Error-message: “no module named bpy”. bpy is only usable inside Blender. So the question is:
Is there a way to access the sounds inside the blend-file with Audaspace without using bpy? I hope it sooooo much :yes:

And like i said: No, i can´t put the sounds outside the blend-file, because of the licenses.

Thank you in advance,

This is possible with aud.Factory(). Have a look at the API:

Edit: Just noticed you have to get sounds internally. This is easy. After packing all sounds add an empty and add actuators to it, each containing a sound. Then in the bge you can get all sounds through the actuators on that empty.

from bge import logic
sound_dict = { a.sound for a in logic.getCurrentScene().objects['Empty'].actuators}

Hello Raco,

i already looked at the API, but i doesn’t work. If i just change…

sound1 =[“ambient.dark.loop.mp3”].factory

… to …

sound1 = aud.Factory(‘ambient.dark.loop.mp3’)

… i get the console message “aud.error: AUD_FileFactory: File couldn’t be read” when i try to play it with this:


Maybe you could take the working code from my first post and change the line in the way you mean it works? This would be very helpful.

Thank you,

I’ve updated my previous post. I’m sorry for the mixup.

Hi Raco,

great! Works perfectly - you just saved our game project:

Thank you so much!


Oh cool, I didn’t know you could access sounds via logic bricks. Looks like I learn something new every day. Cool example, Raco.

I didn’t know either just until today. Glad it worked out for you, MrLarodos.

Yes, i am very glad, too! I got the full sound-db of the game in a cube now. The cube recieves messages and the subject of the message makes the sound with the same name play :slight_smile:
You will get a free copy of the game. Ok, it´s free anyway ;D

How can i mark the thread as solved? O.O

Edit your opening post, go advanced, change prefix (on top) to SOLVED.

BTW: Nice job on the game!

Ah, i found the “SOLVED” :slight_smile: Thank you again. The game will be very scary :slight_smile: If you live, your name will be in the credits. This thing your could have been a showstopper :slight_smile: