Identifying audio bands

Sat Apr 17, 2021 8:46 pm

I have a fairly specific frequency band I'd like to have elements react to. I created a spectrum of 100 bars which shows nicely the frequency I want but how to convert this into values for custom frequency range. Does anyone have any ideas?

whats-the-frequency-kevin.png
whats-the-frequency-kevin.png (6.96 KiB) Viewed 302 times
Sadler
 
Posts: 846
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Identifying audio bands

Sat Apr 17, 2021 9:56 pm

Are you looking to stay within Magic, or are you interested in open-source software, externally?

I happen to use a program called "chataigne" that can easily break bands into sections, and send across OSC nicely into magic.
sjdacruz
 
Posts: 32
Joined: Sat May 30, 2020 4:53 am

Re: Identifying audio bands

Sat Apr 17, 2021 10:09 pm

Sadler, I suspect I have misunderstood your objective as the suggestion below seems too obvious.

The Custom Freq. Range feature can be set to an extremely narrow band, so a global could respond mainly to that narrow band. A quick check with a range 200Hz - 210Hz showed the response was roughly -6dB at 200Hz & 210Hz with respect to the peak at 205Hz.

To display a spectrum with a very narrow frequency range multiple globals responding to adjacent narrow frequency bands would give the scaling factors for adjacent bars.

sjdacruz, the Chataigne software looks very interesting. Thanks for sharing.
Terry Payman
 
Posts: 620
Joined: Sun Sep 14, 2014 8:15 am
Location: UK

Re: Identifying audio bands

Sun Apr 18, 2021 8:11 am

Chataigne looks pretty cool, thanks, especially since it supports Kinect! I will check it out but in this instance probably a bit too much for this small question.

Terry, my question is even simpler, I think. The full spectrum goes from 20 to 20k Hz. Taking a very simplistic approach, dividing the range by the number of bars makes each bar 200 Hz and therefore (considering the green bar) 24 bars from the left would be 4800 Hz. So I'd use 4800 to 5000 in the custom frequency range.

However, I doubt it is a simple as that - logarithmic scales and such! It it that simple?

If the frequency range menu was extended to provide a 'custom iterator frequency range' that would allow one to enter an iteration # (e.g. 24 in this example), which would be a very direct way to achieve this. Even if the maths was linear, this would still be handy.
Sadler
 
Posts: 846
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Identifying audio bands

Sun Apr 18, 2021 2:25 pm

Sadler, the bands are definitely logarithmic so simple math won't work. Tomorrow I can get you the formula for getting the frequency range based on the bar number.
Eric
Site Admin
 
Posts: 3119
Joined: Wed Apr 09, 2014 9:28 pm

Re: Identifying audio bands

Sat Apr 24, 2021 11:13 am

Given a number of iterations 'n' and the band of interest 'b' the lower bound frequency would be 20*(1000^(1/n))^(b-1) and the upper bound frequency would be 20*(1000^(1/n))^b.

Using this for the example above (24th band of 100 bands) gives 98 for the lower frequency and 105 for the upper frequency (rounded to whole numbers). This seems (and sounds) about right.
Sadler
 
Posts: 846
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Identifying audio bands

Sat Apr 24, 2021 3:34 pm

Oops sorry I forgot to get back to you on this. Yes, you figured it out and your formula is mathematically identical to what Magic does, but here is perhaps a simpler way to go about it:

There is a variable called currentFrequency which is set to 20 (as in 20 Hz) to start with, and then it loops over this calculation:

nextFrequency = currentFrequency * (2 ^ (10/numIterations))

The "10" comes from the fact that there are approximately 10 octaves from 20 Hz to 20 kHz.

So if you have 10 iterations, you would get 10 perfect frequency bands: 20 to 40; 40 to 80; 80 to 160; 160 to 320; 320 to 640; 640 to 1280; 1280 to 2560; 2560 to 5120; 5120 to 10240; and 10240 to 20480.

Keeping in mind that it's not linear, 20 iterations would therefore be: 20 to 28.2; 28.2 to 40; etc.

So, to quickly get the starting frequency for iteration "i", you can do: 20 * ((2 ^ (10/numIterations)) ^ i)

Then of course you have to remember that the first starting frequency is actually part of the 0th (zeroth) iteration, because the iterations start at 0. Indeed you figured out that you have to subtract by one.

Thus the starting frequency for band 24 of 100 would be: 20 * ((2 ^ (10/100)) ^ (24-1)) which is 98.5.
The ending frequency would be: 20 * ((2 ^ (10/100)) ^ 24) which is 105.6.

Good work ;)
Eric
Site Admin
 
Posts: 3119
Joined: Wed Apr 09, 2014 9:28 pm

Return to General Discussion

© 2021 Color & Music, LLC • This web site is mobile-friendly