int main(void) { /* Declare an array and fill it with data. */ int myarray[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29} ; char charray[] = "Mary had a little lamb" ; slice(myarray, 3, 6); slice2(charray, 2, 7); return 0 ; }
static sample_t diff_resampled(const SRCParams ¶ms, sample_t *buf1, sample_t *buf2, size_t size) { ///////////////////////////////////////////////////////////////////////////// // After resample only q*nyquist of the bandwidth is preserved. Therefore, // to compare output of the resampler with the original signal we must feed // the resampler with the bandlimited signal. Bandlimiting filter has a // transition band and we must guarantee: // passband + transition_band <= q*nyquist. // // It looks reasonable to make the transition band of the bandlimiting filter // to be equal to the transition band of the resampler. In this case we have: // passband + (1-q)*nyquist <= q*nyquist // passband <= (2q - 1)*nyquist // // In normalized form nyquist = 0.5, so we have following parameters of the // bandlimiting filter: passband = q-0.5, transition band = 0.5*(1-q) ParamFIR low_pass(ParamFIR::low_pass, params.q-0.5, 0, 0.5*(1-params.q), params.a + 10, true); const FIRInstance *fir = low_pass.make(params.fs); BOOST_REQUIRE(fir != 0); int trans_len = fir->length * 2; delete fir; Speakers spk(FORMAT_LINEAR, MODE_MONO, params.fs); samples_t s1, s2; s1.zero(); s1[0] = buf1; s2.zero(); s2[0] = buf2; ChunkSource src1(spk, Chunk(s1, size)); ChunkSource src2(spk, Chunk(s2, size)); Convolver conv1(&low_pass); Convolver conv2(&low_pass); SliceFilter slice1(trans_len, size - trans_len); SliceFilter slice2(trans_len, size - trans_len); FilterChain chain1(&conv1, &slice1); FilterChain chain2(&conv2, &slice2); return calc_diff(&src1, &chain1, &src2, &chain2); }