File: fmosc.alg

package info (click to toggle)
audacity 1.2.4b-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,136 kB
  • ctags: 20,445
  • sloc: ansic: 139,567; cpp: 55,998; sh: 24,963; lisp: 3,772; makefile: 1,683; python: 272
file content (39 lines) | stat: -rw-r--r-- 1,482 bytes parent folder | download | duplicates (10)
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
(FMOSC-ALG
(NAME "fmosc")
(ARGUMENTS ("sound_type" "s") ("double" "step") ("rate_type" "sr")
           ("double" "hz") ("time_type" "t0") ("sound_type" "s_fm")
           ("double" "phase"))
(TABLE "s")
(NOT-IN-INNER-LOOP "s")
(STATE ("table_type" "the_table" "sound_to_table(s)")
       ("double" "table_len" "susp->the_table->length")
       ("double" "ph_incr" "0")
       ("sample_type *" "table_ptr" "susp->the_table->samples")
       ("double" "phase" "compute_phase(phase, step, (long) susp->table_len,
        s->sr, sr, hz, &susp->ph_incr);
    s_fm->scale *= hz != 0 ? (sample_type) (susp->ph_incr / hz)
                                                   : s->sr / (sr * step_to_hz(step))") ) ; cancel 0/0

(ALWAYS-SCALE s_fm)
(INLINE-INTERPOLATION T) ; so that modulation can be low frequency
(STEP-FUNCTION s_fm)
(TERMINATE (MIN s_fm))
(LOGICAL-STOP (MIN s_fm))
(INNER-LOOP-LOCALS "	    long table_index;
            double x1;
")
(INNER-LOOP "table_index = (long) phase;
            x1 = table_ptr[table_index];
            output = (sample_type) (x1 + (phase - table_index) * 
                          (table_ptr[table_index + 1] - x1));
            phase += ph_incr + s_fm;
            while (phase > table_len) phase -= table_len;
            /* watch out for negative frequencies! */
            while (phase < 0) phase += table_len")
(CONSTANT "ph_incr" "table_len" "table_ptr" "table")

(SAMPLE-RATE "sr")
(FINALIZATION "    table_unref(susp->the_table);
")
)