Sample Rate

hilop via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 10 07:57:03 PDT 2016


On Saturday, 9 April 2016 at 14:15:38 UTC, Nordlöw wrote:
> Has anybody more than I thought about representing the sample 
> rate of a sampled signal collected from sources such as 
> microphones and digital radio receivers?
>
> With it we could automatically relate DFT/FFT bins to real 
> frequencies and other cool stuff.
>
> Maybe we could make it part of the standard solution for linear 
> algebra processing and units of measurement in D.
>
> Destroy.

The magnitude is not hard to represent for a buffer.
let's say you have a FFT of 512 sample, each bin N represent a 
sub-sinusoid of a frequency given by (SR/(512*2)) * N. Then 
you've got the power of this sub-sinusoid with Hypoth(bin.real, 
bin.imag).

Since amplitude perception is not linear, the Y (A to db, from 
.0f->.1f to -100f->0.0f scale must be adjusted.
Since the frequency neither the X scale also (frequency to pitch, 
from 0->22050 to 0->127). (I don't remember the formula right now 
but those two converters could be part of the unit framework.)

Now to make the things properly (which means avoiding the 
artifacts, aka the aliasing or the spectrum folding, due to the 
cut at the buffer edge), the buffers must be multiplied by a 
windowing function (e.g hanning, hamming, etc) and overlapped (to 
maintain the original power spectrum).


More information about the Digitalmars-d mailing list