How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound
Dean_Swan at Mitel.COM
Dean_Swan at Mitel.COM
Sat May 6 04:07:25 UTC 2006
Oops, This would only work if you were directly sending
'myStoreSampleCount:bigEndian:on:', which you aren't.
SampledSound>>myStoreSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
super storeSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream.
For now, I would just say rename
SampledSound>>storeSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
to something like:
SampledSound>>oldStoreSampleCount: samplesToStore bigEndian:
bigEndianFlag on: aBinaryStream
and make sure that SampledSound no longer has a
'storeSampleCount:bigEndian:on:' method. To test this, I just removed the
method from SampledSound.
You could also get into silliness like make a proxy for 'SampledSound'
(e.g.. 'MySampledSound') that redirects everything except
'storeSampleCount:bigEndian:on:' to 'SampledSound', but that's a bit much,
in my opinion. I would really just remove the method from SampledSound,
unless you really nead to be able to write the sound to a file with and
without the envelope.
-Dean
Dean_Swan at Mitel.COM
Sent by: squeak-dev-bounces at lists.squeakfoundation.org
05/05/2006 11:48 PM
Please respond to The general-purpose Squeak developers list
To: rjriv at sbcglobal.net
cc: squeak-dev at lists.squeakfoundation.org
Subject: Re: How to Fade-In/Fade-Out a Sampled/Repeating/Mixed Sound
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
"Rob Rothwell" <r.j.rothwell at gmail.com>
05/05/2006 11:03 PM
Please respond to rjriv
To: "Dean_Swan at mitel.com" <Dean_Swan at mitel.com>
cc: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>, Dan at squeakland.org,
jmaloney at media.mit.edu, squeak-dev-bounces at lists.squeakfoundation.org
Subject: Re: How to Fade-In/Fade-Out a
Sampled/Repeating/Mixed Sound
Dean,
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:
mSecsPerStep := 10.
to: mSecsPerStep := 50.
just to drag out the decay a little longer. When I do that,
snd := FMSound new.
snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).
snd setPitch: 200 dur: 5.0 loudness: 0.25.
snd play.
fades out as expected, but then when I turn that tone into a WAV and read
it back in:
snd := FMSound new.
snd setPitch: 200 dur: 5.0 loudness: 0.25.
snd storeWAVOnFileNamed: 'tone.wav'.
snd := (SampledSound fromWaveFileNamed: 'tone.wav').
snd addEnvelope: (VolumeEnvelope newExponentialDecay: 0.96).
snd play.
The tone just plays at a constant volume! Things that make you
go...hmm...
Thanks again,
Rob
On 5/5/06, Dean_Swan at mitel.com <Dean_Swan at mitel.com > wrote:
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
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060506/4946f150/attachment.htm
More information about the Squeak-dev
mailing list
|