Game Development Community

Music not playing

by Bret Snyder · in Torque Game Engine · 03/14/2007 (3:16 pm) · 2 replies

I've read through way too many posts and tutorials on getting background music and button-event sounds to play. I've checked the console log to make sure the scripts are being exec'd and have tried playing the sounds manually. I've tried getting it working in two different working example folders.

This is what I have:

under client/audioProfiles.cs:

new AudioDescription(MusicDesc)
{

volume = 1.0;
isLooping = false;
is3D = false;
type = $MusicAudioType;
};

new AudioProfile(Music)
{
filename = "~data/sound/Music.ogg";
description = "MusicDesc";
preload = false;
};

Also in this file, I added a new channel:

$MusicAudioType = 4;

Above that channel are three channels that were already available:

$GuiAudioType = 1;
$SimAudioType = 2;
$MessageAudioType = 3;

Now, under the client/init.cs:

function loadMainMenu()
{
// Startup the client with the Main menu...
Canvas.setContent( MainMenuGui );
alxPlay(Music); // I've added this line <---------------------

// Make sure the audio initialized.
if($Audio::initFailed) {
MessageBoxOK("Audio Initialization Failed",
"The OpenAL audio system failed to initialize. " @
"You can get the most recent OpenAL drivers here.");
}

Canvas.setCursor("DefaultCursor");
}

------------

The music should play when the main menu loads, correct? I should be able to type, "alxPlay(Music);" into the console to play it manually, correct? Neither of those are true. I've used different channels, different script lines for calling the music, and out of desperation, updated my openAL drivers, but it's just not working. Can anyone give me some advice?

#1
03/14/2007 (6:34 pm)
Everything looks fine to me.

The common place to initialize GUI music is in the "loadStartup()" function inside of "statupGui.gui".
function loadStartup()
{
   StartupGui.done = false;
   Canvas.setContent( StartupGui );
   schedule(100, 0, checkStartupDone );
   alxPlay(AudioStartup); // <--------- Play music here
}

Though it should still work where you're calling it from.

Do you hear any audio at all in Torque? Maybe it's a driver issue or maybe there's a problem with your .ogg file?
#2
03/14/2007 (7:30 pm)
Still no luck. I've tried calling different ogg files instead of the one I created. I also tried running my scripts from a fresh copy of example on another computer. No dice.

I should note that I'm attempting to use these sounds in TGE (not T2D), but that shouldn't make a difference. I've tried running the 2 scripts (audio profile script and the script that calls the sound) in different starter kits. I've got to be missing something, I just don't know what.

Edit: I forgot to mention that other sounds do in fact play. When I start up starter.fps (TGE 1.5), the ambient sounds are playing.

Edit: The only kit I've been able to get the background music working in is the demo. I've stripped down the demo kit so it's identical to mine. Is there a setting or something I'm missing that demo has and the other kits lack?