Hi there again..
I'm still writing my particular-case-vorbis-encoder-and-player, and it
worked fine until now.
I'm having a problem trying to encoding the audio. I need to send the data
very quickly, as soon as i capture it from the sound card.
Currently i have the following (audio captured 16 bits, mono):
void VorbisEncoder::encode(void *data, int r)
{
char *buf = (char *) data;
int vals = r / 2;
float **buffer = vorbis_analysis_buffer(&dsp_state, vals);
for(int i=0;i<vals;i++){
buffer[0][i] = ((buf[i*2 + 1] << 8) |
(0x00ff & (int) buf[i*2])) / 32768.f;
}
vorbis_analysis_wrote(&dsp_state, vals);
while(vorbis_analysis_blockout(&dsp_state, &vblock) == 1){
ogg_packet ogg_pkt;
vorbis_analysis(&vblock, &ogg_pkt);
ogg_stream_packetin(&ogg_stream, &ogg_pkt);
while(1){
int result = ogg_stream_flush(&ogg_stream,
&page);
if(!result)
break;
write_ogg_page(&page);
}
}
}
My problem is that in some cases, i capture some data from the sound card
and i feed it to this function, but vorbis_analysus_blockout doesnt output
any block.
When i encode all the data i capture from the sound card (continuos
audio), it works fine. But if i start detecting levels, and sending to the
encoder only the audio louder that some level, in some cases
vorbis_analysis_blockout returns 0. I guess it's because it doesnt have
enought data to output a regular block.
Any idea how can i make it work ? Or maybe using vorbis to try to transmit
realtime audio is not a good idea ?
Thanks in advance
--
The names of their development products, visual this, visual that, almost
makes one think that you can create software just by looking at your computer
<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-dev-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.
On Friday 12 September 2003 15:52, Eric Ross wrote:> My problem is that in some cases, i capture some data from the sound card > and i feed it to this function, but vorbis_analysus_blockout doesnt output > any block. > > When i encode all the data i capture from the sound card (continuos > audio), it works fine. But if i start detecting levels, and sending to the > encoder only the audio louder that some level, in some cases > vorbis_analysis_blockout returns 0. I guess it's because it doesnt have > enought data to output a regular block. > > Any idea how can i make it work ? Or maybe using vorbis to try to transmit > realtime audio is not a good idea ?Though vorbis would generally be ok for realtime use, the libvorbis vorbis encoder is definately not designed for realtime. Using full VBR (i.e. non-managed modes) will drastically reduce the latency, but it'll still be high. If you need to do this, you may have to write your own vorbis encoder (but it depends on just what latency you can tolerate - 10 ms? 50 ms? 100 ms? 500 ms? Vorbis won't do 10 ms, 50 ms would be very marginal and probably not possible, 100 ms or more should be fine if you take appropriate care.) You'd also find that the ogg layer has a lot of overhead if you do it like this (one packet per page), so you'd want to do it differently anyway (see, for example, the vorbis-over-RTP drafts). You might also be able to get away with it (again, this depends: you haven't given much detail, so I can't say for sure) by just ensuring you always write blocks of audio of some minimum size (for VBR modes, this size needn't be all that large. It depends on sampling rate, so give more details if you want recommendations on this), and using a low-latency encapsulation layer (i.e. probably not ogg). Mike --- >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-dev-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.