This project has moved and is read-only. For the latest updates, please go here.

How to get Decibel values with time span..

Jun 1, 2011 at 6:54 AM

Hi all,

first of I'd like to say this lib is freakin' awesome.. keep up the good work!

anyway, I'm still new at C# and this library and I just have simple question in regards of a project that I'm working for my school..

how can I get Decibel values of a wav/mp3 file I have in every 100 milliseconds?

something like:

Time: 0.6, DB: 0.213623
Time: 0.75, DB: 0.2692261
Time: 0.9, DB: 0.2355957
Time: 3.9, DB: 0.2363281
Time: 3.9, DB: 0.3799744
Time: 4.05, DB: 0.3580322
Time: 4.2, DB: 0.1331177
Time: 7.2, DB: 0.3091431
Time: 7.2, DB: 0.2984009
Time: 7.35, DB: 0.2997437
Time: 7.5, DB: 0.211792
Time: 9, DB: 0.255127
Time: 9.15, DB: 0.2884216
Time: 11.4, DB: 0.2716675
Time: 11.4, DB: 0.3035278
Time: 14.4, DB: 0.157074
Time: 14.55, DB: 0.2964783
Time: 14.7, DB: 0.1188354
Time: 16.5, DB: 0.313385
Time: 16.5, DB: 0.2774658
Time: 16.65, DB: 0.1695557
Time: 19.35, DB: 0.1802063
Time: 19.5, DB: 0.3108826
Time: 19.5, DB: 0.2506409
Time: 19.65, DB: 0.2417908
Time: 19.8, DB: 0.1200562

I'd really appreciate your help :)



Jun 1, 2011 at 8:32 AM

I've answered on StackOverflow

Jun 1, 2011 at 6:43 PM

I saw it.. thanks for the reply but i'm still lost.. I've no idea where to start and what to do exactly..

can you show me an example? or simple code snippets of how to perform this with any wav file..

Jun 1, 2011 at 9:58 PM
Edited Jun 2, 2011 at 7:13 AM

here is what I did.. and I really have no idea if i'm doing it right or not...(the example below supposed to get the decibel values of the 1st second) "as I imagined" =_='

             Mp3FileReader mp3 = new Mp3FileReader(@"file.mp3");
             mp3.Seek(1, SeekOrigin.Current);
             int currentbyte = mp3.ReadByte();
             double volume = Math.Abs(currentbyte / 32768.0);
             double decibels = 20 * Math.Log10(volume);


I'd really appreciate your help if you point me to the right direction..




well after struggling 10 hours with the examples you provided. finally I figured out how to get it to work.

now I'm getting all of the values I need its a bit dirty solution but who cares it works like charm :D

although I'm not gonna post the solution coz its really too long. I extracted most of it from one of your examples and imported it to another simpler program..

then removed all unwanted codes but its still a biggie.. :P

anyway, thanks for help..



Jun 2, 2011 at 11:09 AM

Glad you got it working. Digital audio can be a bit tricky to get your head round at first.