0
0

My excuses to everyone since this is badly off topic and outside the scope of FMOD but since most people here is good at sound, I would like to get some help about two vorbisenc func I am not able to figure out. I would have subscribed to vorbis mailing list but the subscribe method they use is too complicated for me and I cannot find any good resource on internet or the tutorials.

I have built a simple program which records PCM samples from the mic in. This is saved in a wave file for now so I can tell it works correctly.
Now, I would like to encode those PCM samples in a OGG stream.
I am quite sure I followed the tutorials provided with vorbisenc quite well but I am having problems with two functions:

[i:34pr480f]vorbis_analysis_wrote(…)
vorbis_analysis_buffer(…)[/i:34pr480f]

Can someone give me some hints on how those two work?

Thank you for your attention.

  • You must to post comments
0
0

vorbis_analysis_wrote <– Tell the library how much sample we wrote
vorbis_analysis_buffer <– expose the buffer to submit data

  • You must to post comments
0
0

This is not exactly what I was expecting. I already knew that since it’s written in the samples given with vorbisenc.

  • You must to post comments
0
0

Well all you told us was that you ‘needed help’ with said functions. That’s not a very clear inquiry… be a bit more specific. What exactly are you having trouble with? I mean, since you already seem to know what the functions do from the example code, then what more do you need to know to make use of them?

Do you catch my drift? That last post of yours was far too ambiguous for anyone to have expected a straight answer from it… (and this is not to attack you, I’m just trying to let you know for the future)

  • You must to post comments
0
0

The problem is that I have arranged my data.
My data is always mono. By default it is recorded at 16bits per sample but 8bits per sample is still an option.

If I write to the buffers returned by vorbis_analisys_buffer and then I call vorbis_analisys_wrote to tell vorbisenc how much samples I wrote, a crash occurs. Some time the app stops responding, sometimes it crashes, sometimes it stop responding then crashes. The crash is sometimes very hard and causes system to reboot, possibly damaging some files around the HD (this is surely an OS fault, I cannot ask help for that).

KarLox suggested me to uninterleave channels. I really appreciated his help… too bad there’s nothing to uninterleave since I’m getting a mono signal from the mic-in.

If I don’t call vorbis_analysis_wrote everything goes smooth but obviously, the vorbis does not exist at all – so the interaction between those two functions and vorbisenc are a bit unfocused to me.
BTW, why is the buffer returned as a float**?

[code:223c4ro9]
float **buffer = vorbis_analysis_buffer(&vorbisEncoderState, bytes / SAMPLE_SIZE); /* SAMPLE_SIZE is actually #define’d (this is just an experiment) but in the real app will be user selectable. */

/* toReadThisTime is how much bytes we got to encode while SAMPLE_SIZE is bytes per sample, resulting in amount of samples to pass to vorbisenc */
for(unsigned giveToVorbisEnc = 0; giveToVorbisEnc < toReadThisTime / SAMPLE_SIZE; giveToVorbisEnc++) {

 /* This was added after KarLox suggested me to but it does not change everything. Before, I was doing the memcpy call below which should be almost the same thing without the division (I guess this is an error) */
 /* A little on &quot;read&quot;: i figured out this is actually useless - it was used to fragment big recorded streams to shorter streams but I will get the rid of it in the near future and fragment the vorbis directly. */
 buffer[0][giveToVorbisEnc] = (float)*(dataToCompress + read + giveToVorbisEnc) / 32768.0f;
 /* memcpy(buffer[giveToVorbisEnc], dataToCompress + read + giveToVorbisEnc * SAMPLE_SIZE, SAMPLE_SIZE);*/

/* The above works without any error /
}
/
I also tried this one, which is, if I undestood correctly, is wrong /
/
memcpy(buffer, dataToCompress + read, toReadThisTime * SAMPLE_SIZE); */

/* Uncomment this and everything will blow up! /
/
vorbis_analysis_wrote(&vorbisEncoderState, (bytes / SAMPLE_SIZE) / 2);*/
[/code:223c4ro9]

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.