# Py: Audaspace,get sound from actual path.

**URL:** <https://blenderartists.org/t/py-audaspace-get-sound-from-actual-path/557554>\
**Category:** Game Engine Support and Discussion\
**Created:** [November 22, 2012, 4:10am UTC](https://blenderartists.org/t/py-audaspace-get-sound-from-actual-path/557554 "2012-11-22T04:10:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyBlack](https://blenderartists.org/user_avatar/blenderartists.org/johnnyblack/32/11611_2.png) [@JohnnyBlack](https://blenderartists.org/u/JohnnyBlack)\
**Post date:** [November 22, 2012, 4:10am UTC](https://blenderartists.org/t/py-audaspace-get-sound-from-actual-path/557554/1 "2012-11-22T04:10:19Z")

</div>

Hi!  
How would i make audaspace get a file that is located in the same location as the .blend file.  
I have .blend in a folder,and in the same folder i have another folder with sounds into. I dont want to define the full location as I want to make it work no matter where is.

ex:  
sh1\_fire = aud.Factory(’//Weapons\sh1\_fire.wav’)  
handle = device.play(sh1\_fire)

What am I doing wrong?

Thanks.

---

<div class="post-metadata">

**Author:** ![SolarLune](https://blenderartists.org/user_avatar/blenderartists.org/solarlune/32/7258_2.png) [@SolarLune](https://blenderartists.org/u/SolarLune)\
**Post date:** [November 22, 2012, 5:45am UTC](https://blenderartists.org/t/py-audaspace-get-sound-from-actual-path/557554/2 "2012-11-22T05:45:18Z")

</div>

Use logic.expandPath() to expand the path out to where you need it to be. If you give ‘//’ as the first part of the string, it will be relative to the blend file, so:

```auto

 sh1_fire = aud.Factory(logic.expandPath('//Weapons/sh1_fire.wav'))
 handle = device.play(sh1_fire)

```

As a side-note, I believe forward slash characters in strings are escape characters (i.e. ‘\r’ is a return character, while ‘/r’ isn’t). So pay attention that you keep it consistent and use whichever one (forward or back) that works. I believe forward slashes work.

If you define all of your sounds in a single place, then you can optimize things by defining the resource folder and loading the sounds before-hand to make it more readable:

```auto

# Earlier in your code

respath = logic.expandPath('//Weapons/')

logic.sounds = {
'sh1_fire' : aud.Factory(respath + 'sh1_fire.wav').buffer() # Good to buffer sounds that are short and get played a lot
}

# And then, when you want to play...

handle = logic.auddev.play(logic.sounds['sh1_fire'])

```

---

<div class="post-metadata">

**Author:** ![JohnnyBlack](https://blenderartists.org/user_avatar/blenderartists.org/johnnyblack/32/11611_2.png) [@JohnnyBlack](https://blenderartists.org/u/JohnnyBlack)\
**Post date:** [November 22, 2012, 7:10am UTC](https://blenderartists.org/t/py-audaspace-get-sound-from-actual-path/557554/3 "2012-11-22T07:10:50Z")

</div>

Thank you SolarLune, works just great!
