Render DSP to array

Good evening,

I’ve looked all over and the closest I could find was using system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER) to output effected PCM data. I’m trying to effectively render data read using sound->readdata in a single pass using DSP effects. Ideally I would like to do it in place without having to load in a second effected wav file. Is there any way to do this with FMOD?

Thanks in advance for your help.

I’ve found links to several of the algorithms used in FMOD such as the STFT pitch algorithm which does exactly what I am looking for, so it seems like this type of functionality should be easily exposed for all of the effects right?

To run a DSP effect supplied by fmod, onto a sound, you have to play it.
If you play it, you have to capture the result to get the data back, so a DSP with a custom read callback is typically used.

This is done in realtime normally, so for non realtime FMOD_OUTPUTTYPE_NOSOUND_NRT could be used. You could use a stand alone FMOD::System object just for this purpose, and another for normal playback of sounds.

I tried doing exactly that but I don’t think I really understand at a low level how to accomplish this. It doesn’t seem like my pointer array is effected by the DSP, and the only other information I could find wrote the output to a wav file.

This is not enough information for me to help you, can you be more specific

Ok so I’m creating my sound by loading it into a dynamically created array as follows

  FMOD::System     *_system;
FMOD::Sound      *_sound=NULL;
FMOD::Channel    *_channel = 0;
FMOD_RESULT       _result;
unsigned int      _version;
void             *_extradriverdata = 0;
unsigned int length;
unsigned int lengthms;
char *pointer2;
    system->createSound(fileName, FMOD_OPENONLY, NULL, &_sound);
    _sound->getLength(&lengthms, FMOD_TIMEUNIT_PCMBYTES);
    lengthms=int(lengthms);
    //lengthms=70000;
    pointer2 = new char[lengthms];

This is then being passed into a pcmreadcallback basically just like the example user_created_sound . I’ve been succesful at adding DSP effects to sounds which are loaded and played directly with FMOD, but what I’m trying to do is have the DSP effect applied directly in place in a single pass to the data which is in pointer2 in the above code. I was able to do this myself with the pitch change effect but I had to get the stft pitch shift code referenced by FMOD off the authors website. I do want to use VST plugins as well though so I was hoping there would be a way to do this without writing all of the effects myself.

Thanks for your help, hopefully this makes a little more sense.

why do you bother loading the PCM data into an array?
You would play the sound from the filename, then use a capture DSP to capture the float data upon output of the channel or channelgroup. Still need some more information on this one.

The main reason I’m loading it into memory is because I’m using multiple systems as suggested, and rather than loading the sample multiple times into memory I’d prefer to just load it once and pass the pointer between systems, which seems to be working fine. I also need finer control over the sample playback than PlaySound provides.

As far as Capture DSP goes, this sounds like exactly what I need, but when I search the documentation I don’t see any examples of this functionality or how I would go about accomplishing it.

you can load it into memory and use FMOD_OPENMEMORY or FMOD_OPENMEMORY_POINT without needing to load it manually with readData.

A capture DSP is just a user created DSP, there is a custom dsp example in the examples folder

I was under the impression that the user created DSP buffer was for user created effects. I can’t use an existing FMOD DSP effect in a custom DSP callback can I?

you can just ‘pass through’ the signal by doing a memcpy of in to out.
Inbetween though you can capture the signal for your own purposes.