0
0

Hi,

I’m new to this board and i hope that i don’t write anything stuipd.

I want to write an VoIP API using FMOD. For developing and testing i cut the network stuff and do playback and recording in the same programm.

I searched on the examples and ‘usergeneratedsound’ seems to be the best example for playback and ‘streamtodisk’ the best for recording.
I also searched in this board and there are topics with the same problem but sadly with no solution for it.

Well recording works, even with my own buffer class. So after recording when i do an mixdown to my harddisk the wave can be played as wished.

My Problem is the playback. I copied the most from the example ‘usergeneratedsound’ and i just replaced the generating with the data from my buffer. The first seconds are fine but when i get an mysterius effect. The sound seem to loop but the start and end of the loop move on the time line in the same size.
This loop goes infinity.
I can say that it’s not my buffer class because i used it’s data for the mixdown in the same way i want to load it into the buffer.
Maybe i use fmod on a wrong way.

Here is my callback
[code:3c2pxf7e]
FMOD_RESULT F_CALLBACK AudioStreamer::pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
{
signed short *stereo16bitbuffer = (signed short *)data;

// cast sound
FMOD::Sound *snd = (FMOD::Sound *)sound;

// get pointer to the object
void* Object;   
snd->getUserData(&Object); 

// cast object to class
AudioStreamer* ASObject = (AudioStreamer*) Object;

try
{
    // set memory to zero
    memset(data,0,datalen);

    // fill buffer
    ASObject->_BufferStream.Read(stereo16bitbuffer, datalen>>1);
}
catch(...)
{
    return FMOD_ERR_MEMORY;
}

return FMOD_OK;

}
[/code:3c2pxf7e]

i create the sound on this way
[code:3c2pxf7e]
// check – sound already playing?
if(!this->_Playing)
{
// informations – recording sound
memset(&_createsoundexinfoPlaying, 0, sizeof(FMOD_CREATESOUNDEXINFO));
_createsoundexinfoPlaying.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); /* required. */
_createsoundexinfoPlaying.decodebuffersize = 44100; /* Chunk size of stream update in samples. This will be the amount of data passed to the user callback. */
_createsoundexinfoPlaying.length = 44100 * _channels * sizeof(signed short) * 2; /* Length of PCM data in bytes of whole song (for Sound::getLength) */
_createsoundexinfoPlaying.numchannels = _channels; /* Number of channels in the sound. */
_createsoundexinfoPlaying.defaultfrequency = 44100; /* Default playback rate of sound. */
_createsoundexinfoPlaying.format = FMOD_SOUND_FORMAT_PCM16; /* Data format of sound. */
_createsoundexinfoPlaying.pcmreadcallback = AudioStreamer::pcmreadcallback; /* User callback for reading. */
_createsoundexinfoPlaying.userdata = this; /* pointer to this object */

    // create sound
    if(_system->createSound(0, _mode, &_createsoundexinfoPlaying, &_soundPlaying) != FMOD_OK)
    {
        return;
    }

    // play sound
    if(_system->playSound(FMOD_CHANNEL_FREE, _soundPlaying, 0, &_channelPlaying) != FMOD_OK)
    {
        return;
    }

    // set flag
    this->_Playing = true;
}

[/code:3c2pxf7e]

If i start the original sample i don’t get a constant sine wave. It’s moving up and down. Not much but it does.

I hope anyone can tell me what i understnad wrong till now.

Regards Chriss

  • You must to post comments
0
0

As an short addition, the whole stream is playes but in looped steps.

If somebody is interested how it sounds, the testapp can be foud here

http://syntrix.org/tmpdata/fmodex.zip

I’m really confused how this could happen. Because i here nearly the same every loop, just a view ms later. I wonder about that because i delete everey readed data from my buffer.

Is there any flush function for the fmod buffer? As you see on the code above the whole buffer from fmod is set to zero. So how can a loop be played when the buffer is zero?

  • You must to post comments
0
0

I solfed my problem by using an own dsp with its own DSP_READ_CALLBACK.

I analysed the problem with the pcmreadcallback and it seems the the time till the callback is called again is raising.

But if somebody knows how it could be done with the pcmreadcallback i’m still interested in it.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.