## digitalmars.D - Sample Rate

• =?UTF-8?B?Tm9yZGzDtnc=?= (8/8) Apr 09 2016 Has anybody more than I thought about representing the sample
• John Colvin (17/25) Apr 09 2016 I don't have time to do much on this, but would be happy to
• tcak (10/18) Apr 10 2016 I did. I have recorded sound samples by using a voice recorder.
• hilop (16/24) Apr 10 2016 The magnitude is not hard to represent for a buffer.
• TheAnalyst (5/33) Apr 11 2016 Believe me or not but we are living in a world where it's easy to
• Martijn Pot (3/11) Apr 10 2016 Matlab uses timeseries:
• Guillaume Piolat (8/16) Apr 10 2016 What problem would that solve?
```Has anybody more than I thought about representing the sample
rate of a sampled signal collected from sources such as

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.
```
Apr 09 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

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.

I don't have time to do much on this, but would be happy to
advise and/or answer questions if anyone wants to get in to it.
I've spent an unhealthy number of hours in discrete fourier
space, as has my computer.

Damn it, now I'm thinking about it...

The units are easy (either 1/s or 2*pi / s), but in the DFT the
topology of the space is the important/difficult thing (it's a
torus, which in 1-D is just a circle).

When dealing with arrays in fourier space, you can make a lot of
things easy by implementing indexing in terms of an integer type
modulo-N, but there's often tricks to avoid having to do so many
%s. Compilers seem unpredictably fantastic or terrible at
optimising this sort of code.

P.s. very basic definitions that might be vaguely useful, just
because I have them lying around:
https://dl.dropboxusercontent.com/u/910836/fourier.pdf
```
Apr 09 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

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.

I did. I have recorded sound samples by using a voice recorder.
Than I have used my WavReader module to get sample values.

Then I have converted those samples to JSON.

I have written a Javascript code. It uses Wavelets to decompose
the signal into frequencies (that was pretty slow). Than,
amplitude of frequencies were presented in SVG or Canvas with
colours (transition from Blue to Red).

I was trying to build a voice recognition as a research those
days. It was in 2013.
```
Apr 10 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

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).
```
Apr 10 2016
```On Sunday, 10 April 2016 at 14:57:03 UTC, hilop wrote:
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

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).

Believe me or not but we are living in a world where it's easy to
get the information, but very few people are able to understand
the information.
Technician vs Analyst.
```
Apr 11 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

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.

Matlab uses timeseries:
http://nl.mathworks.com/help/matlab/data_analysis/time-series-objects.html
```
Apr 10 2016    Guillaume Piolat <name.lastname gmail.com> writes:
```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

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.

What problem would that solve?

In data formats like WAV the sample rate is stored inside.
In audio processors like plugins the sample rate is passed out of
band.

If you pass the sample rate along with the audio data, then
you'll have to support the hypothetical case where it would
change every buffer. Hence why out-of-band is often preferred.
```
Apr 10 2016