<br><font size=2 face="sans-serif">Hi Rob,</font>
<br>
<br><font size=2 face="sans-serif">This begs the question: &nbsp;&quot;What version of Squeak are you running, and on what platform?&quot;</font>
<br>
<br><font size=2 face="sans-serif">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. &nbsp;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.</font>
<br>
<br><font size=2 face="sans-serif">Your earlier problem really is a problem. &nbsp;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:</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; SampledSound&gt;&gt;myStoreSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream.</font>
<br>
<br><font size=2 face="sans-serif">which would just execute the AbstractSound implementation.</font>
<br>
<br><font size=2 face="sans-serif">So, I'll need some help trying to reproduce your current problem.</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; -Dean</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>&quot;Rob Rothwell&quot; &lt;r.j.rothwell@gmail.com&gt;</b></font>
<p><font size=1 face="sans-serif">05/05/2006 11:03 PM</font>
<br><font size=1 face="sans-serif">Please respond to rjriv</font>
<br>
<td><font size=1 face="Arial">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; &nbsp; &nbsp;&quot;Dean_Swan@mitel.com&quot; &lt;Dean_Swan@mitel.com&gt;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp; &nbsp; &nbsp; &nbsp;&quot;The general-purpose Squeak developers list&quot; &lt;squeak-dev@lists.squeakfoundation.org&gt;, Dan@squeakland.org, jmaloney@media.mit.edu, squeak-dev-bounces@lists.squeakfoundation.org</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound</font></table>
<br>
<br>
<br><font size=3 face="Times New Roman">Dean,<br>
<br>
Thanks for all your help trying to figure this out. &nbsp;However, I am still not able to create any effect on even a SampledSound with a VolumeEnvelope like you suggested. &nbsp;To help hear what is going on I have created a new method, newExponentialDecay in the &nbsp;Envelope class where I have changed: <br>
<br>
 &nbsp; &nbsp;mSecsPerStep := 10. <br>
<br>
 &nbsp; &nbsp;to: &nbsp; mSecsPerStep := 50.<br>
<br>
just to drag out the decay a little longer. &nbsp;When I do that,<br>
<br>
snd := FMSound new.<br>
snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).<br>
snd setPitch: 200 dur: 5.0 loudness: 0.25.<br>
snd play.<br>
<br>
fades out as expected, but then when I turn that tone into a WAV and read it back in:<br>
<br>
snd := FMSound new.<br>
snd setPitch: 200 dur: 5.0 loudness: 0.25.<br>
snd storeWAVOnFileNamed: 'tone.wav'.<br>
snd := (SampledSound fromWaveFileNamed: 'tone.wav').<br>
snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).<br>
snd play.<br>
<br>
The tone just plays at a constant volume! &nbsp;Things that make you go...hmm... <br>
<br>
Thanks again,<br>
<br>
Rob<br>
</font>
<br><font size=3 face="Times New Roman">On 5/5/06, </font><a href=mailto:Dean_Swan@mitel.com><font size=3 color=blue face="Times New Roman"><b><u>Dean_Swan@mitel.com</u></b></font></a><font size=3 face="Times New Roman"> &lt;</font><a href=mailto:Dean_Swan@mitel.com><font size=3 color=blue face="Times New Roman"><u>Dean_Swan@mitel.com </u></font></a><font size=3 face="Times New Roman">&gt; wrote:</font>
<br><font size=2 face="sans-serif"><br>
OK, &nbsp;Here is the answer:</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
There are three implementors of 'storeSampleCound:bigEndian:on:' :</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;AbstractSound&gt;&gt;storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;LoopedSampledSound&gt;&gt;storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;SampledSound&gt;&gt;storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
The AbstractSound implementation does what you want, while the other two (which are identical) do not account for the envelopes. &nbsp;These were all present as of December 2001, &nbsp;attributed to John Maloney and were modified by Stephane Ducasse in 2003 to clean up the way that the current endianness is checked. </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
I don't know why there are two essentially different implementations. &nbsp;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. &nbsp;Does anybody know the history on this? &nbsp;I don't know if it would break any extant code if only the 'AbstractSound' implementation were kept. </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
Regarding 'RepeatingSound', that will take some more digging. &nbsp;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><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
This might be a weakness in how envelopes are used for playback. &nbsp;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><font size=2 face="sans-serif"><br>
As Chris mentioned, the debugger is your friend. &nbsp;Add &quot;self halt.&quot; 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><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;-Dean</font><font size=3 face="Times New Roman"> </font>
<br><font size=2 face="sans-serif"><br>
<br>
Hi Rob,</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
<br>
If you try this:</font><font size=3 face="Times New Roman"> <br>
<br>
 &nbsp; &nbsp; &nbsp; snd := (SampledSound fromWaveFileNamed: 'aWAVFile.wav').<br>
 &nbsp; &nbsp; &nbsp;snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96). <br>
 &nbsp; &nbsp; &nbsp; snd play. </font><font size=2 face="sans-serif"><br>
<br>
You will hear the effect of the envelope, as desired.</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
<br>
This:</font><font size=3 face="Times New Roman"><br>
<br>
 &nbsp; &nbsp; &nbsp; snd storeWAVOnFileNamed: ' out.wav'.</font><font size=2 face="sans-serif"><br>
<br>
should have done what you want, but obviously it does not. &nbsp;I have spent a little time tracking this, but I haven't found the problem yet.</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
<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>
</font><font size=2 face="sans-serif"><br>
<br>
 &nbsp; &nbsp; &nbsp; -Dean</font><font size=3 face="Times New Roman"> </font>
<br>
<br>