# Render DSP to array

**URL:** <https://qa.fmod.com/t/render-dsp-to-array/14893>\
**Category:** FMOD Engine\
**Created:** [July 28, 2019, 3:14am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893 "2019-07-28T03:14:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [July 28, 2019, 3:14am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/1 "2019-07-28T03:14:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [July 29, 2019, 3:24am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/2 "2019-07-29T03:24:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 2, 2019, 4:36am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/3 "2019-08-02T04:36:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [August 8, 2019, 2:57am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/4 "2019-08-08T02:57:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 8, 2019, 3:36am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/5 "2019-08-08T03:36:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [August 8, 2019, 11:53am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/6 "2019-08-08T11:53:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 8, 2019, 10:41pm UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/7 "2019-08-08T22:41:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [August 9, 2019, 12:30pm UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/8 "2019-08-09T12:30:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 10, 2019, 2:49am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/9 "2019-08-10T02:49:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![siditious](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@siditious](https://qa.fmod.com/u/siditious)\
**Post date:** [August 12, 2019, 4:04am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/10 "2019-08-12T04:04:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 12, 2019, 4:23am UTC](https://qa.fmod.com/t/render-dsp-to-array/14893/11 "2019-08-12T04:23:02Z")

</div>

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.
