filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.15k stars 451 forks source link

Calculate RMS of wav files #412

Open nhaberl opened 4 years ago

nhaberl commented 4 years ago

Hi, is there some analytical functions available to determine e.g. RMS over given period?

filoe commented 4 years ago

You can build something like that quite easy yourself. It would be pretty similar to the PeakMeter class: https://github.com/filoe/cscore/blob/master/CSCore/Streams/PeakMeter.cs

In the Read method the samples are getting processed. Pick and store them in some kind of circular buffer and calculate the rms on that. Limit the circular buffer to the number of samples you want to take into perspective within your period.