Game Development Community

AudioEmitters - Upgrading

by Edward F. Maurina III · in Torque Game Engine · 07/01/2003 (9:08 pm) · 42 replies

Hi folks. I'm currently working on 'upgrading' the audioemitter object and I would like to get some input from the users, namely you. Currently the emitters are semi-functional but don't provide very good placement feedback and do not behave as I expect them to based on the parameters available. So, before I get into asking questions I'll give a quick run down on how I think they should work:

3D Mode (Looping->is3D == checked)
In this mode, the audio-emitter is a positional + directional emitter.

Directional Component - Two cones of sound to determine how angles affect the sound.

www.hallofworlds.com/pages/Torque/TorqueImages/SoundCone.jpg
The inner cone volume == 100% * Volume Modifiers
The outer cone volume == VAR% * Volume Modifiers
The rest of the area  == [i]coneOutsideVolume[/i] * Volume Modifiers

The direction of the cones is determined by: [i]coneVector[/i]

Positional Component - Distance from the emitter determines the other component of the sound equation.
[i]referenceDistance[/i] - If you are inside the inner cone and within this distance of the emitter, the volume is 100% (except in water).
[i]maxDistance[/i] - If you are outside of this distance, the emitter is off.

NON-3D Mode (Looping->is3D == unchecked)
In this mode, the sound is on at the same volume at all distances from the emitter (with one exception).
[i]outsideAmbient[/i] - Play the sound except when inside an interior.

Looping Settings
[i]isLooping[/i] - If checked, loop [i]loopCount[/i] times.
[i]loopCount[/i] - Number of times to play sound in looping mode. If -1, repeat forever.
[i]min/maxLoopGap[/i] - Still working this out.

Media Settings
[i]type[/i] - Chooses one of 30 (32?) OpenAL filters to apply to sound.

Current upgrades list
- It is my intention to make the emitters as behave described above. In the HEAD version of Torque, some of these features are working and some are not.
- Add better visual feedback for emitter placement. Curently, there is no way to see where the cones are. I am implementing a visual method of showing the following:
-- Inner Cone (DONE)
-- Outer Cone (DONE)
-- referenceDistance
-- maxDistance
-- Aproximate volume drop-off for inner cone.
- Fix spatial issue with 3D. Currently, the sounds are louder (in one ear) when you are facing away from the emitter at an angle than when you are facing them directly. Semi-mathematically, expressed:
- Total volume in right ear when emitter is directly 
       opposite that ear = X
     - Total volume when facing emitter directly < X.

www.hallofworlds.com/pages/Torque/TorqueImages/ae_90_90.jpgInner/Outer == 90/90

www.hallofworlds.com/pages/Torque/TorqueImages/ae_0_90.jpgInner/Outer == 0/90

www.hallofworlds.com/pages/Torque/TorqueImages/ae_60_90.jpgInner/Outer == 60/90

www.hallofworlds.com/pages/Torque/TorqueImages/ae_60_360.jpgInner/Outer == 60/360

www.hallofworlds.com/pages/Torque/TorqueImages/ae_270_360.jpgInner/Outer == 270/360


What I need from you
1. Do you disagree with any of my descriptions or do you have anything to add?
2. Can you think of any other reasonable features to add? (Now is the time).

Thanks in advance for your feedback.

-Ed
#21
06/05/2004 (5:03 pm)
You freaking rock.
#22
06/05/2004 (5:21 pm)
OK, folks. Like I promised, this is fixed. The audio emitters now provide the following features:

