How to gradually increase or decrease an FMSound frequency over
time?
Hans-Martin Mosner
hmm at heeg.de
Fri Apr 21 05:33:31 UTC 2006
Rob Rothwell wrote:
> Here is essentially what I want to do, which gives a "smooth"
> (stepped) progression from f1 to f2. stepsPerSecond sort of controls
> the "smoothness" of the progression.
>
> f1 := 330.50.
> f2 := 440.90.
> f := f1.
> t := 0.
> sec := 15.
...
Here's a version with PitchEnvelope, which is really smooth and much
less complicated:
f1 := 330.50.
f2 := 440.90.
sec := 15.
envelope := (PitchEnvelope
points: (Array
with: 0 @ 1
with: sec*1000 @ ((f2*2 / f1) log / 2 log))
loopStart: 2 loopEnd: 2)
centerPitch: f1.
(FMSound new setPitch: f1 dur: sec loudness: 0.5)
addEnvelope: envelope;
play
Note that due to the logarithmic pitch slope, the frequency at t=7.5 is
381.73 and not 385.70.
You should really experiment with PitchEnvelope a little more (and
VolumeEnvelope for fade-in/fade-out).
I'm certain that you can achieve your goals with it.
When adding more slope points to the envelope, always remember to set
loopStart and loopEnd to the size of the points array, as you don't want
to have a looping part.
Cheers,
Hans-Martin
More information about the Squeak-dev
mailing list
|