Sound missing?
by Bucko · in Torque Game Builder · 04/02/2005 (10:08 am) · 5 replies
I searched through the documentation for Sound, or audio and found none!!??
I guess I must have missed something obvious but to me it seems there is no sound support in T2D(yet).
I guess I must have missed something obvious but to me it seems there is no sound support in T2D(yet).
About the author
#2
Basically, you need the following:
Setup your datablocks.
This sets up the basic structure of the audio, and specifies types for both looping and non-looping sound effects.
After that, we define the sound effects in a similar way to how to you setup sprite data. Note you can use both .ogg and .wav files.
The next step is to play your audio as follows:
This will get your GroovinMusic playing. Because the type of audio is set to loop when we defined it, it will automatically repeat when it reaches the end.
We can also assign the music to a variable so we can easily check if the music is already playing. Instead of using the line above, you can use:
That says, if the menu music isn't already playing, start it going.
To stop all sounds from playing, use:
I'm sure there's plenty more you can do, but that should get you going :)
04/02/2005 (10:55 am)
It's not too tricky, take a look at the shooter demo code.Basically, you need the following:
Setup your datablocks.
$GuiAudioType = 0;
new AudioDescription(AudioNonLooping)
{
volume = 1.0;
isLooping= false;
is3D = false;
type = $GuiAudioType;
};
new AudioDescription(AudioLooping)
{
volume = 1.0;
isLooping= true;
is3D = false;
type = $GuiAudioType;
};
new AudioProfile(GroovinMusicAudio)
{
filename = "~/client/sounds/Groovin.ogg";
description = "AudioLooping";
preload = true;
};This sets up the basic structure of the audio, and specifies types for both looping and non-looping sound effects.
After that, we define the sound effects in a similar way to how to you setup sprite data. Note you can use both .ogg and .wav files.
The next step is to play your audio as follows:
alxPlay( GroovinMusicAudio );
This will get your GroovinMusic playing. Because the type of audio is set to loop when we defined it, it will automatically repeat when it reaches the end.
We can also assign the music to a variable so we can easily check if the music is already playing. Instead of using the line above, you can use:
if (!alxIsPlaying($menuMusicAudio))
{
$menuMusicAudio=alxPlay( GroovinMusicAudio );
}That says, if the menu music isn't already playing, start it going.
To stop all sounds from playing, use:
alxStopAll();
I'm sure there's plenty more you can do, but that should get you going :)
#3
04/13/2005 (9:21 am)
Torque 2D support ogg?
#4
04/13/2005 (9:42 am)
From the posted code block (emphasis mine:new AudioProfile(GroovinMusicAudio)
{
[b]filename = "~/client/sounds/Groovin.[i]ogg[/i]";[/b]
description = "AudioLooping";
preload = true;
};
#5
1)
is for client side languages later where networking is up and running if you are having the server send sound to the client you need to do
2) When they are called from the server you won't use
the alxplay() seems to cause side effect with mouseover buttons as well, as making the first call to %client.play2d() repeat indefinatly.
@Danny I belive ogg suppory has been included into standard torque so, yes
04/13/2005 (9:47 am)
2 things1)
new AudioDescription/AudioProfile
is for client side languages later where networking is up and running if you are having the server send sound to the client you need to do
datablock AudioDescription/AudioProfile
2) When they are called from the server you won't use
alxPlay(soundName)instead
%client.play2d(soundName);
the alxplay() seems to cause side effect with mouseover buttons as well, as making the first call to %client.play2d() repeat indefinatly.
@Danny I belive ogg suppory has been included into standard torque so, yes
Torque Owner Phillip "Renolc" Gibson