Jump to content

Controlling the pitch of a sound file


Miguelito Shilova
 Share

You are about to reply to a thread that has been inactive for 3694 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I would like to find a way to emulate how a motor changes its pitch as it changes speed. I'm thinking of using the throttle float value to determine the pitch the sound. Is there a function in LSL that can change the pitch of a sound file?

I suspect you could have multiple sound files pre-recorded at different pitches, but I'm wanting a smooth transition between pitch levels, so I don't know how one can achieve that even with multiple files without affecting the pitch of each file on the transition, and if you have to change pitch, then I think using a single file would be best.

Can anyone provide suggestions as to a specific function or a starting point to achieve that kind of result?

Thanks for your help!

Mig

(a slow and blundering, but determined pupil of LSL)

Link to comment
Share on other sites

There's no function like that, but you might be able to create a cool effect by uploading a boatload of sound files that are each a single pure tone -- say, perhaps a 1/4 tone apart.  Play them sequentially on adajcent prims, offset in time and overlapping a bit so they appear to blend together.  It would mean a tedious scripting job but it might make an interesting effect  -- like a digital Moog synthesizer.

Link to comment
Share on other sites

Thanks always for your input!

That is an interesting suggestion ... I might want to lead up to that as I learn how to script a basic sound file call to a throttle float value transmitted on a channel.

Maybe it could be simplfied down to 7 sound files:

 

  1. idle sound (loops)
  2. idle pitching up to a medium speed (when speeding up - doesn't loop)
  3. medium speed ptiching down to idle (when slowing down - doesn't loop)
  4. medium speed (loops)
  5. medium speed pitching up to full speed
  6. full speed pitching down to medium speed
  7. full speed (loops)

I'm already broadcasting the throttle setting to child scripts in each prop for a texture rotation. I could include something there that checks that value to a range of values for each of the situations above, with a single range point for each of the two transitions. (sorry - not sure if this is how seasoned programmers talk out what they want to do) :)

I'm seeing this as a series of if/ else if/ else tests, but I don't know how you go about constructing these tests to check for ranges.

And given the boat throttle send negative values for reverse throttle (<0 = the boat in reverse), I suppose you would need to handle both sets of ranges. 

Mig

Link to comment
Share on other sites

Actually, you may be making this a lot more complicated than it needs to be.  If this were my project, my first move would be to look through free libraries of sounds on the Internet and find ones of motorboats accelerating and decellerating. Why manufacture a complex sound when you can just use a natural one?

  • Like 1
Link to comment
Share on other sites

I agree that I shouldn't have to manufacture the sounds, and I'm sure I can find something for at least two motor states (idle and running) for looping while the boat is either running or not, and two transition sounds (speed up and slow down) that play only when you cross a speed threshold.

I suppose what I'm trying to wrap my mind around is how I would take that throttle cue to determine how I would change between the (now 4) states - maybe the logic would work like this ...

if throttle =!  0

play throttle up once;

play running as loop;

else

play throttle down once;

play throttle idle;

No, I would still have to track the change from 1 and -1 to cue either the throttle up or throttle down sounds to fire, wouldn't I? Otherwise I would get the transition sound at each throttle change. Any suggestion on what that would look like? 

Link to comment
Share on other sites

integer gStep;touch_start(integer num){    if (!gStep)    {        llPlaySound("Powerup",1.0);        llSetTimerEvent(duration_of_powerup_sound);    }    else    {        llPlaySound("Powerdown",1.0);        llSetTimerEvent(duration_of_powerdown_sound);    }    gStep = !gStep;}timer(){    llSetTimerEvent(0.0);    if (gStep)    {        llLoopSound("ThrottleRunning",1.0);    }    else    {        llLoopSound("ThrottleIdle", 1.0);    }}

 You might need to put a llStopSound before each of the llLoopSound calls, but I doubt it.

 

   

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3694 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...