[Webinar] Streamline your web hosting managementRegister Today

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 323

# urgent: PCM data structure

Right,

I'm getting a little confused.  (i guess it's what comes of working on too many things at once).

I have an wave file which I'm analyzing in an attempt to be able to visualise and process the data in various ways.  Now with some help off jrandallsexton I managed to get the file header data fairly easily.  The problem I have now, is reading the data itself.  Now I think i am taking the data into a byte stream correctly.  However, I'm not sure how to process it.

I'm using http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/ for all my information, I'm not sure if it's the best source, but it seems pretty good.

The site describes the sample data as being in a structure of, for example "24 17 1e f3" etc, where "24 17" is the left channel and "1e f3" is the right channel.

Now, I'm getting results (from a different audio sample to the example given on the site) as "113 5 102 97" with no letter charactors involved at any point.  This makes me thing I'm doing something wrong.

Also, even if I get the data in the correct format.  I don't understand what the values are!?  "24 17".. is this Hex? if so, what should I do with it (programmatically) once I have an integer value.  Is this something like Amplitude and Frequency?

I'm affraid I need quite a lot of help with this hense the points.  It's also fairly urgent...

Thanks,

Tim
0
w3tim
• 5
• 3
1 Solution

Commented:
as far as the conversion goes...

the first one could be hex (i would say definately)....but dont forget, the second one could be hex as well.

as far as converting it to decimal, just use the convention

0-9 = exact value (0-9)
a = 10
b = 11
c = 12
d = 13
e = 14
f = 15

now take the number 24, in decimal we pronounce this "twenty four", in hex we pronounce it "two four", and here ill show you why

in decimal 24 equates to (2 * 10^1) + (4 * 10^0) ==> (2 * 10) + (4 * 1) = 24

but in hex 24 equates to (2 * 16^1) + (4 * 1^0) ==> (2 * 16) + (4 * 1) =  36

to use a different example, the "113 5 102 97" you came up with could also be hex, and heres why

hex(113) = (1 * 16^2) + (1 * 16^1) + (3 * 16^0) ==> (1* 256) + (1 * 16) + (3 * 1) = 275

as far as what to do with these values, ill have to get back to you

~b
0

Author Commented:
Many thanks!

I'm not really used to working at even a slightly lower level such as this!

Tim
0

Author Commented:
Update:-

I'm not sure I'm getting anywhere to be honest... I found a website that seemed to have some useful information on it (http://www.music-center.com.br/spec_rif.htm) but I don't know if it's sending me in the wrong direction.
0

Commented:
just to let you know i havent forgot about this question....im not too familiar with audio formatting, so this will be mostly a new adventure for me.  but i did get how to change those pesky hex codes to decimal

create a button and put this in the event handler

MsgBox(CLng("&H" + "113"))

~b

0

Author Commented:
Ah ha, right... so...

There are 2 bytes per channel per sample!?

I read the byte (i.e. 113) then CLng("&H" + "113") so I'll end up with 2 decimal values per channel per sample!?  Is that right?!  Any ideas what the values would represent!?

Tim
0

Commented:
after looking through the net ive found about as much as you have...these two sites

http://www.sonicspot.com/guide/wavefiles.html

http://bdn.borland.com/article/0,1410,21300,00.html

have some info on them.  the first one explains pretty well what the data represents, the second has some C coding to play riff files.

from what ive deciphered, these "samples" are numeric data which is interpreted by the sound card or whatever device, to create a specific sound.

in saying that, it would not be wrong to assume that the two values we are looking at (two hex values for the right, and two hex values for the left) may just be one value.

ill try to illustrate what i mean here.  if our two hex values were "0A" and "11", in decimal you would have

"0A" = 10
"11" = 17

now in binary you would have

10 ==>  0000 1010
17 ==>  0001 0001

now this could be one "value" or in this case "sound byte" which is read into the computer as

0000 1010 0001 0001

the point of me going through this is im not sure if these values are separate, one meaning amplitude and one meaning frequency.

im kinda suprised we havent ran into any pages saying how this data is interpreted by the computer.  it may be out of the scope of your problem, in that these hex values are standard in terms of how the computer interprets sound...regardless of the specific format the sound file is in.  (were getting pretty low level here.)

anyways, im going to try and search for how audio files are interpreted by the machine, and suggest you do to.

i dont think youre going to find any new information on this if you search for the PCM data structure.

~b
0

Author Commented:
Sorry I haven't abandoned this.  I had a busy few weeks while trying to finish up by going on holiday!  I'll be continuing to look at this but I'm going to have to leave it for a bit but I might get back onto it when I catch up with other work.

I'll give everything suggested another go and if I don't get anywhere I'll be back to EE.  I can't see me getting much further on my own though.  If anyone does have any more suggestions then let me know.

Thanks bramsquad, I'll award you the points for now as you have been very helpful!

Tim
0

Author Commented:
I will return to this in a new post at a later date.  Other things have come up and time is too sparse to give to this project at the moment.  Many thanks for the help.  As I stated in my last post, I will award the points to bramsquad.

Thanks,

Tim
0

## Featured Post

• 5
• 3
Tackle projects and never again get stuck behind a technical roadblock.