void aresonvc_nr_fetch(register aresonvc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ sample_type hz_val; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double c3co_reg; register double c3p1_reg; register double c3t4_reg; register double omc3_reg; register double c2_reg; register double c1_reg; register int normalization_reg; register double y1_reg; register double y2_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "aresonvc_nr_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* grab next hz_x1_sample when phase goes past 1.0; */ /* use hz_n (computed below) to avoid roundoff errors: */ if (susp->hz_n <= 0) { susp_check_term_samples(hz, hz_ptr, hz_cnt); susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); susp->hz_pHaSe -= 1.0; /* hz_n gets number of samples before phase exceeds 1.0: */ susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * susp->output_per_hz); susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; susp->c1 = (susp->normalization == 0 ? 0.0 : (susp->normalization == 1 ? 1.0 - susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : 1.0 - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)); } togo = min(togo, susp->hz_n); hz_val = susp->hz_x1_sample; /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; c3co_reg = susp->c3co; c3p1_reg = susp->c3p1; c3t4_reg = susp->c3t4; omc3_reg = susp->omc3; c2_reg = susp->c2; c1_reg = susp->c1; normalization_reg = susp->normalization; y1_reg = susp->y1; y2_reg = susp->y2; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ register double y0, current;current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; } while (--n); /* inner loop */ susp->y1 = y1_reg; susp->y2 = y2_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; susp->hz_n -= togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* aresonvc_nr_fetch */
void fmosc_s_fetch(register fmosc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double table_len_reg; register double ph_incr_reg; register sample_type * table_ptr_reg; register double phase_reg; register sample_type s_fm_scale_reg = susp->s_fm->scale; register sample_block_values_type s_fm_ptr_reg; falloc_sample_block(out, "fmosc_s_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s_fm input sample block: */ susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); togo = min(togo, susp->s_fm_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; table_len_reg = susp->table_len; ph_incr_reg = susp->ph_incr; table_ptr_reg = susp->table_ptr; phase_reg = susp->phase; s_fm_ptr_reg = susp->s_fm_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * (table_ptr_reg[table_index + 1] - x1)); phase_reg += ph_incr_reg + (s_fm_scale_reg * *s_fm_ptr_reg++); while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; } while (--n); /* inner loop */ susp->phase = phase_reg; /* using s_fm_ptr_reg is a bad idea on RS/6000: */ susp->s_fm_ptr += togo; out_ptr += togo; susp_took(s_fm_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* fmosc_s_fetch */
void tapv_sn_fetch(register tapv_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double offset_reg; register double vdscale_reg; register double maxdelay_reg; register long bufflen_reg; register long index_reg; register sample_type * buffer_reg; register sample_block_values_type vardelay_ptr_reg; register sample_type s1_scale_reg = susp->s1->scale; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "tapv_sn_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past the vardelay input sample block: */ susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); togo = min(togo, susp->vardelay_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; offset_reg = susp->offset; vdscale_reg = susp->vdscale; maxdelay_reg = susp->maxdelay; bufflen_reg = susp->bufflen; index_reg = susp->index; buffer_reg = susp->buffer; vardelay_ptr_reg = susp->vardelay_ptr; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double phase; long i; phase = *vardelay_ptr_reg++ * vdscale_reg + offset_reg; /* now phase should give number of samples of delay */ if (phase < 0) phase = 0; else if (phase > maxdelay_reg) phase = maxdelay_reg; phase = (double) index_reg - phase; /* now phase is a location in the buffer_reg (before modulo) */ /* Time out to update the buffer_reg: * this is a tricky buffer_reg: buffer_reg[0] == buffer_reg[bufflen_reg] * the logical length is bufflen_reg, but the actual length * is bufflen_reg + 1 to allow for a repeated sample at the * end. This allows for efficient interpolation. */ buffer_reg[index_reg++] = (s1_scale_reg * *s1_ptr_reg++); if (index_reg > bufflen_reg) { buffer_reg[0] = buffer_reg[bufflen_reg]; index_reg = 1; } /* back to the phase calculation: * use conditional instead of modulo */ if (phase < 0) phase += bufflen_reg; i = (long) phase; /* put integer part in i */ phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase);; } while (--n); /* inner loop */ susp->bufflen = bufflen_reg; susp->index = index_reg; /* using vardelay_ptr_reg is a bad idea on RS/6000: */ susp->vardelay_ptr += togo; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); susp_took(vardelay_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* tapv_sn_fetch */
void quantize_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) { quantize_susp_type susp = (quantize_susp_type) a_susp; int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double factor_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "quantize_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo < 0) togo = 0; /* avoids rounding errros */ if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; factor_reg = susp->factor; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ { float x = *s1_ptr_reg++ * factor_reg; long xx; x = (x > 0.0F ? x + 0.5 : x - 0.5); xx = (long) x; *out_ptr_reg++ = (float) xx; }; } while (--n); /* inner loop */ /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* quantize_n_fetch */
void aresoncv_ni_fetch(register aresoncv_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double c3co_reg; register double coshz_reg; register double c2_reg; register double c1_reg; register int normalization_reg; register double y1_reg; register double y2_reg; register double bw_pHaSe_iNcR_rEg = susp->bw_pHaSe_iNcR; register double bw_pHaSe_ReG; register sample_type bw_x1_sample_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "aresoncv_ni_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp_check_term_samples(bw, bw_ptr, bw_cnt); susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; c3co_reg = susp->c3co; coshz_reg = susp->coshz; c2_reg = susp->c2; c1_reg = susp->c1; normalization_reg = susp->normalization; y1_reg = susp->y1; y2_reg = susp->y2; bw_pHaSe_ReG = susp->bw_pHaSe; bw_x1_sample_reg = susp->bw_x1_sample; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ register double y0, current; if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ /* pick up next sample as bw_x1_sample: */ susp->bw_ptr++; susp_took(bw_cnt, 1); bw_pHaSe_ReG -= 1.0; susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); } current = *s1_ptr_reg++; *out_ptr_reg++ = (float) (y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg); y2_reg = y1_reg; y1_reg = y0 - current; bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->y1 = y1_reg; susp->y2 = y2_reg; susp->bw_pHaSe = bw_pHaSe_ReG; susp->bw_x1_sample = bw_x1_sample_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* aresoncv_ni_fetch */
void clip_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) { clip_susp_type susp = (clip_susp_type) a_susp; int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register sample_type level_reg; register sample_type s_scale_reg = susp->s->scale; register sample_block_values_type s_ptr_reg; falloc_sample_block(out, "clip_s_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s input sample block: */ susp_check_term_log_samples(s, s_ptr, s_cnt); togo = min(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo < 0) togo = 0; /* avoids rounding errros */ if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; level_reg = susp->level; s_ptr_reg = susp->s_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double x = (s_scale_reg * *s_ptr_reg++); *out_ptr_reg++ = (sample_type) (x > level_reg ? level_reg : (x < -level_reg ? -level_reg : x)); } while (--n); /* inner loop */ susp->level = level_reg; /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; out_ptr += togo; susp_took(s_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* clip_s_fetch */
void up_r_fetch(register up_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ sample_type input_DeLtA; sample_type input_val; sample_type input_x2_sample; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; falloc_sample_block(out, "up_r_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp->input_pHaSe = 1.0; } susp_check_term_log_samples(input, input_ptr, input_cnt); input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* grab next input_x2_sample when phase goes past 1.0; */ /* we use input_n (computed below) to avoid roundoff errors: */ if (susp->input_n <= 0) { susp->input_x1_sample = input_x2_sample; susp->input_ptr++; susp_took(input_cnt, 1); susp->input_pHaSe -= 1.0; susp_check_term_log_samples(input, input_ptr, input_cnt); input_x2_sample = susp_current_sample(input, input_ptr); /* input_n gets number of samples before phase exceeds 1.0: */ susp->input_n = (long) ((1.0 - susp->input_pHaSe) * susp->output_per_input); } togo = MIN(togo, susp->input_n); input_DeLtA = (sample_type) ((input_x2_sample - susp->input_x1_sample) * susp->input_pHaSe_iNcR); input_val = (sample_type) (susp->input_x1_sample * (1.0 - susp->input_pHaSe) + input_x2_sample * susp->input_pHaSe); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) input_val; input_val += input_DeLtA; } while (--n); /* inner loop */ out_ptr += togo; susp->input_pHaSe += togo * susp->input_pHaSe_iNcR; susp->input_n -= togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* up_r_fetch */
void reson_n_fetch(register reson_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double c3_reg; register double c2_reg; register double c1_reg; register double y1_reg; register double y2_reg; register sample_block_values_type s_ptr_reg; falloc_sample_block(out, "reson_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s input sample block: */ susp_check_term_log_samples(s, s_ptr, s_cnt); togo = min(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; c3_reg = susp->c3; c2_reg = susp->c2; c1_reg = susp->c1; y1_reg = susp->y1; y2_reg = susp->y2; s_ptr_reg = susp->s_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * *s_ptr_reg++ + c2_reg * y1_reg - c3_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; } while (--n); /* inner loop */ susp->y1 = y1_reg; susp->y2 = y2_reg; /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; out_ptr += togo; susp_took(s_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* reson_n_fetch */
void convolve_s_fetch(register convolve_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register sample_type * h_buf_reg; register long h_len_reg; register long x_buf_len_reg; register sample_type * x_buffer_pointer_reg; register sample_type * x_buffer_current_reg; register sample_type x_snd_scale_reg = susp->x_snd->scale; register sample_block_values_type x_snd_ptr_reg; falloc_sample_block(out, "convolve_s_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the x_snd input sample block: */ susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt); togo = min(togo, susp->x_snd_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; h_buf_reg = susp->h_buf; h_len_reg = susp->h_len; x_buf_len_reg = susp->x_buf_len; x_buffer_pointer_reg = susp->x_buffer_pointer; x_buffer_current_reg = susp->x_buffer_current; x_snd_ptr_reg = susp->x_snd_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ long i; double sum; /* see if we've reached end of x_buffer */ if ((x_buffer_pointer_reg + x_buf_len_reg) <= (x_buffer_current_reg + h_len_reg)) { /* shift x_buffer from current back to base */ for (i = 1; i < h_len_reg; i++) { x_buffer_pointer_reg[i-1] = x_buffer_current_reg[i]; } /* this will be incremented back to x_buffer_pointer_reg below */ x_buffer_current_reg = x_buffer_pointer_reg - 1; } x_buffer_current_reg++; x_buffer_current_reg[h_len_reg - 1] = (x_snd_scale_reg * *x_snd_ptr_reg++); sum = 0.0; for (i = 0; i < h_len_reg; i++) { sum += x_buffer_current_reg[i] * h_buf_reg[i]; } *out_ptr_reg++ = (sample_type) sum; ; } while (--n); /* inner loop */ susp->x_buffer_pointer = x_buffer_pointer_reg; susp->x_buffer_current = x_buffer_current_reg; /* using x_snd_ptr_reg is a bad idea on RS/6000: */ susp->x_snd_ptr += togo; out_ptr += togo; susp_took(x_snd_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* convolve_s_fetch */
void biquadfilt_n_fetch(register biquadfilt_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double z1_reg; register double z2_reg; register double b0_reg; register double b1_reg; register double b2_reg; register double a1_reg; register double a2_reg; register sample_block_values_type s_ptr_reg; falloc_sample_block(out, "biquadfilt_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s input sample block: */ susp_check_term_log_samples(s, s_ptr, s_cnt); togo = min(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; z1_reg = susp->z1; z2_reg = susp->z2; b0_reg = susp->b0; b1_reg = susp->b1; b2_reg = susp->b2; a1_reg = susp->a1; a2_reg = susp->a2; s_ptr_reg = susp->s_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double z0; z0 = *s_ptr_reg++ + a1_reg*z1_reg + a2_reg*z2_reg; *out_ptr_reg++ = (sample_type) (z0*b0_reg + z1_reg*b1_reg + z2_reg*b2_reg); z2_reg = z1_reg; z1_reg = z0;; } while (--n); /* inner loop */ susp->z1 = z1_reg; susp->z2 = z2_reg; /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; out_ptr += togo; susp_took(s_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* biquadfilt_n_fetch */
void avg_s_fetch(avg_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo = 0; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_type *fillptr_reg; register sample_type *endptr_reg = susp->endptr; register sample_block_values_type s_ptr_reg; falloc_sample_block(out, "avg_s_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = (max_sample_block_len - cnt) * susp->stepsize; /* don't run past the s input sample block: */ susp_check_term_log_samples(s, s_ptr, s_cnt); togo = MIN(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo/susp->stepsize) { togo = (susp->terminate_cnt - (susp->susp.current + cnt)) * susp->stepsize; if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo/susp->stepsize) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop * susp->stepsize; } } n = togo; s_ptr_reg = susp->s_ptr; fillptr_reg = susp->fillptr; if (n) do { /* the inner sample computation loop */ *fillptr_reg++ = *s_ptr_reg++; if (fillptr_reg >= endptr_reg) { *out_ptr++ = (*(susp->process_block))(susp); cnt++; fillptr_reg -= susp->stepsize; } } while (--n); /* inner loop */ /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; susp->fillptr = fillptr_reg; susp_took(s_cnt, togo); } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* avg_s_fetch */
void shape_s_fetch(register shape_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double time_to_index_reg; register double origin_reg; register sample_type * fcn_table_reg; register double table_len_reg; register sample_type sin_scale_reg = susp->sin->scale; register sample_block_values_type sin_ptr_reg; falloc_sample_block(out, "shape_s_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the sin input sample block: */ susp_check_term_log_samples(sin, sin_ptr, sin_cnt); togo = min(togo, susp->sin_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; time_to_index_reg = susp->time_to_index; origin_reg = susp->origin; fcn_table_reg = susp->fcn_table; table_len_reg = susp->table_len; sin_ptr_reg = susp->sin_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ register double offset, x1; register long table_index; register double phase = (sin_scale_reg * *sin_ptr_reg++); if (phase > 1.0) phase = 1.0; else if (phase < -1.0) phase = -1.0; offset = (phase + origin_reg) * time_to_index_reg; table_index = (long) offset; if (table_index < 0) table_index = 0; if (table_index >= table_len_reg) table_index = ((long) table_len_reg) - 1; x1 = fcn_table_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (offset - table_index) * (fcn_table_reg[table_index + 1] - x1)); ; } while (--n); /* inner loop */ susp->origin = origin_reg; /* using sin_ptr_reg is a bad idea on RS/6000: */ susp->sin_ptr += togo; out_ptr += togo; susp_took(sin_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* shape_s_fetch */
void tonev_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) { tonev_susp_type susp = (tonev_susp_type) a_susp; int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double scale1_reg; register double c2_reg; register double c1_reg; register double prev_reg; register double hz_pHaSe_iNcR_rEg = susp->hz_pHaSe_iNcR; register double hz_pHaSe_ReG; register sample_type hz_x1_sample_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "tonev_ni_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { register double b; susp->started = true; susp_check_term_samples(hz, hz_ptr, hz_cnt); susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); b = 2.0 - cos(susp->hz_x1_sample); susp->c2 = b - sqrt((b * b) - 1.0); susp->c1 = (1.0 - susp->c2) * susp->scale1; } while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo < 0) togo = 0; /* avoids rounding errros */ if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; scale1_reg = susp->scale1; c2_reg = susp->c2; c1_reg = susp->c1; prev_reg = susp->prev; hz_pHaSe_ReG = susp->hz_pHaSe; hz_x1_sample_reg = susp->hz_x1_sample; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ register double b; /* pick up next sample as hz_x1_sample: */ susp->hz_ptr++; susp_took(hz_cnt, 1); hz_pHaSe_ReG -= 1.0; susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); b = 2.0 - cos(hz_x1_sample_reg); c2_reg = b - sqrt((b * b) - 1.0); c1_reg = (1.0 - c2_reg) * scale1_reg; } *out_ptr_reg++ = (sample_type) (prev_reg = c1_reg * *s1_ptr_reg++ + c2_reg * prev_reg); hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->prev = prev_reg; susp->hz_pHaSe = hz_pHaSe_ReG; susp->hz_x1_sample = hz_x1_sample_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* tonev_ni_fetch */
void coterm_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) { coterm_susp_type susp = (coterm_susp_type) a_susp; int cnt = 0; /* how many samples computed */ sample_type s2_x2_sample; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double s2_pHaSe_iNcR_rEg = susp->s2_pHaSe_iNcR; register double s2_pHaSe_ReG; register sample_type s2_x1_sample_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "coterm_ni_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp_check_term_log_samples(s2, s2_ptr, s2_cnt); susp->s2_x1_sample = (susp->s2_cnt--, *(susp->s2_ptr)); } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = *(susp->s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo < 0) togo = 0; /* avoids rounding errros */ if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; s2_pHaSe_ReG = susp->s2_pHaSe; s2_x1_sample_reg = susp->s2_x1_sample; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ if (s2_pHaSe_ReG >= 1.0) { s2_x1_sample_reg = s2_x2_sample; /* pick up next sample as s2_x2_sample: */ susp->s2_ptr++; susp_took(s2_cnt, 1); s2_pHaSe_ReG -= 1.0; susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); } {sample_type dummy = (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); *out_ptr_reg++ = *s1_ptr_reg++;}; s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->s2_pHaSe = s2_pHaSe_ReG; susp->s2_x1_sample = s2_x1_sample_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* coterm_ni_fetch */
void aresonvc_ns_fetch(register aresonvc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double c3co_reg; register double c3p1_reg; register double c3t4_reg; register double omc3_reg; register double c2_reg; register double c1_reg; register int normalization_reg; register double y1_reg; register double y2_reg; register sample_type hz_scale_reg = susp->hz->scale; register sample_block_values_type hz_ptr_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "aresonvc_ns_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past the hz input sample block: */ susp_check_term_samples(hz, hz_ptr, hz_cnt); togo = min(togo, susp->hz_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; c3co_reg = susp->c3co; c3p1_reg = susp->c3p1; c3t4_reg = susp->c3t4; omc3_reg = susp->omc3; c2_reg = susp->c2; c1_reg = susp->c1; normalization_reg = susp->normalization; y1_reg = susp->y1; y2_reg = susp->y2; hz_ptr_reg = susp->hz_ptr; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ register double y0, current; c2_reg = c3t4_reg * cos((hz_scale_reg * *hz_ptr_reg++)) / c3p1_reg; c1_reg = (normalization_reg == 0 ? 0.0 : (normalization_reg == 1 ? 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)); current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; } while (--n); /* inner loop */ susp->y1 = y1_reg; susp->y2 = y2_reg; /* using hz_ptr_reg is a bad idea on RS/6000: */ susp->hz_ptr += togo; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); susp_took(hz_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* aresonvc_ns_fetch */
void atonev_nr_fetch(register atonev_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ sample_type hz_val; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double cc_reg; register double prev_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "atonev_nr_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* grab next hz_x1_sample when phase goes past 1.0; */ /* use hz_n (computed below) to avoid roundoff errors: */ if (susp->hz_n <= 0) { register double bb; susp_check_term_samples(hz, hz_ptr, hz_cnt); susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); susp->hz_pHaSe -= 1.0; /* hz_n gets number of samples before phase exceeds 1.0: */ susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * susp->output_per_hz); bb = 2.0 - cos(susp->hz_x1_sample); susp->cc = bb - sqrt((bb * bb) - 1.0); } togo = min(togo, susp->hz_n); hz_val = susp->hz_x1_sample; /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; cc_reg = susp->cc; prev_reg = susp->prev; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double current; current = *s1_ptr_reg++; prev_reg = cc_reg * (prev_reg + current); *out_ptr_reg++ = (sample_type) prev_reg; prev_reg -= current;; } while (--n); /* inner loop */ susp->prev = prev_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; susp->hz_n -= togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* atonev_nr_fetch */
/* * The pitch (F0) is determined by finding two periods whose * inner product accounts for almost all of the energy. Let X and Y * be adjacent vectors of length N in the sample stream. Then, * if 2X*Y > threshold * (X*X + Y*Y) * then the period is given by N * In the algorithm, we compute different sizes until we find a * peak above threshold. Then, we use cubic interpolation to get * a precise value. If no peak above threshold is found, we return * the first peak. The second channel returns the value 2X*Y/(X*X+Y*Y) * which is refered to as the "harmonicity" -- the amount of energy * accounted for by periodicity. * * Low sample rates are advised because of the high cost of computing * inner products (fast autocorrelation is not used). * * The result is a 2-channel signal running at the requested rate. * The first channel is the estimated pitch, and the second channel * is the harmonicity. * * This code is adopted from multiread, currently the only other * multichannel suspension in Nyquist. Comments from multiread include: * The susp is shared by all channels. The susp has backpointers * to the tail-most snd_list node of each channel, and it is by * extending the list at these nodes that sounds are read in. * To avoid a circularity, the reference counts on snd_list nodes * do not include the backpointers from this susp. When a snd_list * node refcount goes to zero, the yin susp's free routine * is called. This must scan the backpointers to find the node that * has a zero refcount (the free routine is called before the node * is deallocated, so this is safe). The backpointer is then set * to NULL. When all backpointers are NULL, the susp itself is * deallocated, because it can only be referenced through the * snd_list nodes to which there are backpointers. */ void yin_fetch(yin_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo = 0; int n; sample_block_type f0; sample_block_values_type f0_ptr = NULL; sample_block_type harmonicity; sample_block_values_type harmonicity_ptr = NULL; register sample_block_values_type s_ptr_reg; register sample_type *fillptr_reg; register sample_type *endptr_reg = susp->endptr; if (susp->chan[0]) { falloc_sample_block(f0, "yin_fetch"); f0_ptr = f0->samples; /* Since susp->chan[i] exists, we want to append a block of samples. * The block, out, has been allocated. Before we insert the block, * we must figure out whether to insert a new snd_list_type node for * the block. Recall that before SND_get_next is called, the last * snd_list_type in the list will have a null block pointer, and the * snd_list_type's susp field points to the suspension (in this case, * susp). When SND_get_next (in sound.c) is called, it appends a new * snd_list_type and points the previous one to internal_zero_block * before calling this fetch routine. On the other hand, since * SND_get_next is only going to be called on one of the channels, the * other channels will not have had a snd_list_type appended. * SND_get_next does not tell us directly which channel it wants (it * doesn't know), but we can test by looking for a non-null block in the * snd_list_type pointed to by our back-pointers in susp->chan[]. If * the block is null, the channel was untouched by SND_get_next, and * we should append a snd_list_type. If it is non-null, then it * points to internal_zero_block (the block inserted by SND_get_next) * and a new snd_list_type has already been appended. */ /* Before proceeding, it may be that garbage collection ran when we * allocated out, so check again to see if susp->chan[j] is Null: */ if (!susp->chan[0]) { ffree_sample_block(f0, "yin_fetch"); f0 = NULL; /* make sure we don't free it again */ f0_ptr = NULL; /* make sure we don't output f0 samples */ } else if (!susp->chan[0]->block) { snd_list_type snd_list = snd_list_create((snd_susp_type) susp); /* Now we have a snd_list to append to the channel, but a very * interesting thing can happen here. snd_list_create, which * we just called, MAY have invoked the garbage collector, and * the GC MAY have freed all references to this channel, in which * case yin_free(susp) will have been called, and susp->chan[0] * will now be NULL! */ if (!susp->chan[0]) { ffree_snd_list(snd_list, "yin_fetch"); } else { susp->chan[0]->u.next = snd_list; } } /* see the note above: we don't know if susp->chan still exists */ /* Note: We DO know that susp still exists because even if we lost * some channels in a GC, someone is still calling SND_get_next on * some channel. I suppose that there might be some very pathological * code that could free a global reference to a sound that is in the * midst of being computed, perhaps by doing something bizarre in the * closure that snd_seq activates at the logical stop time of its first * sound, but I haven't thought that one through. */ if (susp->chan[0]) { susp->chan[0]->block = f0; /* check some assertions */ if (susp->chan[0]->u.next->u.susp != (snd_susp_type) susp) { nyquist_printf("didn't find susp at end of list for chan 0\n"); } } else if (f0) { /* we allocated f0, but don't need it anymore due to GC */ ffree_sample_block(f0, "yin_fetch"); f0_ptr = NULL; } } /* Now, repeat for channel 1 (comments omitted) */ if (susp->chan[1]) { falloc_sample_block(harmonicity, "yin_fetch"); harmonicity_ptr = harmonicity->samples; if (!susp->chan[1]) { ffree_sample_block(harmonicity, "yin_fetch"); harmonicity = NULL; /* make sure we don't free it again */ harmonicity_ptr = NULL; } else if (!susp->chan[1]->block) { snd_list_type snd_list = snd_list_create((snd_susp_type) susp); if (!susp->chan[1]) { ffree_snd_list(snd_list, "yin_fetch"); } else { susp->chan[1]->u.next = snd_list; } } if (susp->chan[1]) { susp->chan[1]->block = harmonicity; if (susp->chan[1]->u.next->u.susp != (snd_susp_type) susp) { nyquist_printf("didn't find susp at end of list for chan 1\n"); } } else if (harmonicity) { /* we allocated harmonicity, but don't need it anymore due to GC */ ffree_sample_block(harmonicity, "yin_fetch"); harmonicity_ptr = NULL; } } while (cnt < max_sample_block_len) { /* outer loop */ /* first, compute how many samples to generate in inner loop: */ /* don't overflow the output sample block */ togo = (max_sample_block_len - cnt) * susp->stepsize; /* don't run past the s input sample block */ susp_check_term_log_samples(s, s_ptr, s_cnt); togo = min(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo/susp->stepsize) { togo = (susp->terminate_cnt - (susp->susp.current + cnt)) * susp->stepsize; if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop = 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the output block) */ if (to_stop < togo/susp->stepsize) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we can set * the logical stop flag on this output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new block a the LST */ togo = to_stop * susp->stepsize; } } n = togo; s_ptr_reg = susp->s_ptr; fillptr_reg = susp->fillptr; if (n) do { /* the inner sample computation loop */ *fillptr_reg++ = *s_ptr_reg++; if (fillptr_reg >= endptr_reg) { float f0; float harmonicity; yin_compute(susp, &f0, &harmonicity); if (f0_ptr) *f0_ptr++ = f0; if (harmonicity_ptr) *harmonicity_ptr++ = harmonicity; cnt++; fillptr_reg -= susp->stepsize; } } while (--n); /* inner loop */ /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; susp->fillptr = fillptr_reg; susp_took(s_cnt, togo); } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* yin_fetch */
void atonev_ns_fetch(register atonev_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double cc_reg; register double prev_reg; register sample_type hz_scale_reg = susp->hz->scale; register sample_block_values_type hz_ptr_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "atonev_ns_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past the hz input sample block: */ susp_check_term_samples(hz, hz_ptr, hz_cnt); togo = min(togo, susp->hz_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; cc_reg = susp->cc; prev_reg = susp->prev; hz_ptr_reg = susp->hz_ptr; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double current; register double bb; bb = 2.0 - cos((hz_scale_reg * *hz_ptr_reg++)); cc_reg = bb - sqrt((bb * bb) - 1.0); current = *s1_ptr_reg++; prev_reg = cc_reg * (prev_reg + current); *out_ptr_reg++ = (sample_type) prev_reg; prev_reg -= current;; } while (--n); /* inner loop */ susp->prev = prev_reg; /* using hz_ptr_reg is a bad idea on RS/6000: */ susp->hz_ptr += togo; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); susp_took(hz_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* atonev_ns_fetch */
void up_i_fetch(register up_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ sample_type input_x2_sample; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double input_pHaSe_iNcR_rEg = susp->input_pHaSe_iNcR; register double input_pHaSe_ReG; register sample_type input_x1_sample_reg; falloc_sample_block(out, "up_i_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp_check_term_log_samples(input, input_ptr, input_cnt); susp->input_x1_sample = susp_fetch_sample(input, input_ptr, input_cnt); } susp_check_term_log_samples(input, input_ptr, input_cnt); input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; input_pHaSe_ReG = susp->input_pHaSe; input_x1_sample_reg = susp->input_x1_sample; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ if (input_pHaSe_ReG >= 1.0) { input_x1_sample_reg = input_x2_sample; /* pick up next sample as input_x2_sample: */ susp->input_ptr++; susp_took(input_cnt, 1); input_pHaSe_ReG -= 1.0; susp_check_term_log_samples_break(input, input_ptr, input_cnt, input_x2_sample); } *out_ptr_reg++ = (sample_type) (input_x1_sample_reg * (1 - input_pHaSe_ReG) + input_x2_sample * input_pHaSe_ReG); input_pHaSe_ReG += input_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->input_pHaSe = input_pHaSe_ReG; susp->input_x1_sample = input_x1_sample_reg; out_ptr += togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* up_i_fetch */
void fmosc_i_fetch(register fmosc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double table_len_reg; register double ph_incr_reg; register sample_type * table_ptr_reg; register double phase_reg; register double s_fm_pHaSe_iNcR_rEg = susp->s_fm_pHaSe_iNcR; register double s_fm_pHaSe_ReG; register sample_type s_fm_x1_sample_reg; falloc_sample_block(out, "fmosc_i_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; table_len_reg = susp->table_len; ph_incr_reg = susp->ph_incr; table_ptr_reg = susp->table_ptr; phase_reg = susp->phase; s_fm_pHaSe_ReG = susp->s_fm_pHaSe; s_fm_x1_sample_reg = susp->s_fm_x1_sample; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ long table_index; double x1; if (s_fm_pHaSe_ReG >= 1.0) { /* fixup-depends s_fm */ /* pick up next sample as s_fm_x1_sample: */ susp->s_fm_ptr++; susp_took(s_fm_cnt, 1); s_fm_pHaSe_ReG -= 1.0; susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); } table_index = (long) phase_reg; x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * (table_ptr_reg[table_index + 1] - x1)); phase_reg += ph_incr_reg + s_fm_x1_sample_reg; while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->phase = phase_reg; susp->s_fm_pHaSe = s_fm_pHaSe_ReG; susp->s_fm_x1_sample = s_fm_x1_sample_reg; out_ptr += togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* fmosc_i_fetch */
void oneshot_n_fetch(register oneshot_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double lev_reg; register long oncount_reg; register long cnt_reg; register sample_block_values_type input_ptr_reg; falloc_sample_block(out, "oneshot_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the input input sample block: */ susp_check_term_log_samples(input, input_ptr, input_cnt); togo = MIN(togo, susp->input_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; lev_reg = susp->lev; oncount_reg = susp->oncount; cnt_reg = susp->cnt; input_ptr_reg = susp->input_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ double x = *input_ptr_reg++; if (x > lev_reg) cnt_reg = oncount_reg; cnt_reg--; *out_ptr_reg++ = (cnt_reg >= 0 ? 1.0F : 0.0F);; } while (--n); /* inner loop */ susp->lev = lev_reg; susp->oncount = oncount_reg; susp->cnt = cnt_reg; /* using input_ptr_reg is a bad idea on RS/6000: */ susp->input_ptr += togo; out_ptr += togo; susp_took(input_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* oneshot_n_fetch */
void fmosc_r_fetch(register fmosc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ sample_type s_fm_val; int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double table_len_reg; register double ph_incr_reg; register sample_type * table_ptr_reg; register double phase_reg; falloc_sample_block(out, "fmosc_r_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp->s_fm_pHaSe = 1.0; } susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* grab next s_fm_x1_sample when phase goes past 1.0; */ /* use s_fm_n (computed below) to avoid roundoff errors: */ if (susp->s_fm_n <= 0) { susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); susp->s_fm_pHaSe -= 1.0; /* s_fm_n gets number of samples before phase exceeds 1.0: */ susp->s_fm_n = (long) ((1.0 - susp->s_fm_pHaSe) * susp->output_per_s_fm); } togo = min(togo, susp->s_fm_n); s_fm_val = susp->s_fm_x1_sample; /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; table_len_reg = susp->table_len; ph_incr_reg = susp->ph_incr; table_ptr_reg = susp->table_ptr; phase_reg = susp->phase; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * (table_ptr_reg[table_index + 1] - x1)); phase_reg += ph_incr_reg + s_fm_val; while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; } while (--n); /* inner loop */ susp->phase = phase_reg; out_ptr += togo; susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; susp->s_fm_n -= togo; cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* fmosc_r_fetch */
void stkchorus_n_fetch(register stkchorus_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register struct stkEffect * mych_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "stkchorus_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; mych_reg = susp->mych; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (stkEffectTick(mych_reg, *s1_ptr_reg++)) ; } while (--n); /* inner loop */ susp->mych = mych_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* stkchorus_n_fetch */
void resonvc_ni_fetch(register resonvc_susp_type susp, snd_list_type snd_list) { int cnt = 0; /* how many samples computed */ int togo; int n; sample_block_type out; register sample_block_values_type out_ptr; register sample_block_values_type out_ptr_reg; register double scale1_reg; register double c3co_reg; register double c3p1_reg; register double c3t4_reg; register double omc3_reg; register double c2_reg; register double c1_reg; register int normalization_reg; register double y1_reg; register double y2_reg; register double hz_pHaSe_iNcR_rEg = susp->hz_pHaSe_iNcR; register double hz_pHaSe_ReG; register sample_type hz_x1_sample_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "resonvc_ni_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { susp->started = true; susp_check_term_samples(hz, hz_ptr, hz_cnt); susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; susp->c1 = (susp->normalization == 0 ? susp->scale1 : (susp->normalization == 1 ? susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)) * susp->scale1; } while (cnt < max_sample_block_len) { /* outer loop */ /* first compute how many samples to generate in inner loop: */ /* don't overflow the output sample block: */ togo = max_sample_block_len - cnt; /* don't run past the s1 input sample block: */ susp_check_term_log_samples(s1, s1_ptr, s1_cnt); togo = min(togo, susp->s1_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { togo = susp->terminate_cnt - (susp->susp.current + cnt); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). */ if (to_stop < togo) { if (to_stop == 0) { if (cnt) { togo = 0; break; } else /* keep togo as is: since cnt == 0, we * can set the logical stop flag on this * output block */ susp->logically_stopped = true; } else /* limit togo so we can start a new * block at the LST */ togo = to_stop; } } n = togo; scale1_reg = susp->scale1; c3co_reg = susp->c3co; c3p1_reg = susp->c3p1; c3t4_reg = susp->c3t4; omc3_reg = susp->omc3; c2_reg = susp->c2; c1_reg = susp->c1; normalization_reg = susp->normalization; y1_reg = susp->y1; y2_reg = susp->y2; hz_pHaSe_ReG = susp->hz_pHaSe; hz_x1_sample_reg = susp->hz_x1_sample; s1_ptr_reg = susp->s1_ptr; out_ptr_reg = out_ptr; if (n) do { /* the inner sample computation loop */ if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ /* pick up next sample as hz_x1_sample: */ susp->hz_ptr++; susp_took(hz_cnt, 1); hz_pHaSe_ReG -= 1.0; susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); c2_reg = susp->c2 = c3t4_reg * cos(hz_x1_sample_reg) / c3p1_reg; c1_reg = susp->c1 = (normalization_reg == 0 ? scale1_reg : (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; } while (--n); /* inner loop */ togo -= n; susp->y1 = y1_reg; susp->y2 = y2_reg; susp->hz_pHaSe = hz_pHaSe_ReG; susp->hz_x1_sample = hz_x1_sample_reg; /* using s1_ptr_reg is a bad idea on RS/6000: */ susp->s1_ptr += togo; out_ptr += togo; susp_took(s1_cnt, togo); cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { snd_list_terminate(snd_list); } else { snd_list->block_len = cnt; susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { susp->logically_stopped = true; } } /* resonvc_ni_fetch */