[Etoys] OggVorbisCodec crash

Takashi Yamamiya tak at metatoys.org
Mon Dec 10 14:04:10 EST 2007

Hi Karl,

2007/12/9, karl <karl.ramberg at comhem.se>:
> This method returns a SequentialSound with several SampledSounds
> compressed with OggVorbis in it. It's not optimal as you can notice the
> cut between the each sound.


But the reason why the sound was cut is Vorbis encoder has a state. It
is better to reuse same encoder in a sequence. I'll put such method
into the stream (I'd rather prefer the rewrite #compressWith: itself).

   | newSound sound samplesPerSecond size buffer startIndex stopIndex
tempSound codec |
   codec := OggVorbisCodec new.
   size := self samples size.
   startIndex := 1.
   newSound := SequentialSound new.
   samplesPerSecond := (self computeSamplesForSeconds: 1) size.
       to: size
       by: samplesPerSecond
       do: [:i |
            ((stopIndex _ startIndex + samplesPerSecond) > size)
ifTrue:[ stopIndex _ size].
           buffer := self samples copyFrom: startIndex to: stopIndex.
           sound := SampledSound samples: buffer samplingRate: self
           tempSound := codec compressSound: sound.
               add: tempSound.
           startIndex := stopIndex + 1].
   ^ newSound

- Takashi

More information about the Etoys mailing list