1. 3D visual feedback (i.e. where the emitter sound can be heard and where it is pointing)
2. The ability to disable visual feedback (in case you have lots of emitters and you don't want them to render all the time while editting.) Note: 3D emitters will always render their 3D feedback while they are SELECTED.

In addition to the visual fixes, I re-hooked up some existing code to fix the attentuation problem that was introduced some time back. Basically, the emitters were not turning off at max distance. This is now working again. Additionally, the visual feedback reflects this.

You can wait for the patch to be accepted (submitted today) or you can download it NOW

Note: There are two patch files. One for engine and one for example. Apply both, and please don't ask why I split them up. I don't normally, but had to this time.

Lastly, post comments in this thread if you have issues with the patch or want something else fixed (audio emitter wise).

Thanks,

Ed M.

PS - Here is quicky drop in object for the stronghold mission for those who want to test this:

new AudioEmitter(testae) {
      position = "356.737 314.47 221.262";
      rotation = "0 0 1 82.5059";
      scale = "1 1 1";
      useProfileDescription = "0";
      fileName = "~/data/sound/testing.ogg";
      type = "2";
      volume = "1";
      outsideAmbient = "0";
      referenceDistance = "10";
      maxDistance = "25";
      isLooping = "1";
      loopCount = "-1";
      minLoopGap = "0";
      maxLoopGap = "0";
      enableVisualFeedback = "1";
      is3D = "1";
      coneInsideAngle = "90";
      coneOutsideAngle = "270";
      coneOutsideVolume = "0.25";
      coneVector = "0.991458 0.130424 0";
   };
#23
06/05/2004 (9:05 pm)
Edward,

I'm working on a major reworking of the audio stuff in torque, may I have your permission to include this visual feedback into this?

Thanks
#24
06/05/2004 (9:51 pm)
2. Can you think of any other reasonable features to add? (Now is the time).

I don't know if these could be called "reasonable" features (or if they're already possible with some more sleuthing/coding) but I thought I'd pitch them in:

- Can a sound echo more in a hallway than an open field, automatically? Visually, it'd be like the dots emit from the source, then bounce back -- an echo with variable loudness and echo pause depending on the geometry of the surroundings.

- A step further would be to have an sound_absorb variable tied to each level object, so it would echo more in an empty hall made of wood then a hall with huge curtains on both sides.

- When a continuous sound source is in a room, and you open the door to the room, the sound level should automatically increase although the distance has not.
#25
06/06/2004 (12:19 am)
@marcelo - Of course. No need to ask. If you wait a week it should probably be part of head (unless the patch gets kicked back).

@joshua - some of what you are discussing is possible and I 'believe' some hooks are in place to implement this, but there is real work there. Now as far as getting somekind of visual rep for that, the code I've included in this patch is just a simple spherical/conical rep based on a few parameters. It does not take into account local geometry.

Regarding this, taking into account geometry, adding sound processing code to do that would likely be 'quite' expensive in CPU cycles, which is good for simulation, but probably not for a game, however it is a cool idea.

Basic special effect/filters are available, but require programming.

Hope that answer the questions.

-Ed
#26
07/05/2004 (2:20 pm)
This is in HEAD now.
#27
07/05/2004 (4:03 pm)
The new head audio seems to suggest that there's something wrong with audio.h I think.. I get these errors when I try to build:


Compiling...
audioEmitter.cc
C:\mw\engine\game\audioEmitter.cc(384) : error C2065: 'fAnimRotAngle' : undeclared identifier
C:\mw\engine\game\audioEmitter.cc(577) : error C2065: 'bEnableVisualFeedback' : undeclared identifier
C:\mw\engine\game\audioEmitter.cc(971) : error C2039: 'bEnableVisualFeedback' : is not a member of 'AudioEmitter'
../engine\game/audioEmitter.h(20) : see declaration of 'AudioEmitter'
Error executing cl.exe.

mw.exe - 3 error(s), 0 warning(s)
#28
07/05/2004 (4:45 pm)
I get the same errors as Stefan, and a couple others:

