static int start(sox_format_t * ft) { priv_t *p = (priv_t *) ft->priv; ft->signal.channels = 1; lsx_rawstart(ft, sox_true, sox_false, sox_true, SOX_ENCODING_CVSD, 1); p->last_n_bits = 5; /* 101 */ p->step_mult = exp((-1 / .005 / ft->signal.rate)); p->step_add = (1 - p->step_mult) * (.1 * SOX_SAMPLE_MAX); lsx_debug("step_mult=%g step_add=%f", p->step_mult, p->step_add); return SOX_SUCCESS; }
static void cvsdstartcommon(sox_format_t * ft) { priv_t *p = (priv_t *) ft->priv; p->cvsd_rate = (ft->signal.rate <= 24000) ? 16000 : 32000; ft->signal.rate = 8000; ft->signal.channels = 1; lsx_rawstart(ft, sox_true, sox_false, sox_true, SOX_ENCODING_CVSD, 1); /* * initialize the decoder */ p->com.overload = 0x5; p->com.mla_int = 0; /* * timeconst = (1/e)^(200 / SR) = exp(-200/SR) * SR is the sampling rate */ p->com.mla_tc0 = exp((-200.0)/((float)(p->cvsd_rate))); /* * phase_inc = 32000 / SR */ p->com.phase_inc = 32000 / p->cvsd_rate; /* * initialize bit shift register */ p->bit.shreg = p->bit.cnt = 0; p->bit.mask = 1; /* * count the bytes written */ p->bytes_written = 0; p->com.v_min = 1; p->com.v_max = -1; lsx_report("cvsd: bit rate %dbit/s, bits from %s", p->cvsd_rate, ft->encoding.reverse_bits ? "msb to lsb" : "lsb to msb"); }
static int raw_start(sox_format_t * ft) { return lsx_rawstart(ft, sox_false, sox_false, sox_true, SOX_ENCODING_UNKNOWN, 0); }