[Speex-dev] JSpeex help

Joe Provino - Sun BOS Software Joe.Provino at sun.com
Thu Aug 10 13:08:48 PDT 2006


I have been using speex with a sample rate of 16000 and 2 channels
and also with a sample rate of 32000 and 2 channels.

I often get an exception encoding in SplitShapeSearch.java at the end 
of method quant().

What I've found is that rind is -1 because ind[i] is -1 so 
shape_cb[rind*subvect_size+j] in the for loop causes an
ArrayIndexOutOfBoundsException.

This problem does not seem to occur at 8000 and 2 channels.

Any help would be appreciated!

joe provino

>From  quant() in SplitShapeSearch.java:

    for (i=0; i<nb_subvect; i++) {
      int rind;
      float sign = 1;
      rind = ind[i];
      if (rind >= shape_cb_size) {
        sign = -1;
        rind -= shape_cb_size;
      }

      for (j=0; j<subvect_size; j++)
         e[subvect_size*i+j] = sign*0.03125f*shape_cb[rind*subvect_size+j];  <<<< exception here
      }
        

Here's my initialization code:

	speexEncoder = new org.xiph.speex.SpeexEncoder();

        int mode = 0;

        String s = "Narrow Band";

        if (sampleRate > 8000) {
            s = "Wide Band";
            mode++;         // wide band
        }

        if (sampleRate > 16000) {
            s = "Ultra-Wide Band";
            mode++;         // ultra wide band
        }

        if (Logger.logLevel >= Logger.LOG_INFO) {
            Logger.println("Initializing Speex encoder using "
                + sampleRate + "/" + channels + " " + s);
        }

        if (speexEncoder.init(mode, 0, sampleRate, channels) == false) {
            throw new SpeexException(
                "Speex encoder initialization failed!");
        }

        try {
            speexEncoder.setBigEndian(true);
        } catch (Exception e) {
            bigEndian = false;
        }

        speexEncoder.getEncoder().setVbr(true);


More information about the Speex-dev mailing list