It's possible to work with frequencies(hz) in a code box?
Archive · 201220 old posts
From the original SynthMaker forum (2004–2014), with its members’ names and dates.
distante ·
Well, like the question hehe, I want to know If I can make some maths with a the freq content of a waveform using the code box,
This for add some harmonics and stuff, I can't find the way to add this but a monoin, but this work with 0-1 values and when I use the 0-1 to Hz component I can't connect this with the Code input.
😝
Dell ·
If you mean typing in the exact frequency in the edit box, yes it is possible.
Cheers!
distante ·
I supposse I need to use the 0-1 to hz module first don't?
Dell ·
That would depend on the filter. If the filter cannot recognise standard frequency readings and only 0 - 1 calculations then a converter is in order.
Cheers.
distante ·
Thanks, I will try. 😀
oddson ·
I think the correct answer is 'yes you can do math on Hz values inside code but it's hard to imagine a situation where that would get you anywhere as the basic unit of time in a code calculation is the sample and so a measure of time that's not independent of your sample rate is of limited value.'
distante ·
Sorry, I didn't understand that.... 😊
MegaHurtz ·
The 0-1 thing is basically a way of removing some of the calculations from the chain. So it`s an efficient way of making modules. And is kind of the inverse of Hz already. Because its (if i recall correctly) 0.5 divided by Hz. Which in a lot of cases would remove a divider from every module. Being that dividers are heavy math that takes a lot of cpu. multiply that by a number of modules would make your patch heavy on the cpu.
distante ·
Ohh!!
Thanks for the explication!
trogluddite ·
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.
distante ·
I see, You are right I didn't thing this in that way before, I did some mathlab coding and there I worked with the frequency (well that's what the teacher told me, only had like 4 two hours class)
Well Now I understand the plus of use a 0-1 based freq data!
What happens with a freq variable if you assign for example 1.2, this will be parsing and start with the aliasing of SM cuts the value?
oddson ·
distante wrote: What happens with a freq variable if you assign for example 1.2, this will be parsing and start with the aliasing of SM cuts the value?
Well if you then feed it to an oscillator it will alias -- which means it will fold over and take up a new value that has no harmonic relationship with the intended pitch and will, therefore, sound like crap. (Google search "DSP aliasing".)
I'm not really a DSP guy (see my early posts here for proof of this!) but I believe this means 1.2 will be the same as 0.8 when the sound card tries to recreate the appropriate analog wave for your speaker from the numbers contained in the data stream.
As bad as this sounds, when you have complex signals composed of many harmonic components (with or without some additional non-harmonic noise) and then some of the harmonic components alias, you're in for a real cacophonous mess.
distante ·
Just to be sure I will always make a check that my signal doesn't pass the nyquist freq then!
oddson ·
yes... and that's the easy part.
But if you are playing back a waveform at say 0.6 and it's not a perfect sine wave then the harmonic components other than the first one will be at values like 1.2, 1.8 and 2.4 etc and will alias anyway.
That's the real problem.
distante ·
A couple of first order Low Pass filters can be helpful I suppose, and maybe use the oversampling toolkit before...
trogluddite ·
Oversampling is the only truly effective way.
As oddson rightly said in his earlier posts, aliased frequencies get "reflected" to become other, new, frequencies that are below the Nyquist limit.
For example say you make a wave that has a fundamental of 18kHz.
Unless it is a pure sine, the second harmonic (octave) will be at 36kHz - well above Nyquist.
Lets assume that the sample frequency is 44kHz - so the Nyquist limit is 22kHz. That octave harmonic is 14kHz above the limit.
What happens is that instead of being 14kHz above the limit, it will be transformed to 14kHz below the limit - 22kHz - 14kHz = 8kHz. But 8kHz is below our original fundamental frequency, so low pass filtering is not able to get rid of the "alias".
This also demonstrates something else - the alias at 8kHz, is no longer a harmonic (or sub-harmonic) of the original 18kHz tone - which is why aliasing distortion sounds so much worse than "analogue" distortion.
SM's stock oscillators get around this by using wavetables - they do not alias because they play back short waveform samples that already have the >Nyquist frequencies removed. There are many of these short samples for each waveshape - chosen according to pitch, so that exactly the right harmonics are removed.
If your synth only mixes together (adds/subtracts) multiple oscillators, then all is well, you still have no aliasing - but if you FM or RM (multiplying oscillator outputs), then new frequencies are made that can once again be above the limit.
distante ·
So I suppose that multiple filter pre and post edit are in order.
Is there a table or list of the amount of CPU resources use for each pre made module in SM?
Dell ·
The amount of CPU consumed by your plug-in is based on your Computer.
If you are looking to offer plug-ins publicly, use the lowest computer system you own. This will train you to be more concerned on the amount of drainage taking place than using the strongest computer available, which may be larger than the average person using your plug-in in his/her DAW.
If you are not planning to offer your plug-ins publicly, merely look at the “CPU=” listing on the bottom right hand corner of Synthmaker’s window. That is the true CPU consumption and reflects what to expect if you are planning to use your design in a live host.
In a playback system (DAW) the CPU will vary based on the audio file (non-compressed WAV, compressed MP3 ) in addition to the sample rate of the audio file.
To get a better understanding of Synthmaker, you cannot be afraid of making mistakes to the point you need to force Synthmaker to shutdown. Taking chances is how you will learn the fundamentals of Synthmaker. Once you are afraid of doing something out of the ordinary in Synthmaker, you will never accomplish your goals.
Cheers!
distante ·
Thanks Dell! 😉
Xtinct ·
Hi its not just mistakes that cause it to shut down sometimes a new connection will crash it, then when recovered
will work 😕
Wrote something here? To have a post removed or your name hidden, write to [email protected].