Example #1
0
  /** Initialization of decoder */
  Decoder() {

    synth = synth_buf;
    synth_offset = M;

    decLd8k.init_decod_ld8k();
    postfil.init_post_filter();
    postPro.init_post_process();

    voicing = 60;
  }
Example #2
0
  /**
   * Process <code>SERIAL_SIZE</code> short of speech.
   *
   * @param serial input : serial array encoded in bits_ld8k
   * @param sp16 output : speech short array
   */
  void process(short[] serial, short[] sp16) {
    Bits.bits2prm_ld8k(serial, 2, parm, 1);

    /* the hardware detects frame erasures by checking if all bits
       are set to zero
    */
    parm[0] = 0; /* No frame erasure */
    for (int i = 2; i < SERIAL_SIZE; i++) if (serial[i] == 0) parm[0] = 1; /* frame erased     */

    /* check parity and put 1 in parm[4] if parity error */

    parm[4] = PParity.check_parity_pitch(parm[3], parm[4]);

    int t0_first = decLd8k.decod_ld8k(parm, voicing, synth, synth_offset, Az_dec); /* Decoder */

    /* Post-filter and decision on voicing parameter */
    voicing = 0;

    float[] ptr_Az = Az_dec; /* Decoded Az for post-filter */
    int ptr_Az_offset = 0;

    for (int i = 0; i < L_FRAME; i += L_SUBFR) {
      int sf_voic; /* voicing for subframe */

      sf_voic = postfil.post(t0_first, synth, synth_offset + i, ptr_Az, ptr_Az_offset, pst_out, i);
      if (sf_voic != 0) {
        voicing = sf_voic;
      }
      ptr_Az_offset += MP1;
    }
    Util.copy(synth_buf, L_FRAME, synth_buf, M);

    postPro.post_process(pst_out, L_FRAME);

    floats2shorts(pst_out, sp16);
  }