X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-TCPREMOTEIP: 76.119.234.168 X-Authenticated-UID: jpd AT noqsi DOT com From: John Doty Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: multipart/alternative; boundary=Apple-Mail-2--959974817 Subject: Re: [geda-user] Wav to C array ~ 16 bit to 12 bit Date: Sat, 29 Mar 2014 11:22:16 -0400 In-Reply-To: To: geda-user AT delorie DOT com References: Message-Id: X-Mailer: Apple Mail (2.1085) Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --Apple-Mail-2--959974817 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Mar 29, 2014, at 10:36 AM, Rob Butts wrote: > I have a short 8kHz 16 bit wav pcm file that I converted to an 8kHz 16 = bit unsigned C numerical array. I'm using a 12 bit dac so I need to = convert the 16 bit numerical array to a 12 bit numerical array. > =20 > Before I get started is this just a matter of shifting out the four = most significant bits of the binary 16 bit value? "God is in the details." First of all, sound pressure is relative to ambient static pressure, so = it's signed. I therefore don't understand how your unsigned values are = encoded. You may need to add 0x8000 to get the coding you need. Then, there's the matter of your DAC interface. Is its coding signed or = offset binary? What's the interface? If it's bytes, you have to worry = about which byte comes first. In any case, when mapping a total of 16 = bits to a 12 bit word, you may need to align the most significant bits = or the least significant bits, depending on the DAC and its interface. John Doty Noqsi Aerospace, Ltd. http://www.noqsi.com/ jpd AT noqsi DOT com --Apple-Mail-2--959974817 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
I have a short 8kHz 16 bit wav pcm file that I = converted to an 8kHz 16 bit unsigned C numerical array.  I'm using = a 12 bit dac so I need to convert the 16 bit numerical array to a 12 bit = numerical array.
 
Before I get started is this just a matter of = shifting out the four most significant bits of the binary 16 bit = value?

"God is in the = details."

First of all, sound pressure is = relative to ambient static pressure, so it's signed. I therefore don't = understand how your unsigned values are encoded. You may need to add = 0x8000 to get the coding you need.

Then, = there's the matter of your DAC interface. Is its coding signed or offset = binary? What's the interface? If it's bytes, you have to worry about = which byte comes first. In any case, when mapping a total of 16 bits to = a 12 bit word, you may need to align the most significant bits or the = least significant bits, depending on the DAC and its = interface.

John Doty              Noqsi = Aerospace, Ltd.

http://www.noqsi.com/

jpd AT noqsi DOT com



= --Apple-Mail-2--959974817--