AsmaaHassen / moonblink

Automatically exported from code.google.com/p/moonblink
0 stars 0 forks source link

Change Audio Spectrum to octave scale #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Audio spectrum analyzers are not usually shown in linear scale, but in 
octave scale instead, from 20Hz to 20KHz.

If you do full octave, you should show (in addition to the end points of 
20Hz and 20KHz)

62.5 Hz (can be shown as 63)
125 Hz
250 Hz
500 Hz
1 KHz
2 KHz
4 KHz
8 KHz
16 KHz

If you want to do 1/3rd octave, then show:

25 Hz
31.5 Hz (can be shown as 31)
40 Hz
50 Hz
62.5 Hz (can be shown as 63)
80 Hz
100 Hz
125 Hz
160 Hz
200 Hz
250 Hz
315 Hz
400 Hz
500 Hz
625 Hz
800 Hz
1 KHz
1.25 KHz
1.6 KHz
2 KHz
2.5 KHz
3.15 KHz
4 KHz
5 KHz
6.25 KHz
8  KHz
10 KHz
12.5 KHz
16 KHz

A full screen 1/3rd Octave meter in landscape mode would be neat, but I'd 
focus on the single octave mode first.

Thanks, and great work!

Original issue reported on code.google.com by sileasre...@gmail.com on 1 Dec 2009 at 6:36

GoogleCodeExporter commented 9 years ago
Thanks for the tutorial on log scales... ;-) but while what you say makes 
sense, it
wouldn't actually work terribly well.  The output from the FFT is linear, and
contains 128 frequency bins, all of which I am displaying.  If I convert to log
scale, I would compress some of the high frequencies out of view while making 
the low
frequencies very wide.  I could do a more high-res FFT, but FFT is very heavy 
work,
and I'm already stretching the CPU, specially on older devices.

Plus a linear scale makes it easy to see harmonics.  Play a square wave into 
the mic,
and observe the regular peaks on the graph.

Original comment by heads...@gmail.com on 1 Dec 2009 at 5:03

GoogleCodeExporter commented 9 years ago
So this has been nagging at me, but unfortunately I still think it's 
impractical. 
The spectrum display is around 400 pix wide (in Audalyzer, less in Tricorder).  
I
don't want the bars to be more than about 2 pix wide or the graph looks too 
coarse. 
So to display a log scale of frequency bins from 25Hz to 8k in 200 steps the 
bottom
bins are less than 1Hz wide.  Since the output of the FFT is linear, and the 
number
of frequency bins is half the sample size, I would need to run the FFT on 16k 
samples
at a time.  This has 2 problems -- it's way more than the CPU can handle, and 
the
display would only update once per second.

If you know of an FFT-like algorithm that produces log-scale output directly, 
that
may be more feasible.  It doesn't look good, though:

    http://www.physicsforums.com/showthread.php?t=288020

Original comment by heads...@gmail.com on 2 Dec 2009 at 4:43

GoogleCodeExporter commented 9 years ago
Issue 25 has been merged into this issue.

Original comment by heads...@gmail.com on 11 Dec 2009 at 9:36

GoogleCodeExporter commented 9 years ago
Since this is so widely requested -- and it does make sense -- I've re-opened 
it.  No
promises on a fix time though.

Original comment by heads...@gmail.com on 9 Feb 2010 at 6:30

GoogleCodeExporter commented 9 years ago
Hi, 

Though I understand the problem I also would be very happy about an octave 
view. I sometime do live sound mixing and it would be extremely helpful to have 
a frequency analyzer to find the approximate feedback frequency. As you have an 
equalizer with max. 31 bands, it does not have to be that precise. Probably you 
can make an option to choose between line and octave scale. I really would 
appreciate it very much.

Greetings

Original comment by haas.sie...@gmail.com on 13 Jun 2010 at 9:42

GoogleCodeExporter commented 9 years ago
Not being a programmer I have an idea how one could theoretically solve the 
problem. If you do alternating two different scanning, one low frequency and 
one high frequency scan. Then you probably have enough data to interpolate the 
octave frequencies. The question is if you can switch fast enough between the  
two settings, but I could live with a slow display.

Original comment by haas.sie...@gmail.com on 22 Jun 2010 at 3:04

GoogleCodeExporter commented 9 years ago
Issue 121 has been merged into this issue.

Original comment by heads...@gmail.com on 2 Oct 2010 at 2:40

GoogleCodeExporter commented 9 years ago
The following references may be helpful.
J. C. Brown, "Calculation of a Constant Q Spectral Transform",
J. Acoust. Soc. Am. 89, 4255-434 (1991)
http://homepages.dies.ie/~ajones/papers/28.pdf

Original comment by lawrence.crowl@gmail.com on 2 Oct 2010 at 11:52

