0

i am wondering if there is any way to cycle through a .wav file to get the amplitude/DB of a specific point in the wav file. i am reading it into a byte array now but that has no help to me from what i can see.

i am using this in conjunction with some hardware i have developed that encodes light data into binary and outputs audio. i wont get into the details but i need to be able to do this in c# or c++. i cant find any info on this anywhere. i have never programmed anything relating to audio so excuse me if this is a very easy thing.

i dont have anything started since this is the starting point so if anybody can point me to some functions, libraries, or methods to being able to collect the amplitude of the wave at a specific time in the file, i would greatly appreciate it.

i hope this is enough info, and thank you in advance if you are kind enough to help.

1 Answers1

0

It is possible and it is done in a straightforward way: the file with PCM audio contains one value for every channel, for every (1/sample-rate) of second.

The values however might vary: 8-bit, 16-bit, single precision floating point values. You certainly have to take this into account and this is the reason you cannot take the bytes from byte array directly.

The .WAV file also has a header preceding the actual payload.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • you you are saying i can go through the byte array but it must be converted to a 8/16 bit integer? how do i know which byte is which channel? i found a code example that in a mono file, it skips every other byte in the array and converts to a 16 bit integer, it seems to work and the data is now recognizable. but it says to skip every other value, why is this? thanks for the response! i really appreciate the answer. – Dsfsdaf Dsfadasf Jan 28 '13 at 01:00
  • Because number of bytes in header (and format descriptor) might vary, channel count might vary, type of value varies - you don't normally read `.WAV` files as a byte array and use API/libraries instead. They convert the variety of types to something you want to have, e.g. a mono downmix with normalized floating point values. – Roman R. Jan 28 '13 at 06:01
  • Roman, can u eloberate it a bit more.I am also lookig for getting amplitede of wav at given time – mhrrt Apr 16 '13 at 16:47