Fade In/Out

M

Mike

Hi
how should I program a sdl_mixer fade in and out depending on the
value of X,Y,Z (3D matrix)?
Simply the more away from 0 those values are the more sound should be
faded out and vice versa.
Many thanks
Michael

-----
float X = XPLMGetDataf (pilotX);
float Y = XPLMGetDataf (pilotY);
float Z = XPLMGetDataf (pilotZ);

// fade out channel 0 to finish 3 seconds from now
Mix_FadeOutChannel(0, 3000);

//fade in 3000 miliseconds
Mix_FadeInChannel(0, sound, -1, 3000);
 
M

Mike

So what is your question about C++ logic that can be answered without
knowing anything about the SDL library?

I think I will try FOR alike that i found:

for($i = $startframe; $i < $endframe; $i = $i + $framechange){
$start = $i;
$finish = $i + $framechange - 1;
$offset = $startoffset + $offsetchange * $count;
$coef = $startcoef + $coefchange * $count;
 
M

Mike

Even sdl forum won't accept me....
---------------
Hi. This is the qmail-send program at yahoo.com.
I'm afraid I wasn't able to deliver your message to the following
addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[email protected]>:
Connected to 21.00 but sender was rejected.
Remote host said: .0.0 Access denied
 
M

Mike

ok found another function. now i should avoid X,Y or Z to be 0 or
negativ. ( not passing such values as
Mix_SetDistance only accepts positive numbers.

if(X != 0){
// while (X > start && < end)
//{
Mix_SetDistance(0, X);
}
else
if(Y != 0){
Mix_SetDistance(0, Y);
}
else
if(Z != 0){
Mix_SetDistance(0, Z);
}
}
 
J

Jonathan Lee

ok found another function. now i should avoid X,Y or Z to be 0 or
negativ. ( not passing such values as
Mix_SetDistance only accepts positive numbers.

See, the problem is that since this is not an SDL newsgroup, we
generally don't know what Mix_SetDistance does. As far as I can
tell, you've simply written three if statements that do who
knows what.

Unless someone uses SDL here, we don't know what you're talking
about. It seems that you have a problem understanding how SDL
is used, as opposed to there being some aspect of the C++
language that's an obstacle.

(Of course, if it happens that I Google for Mix_SetDistance and
discover it is supposed to adjust the volume based on the
distance from the listener to the source, then I might suggest
calculating the distance as

d = sqrt((X-x0)*(X-x0)+(Y-y0)*(Y-y0)+(Z-z0)*(Z-z0));

where the listener is at (x0, y0, z0) and the source of the
sound is at (X, Y, Z) which I'm guessing is the notation you
are using).

--Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top