static size_t sox_datwrite(sox_format_t * ft, const sox_sample_t *buf, size_t nsamp) { priv_t * dat = (priv_t *) ft->priv; size_t done = 0; double sampval=0.0; char s[LINEWIDTH]; size_t i=0; /* Always write a complete set of channels */ nsamp -= (nsamp % ft->signal.channels); /* Write time, then sample values, then CRLF newline */ while(done < nsamp) { sprintf(s," %15.8g ",dat->timevalue); lsx_writes(ft, s); for (i=0; i<ft->signal.channels; i++) { sampval = SOX_SAMPLE_TO_FLOAT_64BIT(*buf++, ft->clips); sprintf(s," %15.8g", sampval); lsx_writes(ft, s); done++; } sprintf(s," \r\n"); lsx_writes(ft, s); dat->timevalue += dat->deltat; } return done; }
static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, sox_sample_t * obuf, size_t * isamp, size_t * osamp) { priv_t * p = (priv_t *)effp->priv; size_t i, odone = min(*osamp, (size_t)fifo_occupancy(&p->output_fifo)); double const * s = fifo_read(&p->output_fifo, (int)odone, NULL); SOX_SAMPLE_LOCALS; for (i = 0; i < odone; ++i) *obuf++ = SOX_FLOAT_64BIT_TO_SAMPLE(*s++, effp->clips); p->samples_out += odone; if (*isamp && odone < *osamp) { double * t = fifo_write(&p->input_fifo, (int)*isamp, NULL); p->samples_in += (int)*isamp; for (i = *isamp; i; --i) *t++ = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf++, effp->clips); filter(p); } else *isamp = 0; *osamp = odone; return SOX_SUCCESS; }