It's possible to work with frequencies(hz) in a code box?

If you require help or assistance with anything then please post here

Moderators: electrogear, exonerate

It's possible to work with frequencies(hz) in a code box?

Postby distante on Thu Mar 29, 2012 2:50 am

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.

xP
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby Dell on Thu Mar 29, 2012 8:56 pm

If you mean typing in the exact frequency in the edit box, yes it is possible.

Cheers!
Dell
essemilian
 
Posts: 474
Joined: Sat Sep 26, 2009 6:45 pm
Location: New York

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Thu Mar 29, 2012 9:10 pm

I supposse I need to use the 0-1 to hz module first don't?
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby Dell on Thu Mar 29, 2012 9:45 pm

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.
Dell
essemilian
 
Posts: 474
Joined: Sat Sep 26, 2009 6:45 pm
Location: New York

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Thu Mar 29, 2012 10:48 pm

Thanks, I will try. :D
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby oddson on Fri Mar 30, 2012 2:30 am

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.'
oddson
wiki guru
 
Posts: 3883
Joined: Sun Jul 03, 2005 6:44 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Fri Mar 30, 2012 8:25 pm

Sorry, I didn't understand that.... :blush:
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby MegaHurtz on Fri Mar 30, 2012 8:33 pm

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.
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1502
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Fri Mar 30, 2012 9:13 pm

Ohh!!

Thanks for the explication!
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby 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.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Fri Mar 30, 2012 11:26 pm

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?
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby oddson on Sat Mar 31, 2012 12:53 am

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.
oddson
wiki guru
 
Posts: 3883
Joined: Sun Jul 03, 2005 6:44 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Sat Mar 31, 2012 9:38 pm

Just to be sure I will always make a check that my signal doesn't pass the nyquist freq then!
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby oddson on Sat Mar 31, 2012 10:58 pm

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.
oddson
wiki guru
 
Posts: 3883
Joined: Sun Jul 03, 2005 6:44 pm

Re: It's possible to work with frequencies(hz) in a code box?

Postby distante on Sat Mar 31, 2012 11:24 pm

A couple of first order Low Pass filters can be helpful I suppose, and maybe use the oversampling toolkit before...
Sorry If I don't make myself clear sometimes, my English sucks!
User avatar
distante
essemist
 
Posts: 138
Joined: Thu Mar 15, 2012 4:22 pm

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests