From the original SynthMaker forum (2004–2014), with its members’ names and dates.
tomcollins ·
I am attempting to build multiple filters for use inside of a VST effect, however I want to calculate the coefficients on-the-fly so to speak; that is, I want to generate the coefficients of the equalizer based on the current project's sample rate. To do this requires the sample rate of the current project - how do I go about accessing this in SM code?
I have examined other filter designs posted in this forum and have observed they all have hard-coded coefficients - doesn't this render these filters unusable for people who work at sample rates other than 44.1?
Any and all help is appreciated and I thank you in advance for it.
Cheers,
Tom
Mo ·
Hi welcome to the forum.
tomcollins wrote: I am attempting to build multiple filters for use inside of a VST effect, however I want to calculate the coefficients on-the-fly so to speak; that is, I want to generate the coefficients of the equalizer based on the current project's sample rate. To do this requires the sample rate of the current project - how do I go about accessing this in SM code?
You simply use the "Sample Rate" primitive connected to the code as input.
tomcollins wrote: I have examined other filter designs posted in this forum and have observed they all have hard-coded coefficients - doesn't this render these filters unusable for people who work at sample rates other than 44.1
Yes or it would sound different. I think the most filters here got it calculated outside the code using green components.
trogluddite ·
tomcollins wrote: I have examined other filter designs posted in this forum and have observed they all have hard-coded coefficients - doesn't this render these filters unusable for people who work at sample rates other than 44.1?
Welcome, Tom.
Actually, this is a quite clever way of making code usable for all sample rates. Like a lot of SM's oscillators, most filters use 'normalised' frequency inputs. For these inputs zero represents DC as you would expect, and the maximum value, one, represents the Nyquist Frequency (Sample Rate / 2).
The advantage is that the filter can be hard coded, with the SR adjustment made externally by simply scaling the frequency inputs to get the correct 0-1 range for the current sample rate. As Mo has pointed out, the scaling can often be done using 'Green' components, which use far less CPU than the stream (blue/white) parts - with the 'Sample Rate' component to get the right value, e.g.
Freq (normalised) = 2 * Freq (Hz) / SampleRate
tomcollins ·
Thanks to both Mo and trogluddite for the quick and thorough responses - prior to asking, I searched for 'sample rate' and for the life of me didn't see anything; now that i know what I am looking for, it jumps out at me.
Thanks again gents - I appreciate it.
Wrote something here? To have a post removed or your name hidden, write to [email protected].