File: tapf.alg

package info (click to toggle)
audacity 2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 129,312 kB
  • sloc: ansic: 373,350; cpp: 276,880; sh: 56,060; python: 18,922; makefile: 10,309; lisp: 8,365; xml: 1,888; perl: 1,798; java: 1,551; asm: 545; pascal: 395; sed: 58; awk: 35
file content (46 lines) | stat: -rw-r--r-- 1,812 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(TAPF-ALG
(NAME "tapf")
(ARGUMENTS ("sound_type" "s1") ("double" "offset") ("sound_type" "vardelay")
           ("double" "maxdelay"))
(STEP-FUNCTION "vardelay")
(INTERNAL-SCALING vardelay)
;(ALWAYS-SCALE s1)
(START (MAX s1 vardelay))
(TERMINATE (MIN s1 vardelay))
(LOGICAL-STOP (MIN s1))
(STATE ("double" "offset" "offset * s1->sr")
       ("double" "vdscale" "vardelay->scale * s1->sr")
       ("long" "maxdelay" "(long)(maxdelay * s1->sr)")
       ("long" "bufflen" "max(2, (long) (susp->maxdelay + 0.5))")
       ("long" "index" "susp->bufflen")
       ("sample_type *" "buffer" 
        "(sample_type *) calloc(susp->bufflen + 1, sizeof(sample_type))"))
(SAMPLE-RATE (MAX s1))
(CONSTANT "maxdelay" "offset" "vdscale" "buffer")
(INNER-LOOP-LOCALS "            long phase;
")
(INNER-LOOP "phase = (long) (vardelay * vdscale + offset);
            /* now phase should give number of samples of delay */
            if (phase < 0) phase = 0;
            else if (phase > maxdelay) phase = maxdelay;
            phase = index - phase;
            /* now phase is a location in the buffer (before modulo) */
    
            /* Time out to update the buffer:
             * this is a tricky buffer: buffer[0] == buffer[bufflen]
             * the logical length is bufflen, but the actual length
             * is bufflen + 1 to allow for a repeated sample at the
             * end. This allows for efficient interpolation.
             */ 
            buffer[index++] = s1;
            if (index >= bufflen) {
                index = 0;
            }
    
            /* back to the phase calculation: 
             * use conditional instead of modulo
             */
            if (phase < 0) phase += bufflen;
            output = (sample_type) (buffer[phase])")
(FINALIZATION "    free(susp->buffer);\n")
)