In C, I am using the Libsndfile library to help me read the values of a wav file so that I can do some computations to them after. Although, when I get the output of the file, I am not sure what these numbers mean. Why are the numbers in the millions? At first I thought it was Hz, but it did not make sense in my mind. The information regarding the wav file can be seen below. Under that, I am using the function sf_read_int() to write the values into memory.
What does sf_read_int() do? This was obtained from the api documentation of libsndfile:
I decided to plot some of these huge values on a graph, and it looks very similar to what the wav file should look like (If I imported into audacity and zoomed in on a specific location, I would see this). Note that the values shown are not the same values on the graph, I sampled the values at a random point in time. So I guess the real question is, why are these values so big (in the millions)? And what do they represent? (Are they bytes?)
in limits.h
you can probably find two such definitions (among other stuff):
#define INT_MAX 0x7FFFFFFF
#define INT_MIN 0x80000000
which correspond to the decimal range between -2147483648 and 2147483647.
Libsndfile manual says:
sf_count_t sf_read_int(SNDFILE *sndfile, int *ptr, sf_count_t items);
i.e., reads sound file content into integer values pointed to by int *ptr
. Whichever value falls between INT_MIN
and INT_MAX
is a legitimate value. In libsndfile API
the data type used by the calling program and the data format of the file do not need to be the same.
Please also observe there's no such thing as "frequency" in a sound file. Linear PCM files only consist of raw sample data preceded by a header, whereas "frequency" is a mathematical abstraction or analysis result.
This might be of your interest:
When converting between integer PCM formats of differing size (e.g. using sf_read_int() to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple rule:
Whenever integer data is moved from one sized container to another sized container, the most significant bit in the source container will become the most significant bit in the destination container.
Be sure to thoroughly read the manual, especially when it is clearly written.