Hi all,
I have written a granular plugin effect for fmod studio that works great. Now I would like to write a synth plug-in instrument (like the noise generator) that can be triggered via scripting in game engines (i’m using Unity).
At its most basic, it should be able to deliver a polyphonic sine pluck. It would need a per voice frequency parameter for different notes, but I’m not sure how that would be achieved with the fmod dsp. I am wondering if anyone has any insight about doing something like this. I know some people have done run-time sound synthesis with Csound, but since I’m heavily using FMOD in my project, I want to stick to using fmod event emitters and avoid any audio source components in Unity.
Thanks so much!
Noah
If you happen to be familiar with Max MSP, we have a C++ example for turning RNBO patches into DSPs, which might be a good starting point Making plugins using RNBO - #17 by jeff_fmod.
If you want to tackle it yourself, the only real difference between an effect and an instrument in FMOD is the presence of an input buffer. If you report 0 input buffers and 1 output buffer for FMOD.DSP_DESCRIPTION.numinputbuffers and FMOD.DSP_DESCRIPTION.numoutputbuffers respectively, FMOD Studio will treat it as a generator and allow you to place it in the timeline. The fmod_noise example demonstrates this (and it sounds like you’ve already found it). With that as a base all you will need to do is:
- Replace the
FMODNoiseState::generate method with an oscillator (replace the rand with sinf and give it different values over time)
- Expose frequency as a parameter
FMOD_DSP_INIT_PARAMDESC_FLOAT(p_freq, "Frequency", "Hz", "Frequency", 60, 20000, 440);
- Make as many parameters and oscillators for each voice you want to support
With that, you can trigger your DSP as a Plug-in Instrument and control the frequency with Automation.