Organizing a modal/additive synthesizer in C++/Juce? (Duplicating partials up to "n" # of partials?)

DSP, Plug-in and Host development discussion.
26 posts since 5 Apr, 2017

Post Tue Jun 26, 2018 8:07 pm

I have built some very complex and satisfying modal/additive instruments in Reaktor Core and I'm in the process of trying to convert them over to Juce (C++) for greater efficiency and to allow more partials.

In Reaktor, I designed the synths by creating "sections" as follows:

1) Global general calculations - These were calculations based on pitch/gate and knob values that would be needed for all partials to work from, but only need to be calculated once per note for all partials to share. Each calculation was output to a "bus" (ie. variable), so that each partial could access it.

2) Partial - Macro fed with inputs of: Partial #, gate/pitch, other knobs, and the output variables from the global calculation section.

I then simply copied and pasted the "partial" macro out for as many partials as I wanted and linked them so that they automatically added their sums together and each would be automatically assigned "+1" for its partial number relative to the previous partial.

It's quite burdensome/tedious of course copying and pasting out 50-100 partials.

I presume now that I'm switching to Juce/C++ there will be a more efficient way to handle this. I think the same general principle will still have to apply of performing global calculations up front, and then feeding those calculations via variables to the "partial" section. This is to avoid re-calculating the global calculations for every single partial.

But I am hoping that with Juce/C++, the partial structure can just be defined once, and somewhere within it, I can express that it should run 50-100 copies of itself, each with a different "n" or partial number, where n=1,2,3,4,5... to a specified partial limit.

In general principle, is this something that could be done easily? Is there a particular technique I will need to learn to implement this? Any general guidance on how this could be done would be appreciated.


1068 posts since 9 Jan, 2006

Re: Organizing a modal/additive synthesizer in C++/Juce? (Duplicating partials up to "n" # of partials?)

Post Tue Jun 26, 2018 9:14 pm

You could look at classes. They are essentially just objects that can hold parameters and perform functions. Once you've defined a suitable sine wave class, or whatever, then you can instantiate as many those as needed.

C++ can be a deep subject and this isn't really a C++ tutorials forum, (though I'm sure you can pick up some tips here) I'd suggest picking up a decent book on the subject to get started.

Return to “DSP and Plug-in Development”