X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com Message-ID: <5336E080.5080600@buffalo.edu> Date: Sat, 29 Mar 2014 11:02:24 -0400 From: "Stephen R. Besch" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: geda-user AT delorie DOT com Subject: Re: [geda-user] Wav to C array ~ 16 bit to 12 bit References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PM-EL-Spam-Prob: X: 10% Reply-To: geda-user AT delorie DOT com On 03/29/2014 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. > > Before I get started is this just a matter of shifting out the four most > significant bits of the binary 16 bit value? > That depends on the nature of the signal. Usually the noise is mostly in the low order bits so you may want to dump at least one or 2 of those. But first, you may also want to examine the high order bits. Depending upon the initial gain settings when the data was sampled, one or 2 of the high order bits may be all the same anyway. In either case, I think I would do this in 2 stages. First, shift up to get rid of unused dynamic range at the top end. Then throw away the rest at the low end where the noise is. You may want to signal average the low bits, say 3 bits into 1 or 4 bits into 2 Steve Besch -- fictio cedit veritati