DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Convert A 1D Array Wave File To A Stereo 2D Array

05.20.2008
| 4462 views |
  • submit to reddit
        
    private int[][] zetOmNaarStereoStream(byte[] arrbBuffer){
        int lengte = arrbBuffer.length / 4;
        int[][] arriUitvoer = new int[2][lengte];
        for (int iTeller=0 ; iTeller<lengte ; iTeller++){
            //Linker kanaal
            arriUitvoer[0][iTeller] = (arrbBuffer[((iTeller * 4) + 0)] & 0xFF) | (arrbBuffer[((iTeller * 4) + 1)] << 8);
            //Rechter kanaal
            arriUitvoer[1][iTeller] = (arrbBuffer[((iTeller * 4) + 2)] & 0xFF) | (arrbBuffer[((iTeller * 4) + 3)] << 8);
        }
        return arriUitvoer;
    }