Hi, Please excuse my ignorance but I'm having trouble with a very basic matter: I'm using vorbisfile to stream audio to the waveout device in Win32 (using waveOutWrite). I'm basically reading packets from an ogg file and streaming them using a simple buffering scheme. The thing is, this works great when the bitrate is more or less constant but the audio sounds garbled if there is a radical bitrate change. Which makes sense but I don't know how to handle this using vorbisfile! I know I must use ov_instant_bitrate() in some way. I'd really appreciate some help. Thanks and excuse my newbie-ness! Agustin --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
volsung@mailsnare.net
2003-Oct-17 13:04 UTC
[vorbis] Streaming audio to the waveout device
Quoting Agustin Cordes <acordes@elinpar.com>:> Please excuse my ignorance but I'm having trouble with a very basic matter: > I'm using vorbisfile to stream audio to the waveout device in Win32 (using > waveOutWrite). I'm basically reading packets from an ogg file and streaming > them using a simple buffering scheme. The thing is, this works great when > the bitrate is more or less constant but the audio sounds garbled if there > is a radical bitrate change. Which makes sense but I don't know how to > handle this using vorbisfile! I know I must use ov_instant_bitrate() in some > way. I'd really appreciate some help. > Thanks and excuse my newbie-ness!Hi, I don't understand the problem you are describing. If you are decoding audio data with vorbisfile and sending it to the waveout device, then I don't see how ov_instant_bitrate() would help you. ov_instant_bitrate() will just estimate the bitrate since the last time the function was called. I don't see how this information would help fix audio problems. However, other possibilities that might cause intermittent garbled output: * ov_read() frequently returns fewer PCM samples than you tell it to. This is not a bug, but rather by design. (It stops decoding when you get to the end of the current Vorbis packet. The next call will decode another packet.) Make sure you are checking the return value from ov_read() to see how much audio was written. * Buffering might also be a problem. A simple, single-threaded read/write application can sometimes get into trouble if the audio playback device runs out of audio to play while the program is blocked waiting for I/O (and thus not decoding more audio). The fix here is to redesign your application, so you probably want to rule out all other bugs before considering this. Can you describe in more detail what the garbled audio sounds like? Are their gaps? Stuttering? Noise? --- Stan Seibert --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
>Hi, I don't understand the problem you are describing. If you aredecoding > audio data with vorbisfile and sending it to the waveout device, then I don't > see how ov_instant_bitrate() would help you. ov_instant_bitrate() will just > estimate the bitrate since the last time the function was called. I don't see > how this information would help fix audio problems. >However, other possibilities that might cause intermittent garbled output: >* ov_read() frequently returns fewer PCM samples than you tell it to. This is > not a bug, but rather by design. (It stops decoding when you get to the end of > the current Vorbis packet. The next call will decode another packet.) Make > sure you are checking the return value from ov_read() to see how much >audio was > written. >* Buffering might also be a problem. A simple, single-threaded read/write > application can sometimes get into trouble if the audio playback device runs > out of audio to play while the program is blocked waiting for I/O (and thus not > decoding more audio). The fix here is to redesign your application, so you > probably want to rule out all other bugs before considering this. >Can you describe in more detail what the garbled audio sounds like? Are their >gaps? Stuttering? Noise? The reason I mentioned the bitrate was because of this comment on the official decoding example: /* we don't bother dealing with sample rate changes, etc, but you'll have to*/ But now that you explained what ov_instant_bitrate() I understand I shouldn't bother with it. About the things you mention: * I'm not checking the ov_read() return value. In fact, I'm using a fixed value for the packets I stream to the waveout device, but it seems their size may vary. I will check this out. * I'm pretty sure I'm not running out of buffer. I'm running traces to see how much buffer I've left and there's plenty of it. As a matter of fact, I'm using a multi-threaded application with double-buffering (I guess it's not _so_ simple!). The garbled audio sounds very much like gaps. It looks like the ov_read() ret value might be it. The thing that puzzles me is that if I encode a file with CBR it works great but when I encode the same file with VBR it doesn't. Thanks! --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Perfect! Beautiful! I needed to keep in mind the amount of samples returned. Thank you very much, Stan! AgustÃn Cordes <p>--- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.