\Torque\torque\engine\game\audioEmitter.cc(384) : error C2065: 'fAnimRotAngle' : undeclared identifier
\Torque\torque\engine\game\audioEmitter.cc(385) : error C3861: 'fAnimRotAngle': identifier not found, even with argument-dependent lookup
\Torque\torque\engine\game\audioEmitter.cc(385) : error C3861: 'fAnimRotAngle': identifier not found, even with argument-dependent lookup
\Torque\torque\engine\game\audioEmitter.cc(577) : error C2065: 'bEnableVisualFeedback' : undeclared identifier
\Torque\torque\engine\game\audioEmitter.cc(800) : error C3861: 'bEnableVisualFeedback': identifier not found, even with argument-dependent lookup
\Torque\torque\engine\game\audioEmitter.cc(928) : error C3861: 'bEnableVisualFeedback': identifier not found, even with argument-dependent lookup
\Torque\torque\engine\game\audioEmitter.cc(971) : error C2039: 'bEnableVisualFeedback' : is not a member of 'AudioEmitter'
../engine\game\audioEmitter.h(20) : see declaration of 'AudioEmitter'
#29
07/05/2004 (4:59 pm)
The var fAnimRotAngle is declared in the constructor
AudioEmitter::AudioEmitter(bool client)
and is not declared in the appropriate header file.

It is declared as a static in
void AudioEmitter::render3DVisualFeedBack(void)

That is the only place I can see it being called. I just removed
it from the constructor and it worked fine.

Also make sure that bEnableVisualFeedback and void render3DVisualFeedBack(void); are declared in audioEmitter.h.

This just allows you to turn the visual on and off in the editor.

Hope this helps........
#30
07/06/2004 (4:04 am)
Nope, that didn't solve it for me :( Anyone know why it's giving these errors? Did I do something wrong, or did gg upload faulty files?
#31
07/06/2004 (4:16 am)
I am having the same problem. I just got the latest HEAD version.
#32
07/06/2004 (5:41 am)
Hmm...I had the same problem untill I tracked it down as I said. I am using the HEAD from about two weeks ago. Mine works great. I have made allot of changes in the audio section. I'll take a look and see if anything I did there would affect this.
#33
07/06/2004 (6:46 am)
There is a problem with the codebase.

The variables in the class are not being referenced correctly.

fAnimRotAngle should be mAnimRotAngle
and
bEnableVisualFeedback should be mEnableVisualFeedback

or the other way around since this is my first time viewing torque source and I am not sure of the naming conventions.

Should this be in another forum?
#34
07/06/2004 (7:51 am)
This discussion is in the right place.

I apparently screwed up when I did some renaming for consistency. And I thought I had checked that... should be ok now, I've checked in a fixed copy. Sorry guys!
#35
07/06/2004 (8:24 am)
Yay, thanks alot Ben, downloading the new files now!

Edit: They work :)
#36
07/06/2004 (10:31 am)
No probs.

I'm sure it has happened to all of us before.
CM software hasn't reached the point yet where it is people-proof. :)
#37
07/06/2004 (3:12 pm)
Well... guess I missed that one. Good catch Matthew. I went about it in a different direction. This is a classic case of more heads are better than one! :)
#38
07/06/2004 (3:38 pm)
Thanks.

Someday I hope to be able to contribute to this project.
Since I've only had Torque for about a few weeks now I am still just trying to wrap my head around Torque script. This could take a little while.
#39
07/08/2004 (12:49 pm)
@Ben,
Take a look at these while you're in there...

In bool AudioEmitter::update() around line 218
if(mDirty.test(Transform))
      {
         Point3F pos;
         mObjToWorld.getColumn(3, &pos);
         alxSource3f(mAudioHandle, AL_POSITION, pos.x, pos.y, pos.z);
      }
add the following for direction:
if(mDirty.test(Transform))
      {
         Point3F pos;
         mObjToWorld.getColumn(3, &pos);
         alxSource3f(mAudioHandle, AL_POSITION, pos.x, pos.y, pos.z);
         //Make sure we update the direction also ???
         [b]mObjToWorld.getColumn(1, &pos);
         alSource3f(mAudioHandle, AL_DIRECTION, pos.x, pos.y, pos.z);[/b]
      }


Also,
if(smDefaultDescription.mType == smDefaultDescription.mType) mDirty.clear(AudioType);
should be:
if([b]mDescription.mType[/b] == smDefaultDescription.mType) mDirty.clear(AudioType);

BTW, Edward, does this fix the sound via conevector or is this simply a graphics fix?
#40
07/08/2004 (1:18 pm)
Hmm... interesting. Ed, what do you make of these fixes?