[lost] sound problem

Posted By: Nowherebrain

[lost] sound problem - 08/19/07 16:38

I loop a sound(snd_loop, a waterfall in this case) and use a var to increse or decrease it's volume...using snd_tune and a var to adjust the volume.
I call it in the entity action in side a while loop(one problem), so the sound gets called and called and called...annoying.
I also cannot get it to respond to snd_tune, but this is how I want to adjust the volume...
I want to keep this in the ent action or create a sound ent using the aug model or something that I can set to invisible and passable later...
any knowledge that can be passed on would help.
Also, is there a trick to using the "add sound" in the editor, I can never get them to work.
Posted By: quasarchangel

Re: [lost] sound problem - 08/19/07 17:25

Check it in the loop with a snd_playing(snd_handle) function. Thinking about other requests...
Posted By: EpsiloN

Re: [lost] sound problem - 08/19/07 17:26

First...
Code:

snd_tune (Handle, Volume, 0, 0);


And second...call the snd_loop from outside the while loop. Eg. :
You have:
Code:

while(1)
{
snd_handle = snd_loop(sound_file_str,100,0);
wait(1);
}


Change it to:
Code:

snd_handle = snd_loop(sound_file_str,100,0);
while(1)
{
if(key_a == 1) { snd_var += 5 * time; }
if(key_d == 1) { snd_var -= 5 * time; }
snd_tune(snd_handle,snd_var,0,0);
wait(1);
}


Hope this helps

EDIT: Right click > Add > Add sound > Sound file.wav
Right click while selected > Properties > Change the range (shouldnt be too small) and the volume. Build as normal (default) and enjoy stereo
Posted By: Nowherebrain

Re: [lost] sound problem - 08/19/07 18:31

so snd_tune is calling the snd_handle too, I thought it was just modifying the playing sound? if so then that is another problem I'm having....
I also need to define snd_handle as a global variable...(var snd_handle;)if I want to adjust the sound from a different function or ent correct?
I'll look further. Thank you.
Posted By: EpsiloN

Re: [lost] sound problem - 08/19/07 18:34

Yes , define 50 snd handles and every time you assign a sound to a variable check to see if each one of them is empty. (Array...) You could than have multiple handles for multiple sounds and control them one by one.
Posted By: quasarchangel

Re: [lost] sound problem - 08/19/07 19:05

Or you could use one of the current entity's skills as a handle.
Posted By: Nowherebrain

Re: [lost] sound problem - 08/20/07 00:45

eitherway...more typing than I want...I will find a solution, and I appreciate all the input...
Posted By: Nowherebrain

Re: [lost] sound problem - 08/20/07 02:26

OK, I'm sooo frustrated right now...I had to walk away...
I'm positive I know what I am doing and it either..
a)doesn't play.
b)loops over itself eternaly.
AAAAHHHHHHH!!!!

here is my basic implementation...
sound waterfall = <water.wav>;
var volume;
var s_handle;
action some_action
{
set some stuff(passable etc..)
s_handle = snd_loop(waterfall, volume,0);
while(player != null)
{
if(vec_dist(player.x,my.x) < 1000)
{
volume += 1 * time_step/4;
}
snd_tune(s_handle,volume,-10,0);
wait(1);
}
}
I may have missed a bracket, but this is my "basic" setup.
I've even tried setting the handle in a separate loop(same action)before this main loop.
Posted By: Nowherebrain

Re: [lost] sound problem - 08/20/07 02:27

P.S. how do you get your code to show up correctly after typing it...I hate how mine always aligns to the left.
Posted By: flits

Re: [lost] sound problem - 08/20/07 12:18

i searc and seacrh but i did found it i think

s_handle = snd_loop(waterfall, 1,0);
Posted By: quasarchangel

Re: [lost] sound problem - 08/20/07 13:00

Why do you want to adjust the volume? Why not just assign the action to the waterfall itself, if you are not doing so already, and then use ent_playloop ( ENTITY*, SOUND*, var volume); function, with a volume of something greater than 100, which will then be heard from a greater distance, and it will become louder the closer you get to it. Check the manual for more info.
Posted By: Nowherebrain

Re: [lost] sound problem - 08/20/07 23:28

Yes, I want positional audio...thanks...lifesaver, if this works....probably will.
Posted By: Nowherebrain

Re: [lost] sound problem - 08/21/07 23:23

it works, thank you....I was making a mountain out of a mole hill. I knew it could not be that hard.
© 2024 lite-C Forums