Example #1
0
void flute_freq_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
    {
    flute_freq_susp_type susp = (flute_freq_susp_type) a_susp;
    time_type final_time = susp->susp.t0;
    long n;

    /* fetch samples from breath_env up to final_time for this block of zeros */
    while ((round((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >=
	   susp->breath_env->current)
	susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt);
    /* fetch samples from freq_env up to final_time for this block of zeros */
    while ((round((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >=
	   susp->freq_env->current)
	susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt);
    /* convert to normal processing when we hit final_count */
    /* we want each signal positioned at final_time */
    n = round((final_time - susp->breath_env->t0) * susp->breath_env->sr -
         (susp->breath_env->current - susp->breath_env_cnt));
    susp->breath_env_ptr += n;
    susp_took(breath_env_cnt, n);
    n = round((final_time - susp->freq_env->t0) * susp->freq_env->sr -
         (susp->freq_env->current - susp->freq_env_cnt));
    susp->freq_env_ptr += n;
    susp_took(freq_env_cnt, n);
    susp->susp.fetch = susp->susp.keep_fetch;
    (*(susp->susp.fetch))(a_susp, snd_list);
}
Example #2
0
void tonev_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
    {
    tonev_susp_type susp = (tonev_susp_type) a_susp;
    time_type final_time = susp->susp.t0;
    long n;

    /* fetch samples from s1 up to final_time for this block of zeros */
    while ((round((final_time - susp->s1->t0) * susp->s1->sr)) >=
	   susp->s1->current)
	susp_get_samples(s1, s1_ptr, s1_cnt);
    /* fetch samples from hz up to final_time for this block of zeros */
    while ((round((final_time - susp->hz->t0) * susp->hz->sr)) >=
	   susp->hz->current)
	susp_get_samples(hz, hz_ptr, hz_cnt);
    /* convert to normal processing when we hit final_count */
    /* we want each signal positioned at final_time */
    n = round((final_time - susp->s1->t0) * susp->s1->sr -
         (susp->s1->current - susp->s1_cnt));
    susp->s1_ptr += n;
    susp_took(s1_cnt, n);
    n = round((final_time - susp->hz->t0) * susp->hz->sr -
         (susp->hz->current - susp->hz_cnt));
    susp->hz_ptr += n;
    susp_took(hz_cnt, n);
    susp->susp.fetch = susp->susp.keep_fetch;
    (*(susp->susp.fetch))(a_susp, snd_list);
}
Example #3
0
void alpassvc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
    {
    alpassvc_susp_type susp = (alpassvc_susp_type) a_susp;
    time_type final_time = susp->susp.t0;
    long n;

    /* fetch samples from input up to final_time for this block of zeros */
    while ((round((final_time - susp->input->t0) * susp->input->sr)) >=
	   susp->input->current)
	susp_get_samples(input, input_ptr, input_cnt);
    /* fetch samples from delaysnd up to final_time for this block of zeros */
    while ((round((final_time - susp->delaysnd->t0) * susp->delaysnd->sr)) >=
	   susp->delaysnd->current)
	susp_get_samples(delaysnd, delaysnd_ptr, delaysnd_cnt);
    /* convert to normal processing when we hit final_count */
    /* we want each signal positioned at final_time */
    n = round((final_time - susp->input->t0) * susp->input->sr -
         (susp->input->current - susp->input_cnt));
    susp->input_ptr += n;
    susp_took(input_cnt, n);
    n = round((final_time - susp->delaysnd->t0) * susp->delaysnd->sr -
         (susp->delaysnd->current - susp->delaysnd_cnt));
    susp->delaysnd_ptr += n;
    susp_took(delaysnd_cnt, n);
    susp->susp.fetch = susp->susp.keep_fetch;
    (*(susp->susp.fetch))(a_susp, snd_list);
}
Example #4
0
/* pvshell_test_g -- get next sample block and check flags
 *
 * Only call this from PVSHELL_TEST_G macro
 */
long pvshell_test_g(pvshell_type susp)
{
    long flags = 0;
    susp_get_samples(g, g_ptr, g_cnt); /* warning: macro references susp */
    if (susp->g->logical_stop_cnt == susp->g->current - susp->g_cnt) {
        flags |= PVSHELL_FLAG_LOGICAL_STOP;
    }
    if (susp->g_ptr == zero_block->samples) {
        flags |= PVSHELL_FLAG_TERMINATE;
    }
    return flags;
}
Example #5
0
void sax_all_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
    {
    sax_all_susp_type susp = (sax_all_susp_type) a_susp;
    time_type final_time = susp->susp.t0;
    long n;

    /* fetch samples from breath_env up to final_time for this block of zeros */
    while ((round((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >=
	   susp->breath_env->current)
	susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt);
    /* fetch samples from freq_env up to final_time for this block of zeros */
    while ((round((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >=
	   susp->freq_env->current)
	susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt);
    /* fetch samples from reed_stiffness up to final_time for this block of zeros */
    while ((round((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr)) >=
	   susp->reed_stiffness->current)
	susp_get_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt);
    /* fetch samples from noise_env up to final_time for this block of zeros */
    while ((round((final_time - susp->noise_env->t0) * susp->noise_env->sr)) >=
	   susp->noise_env->current)
	susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt);
    /* fetch samples from blow_pos up to final_time for this block of zeros */
    while ((round((final_time - susp->blow_pos->t0) * susp->blow_pos->sr)) >=
	   susp->blow_pos->current)
	susp_get_samples(blow_pos, blow_pos_ptr, blow_pos_cnt);
    /* fetch samples from reed_table_offset up to final_time for this block of zeros */
    while ((round((final_time - susp->reed_table_offset->t0) * susp->reed_table_offset->sr)) >=
	   susp->reed_table_offset->current)
	susp_get_samples(reed_table_offset, reed_table_offset_ptr, reed_table_offset_cnt);
    /* convert to normal processing when we hit final_count */
    /* we want each signal positioned at final_time */
    n = round((final_time - susp->breath_env->t0) * susp->breath_env->sr -
         (susp->breath_env->current - susp->breath_env_cnt));
    susp->breath_env_ptr += n;
    susp_took(breath_env_cnt, n);
    n = round((final_time - susp->freq_env->t0) * susp->freq_env->sr -
         (susp->freq_env->current - susp->freq_env_cnt));
    susp->freq_env_ptr += n;
    susp_took(freq_env_cnt, n);
    n = round((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr -
         (susp->reed_stiffness->current - susp->reed_stiffness_cnt));
    susp->reed_stiffness_ptr += n;
    susp_took(reed_stiffness_cnt, n);
    n = round((final_time - susp->noise_env->t0) * susp->noise_env->sr -
         (susp->noise_env->current - susp->noise_env_cnt));
    susp->noise_env_ptr += n;
    susp_took(noise_env_cnt, n);
    n = round((final_time - susp->blow_pos->t0) * susp->blow_pos->sr -
         (susp->blow_pos->current - susp->blow_pos_cnt));
    susp->blow_pos_ptr += n;
    susp_took(blow_pos_cnt, n);
    n = round((final_time - susp->reed_table_offset->t0) * susp->reed_table_offset->sr -
         (susp->reed_table_offset->current - susp->reed_table_offset_cnt));
    susp->reed_table_offset_ptr += n;
    susp_took(reed_table_offset_cnt, n);
    susp->susp.fetch = susp->susp.keep_fetch;
    (*(susp->susp.fetch))(a_susp, snd_list);
}
Example #6
0
void convolve_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
    convolve_susp_type susp = (convolve_susp_type) susp;
    time_type final_time = susp->susp.t0;
    long n;

    /* fetch samples from x_snd up to final_time for this block of zeros */
    while ((round((final_time - susp->x_snd->t0) * susp->x_snd->sr)) >=
            susp->x_snd->current)
        susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt);
    /* convert to normal processing when we hit final_count */
    /* we want each signal positioned at final_time */
    n = round((final_time - susp->x_snd->t0) * susp->x_snd->sr -
              (susp->x_snd->current - susp->x_snd_cnt));
    susp->x_snd_ptr += n;
    susp_took(x_snd_cnt, n);
    susp->susp.fetch = susp->susp.keep_fetch;
    (*(susp->susp.fetch))(a_susp, snd_list);
}
Example #7
0
void convolve_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
    convolve_susp_type susp = (convolve_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;

    sample_type *R = susp->R;
    sample_type *R_current;
    int N = susp->N;
    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;
        /* if we need output samples, generate them here */
        if (susp->R_current >= R + N) {
            /* Copy N samples of x_snd into X and zero fill to size 2N */
            int i = 0;
            sample_type *X = susp->X;
            sample_type *H = susp->H;
            int to_copy;
            while (i < N) {
                if (susp->x_snd_cnt == 0) {
                    susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt);
                    if (susp->x_snd->logical_stop_cnt ==
                            susp->x_snd->current - susp->x_snd_cnt) {
                        min_cnt(&susp->susp.log_stop_cnt, susp->x_snd,
                                (snd_susp_type) susp, susp->x_snd_cnt);
                    }
                }
                if (susp->x_snd_ptr == zero_block->samples) {
                    min_cnt(&susp->terminate_cnt, susp->x_snd,
                            (snd_susp_type) susp, susp->x_snd_cnt);
                    /* extend the output to include impulse response */
                    susp->terminate_cnt += susp->h_len;
                }
                /* copy no more than the remaining space and no more than
                 * the amount remaining in the block
                 */
                to_copy = min(N - i, susp->x_snd_cnt);
                memcpy(X + i, susp->x_snd_ptr,
                       to_copy * sizeof(*susp->x_snd_ptr));
                susp->x_snd_ptr += to_copy;
                susp->x_snd_cnt -= to_copy;
                i += to_copy;
            }
            /* zero fill to size 2N */
            memset(X + N, 0, N * sizeof(X[0]));
            /* Compute FFT of X in place */
            fftInit(susp->M);
            rffts(X, susp->M, 1);
            /* Multiply X by H (result goes into X) */
            rspectprod(X, H, X, N * 2);
            /* Compute IFFT of X in place */
            riffts(X, susp->M, 1);
            /* Shift R, zero fill, add X, all in one loop */
            for (i = 0; i < N; i++) {
                R[i] = R[i + N] + X[i];
                R[i + N] = X[i + N];
            }
            /* now N samples of R can be output */
            susp->R_current = R;
        }
        /* compute togo, the number of samples to "compute" */
        /* can't use more than what's left in R. R_current is
           the next sample of R, so what's left is N - (R - R_current) */
        R_current = susp->R_current;
        togo = min(togo, N - (R_current - R));

        /* 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 &&
                susp->susp.log_stop_cnt <= susp->susp.current + cnt + togo) {
            togo = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
            if (togo == 0) break;
        }

        n = togo;
        out_ptr_reg = out_ptr;
        if (n) do { /* the inner sample computation loop */
                *out_ptr_reg++ = (sample_type) *R_current++;
            } while (--n); /* inner loop */

        /* using R_current is a bad idea on RS/6000: */
        susp->R_current += togo;
        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;
    }
} /* convolve_s_fetch */