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

Rob Rothwell r.j.rothwell at gmail.com
Sat May 6 06:42:45 UTC 2006


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.

It would seem that the answer lies somewhere in how stereo vs mono sounds
are handled.  Ultimately, I want to use a VolumeEnvelope on a MixedSound
that contains both a stereo RepeatingSound, a Left channel FMSound, and a
Right channel FMSound.  I am actually starting to think that will be
possible!

Thanks again.  I feel like I am finally starting to "understand" Squeak a
bit...thanks to a good problem that I have a desire to solve!

--Rob

On 5/5/06, Dean_Swan at mitel.com <Dean_Swan at mitel.com> wrote:
>
>
> Hi Rob,
>
> This begs the question:  "What version of Squeak are you running, and on
> what platform?"
>
> I just tried your example on Squeak 3.7-5989 on my G4 iBook (OS X 10.4.6,
> Squeak 3.8.12beta4U VM), and your example works fine.  It writes out the
> tone to a file without any decay, then the SampledSound plays with the decay
> after reading the tone back in and adding the envelope.
>
> Your earlier problem really is a problem.  We'll have to see what the
> others say for future versions, but for now you could just make a new method
> on SampledSound, something like:
>
>         SampledSound>>myStoreSampleCount: samplesToStore bigEndian:
> bigEndianFlag on: aBinaryStream
>                 super storeSampleCount: samplesToStore bigEndian:
> bigEndianFlag on: aBinaryStream.
>
> which would just execute the AbstractSound implementation.
>
> So, I'll need some help trying to reproduce your current problem.
>
>         -Dean
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060506/bac34211/attachment.htm


More information about the Squeak-dev mailing list