[vorbis] Ogg ouput using libvorbisfile

Oscar Sundbom oscar at moosecomrade.mine.nu
Sun Jul 27 16:46:12 PDT 2003



On 27 Jul 2003 18:29:33 -0400
"David St.Clair" <dstclair at cs.wcu.edu> wrote:

> Actually, doing a cat file.wav > /dev/dsp plays fine (just a low
> bitrate.)  The sound I'm getting is distorted.  The sound I'm getting is
> something like the sound you get when doing cat file.ogg >/dev/dsp
> (ugly)   (This is with fwrite())
> 
> I tried setting ioctl()s (opening /dev/dsp with open()) and using
> write() instead of fwrite() and I get a decoded ogg output, but after
> about 11 seconds it starts to choke and it seems like it's not
> buffered.  Don't know what's going on.  Any ideas?

Actually, what Tom said is completely correct. I think/guess /dev/dsp is set up for signed 8 bit audio at 8000
samples/second, though it may be unsigned. If you manage to cat a wave file there and get good sound, it's using
the same bitrate and sign as /dev/dsp does by default.
I'm guessing the Vorbis decoding function returns 16 bit signed audio (though if I remember correctly, that can be changed), so you need to set up /dev/dsp accordingly.
In short this would be:
ioctl(fd, SNDCTL_DSP_SETFMT, &format);
ioctl(fd, SNDCTL_DSP_CHANNELS, &channels);
ioctl(fd, SNDCTL_DSP_SPEED, &samplerate);

where format is (most probably) AFMT_S16_LE, channels set to 2 and samplerate to 44100, but the last two you
should be able to get out of libvorbis functions.

Hope it helps.
Oscar

PS. You might check out OSS programming docs at their site (or just browse through /usr/include/linux/soundcard.h, like me :) )


-- 
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis mailing list