Game Development Community

Intro audio

by James Bond · in Torque Game Engine · 03/07/2005 (11:36 am) · 13 replies

Hi people,

I am trying to play a .ogg file when the main menu appers on screen.

How or what is the best way to do this?

Many thanks in advance,
-James B

#1
03/07/2005 (11:53 am)
$musicHandle = alxPlay(SplashSound);

This can handle the splash screen sound, defined in /client/init.cs , and under initClient();

EDIT: Oops, don't forget to add:
new AudioProfile(SplashSound)
{
filename = "~/data/sound/foosound.ogg";  //add your music
description = "AudioMessage";
preload = false;
};
in audioprofiles.cs


EDIT2: Then, to add sound to the mainmenu, define another audio profile, but be sure to:
alxStop($musicHandle);

To stop the music
#2
03/07/2005 (12:13 pm)
Frogger,

where am i adding $musicHandle = alxplay(SplashSound);
and alxStop($musicHandle);


Thanks,
-James B.
#3
03/07/2005 (12:20 pm)
All the start-up stuff occurs in initClient(); Which is in /client/init.cs . You normally will stop the splash screen audio in loadmainmenu(); , In which you would then startup any other audio that you wanted to play at that time. Last, you will want to stop the audio for the menu just before a game is started, which could be right after torque loads the lighting for a mission.
#4
03/07/2005 (1:09 pm)
I got the .ogg to play but it continues into the mission?
#5
03/13/2005 (8:36 am)
You have add "alxStop($musicHandle);" before the game starts. I'm new to the engine so I don't know where the lighting for the mission is.
#6
03/13/2005 (8:40 am)
You would add it to the onservercreate or something like that

EDIT i think you can add it after the function onMissionLoaded() in game.cs but dont hold my word for it.
#7
03/13/2005 (12:52 pm)
Thanks Ben thaty worked.

Im begining to work out what dose what in torque now, and thanks again also to Frogger, you clearly aint no idiot
-James B.
#8
03/14/2005 (3:15 pm)
I have it like so to play behind the main menu, in the game, and when you end the mission returning to the main menu:

client/init.cs

if($Audio::initFailed) {
MessageBoxOK("Audio Initialization Failed",
...
}

alxStopAll();
$musicHandle = alxPlay(PreGameMusic);


client/scripts/PlayGui.cs


function PlayGui::onWake(%this)
{
// Turn off any shell sounds...
// alxStop( ... );
alxStopAll();
$musicHandle = alxPlay(InGameMusic);


client/scripts/serverConnect.cs

function disconnectedCleanup()
{
// Clear misc script stuff
HudMessageVector.clear();

// Terminate all playing sounds
alxStopAll();
if (isObject(MusicPlayer))
MusicPlayer.stop();
$musicHandle = alxPlay(PreGameMusic);


client/scripts/audioProfiles.cs

$MusicAudioType = 4;

new AudioDescription(MusicLooping)
{
volume = 8.0;
isLooping= true;
is3D = false;
type = $MusicAudioType;
};

new AudioProfile(InGameMusic)
{

filename = "~/data/sound/music/f1.ogg";
description = "MusicLooping";
preload = true;

};

new AudioProfile(PreGameMusic)
{

filename = "~/data/sound/music/f2.ogg";
description = "MusicLooping";
preload = true;

};

BTW .ogg files work without any extra steps now. Used to have to add it in, it's now part of the code tree.
#9
05/01/2005 (9:39 pm)
I can't get this to work at all!

It seems so simple too. I am using the lighting pack and I understand the file structure is tweaked a little from what you are using here, but I can't seem to get it to work.

I've worked on this silly thing for two hours now and have placed the code in various init.cs and audioProfile.cs locations; in client, in server, in data folders.

I also am trying to locate to scripts that would launch the other .ogg sounds in the sound folder and can't seem to find them anywhere.
#10
05/02/2005 (1:14 am)
I looked into console.log and found this line:

Unable to locate audio profile 'SplashSound'
#11
12/19/2007 (12:45 am)
I'm doing this same thing, I followed the instructions both here and [url="http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2729"] here.

Either way I end up with an Unable to locate audio profile "Main_MenuMusic" in my console
#12
01/22/2008 (9:13 am)
Richard Bottoms information posted on March 15, 2005 works perfectly. Thanks Richard.

Robert
#13
07/23/2009 (10:54 am)
I'm doing the same thing Zach said he is doing and I got the exact same result:

Quote:
I'm doing this same thing, I followed the instructions both here and [url="http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2729"] here.

Either way I end up with an Unable to locate audio profile "Main_MenuMusic" in my console