⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 add.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 3 页
字号:
/*    if (susp->s1_ptr == zero_block->samples) { -sep21 RBD*/    if (susp->terminate_bits & 1) {        if (susp->s2) {            s2_start = (long) ((susp->s2->t0 - susp->susp.t0) *                susp->s2->sr + 0.5);D 	    nyquist_printf("add_s_nn_fetch: s2_start %d\n", s2_start);        }        togo = 0;B       if (togo == 0) stdputstr("togo is zero at checkpoint 2\n");        if (susp->s2 && susp->susp.current == s2_start) {            /* s2 starting and s1 stops */            /* go to s2 alone state */            sound_unref(susp->s1);            susp->s1 = NULL;            susp->susp.fetch = add_s2_nn_fetch;D            stdputstr("add_s_nn_fetch: other installed, calling now...\n");            add_s2_nn_fetch(susp, snd_list);        } else if (susp->s2 && susp->susp.current < s2_start) {            /* s2 not started and s1 stops */            /* go to zero-fill state */            sound_unref(susp->s1);            susp->s1 = NULL;            susp->susp.fetch = add_zero_fill_nn_fetch;B           stdputstr("add_s_nn_fetch: zero_fill installed\n");            add_zero_fill_nn_fetch(susp, snd_list);        } else if (susp->s2) {D	    stdputstr("add_s_nn_fetch: unexpected condition\n");            EXIT(1);        } else /* no s2 */ {            snd_list_terminate(snd_list);        }D	nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp);        return; /* fetching taken care of by another routine */    }/*    if (susp->terminate_cnt != UNKNOWN &&        susp->terminate_cnt <= susp->susp.current + togo) {        togo = susp->terminate_cnt - susp->susp.current;    } */    /* 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;        if (to_stop < togo) {            if (to_stop == 0) {                susp->logically_stopped = true;            } else togo = to_stop;        }B       if (togo == 0) stdputstr("togo is zero at checkpoint 3\n");D	nyquist_printf("add_s1_nn_fetch: to_stop %d togo %d\n", to_stop, togo);    }    /* consider other signal? don't run past its start time... */    if (susp->s2) {        s2_start = ROUND((susp->s2->t0 - susp->susp.t0) *            susp->s2->sr);        if (s2_start < susp->susp.current + togo)            togo = MIN(togo, s2_start - susp->susp.current);B           if (togo == 0) stdputstr("togo is zero at checkpoint 4\n");    }    /*     * two cases: copy a partial block or manipulate pointers for     * copyless transfer of whole block (may not be full block):     *     * copy partial block when:     *   o samples begin in middle of block     *   o stopping time is before end of block (when other signal     *     splits the block for this signal)     * transfer (copyless) block when:     *   o the block is of maximum size     *   o the block is small due to logical stop time or termination     *     time     */    if (susp->s1_ptr == susp->s1_bptr->samples &&        susp->s1_cnt == togo) {        /*         * we want to copy this whole block (starting at the beginning         * and going to the rest of the block) -- just do pointers.         */        /* just fetch and pass blocks on */        if (0) nyquist_printf("add[%p,%p] (s%d_nn) %p starting uncopy, togo %d\n", susp->s1, susp->s2,               1, susp, togo);        snd_list->block = susp->s1_bptr;        (susp->s1_bptr->refcnt)++;        if (0) nyquist_printf("add[%p,%p] (s%d_nn) %p shared block %p zero_block %p\n",susp->s1, susp->s2,               1, susp, susp->s1_bptr, zero_block);        susp_took(s1_cnt, togo);        snd_list->block_len = togo;        /* if other is terminated and sound_types match, collapse */        /* NOTE: in order to collapse, we need s2 to be generating         * blocks and linking them onto a sound list.  This is true         * when the get_next fn is SND_get_next.  (A counterexample is         * SND_get_zeros, which returns zero blocks but does not link         * them onto the sound list.         */        if (0) nyquist_printf("s2 %p thissr %g suspsr %g get_next %d lsc %d\n",                susp->s2, susp->s1->sr, susp->susp.sr,                susp->s1->get_next == SND_get_next,                susp->s1->logical_stop_cnt == UNKNOWN);        if (susp->s2 == NULL && susp->s1->sr == susp->susp.sr &&            susp->s1->get_next == SND_get_next &&            susp->s1->logical_stop_cnt == UNKNOWN) {            snd_list_type addend_list;D	    nyquist_printf("add[%p,%p]: collapsing! LSC %d\n", susp->s1, susp->s2,                      (int)susp->s1->logical_stop_cnt);D	    sound_print_tree(susp->s1);            /* will "current" values match? */            /* 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;            }            /* free the superfluous sound_type and susp */            addend_list = susp->s1->list->u.next;            snd_list_ref(addend_list);            snd_list_unref(snd_list->u.next);            snd_list->u.next = addend_list;            return;        }    } else {        /*         * we want to copy a partial block         */        /* assume the snd_list is the one with a null block */        /*         * put a fresh, clean block in the snd_list         * (get new snd_list later)         */        falloc_sample_block(out, "add_s1_nn_fetch");        snd_list->block = out;        out_ptr = out->samples;B        nyquist_printf("add[%p,%p] (s1_nn) %p new block %p, s1_ptr %p block %p s1_cnt %d togo %d\n", susp->s1, susp->s2, susp, out, susp->s1_ptr, susp->s1_bptr->samples, (int)susp->s1_cnt, togo);        n = togo;B       if (togo == 0) stdputstr("togo is zero at checkpoint 5\n");B	if (togo == 0) nyquist_printf(        "add[%p,%p] (s%d_nn) %p starting copy loop, togo %d\n",               susp->s1, susp->s2, 1, susp, togo);        while (n--) { /* the inner sample computation loop */            /* scale? */            *out_ptr++ = *(susp->s1_ptr++);        } /* inner loop */        susp_took(s1_cnt, togo);        snd_list->block_len = togo;    }    /* add a new snd_list for the susp */    susp->susp.current += togo;D   stdputstr("testing...");    /*     * test for termination or change of state,     * note s2_start computed earlier     */    if (susp->s2 && susp->susp.current == s2_start &&        susp->s1->list != zero_snd_list) {        /* s2 starting and s1 continues */        /* go to s1+s2 state */        susp->susp.fetch = add_s1_s2_nn_fetch;D        stdputstr("add_s_nn_fetch: add_s1_s2_fetch installed\n");    } else if (susp->terminate_bits == 3) {        /* s2 finished and s1 stops */        /* go to terminal state */        susp->s1 = NULL;D        nyquist_printf("add_s_nn_fetch: go to terminal state.  susp->s2 %p, \               susp->susp.current %d, s2_start %d, susp->s1->list %p, \               zero_snd_list %p\n", susp->s2, (int)susp->susp.current,               s2_start, susp->s1->list, zero_snd_list);        /* !!! free resources and set up pointers to terminal snd_list */        /* !!! logically stopped? */    }    /* test for logical stop */    if (susp->logically_stopped) {D        stdputstr("add_s_nn_fetch: snd_list->logically_stopped\n");        snd_list->logically_stopped = true;    } else if (susp->susp.log_stop_cnt == susp->susp.current) {D        stdputstr("add_s_nn_fetch: susp->logically_stopped\n");        susp->logically_stopped = true;    }D    {        if (susp->logically_stopped || snd_list->logically_stopped)             stdputstr("STOPPED\n");        else nyquist_printf("ok: current %d\n", (int)susp->susp.current); }}void add_s2_nn_fetch(susp, snd_list)  register add_susp_type susp;  snd_list_type snd_list;{    int togo, s1_start=0;    int n;    sample_block_type out;    register sample_block_values_type out_ptr;D   nyquist_printf("add_s2_nn_fetch(susp %p, snd_list %p)\n",           susp, snd_list);#ifdef GC_DEBUG    snd_list_report(snd_list, "add_s2_nn_fetch");#endif    /*     * first compute how many samples to copy (or transfer)     */    /* see what the next samples look like */    susp_check_term_log_block_samples(s2, s2_bptr,                                      s2_ptr, s2_cnt, 2, 3);    /* don't run past the s2 input sample block: */    togo = susp->s2_cnt;    /* don't run past terminate time of this signal */    /* if (susp->s2_ptr == zero_block->samples) { -sep21 RBD*/    if (susp->terminate_bits & 2) {        if (susp->s1) {            s1_start = ROUND((susp->s1->t0 - susp->susp.t0) *                susp->s1->sr);             if (0) nyquist_printf("add_s_nn_fetch: s1_start %d\n", s1_start);        }        togo = 0;        if (susp->s1 && susp->susp.current == s1_start) {            /* s1 starting and s2 stops */            /* go to s1 alone state */            sound_unref(susp->s2);            susp->s2 = NULL;            susp->susp.fetch = add_s1_nn_fetch;D            stdputstr("add_s_nn_fetch: other installed, calling now...\n");            add_s1_nn_fetch(susp, snd_list);        } else if (susp->s1 && susp->susp.current < s1_start) {            /* s1 not started and s2 stops */            /* go to zero-fill state */            sound_unref(susp->s2);            susp->s2 = NULL;            susp->susp.fetch = add_zero_fill_nn_fetch;D            stdputstr("add_s_nn_fetch: zero_fill installed\n");            add_zero_fill_nn_fetch(susp, snd_list);        } else if (susp->s1) {D	    stdputstr("add_s_nn_fetch: unexpected condition\n");            EXIT(1);        } else /* no s1 */ {            snd_list_terminate(snd_list);        }D	nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp);        return; /* fetching taken care of by another routine */    }/*    if (susp->terminate_cnt != UNKNOWN &&        susp->terminate_cnt <= susp->susp.current + togo) {        togo = susp->terminate_cnt - susp->susp.current;    } */    /* 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;        if (to_stop < togo) {            if (to_stop == 0) {                susp->logically_stopped = true;            } else togo = to_stop;        }B       if (togo == 0) stdputstr("togo is zero at checkpoint 3\n");D	nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo);    }    /* consider other signal? don't run past its start time... */    if (susp->s1) {        s1_start = ROUND((susp->s1->t0 - susp->susp.t0) *            susp->s1->sr);        if (s1_start < susp->susp.current + togo)            togo = MIN(togo, s1_start - susp->susp.current);    }    /*     * two cases: copy a partial block or manipulate pointers for     * copyless transfer of whole block (may not be full block):     *     * copy partial block when:     *   o samples begin in middle of block     *   o stopping time is before end of block (when other signal     *     splits the block for this signal)     * transfer (copyless) block when:     *   o the block is of maximum size     *   o the block is small due to logical stop time or termination     *     time     */    if (susp->s2_ptr == susp->s2_bptr->samples &&        susp->s2_cnt == togo) {        /*         * we want to copy this whole block (starting at the beginning

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -