Sound plays in one instance, but not another...
by Clark Kromenaker · in Torque Game Engine · 03/26/2006 (11:27 am) · 1 replies
Hi,
There might be something stupid that I'm missing, but it seems to me that this should be working.
For my options dialog, I have the following lines to play a some test audio while adjusting the volume:
$TestHandle = alxCreateSource("Voice", expandFilename("~/data/sound/voice/voicevol.ogg"));
alxPlay($TestHandle);
Voice is an audioDescription and it opens this file and works fine.
In another instance, I'm adding a feature where clicking on a 3D item gives an audio description of it. So, in the .mis file, I went to the object's datablock and inserted a variable holding a path to the test sound, like so:
new StaticShape(SimpleCrate2) {
position = "-6 6 1";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Test";
collideable = "1";
//Verb stuff
smartCursor = true;
objectName = "Crate";
verbLook = true;
txtLook = "It's a crate.";
oggLook = "~/data/sound/voice/voicevol.ogg"; ( *PATH TO VOICE FILE*)
verbOpen = true;
txtOpen = "The crate is locked up tight; you aren't getting in there.";
verbClose = true;
txtClose = "That crate is already closed!";
};
When the player chooses the "look" action, it displays the txtLook variable onto the playerInterface.gui...which works fine. After this, it should play a sound like it does in the optionsDlg. However, when I put these lines:
$VoiceHandle = alxCreateSource("Voice", expandFilename(%voiceFile)); //setup on Voice channel
echo(%voiceFile);
alxPlay($VoiceHandle); //play sound file
into the function in playerInterface.gui, I get a "cannot find audio profile '0'" error. Now, the options instance and this instance are in the same directory and nearly the same thing. And the echo returns the correct file path (%voiceFile holds the oggLook variable from SimpleCrate).
Can anyone see a reason why this wouldn't play?
There might be something stupid that I'm missing, but it seems to me that this should be working.
For my options dialog, I have the following lines to play a some test audio while adjusting the volume:
$TestHandle = alxCreateSource("Voice", expandFilename("~/data/sound/voice/voicevol.ogg"));
alxPlay($TestHandle);
Voice is an audioDescription and it opens this file and works fine.
In another instance, I'm adding a feature where clicking on a 3D item gives an audio description of it. So, in the .mis file, I went to the object's datablock and inserted a variable holding a path to the test sound, like so:
new StaticShape(SimpleCrate2) {
position = "-6 6 1";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Test";
collideable = "1";
//Verb stuff
smartCursor = true;
objectName = "Crate";
verbLook = true;
txtLook = "It's a crate.";
oggLook = "~/data/sound/voice/voicevol.ogg"; ( *PATH TO VOICE FILE*)
verbOpen = true;
txtOpen = "The crate is locked up tight; you aren't getting in there.";
verbClose = true;
txtClose = "That crate is already closed!";
};
When the player chooses the "look" action, it displays the txtLook variable onto the playerInterface.gui...which works fine. After this, it should play a sound like it does in the optionsDlg. However, when I put these lines:
$VoiceHandle = alxCreateSource("Voice", expandFilename(%voiceFile)); //setup on Voice channel
echo(%voiceFile);
alxPlay($VoiceHandle); //play sound file
into the function in playerInterface.gui, I get a "cannot find audio profile '0'" error. Now, the options instance and this instance are in the same directory and nearly the same thing. And the echo returns the correct file path (%voiceFile holds the oggLook variable from SimpleCrate).
Can anyone see a reason why this wouldn't play?
Torque Owner Clark Kromenaker
If I have:
new AudioDescription(Voice)
{
volume = 3.0;
isLooping = false;
is3D = true;
type = $VoiceAudio;
};
and then this line works:
$TestHandle = alxCreateSource("Voice", expandFilename("~/data/sound/voice/voicevol.ogg"));
then why won't this line work?
$VoiceHandle = alxCreateSource("Voice", %expandVoiceFile); //setup on Voice channel
They should both be using the Voice description, right? The second one works if I change the description from "Voice" to "Default", but I don't understand why...
EDIT: Figured it out :)
The audio channel was set to a volume of 0, even though my option slider defaulted to 0.8, which meant that the volume was only turned on if I messed with the slider before trying to play sound. I added a couple of alxSetChannelVolume statements where they won't be missed when executing.