<br><font size=2 face="sans-serif">Hi Rob,</font>
<br>
<br><font size=2 face="sans-serif">This begs the question: "What version of Squeak are you running, and on what platform?"</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. 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. 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"> SampledSound>>myStoreSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font>
<br><font size=2 face="sans-serif"> 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"> -Dean</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>"Rob Rothwell" <r.j.rothwell@gmail.com></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"> </font>
<br><font size=1 face="sans-serif"> To: "Dean_Swan@mitel.com" <Dean_Swan@mitel.com></font>
<br><font size=1 face="sans-serif"> cc: "The general-purpose Squeak developers list" <squeak-dev@lists.squeakfoundation.org>, Dan@squeakland.org, jmaloney@media.mit.edu, squeak-dev-bounces@lists.squeakfoundation.org</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=3 face="Times New Roman">Dean,<br>
<br>
Thanks for all your help trying to figure this out. However, I am still not able to create any effect on even a SampledSound with a VolumeEnvelope like you suggested. To help hear what is going on I have created a new method, newExponentialDecay in the Envelope class where I have changed: <br>
<br>
mSecsPerStep := 10. <br>
<br>
to: mSecsPerStep := 50.<br>
<br>
just to drag out the decay a little longer. 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! 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"> <</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">> wrote:</font>
<br><font size=2 face="sans-serif"><br>
OK, 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>
AbstractSound>>storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
LoopedSampledSound>>storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
SampledSound>>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. 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><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. 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><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
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><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. 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. 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><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
-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>
snd := (SampledSound fromWaveFileNamed: 'aWAVFile.wav').<br>
snd addEnvelope: (VolumeEnvelope exponentialDecay: 0.96). <br>
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>
snd storeWAVOnFileNamed: ' out.wav'.</font><font size=2 face="sans-serif"><br>
<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"> </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>
-Dean</font><font size=3 face="Times New Roman"> </font>
<br>
<br>