[Tremor] Resampling while decoding

Michael Smith msmith at xiph.org
Fri Jun 16 08:54:54 PDT 2006


On 6/16/06, Martin Vilcans <mvilcans at digital-legends.com> wrote:
> Hi list,
>
> I'm developing a game that will use Tremor for decoding Vorbis and got
> this idea about supporting different sample rates. We'll have to support
> several different sample rates but the Vorbis streams are at a fixed
> frequency. We can resample the decoded samples in realtime, but I'm
> wondering if there is a more efficient way to play back a Vorbis stream
> at a specific sampling rate. I suspect that there might be some
> efficient way to resample while decoding, but this might be just because
> I don't know much of how a Vorbis stream is constructed.
>
> Also, perhaps it's possible to increase quality without sacrificing
> speed. For example, if the Vorbis stream uses a rate of 44 kHz, but the
> playback rate is 22 kHz, we'd normally decode the stream, apply a
> high-pass filter to remove frequencies above the Nyqvist frequency and
> resample by averaging every two samples. Instead, perhaps the decoder
> can simply not decode the upper half of the frequency spectrum (the
> 11-22 kHz band). That would give the same effect as applying a low-pass
> filter to the decoded samples. Then we can do a quick resample by simply
> removing every other sample.

libvorbisfile has a way of decoding at half-rate, you could use that.
I'm not sure if the version of vorbisfile in tremor includes that, but
I'd imagine you could port the halfrate bits across to tremor if not.

This doesn't help with doing arbitrary other sampling rates, though -
for that, you will indeed need a resampler.

Mike (a some-time vorbis hacker, also in Barcelona)


More information about the Tremor mailing list