Sound questions
by Michael K. · in Torque Game Builder · 01/05/2009 (3:35 am) · 4 replies
Hi,
i just have two short questions regarding sound...
1) Is there a way to fade out a looping music track?
2) Does alxplay handle looping start and end points? For example: i would like alxplay to play my music loop the first time completely... but the second time i want my music loop to play from 00:30 to 00:45 and then continuesly loop that part.
thanks!
- Michael
i just have two short questions regarding sound...
1) Is there a way to fade out a looping music track?
2) Does alxplay handle looping start and end points? For example: i would like alxplay to play my music loop the first time completely... but the second time i want my music loop to play from 00:30 to 00:45 and then continuesly loop that part.
thanks!
- Michael
#2
Does anyone know what the 'type' variable is in the AudioDescription block:
If it is the channel of the sound played there might be a way to fade out individual sounds.
01/06/2009 (3:29 am)
Here's a quick way to fade sound://decrease volume until stop
if(%this.soundPlaying)
{
%vol = alxGetChannelVolume( 0 );
if(%vol > 0)
{
%vol -= 0.025;
echo("Decreasing volume");
}
alxSetChannelVolume( 0 , %vol );
if(%vol <= 0.5)
{
echo("Stopping sound.");
alxStop(%this.playSound);
%this.soundPlaying = false;
}
}Does anyone know what the 'type' variable is in the AudioDescription block:
datablock AudioDescription(AudioLoopingSoft)
{
volume = 0.50;
isLooping = true;
is3D = false;
type = $GuiAudioType;
};If it is the channel of the sound played there might be a way to fade out individual sounds.
#3
01/06/2009 (10:07 am)
The TYPE variable is the channel used to play that sound... TGB can handle up to 32 channels, but i dont really, know how to define them... does anyone know how to doit?
Torque Owner Robert Geiman
Out of the box, no this cannot be done. However, check out my VMPlayer resource for TGE, it should allow you to do what you are looking to do. You should have no difficulties getting this to work for TGB as the audio code is still the same.
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9560
To modify the start/end points dynamically like you are looking to do, try the code below:
function ModifyBattleIntroSongStart() { $VMPlayer.SetTrackStartPosition("Battle", 1, 30); // Modify song to start playing at 30 second mark $VMPlayer.SetTrackStopPosition("Battle", 1, 45); // Modify song to stop playing at 45 second mark $VMPlayer.RemoveEventFromTrack("Battle", 1, 60); // Don't need to change the start position anymore } $VMPlayer.AddPlaylist("Battle", "~/data/sound/Music/Battle.ogg"); // Create "Battle" playlist with one song $VMPlayer.AddEventToTrack("Battle", 1, ModifyBattleIntroSongStart, 60); // Call this event after 60 seconds have been played (the end of the song) $VMPlayer.LoadPlaylist("Battle"); $VMPlayer.EnableRepeat(true); $VMPlayer.Play();