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

Dan Ingalls Dan at SqueakLand.org
Thu May 4 05:13:46 UTC 2006


Hi, Rob -

I can't vouch for storeWAVOn, but I have used the following to build some pretty cool wind chimes...
	| snd |
	snd _ FMSound new.
	snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.985).
	(snd setPitch: 2000 dur: 4.0 loudness: 0.5) play

Well, actually I did just try it and got a .wav file that sounded right...
	| snd |
	snd _ FMSound new.
	snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.985).
	(snd setPitch: 2000 dur: 4.0 loudness: 0.5) storeWAVOnFileNamed: ' out.wav'.

Hope this helps.

	- Dan

>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: 1.
>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...
>
>Thanks,
>
>Rob




More information about the Squeak-dev mailing list