GoogleCodeExporter commented 9 years ago
If we are picking audio frequencies, I recommend that they be based on the 
standard concert frequency A=440 Hz.  Multiply or divide by sqrt(12) to get the 
next note.  The range of course depends on implementation constraints, but a 
reasonable guide is:
   12   lowest audible frequency under ideal conditions
   13.7 lowest audible A
   20   lowest normally audible frequency
   27.5 lowest A on a piano
  440   standard concert A
 3520   highest A on a piano
 4186.0 highest key on a piano
14080   highest audible A
20000   highest normally audible frequency (lower with age)
23000   highest audible frequency

Original comment by lawrence.crowl@gmail.com on 3 Oct 2010 at 12:35

GoogleCodeExporter commented 9 years ago
@Lawrence:

Those frequencies don't match up with the standard center frequencies for audio 
engineering in any context.  Everything is based around the standard of 1KHz 
reference level, used in origination, broadcast, exhibition, etc. (e.g. "tone 
and bars" for TV)  Also, equalizer equipment is centered around 1KHz, so that 
the results of the standard spectrum analysis can be directly translated to the 
EQ. (e.g. "My Spectrum Analyzer is showing a 3dB peak at 4KHz, I need to pull 
down 4KHz by 3dB on my EQ")

Since multiple issues have been merged into this one, I'll repeat the standard 
octave and 1/3 octave center frequencies here:

If you do full octave, you should show (in addition to the end points of 
20Hz and 20KHz)

62.5 Hz (can be shown as 63)
125 Hz
250 Hz
500 Hz
1 KHz
2 KHz
4 KHz
8 KHz
16 KHz

If you want to do 1/3rd octave, then show:

25 Hz
31.5 Hz (can be shown as 31)
40 Hz
50 Hz
62.5 Hz (can be shown as 63)
80 Hz
100 Hz
125 Hz
160 Hz
200 Hz
250 Hz
315 Hz
400 Hz
500 Hz
625 Hz
800 Hz
1 KHz
1.25 KHz
1.6 KHz
2 KHz
2.5 KHz
3.15 KHz
4 KHz
5 KHz
6.25 KHz
8  KHz
10 KHz
12.5 KHz
16 KHz

A full screen 1/3rd Octave meter in landscape mode would be neat, but I'd 
focus on the single octave mode first.

Original comment by sileasre...@gmail.com on 3 Oct 2010 at 12:55

GoogleCodeExporter commented 9 years ago
Just another note about this - human hearing is log in both scale and 
frequency.  Whereas we can all definitely hear the difference between 62.5Hz 
and 125Hz, we cannot hear the difference between 16KHz and 16.125KHz - the same 
linear difference, but dramatically different log difference.

This article at Wikipedia provides significant background on pink noise (equal 
power per octave, where PSD = 1/f).  This should provide deeper understanding 
of why log scale analysis is so important.  While you are there, make sure to 
listen to the white, pink, and brown noise samples to understand the 
distinctions.  

http://en.wikipedia.org/wiki/Pink_noise

A very direct way of doing your linear to log conversion, if you don't already 
have an FFT which provides it directly, would be to create "bins" around the 
center frequencies, and take all linear FFT result in those bins and average 
them together to provide the value for that particular center frequency.

A faster, although less accurate way to do it, is to pick the closest linear 
FFT point to the log center frequency, and use it to represent the log 
frequency.

Looking forward to a standard octave scale Tricorder.  Would even pay ~$5 for a 
1/3rd Octave (landscape mode) Tricorder app.

Thanks!

Original comment by sileasre...@gmail.com on 3 Oct 2010 at 1:16

GoogleCodeExporter commented 9 years ago
sileasresearch writes "Those [music] frequencies don't match up with the 
standard center frequencies for audio engineering in any context."

That may be true, but if you ask 100 people in the street whether they would 
like an app that told them what musical note was playing or that matched audio 
engineering practice, I am quite confident they would ask for the musical note. 

Original comment by lawrence.crowl@gmail.com on 6 Oct 2010 at 6:55

GoogleCodeExporter commented 9 years ago
@Lawrence:

I appreciate your comment about this, but I think that would be a different app 
altogether.  Steping back a bit, the "tricorder" app is a measurement 
instrument, providing fairly detailed sensor information, presented in a highly 
technical manner.  Presentation of the audio spectrum which matches the only 
technical standard by which it is presented in other commercially available 
software and hardware spectrum analyzers makes the most sense as part of this 
measurement instrument app.  

I would suggest that recognizing musical notes would be a completely different 
app (not Tricorder) which provides iconography which matches that usage, such 
as a 88 key piano, highlighting the notes which appear to be sensed. This would 
require analysis of the peaks to determine which notes should be highlighted.  
This very well may be an app which could be commercially available, and may in 
fact be an augmentation to various guitar tuning apps already out there.

Thanks for your comments.  

Original comment by sileasre...@gmail.com on 6 Oct 2010 at 7:13

GoogleCodeExporter commented 9 years ago
Issue 127 has been merged into this issue.

Original comment by heads...@gmail.com on 1 Nov 2010 at 3:19