Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sound pitch (to simulate engine sound)

Ward Goodnight
Registered User
Join date: 23 May 2006
Posts: 23
05-25-2006 16:37
I'm looking for a way to adjust sound pitch, for an engine sim. When the engine RPM increases, so does pitch. I can't find any functions for adjusting it, I was hoping someone had a suggestion.
Salen Welesa
Kupo? Dook?
Join date: 13 Jul 2005
Posts: 65
05-25-2006 16:47
The best way I've seen to do it is at specific speeds, make a script that adjusts to a 'higher RPM' sound. At 20%, you sound real slow, 50%, more, and 80% sounds real high on the RPMs.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-25-2006 17:31
There isn't the ability to manipulate sounds like that. You can start, stop, loop existing sounds and control the volume, but not affect their pitch, attack, nor (directly) their duration (you can obviously stop early, but you can't play back at a higher rate to play the whole sound in less time which is a cheap pitch change usually).

You'll have to make the different sounds and then tie them to the engine rates, starting stopping and looping them as appropriate as the previous poster suggested.
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
05-25-2006 18:04
I've seen a couple approaches and tried several. the best way I've found is to fade from one to another but it requires two prims. Lower the volume incrementally in one prim will raising the volume incrementally for a different sound in the second prim. The overlap actually isn't a bad engine effect. The other options are to just switch like was suggested but that's kind of jarring. You can also play with sound queuing and create transition sounds but there will still be small gaps between clips, there are some annoying blips that are bugs in SL sound (can hear it in some of the freebee motorcycles), it requires uploading many many more sounds, and it requires more scripting.

oh the overlapping fade isn't bugless either :). If you try changing the volume and crossing a sim border almost simultaneously, sometimes the sound will stop all together until you change the volume again.
_____________________
Cobalt Neutra
As seen on radio
Join date: 13 Sep 2004
Posts: 48
05-26-2006 01:33
The "transition sounds" seems to be what you guys used for the dominus shadow, is that right?

I'm trying to code sound into a car at the moment, and I'm running into that same choppy stuttering that the freebie motorcycles suffer from.

What would you judge to be the most effective means of handling sound for a car/vehicle?
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
05-26-2006 10:11
The shadow sounds were mostly done by Francis. It does sort of do the fading thing but instead of having the second prim also looping a sound, it just plays a transition sound once over the top of the engine sound switches. That avoids the need to change the volume on any of the sounds. The transition sound typically fades in and out on it's own, since it doesn't have to be looped.

The blip comes from using llPlaySound or llLoopSound to change another sound that's playing via llPlaySound or llLoopSound. To avoid the blip stop the first sound before starting the new one. Obviously, that will sometimes increase the gap between the two sounds, but not by as much as you might think :). That's where the overlapped transition sound in another prim comes in. llSetSoundQueuing(TRUE) can also work. When that's enabled then calling llLoopSound or llPlaySound won't interupt the currently playing sound, but instead start them after the current sound finishes. Couple problems with it, It only has queue depth of one. You can play a sound, and queue one sound, that's it. Also, I believe on llPlaySound, llStopSound won't stop the sound until it's finished when queuing is enabled (this may have changed).
_____________________
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
05-26-2006 16:29
Hiya :)

I think Rickard is talking about an earlier pre-release version of the Dominus Shadow sound system.

In its current incarnation, there are 3 (or more depending on how you count) sound emitters. Transition sounds are indeed played overtop sound state changes.

I believe llStopSound will kick in immediately, regardless of where you are in the sound queue/loop. Memory is fuzzy (It's been over half a year since I coded that part) but I think one of the irritating gotchas was that you can't change the sound volume while a clip is playing, so you need to stop it, and change the volume.

I *think* one of the work arounds for to eliminate the sound gap between stopping and starting the next was to start the next sound in another prim, before stopping it in the current one.
_____________________
--
~If you lived here, you would be home by now~
Cobalt Neutra
As seen on radio
Join date: 13 Sep 2004
Posts: 48
05-27-2006 04:46
So that would be something like:

Prim 1:

llLoopSound(idle sound)

llStopsound()

llSleep(time length)


Prim2:

llTriggerSound(transition sound)


Prim1:

(sleep timer runs out)

llLoopSound (accelerate)


...and vice versa to go back again?