2 Replies Latest reply: Jul 29, 2009 11:12 AM by 843802 RSS

    jspeex encoding

    843802
      i wand encode the captured audio using jpeex, anybody help me..
        • 1. Re: jspeex encoding
          843802
          i had work with this codec
          what is the problems with u?
          and what u would to do with it
          • 2. Re: jspeex encoding
            843802
            i have problem it too. my problem is how to encode sound wav using speex and then decoding that data.
            i'm using class speexEncoder and speexdecoder but i can't.
            ======
            int bsize=640;
            bsize *= Math.pow(2, mode);
            byte[] b = new byte[bsize];
            System.out.println(bsize);
            // fill in some dummy-data
            Random r = new Random();
            for (int i=0; i<b.length; i++){
            b[i] = (byte)r.nextInt();
            }

            System.out.println("\nMode="+mode+" quality="+quality+" buffersize="+b.length);

            System.out.println("Size before compression="+b.length);
            /*
            * Encode
            */
            SpeexEncoder enc = new SpeexEncoder();
            enc.init(mode, quality, 44100, 2);
            for(int i=0;i<b.length;i++)
            System.out.println(b);
            enc.processData(b, 0, b.length);

            int sizeAfterCompression = enc.getProcessedDataByteSize();
            byte[] temp = new byte[sizeAfterCompression];
            enc.getProcessedData(temp, 0);

            System.out.println("Size after compression="+sizeAfterCompression);

            /*
            * Decode
            */
            SpeexDecoder dec = new SpeexDecoder();
            dec.init(mode,44100,2,true);
            try {
            dec.processData(temp, 0, temp.length);
            } catch (StreamCorruptedException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
            int sizeAfterDecompression = dec.getProcessedDataByteSize();
            byte[] decoded = new byte[sizeAfterDecompression];

            dec.getProcessedData(decoded, 0);
            for(int i=0;i<decoded.length;i++)
            System.out.println(decoded[i]);
            System.out.println("Size after decompression="+sizeAfterDecompression);
            }
            //}
            }