I am a relative newcomer to FMOD Ex, and am having trouble using the FMOD_DSP_TYPE_COMPRESSOR stock DSP to write compressor data to disk. Here is where I am at: I have successfully written a program (C++ VC6) that opens a standard 16 bit, stereo, 44,100 .wav file, sets up the compressor dsp, plays the file, and responds correctly to the four controls. So far, so good, but I would like to save the data that has been processed by the compressor dsp to disk. When I use the function readData() to read incoming data from a stream, it has not been processed by the dsp, but rather, is the same as the input stream. On the other hand, the function getWaveData() returns with the dsp-processed data, but represents a time-varying "snapshot" of the input data, leading to a garbled output file, and the float array returned by getWaveData() doesn’t appear to be in sync with the input file as it is being streamed. It seems possible to use setCallback() with addDSP() to solve the problem, but I am not sure if this is true, and have not yet learned how to do it in any event. I have perused most if not all of the example files (the dsppluginviewer example comes close, but the "Record" function therein is confusing, as it doesn’t appear to write anything to disk), as well as countless forum articles, to no avail.
therefore, your help / suggestions would be mot gratefully appreciated.

Thanks very much.

Code snippets:

result = c_system->createDSPByType(FMOD_DSP_TYPE_COMPRESSOR, &dsp_compressor);

result = c_system->addDSP(dsp_compressor);

result = dsp_compressor->setParameter(FMOD_DSP_COMPRESSOR_THRESHOLD,  (float) nThreshold);
result = dsp_compressor->setParameter(FMOD_DSP_COMPRESSOR_ATTACK,     (float) nAttack);
result = dsp_compressor->setParameter(FMOD_DSP_COMPRESSOR_RELEASE,    (float) nRelease);
result = dsp_compressor->setParameter(FMOD_DSP_COMPRESSOR_GAINMAKEUP, (float) nGain);


do {
    result = sound->readData ((char *)data, CHUNKSIZE, &read);
    fwrite((char *)data, read, 1, outfp);
    bytesread += read;
while (result == FMOD_OK && read == CHUNKSIZE);


    result = c_system->getStreamBufferSize(&stream_buffersize,0);

        wavearray,          // float *  wavearray, 
        stream_buffersize,  // numvalues 
        0);                 // int  channeloffset

    for (int i=0; i< stream_buffersize; i++) 
        short_wavearray [i] = (short) (32768.0f * wavearray [i]);
    fwrite ((char *) short_wavearray, stream_buffersize, 1, outfp);
  • You must to post comments

My previous post began:

"I am a relative newcomer to FMOD Ex, and am having trouble using the FMOD_DSP_TYPE_COMPRESSOR stock DSP to write compressor data to disk…"

Despite all odds, my brain managed to generate enough bio-electricity for me to figure out how to do this all by myself, using

init(32, FMOD_INIT_STREAM_FROM_UPDATE, _T(szOutputFileName))

and running system->update() as rapidly as practical.

in case anyone else might be having the same problem with this or with other stock DSP’s.

The conceptual hangup was how to set a callback for createDSPByType(), which unfortunately still exceeds my band-width.

Thanks anyway.


  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.