hi on my device i can sample only at 32khz and want to use speex at 16khz so i need to down-convert the input signal by factor of 2. does anyone provide me a reference to some code that does that? are there any trick to do that? i tried to add to subsequent sample but the result was very bad. what are the requrment from a decimation filter for audio? thanks, nir -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20100626/5436f3b3/attachment.htm
I've done something similar in Groovy/Java using Wave files. In my case I was downsampling from 16bit to 8bit. Here's the core of my conversion logic. def convertData(def inputStream, def outputStream) { boolean otherByte = false inputStream.eachByte { if(otherByte) { //invert high order byte int inverted = ((int)it) ^ 0x00000080 byte[] toWrite = new byte[1]; toWrite[0] = (byte)inverted outputStream.write toWrite otherByte = false } else otherByte = true } } Basically you need to write every other byte in thePCM sample stream. Clifton Craig Software Engineer http://codeforfun.wordpress.com clifton.craig at gmail.com On Jun 26, 2010, at 9:50 AM, nir elkayam wrote:> hi > > on my device i can sample only at 32khz and want to use speex at 16khz so i need to down-convert the input signal by factor of 2. > does anyone provide me a reference to some code that does that? are there any trick to do that? > > i tried to add to subsequent sample but the result was very bad. > what are the requrment from a decimation filter for audio? > > thanks, > nir > _______________________________________________ > Speex-dev mailing list > Speex-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev
thanks, but actualy this is not my problem. changing sampling rate may have more problem because of aliasing which need to be removed. On Sat, Jun 26, 2010 at 6:18 PM, Clifton Craig <clifton.craig at gmail.com>wrote:> I've done something similar in Groovy/Java using Wave files. In my case I > was downsampling from 16bit to 8bit. Here's the core of my conversion logic. > > def convertData(def inputStream, def outputStream) { > boolean otherByte = false > inputStream.eachByte { > if(otherByte) { > //invert high order byte > int inverted = ((int)it) ^ 0x00000080 > byte[] toWrite = new byte[1]; toWrite[0] = (byte)inverted > outputStream.write toWrite > otherByte = false > } else otherByte = true > } > } > Basically you need to write every other byte in thePCM sample stream. > > > > Clifton Craig > Software Engineer > http://codeforfun.wordpress.com > clifton.craig at gmail.com > > On Jun 26, 2010, at 9:50 AM, nir elkayam wrote: > > > hi > > > > on my device i can sample only at 32khz and want to use speex at 16khz so > i need to down-convert the input signal by factor of 2. > > does anyone provide me a reference to some code that does that? are there > any trick to do that? > > > > i tried to add to subsequent sample but the result was very bad. > > what are the requrment from a decimation filter for audio? > > > > thanks, > > nir > > _______________________________________________ > > Speex-dev mailing list > > Speex-dev at xiph.org > > http://lists.xiph.org/mailman/listinfo/speex-dev > >-- ??? ?????? ??: 050-3930056 nir.elkayam at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20100626/325ba918/attachment.htm
Speexdsp library included with speex has a good resampler you can use for the purpose. You can find the headers in speex/speex_resampler.h, and source in speex/resample.c On Jun 26, 2010, at 9:50, nir elkayam <nir.elkayam at gmail.com> wrote:> hi > > on my device i can sample only at 32khz and want to use speex at > 16khz so i need to down-convert the input signal by factor of 2. > does anyone provide me a reference to some code that does that? are > there any trick to do that? > > i tried to add to subsequent sample but the result was very bad. > what are the requrment from a decimation filter for audio? > > thanks, > nir > _______________________________________________ > Speex-dev mailing list > Speex-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev