Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
I tried this option. Seems to be working as it should.
using System;
using NAudio.Wave;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var waveIn = new WaveInEvent();
waveIn.DataAvailable += WaveOnDataAvailable;
waveIn.WaveFormat = new WaveFormat(8000, 1);
waveIn.StartRecording();
Console.ReadLine();
}
private static void WaveOnDataAvailable(object sender, WaveInEventArgs e)
{
for (int index = 0; index < e.BytesRecorded; index += 2)
{
short sample = (short)((e.Buffer[index + 1] << 8) | e.Buffer[index + 0]);
float amplitude = sample / 32768f;
float level = Math.Abs(amplitude); // от 0 до 1
Console.WriteLine("Уровень: {0}%.", level * 100);
}
}
}
}
nAudio library . There are simple examples there: you set the sampling rate, bit depth and buffer size and get an event in the arguments of which is an array of amplitudes for this filling of this buffer.
It?
www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html
Oops. Not that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question