Changing AudioEmitter settings (or anything in .mis) during game
by Brett Baskovich · in Torque Game Engine · 07/23/2006 (8:22 am) · 17 replies
I inserted an AudioCloseLooping3d emitter in the World Editor and it started playing and looping with no problem. However, when I tried changing values such as loopCount, outsideAmbient, and minLoopGap and maxLoopGap (which I assume should produce a random delay between loops) there's no change- it loops the same way as before, forever.
I see the same info in both the WorldEditor and .mis file. I've tried other descriptions with the same results. I'm normally not using a profile but I did try it, again no change.
I see the same info in both the WorldEditor and .mis file. I've tried other descriptions with the same results. I'm normally not using a profile but I did try it, again no change.
About the author
#2
The settings don't have any effect at all, ever, after restarting or changing the .mis file.
07/23/2006 (9:59 am)
Yes, I've realized that many things don't update when you hit Apply. That's not the problem.The settings don't have any effect at all, ever, after restarting or changing the .mis file.
#3
Remember, your audioProfile descriptions *will* overwrite whatever duplicate field in the actual emitter. You have to make the Audio Description null for the settings in the emitter to take effect, or else it will use the description instead.
07/23/2006 (3:08 pm)
Then you haven't set it up correctly.Remember, your audioProfile descriptions *will* overwrite whatever duplicate field in the actual emitter. You have to make the Audio Description null for the settings in the emitter to take effect, or else it will use the description instead.
#4
from .mis file:
and in the server audioProfiles.cs:
and I've tried it with and without an AudioProfile:
No compiling errors.
07/23/2006 (4:08 pm)
I didn't have any of those settings in the description or profile... I added them so everything is the same but still nothing:from .mis file:
new AudioEmitter(Beep) {
position = "46.9628 -393.506 4.32887";
rotation = "1 0 0 0";
scale = "1 1 1";
[b]profile = "Beep"; // have tried without
useProfileDescription = "0"; // have tried on and off
description = "AudioCloseLooping3d"; // have tried a couple others[/b]
fileName = "~/data/sound/beep.wav";
type = "2";
volume = "1";
outsideAmbient = "0";
ReferenceDistance = "5";
maxDistance = "35";
isLooping = "1";
[b]loopCount = "5"; // I'm trying to modify these things
minLoopGap = "100000";
maxLoopGap = "100000";[/b]
enableVisualFeedback = "1";
is3D = "1";
coneInsideAngle = "90";
coneOutsideAngle = "120";
coneOutsideVolume = "0.25";
coneVector = "0 1 0";
};and in the server audioProfiles.cs:
datablock AudioDescription(AudioCloseLooping3d)
{
volume = 1.0;
isLooping= true;
[b]minLoopGap = "100000"; // just added
maxLoopGap = "100000";
loopCount="5";[/b]
is3D = true;
ReferenceDistance= 10.0;
MaxDistance= 50.0;
type = $SimAudioType;
};and I've tried it with and without an AudioProfile:
datablock AudioProfile(Beep)
{
filename = "~/data/sound/beep.wav";
description = "AudioCloseLooping3d";
preload = true;
[b]minLoopGap = "100000"; // just added
maxLoopGap = "100000";
loopCount="5";[/b]
};No compiling errors.
#5
Problem is... what I need to do is change the delays during the game. If I just change the variables it doesn't do a thing. I've tried stopping and restarting the sound but none of the audio commands seem to work with Emitters (no $handle for them?). If I use AudioProfiles instead, which I can create and stop, the delay/loop variables no longer do anything- I think they're only implemented for Emitters.
Anyone have any ideas?
07/24/2006 (3:36 pm)
Ok... those variables work now that I stopped using any sort of profile/description (well... I think that's it... I've tried so many things I'm not sure what worked)new AudioEmitter(Beep) {
position = "46.558 -393.761 4.6";
rotation = "1 0 0 0";
scale = "1 1 1";
//Profile = "BeepProfile";
useProfileDescription = "0";
//fileName = "0";
filename = "~/data/sound/beep.wav";
type = "2";
volume = "1";
outsideAmbient = "1";
ReferenceDistance = "5";
maxDistance = "35";
isLooping = "1";
loopCount = "5";
minLoopGap = "500";
maxLoopGap = "500";
enableVisualFeedback = "1";
is3D = "1";
coneInsideAngle = "90";
coneOutsideAngle = "120";
coneOutsideVolume = "0.25";
coneVector = "0 1 0";
};Problem is... what I need to do is change the delays during the game. If I just change the variables it doesn't do a thing. I've tried stopping and restarting the sound but none of the audio commands seem to work with Emitters (no $handle for them?). If I use AudioProfiles instead, which I can create and stop, the delay/loop variables no longer do anything- I think they're only implemented for Emitters.
Anyone have any ideas?
#6
07/24/2006 (6:58 pm)
I'm looking into audioEmitter.cc and it should use the changed variables- only they're not getting passed from Script to C++. I use Beep.maxLoopGap = "0"; and such, is that the correct syntax?
#7
07/25/2006 (6:29 am)
Ok, maybe this is a more general question... how do you change objects' variables defined in the .mis mission file?
#8
Come on, it must be possible to change the objects defined in the mission file... otherwise they'd just... sit there.
08/03/2006 (10:02 am)
*bump*Come on, it must be possible to change the objects defined in the mission file... otherwise they'd just... sit there.
#9
08/03/2006 (10:06 am)
Obj.foo = bar;
#10
08/03/2006 (10:23 am)
Thanks, but I have tried that (Beep.minLoopGap = 0; and such)... you can access fields like that but not change them, I'm not sure if it's a server/client or script/C++ issue, but there seem to be two versions of the object... I'm testing it in an onCollision method which I imagine would be called by the server...
#11
Simplest way must be to delete the emitter and add a new one with your other settings.
08/03/2006 (2:36 pm)
I don't think the emitter updating when you change it on the fly with a trigger or something else.Simplest way must be to delete the emitter and add a new one with your other settings.
#12
To clarify, I added a print function in audioemitter.cc that shows I'm not successfully altering the values at all, it's not an issue of whether it's using the updates or not...
08/03/2006 (5:16 pm)
Well... I can't delete the Emitter without being able to access it...To clarify, I added a print function in audioemitter.cc that shows I'm not successfully altering the values at all, it's not an issue of whether it's using the updates or not...
#13
... first I just tried setting the values, then figured out I needed to make those values persistent fields to edit them in Script so I did, but it still didn't work... so I wrote a console method to change the values, but that didn't work... I tried making AudioHandle a persistent field so I could stop and start the sound, but that didn't work... it seems like everything is just accessing and changing a copy of the emitter... what is going on??
08/06/2006 (1:26 pm)
Time to bump and add more info I think...... first I just tried setting the values, then figured out I needed to make those values persistent fields to edit them in Script so I did, but it still didn't work... so I wrote a console method to change the values, but that didn't work... I tried making AudioHandle a persistent field so I could stop and start the sound, but that didn't work... it seems like everything is just accessing and changing a copy of the emitter... what is going on??
#14
It was a server/client thing, probably obvious to most people but this was the first time I'd faced it... needed to set the dirty mask and dirty bits so it would send the changes to the client... so if you want to update the rate at which something plays during the game, add to audioEmitter.cc:
and of course
then just use SoundName.setLoopGaps(100,150); in a script.
08/12/2006 (7:25 pm)
For anyone who cares...It was a server/client thing, probably obvious to most people but this was the first time I'd faced it... needed to set the dirty mask and dirty bits so it would send the changes to the client... so if you want to update the rate at which something plays during the game, add to audioEmitter.cc:
void AudioEmitter::setLoopGaps(int min, int max)
{
mDescription.mMinLoopGap = min;
mDescription.mMaxLoopGap = max;
mDirty.set(MinLoopGap); mDirty.set(MaxLoopGap);
setMaskBits(DirtyUpdateMask);
}
ConsoleMethod(AudioEmitter,setLoopGaps,bool,4,4, "...")
{
object->setLoopGaps(dAtoi(argv[2]),dAtoi(argv[3]));
return true;
}and of course
void AudioEmitter::setLoopGaps(int min, int max);in the .h.
then just use SoundName.setLoopGaps(100,150); in a script.
#16
isLooping = "1";
loopCount = "-1";
minLoopGap = "500";
maxLoopGap = "2500";
I'd also like to confirm that the level needs to be re - loaded before the changes are affected ?
08/28/2009 (6:49 pm)
I'm trying to use the Loop gap feature too and find it hard to understand. The end result I am hoping for is to have a one shot type sound loop and repeat at a variable rate between 5500 and 2500 milliseconds. I'm directly editing the mission.mis file. Here's what I have it set to :isLooping = "1";
loopCount = "-1";
minLoopGap = "500";
maxLoopGap = "2500";
I'd also like to confirm that the level needs to be re - loaded before the changes are affected ?
#17
isLooping = "1";
loopCount = "-1";
maxLoopGap = "150";
minLoopGap = "100";
08/28/2009 (6:54 pm)
I can see that when I re-load the mission.mis that my loopGap settings are changed now to :isLooping = "1";
loopCount = "-1";
maxLoopGap = "150";
minLoopGap = "100";
Torque Owner Stefan Lundmark
This has been covered a million times. Audio Emitters do not update correctly when pressing apply, sometimes you have to restart or just move a bit so the simulation updates.