PlayAudio() problems
by Zachary Seldess · in Torque Game Engine · 05/22/2007 (8:18 pm) · 4 replies
Hi everyone,
I've been playing around with imbedding sounds in ShapeBase items in TGE 1.5.2. I have five instances of the ItemData Datablock, each with a different soundProfile, and I'm calling %obj.playAudio(0, "SoundProfile") on each of their ::onAdd's.
For some reason, the fifth instance of ItemData doesn't play the audio file. I have tried to call playAudio from the console while in-game and nothing happens (no errors, but no sounds). On the other hand, if I call playAudio and include one of the other four SoundProfiles as the second argument, it plays!
The audio file being loaded by the fifth AudioProfile is fine (I've substituted others to check). Here are the Audio Descriptions/Profiles from /server/audioProfiles.cs. There are 5 corresponding objects in my mission file:
ANY help would be greatly appreciated. I've spent a bunch of time on this and am at an impass. And I definitely want more imbedded sounds as I'm primarily using Torque as an environment for designing interactive sound art... so this is crucial.
best,
Zachary
And here are the ItemData Datablocks from /server/logoitem.cs and /server/barrel.cs:
I've been playing around with imbedding sounds in ShapeBase items in TGE 1.5.2. I have five instances of the ItemData Datablock, each with a different soundProfile, and I'm calling %obj.playAudio(0, "SoundProfile") on each of their ::onAdd's.
For some reason, the fifth instance of ItemData doesn't play the audio file. I have tried to call playAudio from the console while in-game and nothing happens (no errors, but no sounds). On the other hand, if I call playAudio and include one of the other four SoundProfiles as the second argument, it plays!
The audio file being loaded by the fifth AudioProfile is fine (I've substituted others to check). Here are the Audio Descriptions/Profiles from /server/audioProfiles.cs. There are 5 corresponding objects in my mission file:
ANY help would be greatly appreciated. I've spent a bunch of time on this and am at an impass. And I definitely want more imbedded sounds as I'm primarily using Torque as an environment for designing interactive sound art... so this is crucial.
best,
Zachary
datablock AudioProfile(LogoSoundProfile1)
{
filename = "~/data/sound/Logo1.ogg";
description = "LoopingLogoSound";
preload = true;
};
datablock AudioProfile(LogoSoundProfile2)
{
filename = "~/data/sound/Logo2.ogg";
description = "LoopingLogoSound";
preload = true;
};
datablock AudioProfile(LogoSoundProfile3)
{
filename = "~/data/sound/Logo3.ogg";
description = "LoopingLogoSound";
preload = true;
};
datablock AudioProfile(LogoSoundProfile4)
{
filename = "~/data/sound/Logo4.ogg";
description = "NonLoopingLogoSound";
preload = true;
};
datablock AudioProfile(BarrelSoundProfile)
{
filename = "~/data/sound/BarrelSound.ogg";
description = "LoopingBarrelSound";
preload = true;
};
datablock AudioProfile(Wind)
{
filename = "~/data/sound/Wind.ogg";
description = "AudioLooping2d";
preload = true;
};And here are the ItemData Datablocks from /server/logoitem.cs and /server/barrel.cs:
//from /server/logoitem.cs
datablock ItemData(TorqueLogoItem1)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
friction = 0.5;
gravityMod = 0.1;
soundProfile = "LogoSoundProfile1";
sticky = false;
};
datablock ItemData(TorqueLogoItem2:TorqueLogoItem1)
{
soundProfile = "LogoSoundProfile2";
};
datablock ItemData(TorqueLogoItem3:TorqueLogoItem1)
{
soundProfile = "LogoSoundProfile3";
};
datablock ItemData(TorqueLogoItem4:TorqueLogoItem1)
{
soundProfile = "LogoSoundProfile4";
};
//TorqueLogoItem Datablock Methods
function TorqueLogoItem1::onAdd(%this,%obj)
{
%obj.playAudio(0, LogoSoundProfile1);
}
function TorqueLogoItem2::onAdd(%this,%obj)
{
%obj.playAudio(0, LogoSoundProfile2);
}
function TorqueLogoItem3::onAdd(%this,%obj)
{
%obj.playAudio(0, LogoSoundProfile3);
}
function TorqueLogoItem4::onAdd(%this,%obj)
{
%obj.playAudio(0, LogoSoundProfile4);
}
// from server/barrel.cs
datablock ItemData(BarrelSoundItem)
{
category = "Items";
shapeFile = "~/data/shapes/barrels/FBarrel01.dts";
friction = 0.5;
gravityMod = 0.1;
soundProfile = "BarrelSoundProfile";
sticky = false;
};
//BarrelSoundItem Datablock Methods
function BarrelSoundItem::onAdd(%this,%obj)
{
%obj.playAudio(0, BarrelSoundProfile);
}About the author
#2
The Audio code in Torque is full of bugs, and I think it's about to be replaced.
05/23/2007 (7:26 am)
The console should say how many hardware channels you are using. If not then there's a function call you can use to get it.The Audio code in Torque is full of bugs, and I think it's about to be replaced.
#3
Regarding channels, are there a limited number of sounds that can play on one channel? I'm a bit confused about the slot specification in playAudio(slot, SoundProfile) -- Is the slot the "channel". "Channel" is a confusing term in this context as it normally refers to audio streams (i.e. stereo=2 channels, quad=4 channels).
Thanks.
05/23/2007 (8:02 am)
Thanks Stefan,Regarding channels, are there a limited number of sounds that can play on one channel? I'm a bit confused about the slot specification in playAudio(slot, SoundProfile) -- Is the slot the "channel". "Channel" is a confusing term in this context as it normally refers to audio streams (i.e. stereo=2 channels, quad=4 channels).
Thanks.
#4
I changed the "0." to "0.0" and viola, no more mysterious problems playing audio!
Actually, first I moved around the AudioProfiles a bit to see if that was the problem (placed them above the instantiations of their corresponding ItemData datablocks). After moving them, the engine started to crash on Mission loadup. Then I found the "0." and changed it. So I think that was the problem. I don't know why it didn't crash before moving the audioProfiles, but hey... it works now and that what matters to me!!
Zachary
05/23/2007 (4:59 pm)
Solved it. One of my AudioDescription datablocks had a ReferenceDistance = 0.; I changed the "0." to "0.0" and viola, no more mysterious problems playing audio!
Actually, first I moved around the AudioProfiles a bit to see if that was the problem (placed them above the instantiations of their corresponding ItemData datablocks). After moving them, the engine started to crash on Mission loadup. Then I found the "0." and changed it. So I think that was the problem. I don't know why it didn't crash before moving the audioProfiles, but hey... it works now and that what matters to me!!
Zachary
Torque Owner Zachary Seldess
I'm running Torque on Windows XP in Bootcamp on a Macbook Pro DualCore Intel. I tried using an external audio device (Presonus Firebox), but had same problem - all but one sound playing.
Again, ANY help would be great. If you know of a resource or another post on this issue, please pass it along.
Hopefully SOMEBODY will offer help. As I said before, sound is crucial for me, and I seem to be at an impass. If it can't be solved soon, I may have to find another engine...