Solved

urgent: PCM data structure

Posted on 2004-09-24
9
304 Views
Last Modified: 2006-11-17
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
Comment
Question by:w3tim
  • 5
  • 3
9 Comments
 
LVL 8

Expert Comment

by:bramsquad
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
Many thanks!

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

Tim
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 8

Expert Comment

by:bramsquad
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 8

Accepted Solution

by:
bramsquad earned 500 total points
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now