SynthMaker

Getting The User's Sample Rate

Archive · 2012 4 old posts

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].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.