Writing Custom Plug-In Instrument

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.