by trogluddite on Fri Mar 30, 2012 10:50 pm
The conversion from Hz to 0-1 ("normalised") is...
Normalised = 0.5 * (Hz / SampleRate)
As oddson hinted, the numbers given to oscillators/filters etc. need to change depending on the sample rate. A faster sample rate is like making a vinyl or tape go faster - it changes the frequency of things, so the numbers in the code have to change a make everything the right pitch again
So filters/oscillators are usually made so that instead of Hz, they use 0 (=Lowest freq) to 1 (=Highest Freq). The lowest frequency is still zero (DC or silence!). And the highest frequency is always half of the sampling rate - that's called the "Nyquist Limit", and it's kind of like the "speed of light" in DSP - frequencies bigger than than just won't work - they make horrible aliasing distortion.
The reason why 0-1 is so cool is that the maths equations to make oscillators etc. are much simpler, and that means that it will use less CPU power.
SM is able to read the sample rate from your soundcard or VST host, so this makes it easy to be sure that your synth/FX will always sound the same, no matter what sample rate si being used.
The oscillators could have code put inside to make them use Hz directly - but as MegaHertz said, the divide part of the formula uses a lot of CPU, so having a separate "Hz to 0-1" module means you can just convert once, and then send that value everywhere that it's needed.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.