Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

3D and Triggered Sounds

From UamWiki
Revision as of 14:11, 6 January 2011 by AndyLegate (talk | contribs) (Created page with 'Okay, so before we start, take a look at the first thread "Putting In Sounds" You need to already know how to put in a sound emitter into your Age and how to do the scripting fo…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Okay, so before we start, take a look at the first thread "Putting In Sounds"

You need to already know how to put in a sound emitter into your Age and how to do the scripting for it.

This tutorial will deal with making those sounds 3D and/or Triggered......


Why Use 3D Sounds?

Good question! Glad I asked it!

Because the way the world really works, 99% of all sounds you hear are 3D! They originate at a source that is located in a 3 dimensional world. That sound has to travel to you, and the sound waves will reach you from a certain angle, depending on how you have your ears turned.

The other 1% would be the wind rushing past your ears, as that makes it sound like the wind is surrounding you, or ringing you might have in your ears.

Or voices speaking to you that now one else can hear......

Er, uhm.......if it's a ringing you have in your ears....then get your butt to the hospital as there is something wrong with your hearing, and you could loose it!

If it's voices.....er, please don't ever come visit me.....

Okay, now first I must say this: if you are deaf, partially deaf, or require a hearing aid to hear, you may have a hard time setting up sounds in your Age. Don't let that stop you though! Get a friend or family member that can hear to help you! I'm quite sensitive to people that can not hear as my first wife's grandparents were both deaf all their lives, and for a little while there, we though our first born daughter had become deaf while an infant.

Now, for most people, we've all sat and talked to someone. While that someone was talking, you may have gotten up and moved around. You notice that their voice will move left to right (or vice versa) depending on where you are moving and turning your head.

All sounds are like this. That Air Conditioner that is running, the sound from it. From your TV, from your computer, from the dog barking outside.

So the sounds we hear have a origination point. The sound has to travel too. And depending on how close your are (and how loud the sound is being made) will determine how loud it sounds to you.

So as we are trying to make our Age's as real as possible, you want to do this with your sounds in your Age, unless it's a special ambient sound (like wind) or background music that plays in the Age.

So let's get to it!


Getting Started

Okay, in this example, I'm going to use a large gear that is turning. It's part of some machine that is just running all the time in the Age. So what triggers the sound is you linking in. As it is constantly running, we'll want the sound to play over and over.

Now, as I said, you need to be familiar with putting a sound emitter into your Age and the basic scripting for it.

With this gear, I'm going to put the sound emitter smack in the middle of the gear. Objects in your Age will NOT block sound!

You have to make a sound file for it to and put it into blender. Now we do the scripting:

gearemit1:
    type: soundemit
    sound:
        flags:
          - autostart
          - looping
          - is3dsound
        file: gearsound
        volume: 0.5
        minfdist: 5
        maxfdist: 100
        type: SoundFX

Okay, let me explain somethings in the script:

Under flags we have:

- autostart This makes the sound start playing as soon as you link in. If you don't want that, then don't include this line.

- looping This makes the sound play over and over and over, well you get the picture. If you only want the sound to play once, don't put in this line.

- is3dsound This makes the sound 3D, so that if you turn your avie left or right, the sound will move back and forth to either one of your speakers. It will also make the sound get louder as you approach, and fade as you move away.

That brings us to our next two lines:

minfdist: and maxfdist:

This is VERY important! If you do not put these two in, and you make the sound 3D by putting in the - is3dsound flag, YOUR SOUND WILL NOT PLAY!!!

So remember to put these in!

minfdist: this is the minimum distance the avie needs to be from the sound emitter for the sound to be at it's loudest volume. The value you give it is in Blender Units. I've set mine to 5, so that means that when you get within 5 feet of the emitter, the sound will be as loud as it can get.

maxfdist: this is the maximum distance the avie can be and still hear the sound. As you move away from the emitter, the sound will begin to fade, so that once you get to the maximum distance the sound will not be hear anymore. This is good as it makes it very realistic! The value you put here is also in Blender units. I've got mine set to 100, so after 100 feet, the avie won't hear the sound anymore.

The rest of the script is discussed in my basic sound thread.


Triggered Sounds

What are Triggered Sounds? Simple.....

A triggered sound is a sound that does not play unless something happens: IE a button is pushed, lever pulled, avatar walking into a certain area, etc, etc.

To make a triggered sound, you still have to put in the sound emitter and give it scripting. Let me show my scripting for my gear again:

gearemit1:
    type: soundemit
    sound:
        flags:
          - is3dsound
          - looping
        file: gearsound
        volume: 0.5
        minfdist: 5
        maxfdist: 100
        type: SoundFX

As you can see, this time, I did not put in the - autostart because I don't want the sound to start until AFTER I do something.

How do we trigger the sound?

That's a good question, and has many different answers. The main one being another question:

"What is it you want to do?"

For pushing buttons, pulling levers, touching something, etc, that will require scripting for all that, and that is where you will put in the trigger for the sound to be played or started.

For learning how to do THAT, go to this thread here to start learning how:

How To Make Something Clickable

Now, let's do the easy thing here: let's make the sound start simply because the avatar walking into a certain area.

You'll need to put in a region around the area where the avatar will get to to start the sound. If it's a room, you'd have a large box around the room. So go to the scripting window and add a generic logic region. Then scale it and move it around until you have it like you want it.

Please note: The way this works is: the avatar enters the region, that toggles the sound. Since the sound is off right now, it will toggle it on. The moment the avatar walks out of the region, the sound will be toggled off.

Linking in to a region will NOT toggle the sound to on using this script! For that, you will need a different set up.

Once you have the region done, simply add this to your ALCscript:


gearsoundregion:
    region:
        type: soundregion
        soundemitter: gearemit1


Where gearsoundregion is the name of the region I made (put whatever you called yours here), and gearemit1 is the name of the sound emitter I put in (put whatever you called yours here).

That's all there is to it.


Tips on sounds

Before I stop here, please know that there are more complex flags you can set for sounds. Please take a look at the GoW Wiki for those.

Fading sounds. There is a flag for this, however, I've always used the 3d sound for this, and simply used the minfdist and maxfdist. I've never noticed anything bad, or wrong about it.

Overlapping sounds: you can achieve this by making the sounds 3D, but making sure that the maxfdist on both sound emitters is set so that the edges of the sounds over lap.

Moving sounds: Yes, you can make a sound move! Just parent the emitter to the moving object, and make sure you make the sound emitter a 3d sound! (there's a bit more about this, but it does work, I've tried it out, and it's cool! NOT to be confused with kickable objects, that is done differently).


Return To: Andy's Blender Tutorials