How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound
Dean_Swan at Mitel.COM
Dean_Swan at Mitel.COM
Fri May 5 22:33:44 UTC 2006
OK, Here is the answer:
There are three implementors of 'storeSampleCound:bigEndian:on:' :
AbstractSound>>storeSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
LoopedSampledSound>>storeSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
SampledSound>>storeSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
The AbstractSound implementation does what you want, while the other two
(which are identical) do not account for the envelopes. These were all
present as of December 2001, attributed to John Maloney and were modified
by Stephane Ducasse in 2003 to clean up the way that the current
endianness is checked.
I don't know why there are two essentially different implementations. My
initial inclination is that the 'LoopedSampledSound' and 'SampledSound'
implementaions are unnecessary and should be removed, but I really don't
know what John was thinking about, and the comments don't really say. Does
anybody know the history on this? I don't know if it would break any
extant code if only the 'AbstractSound' implementation were kept.
Regarding 'RepeatingSound', that will take some more digging. I can say
that if you add the envelope to the SampledSound that is created from the
wave file, then create a RepeatingSound using the SampledSound that has an
amplitude envelope, you will hear the envelope for each repetition.
This might be a weakness in how envelopes are used for playback.
Presumably, an envelope applied to the 'RepeatingSound' should control the
overall volume of the composite sound, but that doesn't seem to be what is
happening.
As Chris mentioned, the debugger is your friend. Add "self halt." before
a message send you want to debug, click on 'Debug' when the 'Halt'
notification window pops up and then use the 'Over' and 'Into' buttons to
single step through the code.
-Dean
Dean_Swan at Mitel.COM
Sent by: squeak-dev-bounces at lists.squeakfoundation.org
05/05/2006 05:11 PM
Please respond to The general-purpose Squeak developers list
To: rjriv at sbcglobal.net, The general-purpose Squeak developers list
<squeak-dev at lists.squeakfoundation.org>
cc: Dan at SqueakLand.org, jmaloney at media.mit.edu
Subject: Re: How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound
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.
This:
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).
-Dean
"Rob Rothwell" <r.j.rothwell at gmail.com>
Sent by: squeak-dev-bounces at lists.squeakfoundation.org
05/03/2006 10:25 PM
Please respond to rjriv; Please respond to The general-purpose Squeak
developers list
To: squeak-dev at lists.squeakfoundation.org
cc:
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:
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060505/d7b617c0/attachment.htm
More information about the Squeak-dev
mailing list
|