Re: Playing wave file data
Re: Playing wave file data
- Subject: Re: Playing wave file data
- From: Steve Bird <email@hidden>
- Date: Wed, 15 Oct 2003 16:07:05 -0400
On Wednesday, October 15, 2003, at 03:44 PM, B&L wrote:
Here is how I interpret the data:
The data is in little endian format, so I read one byte (a) and then
the other (b). The b byte is shifted up 8 positions and the a byte is
put into the first 8 bytes.
--- You don't mention anything about reading the header. You should
read the header to determine whether the WAV file is 8-bit or 16-bit,
mono or stereo. That could make a difference in sound quality.
Then I convert it to a signed int with some byte handling remembering
that 0x8000 is the same as zero. All below is inverted and then
negated. If it is above then it is interpreted as a positive value.
--- Do you know that it's 16 bit sound?
--- I've never seen offset-binary used in a 16-bit WAV file (8-bits
sometimes, yes).
--- IIRC, you use 16-bit WAV data as is (without arithmetic)
Since the output should be a float between 1 and -1 I multiply the
data with 0.00000000001, anything higher made it sound like my
speakers would blow :-)
--- There *-IS-* some math behind this - don't just make up a number.
If it's 16-bit sound, it has a range of -32768..+32767. So divide
(using floating-point arithmetic) the sound integers by 32767 to get
+/- 1.00000.
I can recognize the sound but there is a lot of noise in there also!
--- It's amazing how badly you can mangle the data and still hear what
you're expecting (ears and brains are wonderful things - everybody
should have some!).
That's symptomatic of high-bit-inversion. In your case, I'd bet on the
high-bit being incorrectly inverted.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.