<br><font size=2 face="sans-serif">OK, Here is the answer:</font>
<br>
<br><font size=2 face="sans-serif">There are three implementors of 'storeSampleCound:bigEndian:on:' :</font>
<br>
<br><font size=2 face="sans-serif"> AbstractSound>>storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font>
<br>
<br><font size=2 face="sans-serif"> LoopedSampledSound>>storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font>
<br>
<br><font size=2 face="sans-serif"> SampledSound>>storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif"> -Dean</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>Dean_Swan@Mitel.COM</b></font>
<br><font size=1 face="sans-serif">Sent by: squeak-dev-bounces@lists.squeakfoundation.org</font>
<p><font size=1 face="sans-serif">05/05/2006 05:11 PM</font>
<br><font size=1 face="sans-serif">Please respond to The general-purpose Squeak developers list </font>
<br>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To: rjriv@sbcglobal.net, The general-purpose Squeak developers list <squeak-dev@lists.squeakfoundation.org></font>
<br><font size=1 face="sans-serif"> cc: Dan@SqueakLand.org, jmaloney@media.mit.edu</font>
<br><font size=1 face="sans-serif"> Subject: Re: How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound</font></table>
<br>
<br>
<br><font size=2 face="sans-serif"><br>
Hi Rob,</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
If you try this:</font><font size=3 face="Times New Roman"> <br>
<br>
snd := (SampledSound fromWaveFileNamed: 'aWAVFile.wav').<br>
snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96). <br>
snd play. <br>
</font><font size=2 face="sans-serif"><br>
You will hear the effect of the envelope, as desired.</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
This:</font><font size=3 face="Times New Roman"><br>
<br>
snd storeWAVOnFileNamed: ' out.wav'.<br>
</font><font size=2 face="sans-serif"><br>
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.</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
I will send another reply when I figure this out (maybe today, or later this weekend).</font><font size=3 face="Times New Roman"> <br>
<br>
</font><font size=2 face="sans-serif"><br>
-Dean</font><font size=3 face="Times New Roman"> <br>
<br>
<br>
<br>
<br>
</font>
<table width=100%>
<tr valign=top>
<td width=1%>
<td width=52%><font size=1 face="sans-serif"><b>"Rob Rothwell" <r.j.rothwell@gmail.com></b></font><font size=3 face="Times New Roman"> </font><font size=1 face="sans-serif"><br>
Sent by: squeak-dev-bounces@lists.squeakfoundation.org</font><font size=3 face="Times New Roman"> </font>
<p><font size=1 face="sans-serif">05/03/2006 10:25 PM</font><font size=3 face="Times New Roman"> </font><font size=1 face="sans-serif"><br>
Please respond to rjriv; Please respond to The general-purpose Squeak developers list </font><font size=3 face="Times New Roman"> </font>
<td width=46%><font size=1 face="Arial"> </font><font size=1 face="sans-serif"><br>
To: squeak-dev@lists.squeakfoundation.org</font><font size=3 face="Times New Roman"> </font><font size=1 face="sans-serif"><br>
cc: </font><font size=3 face="Times New Roman"> </font><font size=1 face="sans-serif"><br>
Subject: How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound</font></table>
<br><font size=3 face="Times New Roman"><br>
<br>
<br>
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. <br>
<br>
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. <br>
<br>
For example...<br>
<br>
snd := RepeatingSound new.<br>
snd setSound: (SampledSound fromWaveFileNamed: 'aWAVFile.wav') iterations: 1.<br>
snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96).<br>
snd storeWAVOnFileNamed: ' out.wav'.<br>
<br>
...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...<br>
<br>
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! <br>
<br>
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...<br>
<br>
Thanks,</font>
<br><font size=3 face="Times New Roman"><br>
Rob<br>
</font><font size=2 face="Courier New"><br>
</font><font size=3 face="Times New Roman"><br>
<br>
</font><font size=2 face="Courier New"><br>
</font>
<br>
<br>