Positioned Audio [3D audio] with Torque 2d
by Julian Liebl · in Torque Game Builder · 10/01/2011 (6:50 am) · 1 replies
Hey,
I have the following problem: Sounds play perfect and are working great but for example we have a chainsaw which makes a sound. Now when we move away from this chainsaw the sound repeats itself at the same volume level even so we set the postions and is3d = true. What am I missing? Thanks for any help.
Here is my code so far:
new AudioDescription(DREID)
{
isLooping = true;
//isStreaming = false;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 15.0;
type = $GuiAudioType;
};
function playTest3D(%sound, %volume, %posX, %posY)
{
// get profile for background sound and set default volume
%path = "SoundFX/";
getAudio(%sound, %path, "DREID");
alxSetChannelVolume($GuiAudioType, %volume);
// play background sound
$dreid = alxPlay(%sound, %posX, %posY);
}
function getAudio(%name, %path, %type)
{
echo(%this.owner.name);
if (isObject(%name))
return;
new AudioProfile(%name)
{
filename = "~/data/audio/" @ %path @ %name @ ".ogg";
description = %type;
preload = true;
};
}
I have the following problem: Sounds play perfect and are working great but for example we have a chainsaw which makes a sound. Now when we move away from this chainsaw the sound repeats itself at the same volume level even so we set the postions and is3d = true. What am I missing? Thanks for any help.
Here is my code so far:
new AudioDescription(DREID)
{
isLooping = true;
//isStreaming = false;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 15.0;
type = $GuiAudioType;
};
function playTest3D(%sound, %volume, %posX, %posY)
{
// get profile for background sound and set default volume
%path = "SoundFX/";
getAudio(%sound, %path, "DREID");
alxSetChannelVolume($GuiAudioType, %volume);
// play background sound
$dreid = alxPlay(%sound, %posX, %posY);
}
function getAudio(%name, %path, %type)
{
echo(%this.owner.name);
if (isObject(%name))
return;
new AudioProfile(%name)
{
filename = "~/data/audio/" @ %path @ %name @ ".ogg";
description = %type;
preload = true;
};
}
About the author
Torque Owner Rpahut