How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound

Dean_Swan at Mitel.COM Dean_Swan at Mitel.COM
Fri May 5 21:11:59 UTC 2006

Hi Rob,

If you try this:

        snd := (SampledSound fromWaveFileNamed: 'aWAVFile.wav').
        snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96).
        snd play.

You will hear the effect of the envelope, as desired.


        snd storeWAVOnFileNamed: ' out.wav'.

should have done what you want, but obviously it does not.  I have spent a 
little time tracking this, but I haven't found the problem yet.

I will send another reply when I figure this out (maybe today, or later 
this weekend).


"Rob Rothwell" <r.j.rothwell at>
Sent by: squeak-dev-bounces at
05/03/2006 10:25 PM
Please respond to rjriv; Please respond to The general-purpose Squeak 
developers list 

        To:     squeak-dev at
        Subject:        How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound

Does anyone know how to fade a mixed sound?  I am creating a MixedSound 
which includes both a RepeatingSound (based on a looped SampledSound from 
a WAV file), and an FMSound. 

I pretty much know how to apply a VolumeEnvelope to an FMSound by looking 
at the exponentialDecay method, but applying a VolumeEnvelope to a 
SampledSound, RepeatingSound, or MixedSound seems to have no effect. 

For example...

snd := RepeatingSound new.
snd setSound: (SampledSound fromWaveFileNamed: 'aWAVFile.wav') iterations: 
snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96).
snd storeWAVOnFileNamed: ' out.wav'.

...shows no effect on the waveforms in the resulting WAV file, even if I 
change the step size of the increments in the exponentialDecay to drag the 
decay out much further...

Do I need to write a method to modify the SoundBuffer values of the 
SampledSound directly?  If so, I'm afraid I will need much more help! 

I just don't know enough technically about sound generation to trace my 
way through the updateTargetAt method of the VolumeEnvelope class to 
figure out what is going on with a non-FMSound...



-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Squeak-dev mailing list