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

Rob Rothwell r.j.rothwell at gmail.com
Sun May 7 19:40:11 UTC 2006


Dean,

Ok, I *think* I can probably do this on my own now...

I was just not understanding some of the basic "rules:"

1.  Envelopes are not rules that you apply to a sound, they are objects that
"go with" the sound, and you must have a separate envelope for each sound.
You can't apply the same envelope twice (i.e. to the left channel and right
channel of a MixedSound).  I did this by accident with PitchEnvelopes,
because I needed separate envelopes for each channel to do what I wanted to
do, but I didn't make the connection.

2.  MixedSounds are just weird.  Don't mix two MixedSounds.  It will dilute
the volume or the time of the final product, depending on how you do it.
Mix "pure" sounds instead.  Also, many classes like SampledSound and
RepeatingSound actually return MixedSounds upon creation, depending on
whether or not you are working with stereo sounds or not.  Sometimes they
force them into MONO because they are derived from AbstractSound, which
returns isStereo := false.  Anyway, you need to break them down into their
left and right channels before mixing them with other sounds or else you run
into the MixedSound dilution problem.

3.  All in all, it is best just to create a separate envelope for each
channel of each sound you are working with when dealing with stereo sounds,
and then mix them together at the end.  Of course, you can create classes
that do some of this for you, but they need to make a COPY of the envelope
you wish to apply to both channels, not use the same one twice.

Thank again for all your help; I'm pretty sure I can get there from here!

--Rob

On 5/6/06, Rob Rothwell <r.j.rothwell at gmail.com> wrote:
>
> Hello Dean,
>
> As I said before, something was funky with my image.  In a clean 3.8 image
> (although I have changed the SoundPlayer SamplingRate to 44100), I created a
> new storeWAVOnFileNamed method for a SampledSound as you suggested, and that
> worked!  However, when I tried it with the pre-existing WAV sample I
> originally wanted to use, it didn't work--which led me to the following:
>
> "This works when creating a mono sound"
>
> snd := FMSound new.
> snd setPitch: 200 dur: 5.0 loudness: 0.25.
> snd storeWAVOnFileNamed: 'monotone.wav'.
> snd := (SampledSound fromWaveFileNamed: 'monotone.wav ').
>
> snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).
> snd play.
>
> "It does not work for stereo..."
>
> snd := FMSound new.
> snd setPitch: 200 dur: 5.0 loudness: 0.25.
>
> "Turn the sound into a stereo sound and save it as a WAV"
> mix := MixedSound new.
> mix add: snd.
> mix storeWAVOnFileNamed: 'stereotone.wav'.
>
> "Read a STEREO sound from a WAV as a SampledSound and try to modify it"
> snd := (SampledSound fromWaveFileNamed: ' stereotone.wav').
>
> snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).
> snd play.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060507/e3652232/attachment.htm


More information about the Squeak-dev mailing list