示例#1
0
 public byte[] encode_frame(short[] audio) {
   _spxe.processData(audio, 0, audio.length);
   int sz = _spxe.getProcessedDataByteSize();
   byte[] wireOut = new byte[sz];
   int got = _spxe.getProcessedData(wireOut, 0);
   return wireOut;
 }
示例#2
0
 public SpeexCodec(boolean wide) {
   _speexmode = wide ? 1 : 0;
   _sampleRate = wide ? 16000 : 8000;
   _iaxcn = wide ? CodecFace.AUDIO_SPEEX16 : CodecFace.AUDIO_SPEEX;
   _name = wide ? "SPEEX" : "SPEEX";
   _spxe = new SpeexEncoder();
   int q = wide ? 7 : 3;
   _spxe.init(_speexmode, q, _sampleRate, 1); // _mode, _quality, _sampleRate, _channels);
   _spxe.getEncoder().setComplexity(2);
   Log.debug(
       "Speex mode "
           + _spxe.getEncoder().getMode()
           + " encoder configured with rate ="
           + _spxe.getEncoder().getSamplingRate()
           + " Quality ="
           + q
           + " compexity = "
           + _spxe.getEncoder().getComplexity()
           + " packet size = "
           + _spxe.getEncoder().getEncodedFrameSize() / 8
           + " bitrate = "
           + _spxe.getEncoder().getBitRate() / 1024.0);
   _spxd = new SpeexDecoder();
   _spxd.init(_speexmode, _sampleRate, 1, false); // _mode, _sampleRate, _channels, false);
   _aframesz = wide ? 320 : 160; // number of shorts in an audio frame;
 }