Timing in C # Real-Time Audio Analysis

I am trying to define beats per minute from real-time sound in C #. This is not the music I discover, although it is just a constant sound. My problem is determining the time between these taps, so I can define the โ€œtaps per minuteโ€ that I tried using in the WaveIn.cs class, but I donโ€™t quite understand how to fetch it. I do not get the given number of samples per second for analysis. I guess I just donโ€™t know how to read the exact number of samples per second to find out the time between samples.

Any help that helps me in the right direction would be greatly appreciated.

+3
source share
3 answers

I'm not sure which WaveIn.cs class you are using, but usually with the code that records the audio, you either A) say that the code starts recording, and then at some later point you indicate that the code stops and you return an array (usually of type short []) that contains data recorded during this period of time; or B) inform that the code starts writing with the specified buffer size, and as each buffer is filled, the code calls back to the method that you defined with reference to the filled buffer, and this process continues until you report this to stop recording.

, - 16 (aka 2 ) , 44100 (1 ). (A), , , 10 . [] 441 000 (44 100 x 10). , "", , 0, 22 050, 44 100, 66 150 .. , . 5 (- , 22 050 44 100 ), , 2 , , 120 BPM.

(B) , 44100 ( 1 ). 0 22 050. , , 120 BPM.

, . . "" , , .

+3

, "".

- , . 44 100 , , , 88 200 () .

, - :

alt text
(: vbaccelerator.com)

What you are looking for is this peak ------------^

.

+2

, WaveIn.cs, WaveLib.WaveInRecorder WaveLib.WaveFormat . , .. , .. , , "" .

Since you know the sampling rate of the audio stream (for example, 44100 samples per second), take the average peak distance (in samples), multiply by 1 / (sampling speed) to get the time (in seconds) between the taps, divide by 60 to get the time (in minutes) between the taps and invert to get taps / minute.

Hope that helps

+1
source

Source: https://habr.com/ru/post/1714914/


All Articles