File: shape.alg

package info (click to toggle)
nyquist 3.24%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 58,156 kB
  • sloc: ansic: 74,757; lisp: 18,169; java: 10,942; cpp: 6,688; sh: 175; xml: 58; makefile: 40; python: 15
file content (37 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (12)
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
(SHAPE-ALG
        (NAME "shape") 
        (ARGUMENTS ("sound_type" "sin") ("sound_type" "fn") 
                   ("double" "origin"))
        (START (MIN sin))       
        (TABLE "fn")
        (NOT-IN-INNER-LOOP "fn")
        (STATE 
               ("double" "time_to_index" "fn->sr")
               ("double" "origin" "origin")
               ("table_type" "the_table" "sound_to_table(fn)")
               ("sample_type *" "fcn_table" "susp->the_table->samples")         
               ("double" "table_len" "susp->the_table->length") )
        (TERMINATE (MIN sin))
        (LOGICAL-STOP (MIN sin))
        (INNER-LOOP "register double offset, x1;
            register long table_index;
            register double phase = sin;
            if (phase > 1.0) phase = 1.0;
            else if (phase < -1.0) phase = -1.0;
            offset = (phase + origin) * time_to_index;
            table_index = (long) offset;
            if (table_index < 0) { 
                table_index = 0; 
                offset = 0;
            }
            if (table_index >= table_len) {
                offset = table_len - 1;
                table_index = (long) offset;
            }
            x1 = fcn_table[table_index];
            output = (sample_type) (x1 + (offset - table_index) * 
                     (fcn_table[table_index + 1] - x1))")
        (ALWAYS-SCALE sin)
        (CONSTANT "table_len" "time_to_index" "origen" "fcn_table" "the_table")
        (FINALIZATION "table_unref(susp->the_table);\n")
)