portable sound naming?

hi, so if i have all the sounds once as .mp3 file names and then once as .wav file names, how do i make the nmml and code not have lots of conditional stuff to choose between the 2? and also if i have lots of sounds then manually doing rename is tiresome …

Viewing 1 to 10 (10 Total)
portable sound naming?

raould

raould
Total Posts: 224
Joined: December 03, 2011

hi, so if i have all the sounds once as .mp3 file names and then once as .wav file names, how do i make the nmml and code not have lots of conditional stuff to choose between the 2? and also if i have lots of sounds then manually doing rename is tiresome and likely to drift away from being correct while things are being developed.

i think what i'm day dreaming of is a way to tell the nmml file to remove all extensions in the rename. (maybe it can already do that? but i didn't see it or see how.)

that way in my haxe code i can just load "explosion" instead of having to #if MP3 "explosion.mp3" #else "explosion.wav" #end type stuff.

Tags:
Posted on August 12, 2012 at 12:32 PM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

(p.s. you can't just leave the files on disk having no extension because then nme can't figure out what kind of files they are and so building fails.)

Posted on August 12, 2012 at 12:33 PM

Huge

Huge
Total Posts: 546
Joined: October 07, 2011

Re: portable sound naming?

Hi,
You can use variables in nmml:

<set name="ext" value= "ogg" />
<set name="ext " value= "mp3" if="desktop"/>


<assets>
<asset name="path/mySound.${ext}" id="mySoundId" />
</assets>

Then you can refer to your sound with "mySoundId" inside your code.

Hugh

Posted on August 13, 2012 at 12:21 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

thank you for the info, i will give that a try!

Posted on August 13, 2012 at 7:47 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

p.s. that seems to require i list each sound individually still, which is a maintenance problem. it would be nice if there were a way some day in the future to use the wildcard thing still so that the sound assets could be a one-liner, although i don't know the best syntax -- maybe by somehow making it possible to strip extensions i guess? i mean it doesn't make a lot of sense to me for the final haxe program to care about sound format, ideally.

http://pastebin.com/iqGc7es4
<assets type="sound" path="Resources/Sfx/Wav" path_rename="sfx" include="*" drop_extensions="true" unless="target_flash"/>
<assets type="sound" path="Resources/Sfx/Mp3" path_rename="sfx" include="*" drop_extensions="true" if="target_flash"/>

or something like that

Posted on August 13, 2012 at 7:55 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

p.p.s. what is the difference between "id" and "name" for a sound asset line in nmml? i can't recall having seen "id" used before, only "name".

Posted on August 13, 2012 at 8:11 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

i can't get renaming to work still yet

<assets path="Resources/Sfx/Wav">
<sound name="beat1.wav" rename="beat1"></sound>
</assets>

ends up with null assets in-game. using "id" instead of "rename" also gives null assets.

<assets>
<sound name="Resources/Sfx/Wav/beat1.wav" id="beat1"/>
</assets>

also leads to nulls.

Posted on August 13, 2012 at 8:47 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

[resolved] Re: portable sound naming?

ah hah!

because i had used rename="sfx" before my haxe asset loading string was including "sfx/" so this works now:
<assets>
<sound name="Resources/Sfx/Wav/beat1.wav" id="sfx/beat1"/>
</asests>




unfortunately i have to "manually" list out each and every sound file, oh well, here is what i have in my Makefile:
rm nme.nmml /tmp/nmml.*
SOUNDS_LINE=`grep -n SOUNDS_HERE nme.nmml.template | sed 's/:.*//'`; \
gen_nmml.sh Resources/Sfx/Mp3 mp3 > /tmp/nmml.mp3.frag; \
printf "%d" $$SOUNDS_LINE > /tmp/nmml.mp3.sed; \
echo "r /tmp/nmml.mp3.frag" >> /tmp/nmml.mp3.sed; \
sed -f /tmp/nmml.mp3.sed nme.nmml.template > nme.nmml

Posted on August 13, 2012 at 8:53 AM

Huge

Huge
Total Posts: 546
Joined: October 07, 2011

Re: portable sound naming?

Hi,
I think "name"/"rename" refer to the file name on disk, and imply an id if not set.
I generally do not care about this, and I just use 'id'.

You could do something like this:

<assets path="Resources/Sfx" include="*.wav" if="windows" />
<assets path="Resources/Sfx" include="*.ogg" unless="windows" />

Then, in haxe code:

function myLoadSound(inName:String)
{
#if windows
loadSound(inName + ".wav");
#else
loadSound(inName + ".ogg");
#end
}

Hugh

Posted on August 14, 2012 at 12:18 AM

raould

raould
Total Posts: 224
Joined: December 03, 2011

Re: portable sound naming?

hi,

thanks for all the help, here, it is working for me.

[overall i got it working with how nme appears to work, but it is really not how ideally -- in the future parallel universe of free time and energy -- i think it really should work. there should be no reason to have #ifs in the haxe code for this kind of thing. i did manage to avoid having #ifs but at the cost of writing scripts to generate all the appropriate <sound> asset lines in the nme.nmml file (as i noted with the Makefile excerpt above).]

Posted on August 14, 2012 at 11:51 AM