[Speex-dev] Down Convertion from 32Khz to 16Khz

Clifton Craig clifton.craig at gmail.com
Sat Jun 26 08:18:36 PDT 2010


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



More information about the Speex-dev mailing list