Audio not loading or playing
by Jonathan R Hopkins · in Technical Issues · 05/20/2009 (10:08 am) · 3 replies
So I'm trying to get an AudioProfile and AudioDescription to work so I can have music and sounds playing in my game. I'm using Torque Game Builder 1.7.4 on Windows Vista Home Premium 64-bit.
Here's the code:
(Note that I've put some of the lines into comments while troubleshooting because I thought this may have been the cause.)
The error follows the curly bracket right after the new AudioProfile. Earlier it was saying that AudioLooping is not a member of AudioProfiles or something like that, but I can't seem to get that same issue to pop up anymore. It says its a parse error, but I can't see anything wrong with the syntax.
Either way, I have no idea what might be causing this. I've followed the tutorial almost verbatim for audio loading/playing, and I've even tried the tutorial file itself (as you can see with shieldhit.ogg)
I've tried switching between nonlooping and looping, and I've tried changing the name too. I can't figure it out.
Any help that anyone can offer would be muchly appreciated. Thanks!
Oh and I had one other quick question. What music/audio formats does Torque support?
Here's the code:
(Note that I've put some of the lines into comments while troubleshooting because I thought this may have been the cause.)
//-----------------------------------------------------
//Lincoln V, Audio setup
//-----------------------------------------------------
//Sets up the audio files and functionalities
//Sets up the datablocks
new AudioDescription(AudioLooping)
{
volume=1.0;
isLooping=true;
is3D=false;
type=$GuiAudioType;
}
//Loads in the files
//%loadsAttempted = 0;
//%loadsSuccessful = 0;
//%loadsAttempted += 1;
new AudioProfile(testAudio)
##{##
filename="~/data/audio/shieldhit.ogg";
description = "AudioLooping";
preload = true;
//%loadsSuccessful +=1;
}
//echo(%loadsSuccessful @ " of " @ %loadsAttempted @ " audio profiles loaded successfully.");The error follows the curly bracket right after the new AudioProfile. Earlier it was saying that AudioLooping is not a member of AudioProfiles or something like that, but I can't seem to get that same issue to pop up anymore. It says its a parse error, but I can't see anything wrong with the syntax.
Either way, I have no idea what might be causing this. I've followed the tutorial almost verbatim for audio loading/playing, and I've even tried the tutorial file itself (as you can see with shieldhit.ogg)
I've tried switching between nonlooping and looping, and I've tried changing the name too. I can't figure it out.
Any help that anyone can offer would be muchly appreciated. Thanks!
Oh and I had one other quick question. What music/audio formats does Torque support?
#2
It turns out that I tried that earlier too, but I had a variable that was local to the script in the audioDescription block, so it still returned a parse error and I assumed it didn't help.
05/21/2009 (8:11 am)
Aha! That really helped. Thank you!It turns out that I tried that earlier too, but I had a variable that was local to the script in the audioDescription block, so it still returned a parse error and I assumed it didn't help.
#3
And keep in mind that trying to introduce a variable (especially local) as a field will not work. You can reference a global variable, but datablocks are really just constructs that contain data for certain object classes and not something that would create or manipulate a variable.
05/21/2009 (8:21 am)
Glad you got it. The semi-colon at the end of a datablock is something that I sometimes forget myself, but when you see it enough times it becomes obvious.And keep in mind that trying to introduce a variable (especially local) as a field will not work. You can reference a global variable, but datablocks are really just constructs that contain data for certain object classes and not something that would create or manipulate a variable.
Associate Michael Hall
Distracted...
new AudioDescription(AudioLooping) { volume = 1.0; isLooping = true; is3D = false; type = $GuiAudioType; };Notice the semi-colon after the closing brace.