Loading & playing audio files on the fly
by Luis Anton · in Torque Game Engine · 10/04/2004 (2:42 am) · 2 replies
Hi,
we are developing an application where there are a lot of spoken dialogs. Right now, I'm using audio datablocks to define these dialogs and then I use alxPlay when I need one of them. I have to define almost two hundred audio datablocks this way (well, I just have a few of them right now for testing purposes, but the application will easily require two hundred audioProfiles):
datablock AudioProfile(Introduction)
{
filename = "~/data/sound/mansion/introduction/introductionDialog1.wav";
description = "Audio2D";
preload = false;
};
Well, it's a pretty hard way of doing it. Too many definitions, and in most cases you will only hear them once (like that introduction).
I am looking for something simpler, like
playWavFile("~/data/sound/mansion/introduction/introductionDialog1.wav");
where playWavFile would just play that wav, nothing else. No 3D, surround or anything, just the wav file.
Is there something like that within the script functions?
we are developing an application where there are a lot of spoken dialogs. Right now, I'm using audio datablocks to define these dialogs and then I use alxPlay when I need one of them. I have to define almost two hundred audio datablocks this way (well, I just have a few of them right now for testing purposes, but the application will easily require two hundred audioProfiles):
datablock AudioProfile(Introduction)
{
filename = "~/data/sound/mansion/introduction/introductionDialog1.wav";
description = "Audio2D";
preload = false;
};
Well, it's a pretty hard way of doing it. Too many definitions, and in most cases you will only hear them once (like that introduction).
I am looking for something simpler, like
playWavFile("~/data/sound/mansion/introduction/introductionDialog1.wav");
where playWavFile would just play that wav, nothing else. No 3D, surround or anything, just the wav file.
Is there something like that within the script functions?
#2
10/04/2004 (10:27 am)
Thanks, I'll do it that way. I thought I needed a profile in order to get sounds.
Torque Owner Sam3d
You could use a simple function to create a 2D emitter and change the filename for each call.
Something like this should work, although you should destroy the prior emitter before making a new one.
function makeAudio1() {
$sfx1 = new AudioEmitter() {
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
useProfileDescription = "0";
fileName = "~/data/sound/b_monoB.wav";
type = "2";
volume = "1";
outsideAmbient = "1";
isLooping = "0";
};
MissionCleanup.add($sfx1);
echo("Inserting Audio Emitter 1: " @ $sfx1);
}
The best audio doc I know of is incldued in Ed Maurina's awesome Essential Guide to TGE, in the TechSchool_MissionObjects section...
www.hallofworlds.com/pages/Torque/EssentialGuide/EGTGE.zip