Converting from Sequential to Sampled Sounds?

Andreas Raab raab at isgnw.cs.Uni-Magdeburg.DE
Thu Feb 5 00:38:05 UTC 1998


> Actually, I'm much less ambitious than that :-).  I want to build a web
> page (for example) where someone could type "c d e d e d c" into a textbox,
> click a button, and get a u-law link that they could click on to actually
> hear the tune that they just specified.

Provided you got your SequentialSound already the conversion to
SampledSound should be not to difficult. You can ask the sound for its
samplesRemaining and Provide a SoundBuffer of appropriate size. This is
just like SoundPlayer playLoop, i.e.

| nSamples buffer |
nSamples := mySound samplesRemaining.
buffer := SoundBuffer newStereoSampleCount: nSamples.
mySound 
  mixSampleCound: nSamples
  into: buffer
  leftVol: 1.0
  rightVol: 1.0

That's all - in theory. Now you can go and use SampledSound>>uLawEncode:
to do the rest. Note the buffer returned by the above snippet can not be
used directly by SampledSound at the moment, because the mix-in always
uses stereo samples but SampledSound does currently only support mono
samples.

Oh, I just checked and noticed that you have to ask each sound in the
SequentialSound for its samplesRemaining because SequentialSound returns
either zero or one million (John, is there any reason for this?!). But
that's no big deal either.

Hope that helps,
  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list