I have 2 identical user created playback streams. Each stream is someone speaking. I take each voice sample of a specific size and feed it into the callback buffer. If I play them seperately they are fine. If I take each voice sample and feed both to a single stream there is stuttering. Any idea why? They are both FMOD_SOUND_FORMAT_PCM16, and at the same rate.
- me62 asked 7 years ago
I receive voice sample over internet. They are marked "partA" or "partB". Using FMOD_OPENUSER I copy each partA into the read callback buffer of one stream. It plays fine. The same for partB on a seperate stream.
BUT if I have only ONE stream and put both partA and partB into the call back buffer the sound comes out stuttering.
This isn’t an issue with FMOD it’s an issue with your input data. You can’t just pass blocks of data from two separate streams in an arbitrary order and expect FMOD to somehow know the correct ordering. You need to buffer the data yourself and create contiguous streams which are syncronized, then pass that into FMOD.
[quote:1u8o2bg9][aaaa] [bbbb] [bbbb] [aaaa] [bbbb] [aaaa] [aaaa] [aaaa] [bbbb] [bbbb][/quote:1u8o2bg9]
I’m not entirely sure what you are trying to acheive but if you do it like that it will definately cause stuttering.
Assuming each block above is 1024 samples, it would be:
21ms of A
42ms of B
21ms of A
21ms of B
63ms of A
42ms of B
When you chop and change that quickly it will sound like stuttering. Why are you trying to combine them together?
I have two communication streams I am playing back: "a" and "b". I would like them to play in the order each "a" or "b" is received. They come in at 1024 bytes of "a" or "b". I do not know the order they will arrive. If I collect all "a" in one stream and "b" in a seperate stream they play fine. BUT they are not synchronized. The sounds come out like they are talking over each other.
If I put them on one stream they are synchronized like a conversation BUT they stutter.
What do you recommend I do?
I have tried realtimestitching with mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE. And have a pcmreadcallback() to pull in the data stored for "a" or "b". I give subsound = "a", subsound = "b". Each subsound only has a 1024 chunk received. But in the code below "currentsubsoundid != subsoundid" is never true. I do not know why. It is always currentsubsoundid == 0. And sometimes if it does say true and switch to playing subsound it then sticks on that.
[code:1r150vv9] if (currentsubsoundid != subsoundid)
I am kinda committed to FMOD at this point. Any suggestion is appreciated. Is there a way to avoid [quote:1r150vv9]When you chop and change that quickly it will sound like stuttering[/quote:1r150vv9]. thanks
The order is based on how "a" or "b" is received. They are placed in the buffer as received:
[aaaa] [bbbb] [bbbb] [aaaa] [bbbb] [aaaa] [aaaa] [aaaa] [bbbb] [bbbb]
So when receive [aaaa]. Those bytes are placed in buffer. What ever is received next is appended to that buffer (be it [aaaa] or [bbbb]). They are always the same size bytes of "a" or "b" when they are received and so placed in the buffer in the same chunk size. They are always placed as a set of "a" or "b" never mixed.
IF I place all the "a" in one stream:
[aaaa] [aaaa] [aaaa] [aaaa] [aaaa] [aaaa]
And all of the "b" in a different stream, each stream plays perfectly. WHEN they are both placed in one stream the playback is perfect for a certain time, say a couple seconds, then stuttering, then fine, etc. For example, all the bytes associated with "a" play fine. But then when start playing the "b"s I hear a stutter for a couple seconds. Then all of a sudden "b" bytes play fine and it is the "a" that are stuttering.
AHHH. thanks for any insight on my problem.
Stream creation (for single or two seperate):
[code:34rhn493]FMOD::Sound PlayerEx::CreateMonoStream(Audio streamAudio, int numBytes)
FMOD_MODE mode = FMOD_OPENONLY | FMOD_CREATESTREAM | FMOD_OPENRAW | FMOD_OPENUSER | FMOD_HARDWARE | FMOD_LOOP_NORMAL;
int channels = 1;
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); /* required./
createsoundexinfo.decodebuffersize = 8000;
createsoundexinfo.length = numBytes;
createsoundexinfo.numchannels = channels;
createsoundexinfo.defaultfrequency = 8000;
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16;
createsoundexinfo.pcmreadcallback = pcmreadaudio; / User callback for reading. /
//createsoundexinfo.pcmsetposcallback = pcmsetposcallback; / User callback for seeking. */
createsoundexinfo.userdata = streamAudio;
result_ = system_->createSound(0, mode, &createsoundexinfo, &sound);
[quote:r70z72ls]if I have only ONE stream and put both partA and partB into the call back buffer the sound comes out stuttering.[/quote:r70z72ls]
How are you putting both into the callback buffer?
sequentially like this:
[aaaa] [aaaa] [aabb] [bbbb] [bbbb]
interleaved like this:
or some other way?
Please login first to submit.