File: exprel.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 (50 lines) | stat: -rw-r--r-- 1,643 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
40
41
42
43
44
45
46
47
48
49
50
;; this is the beginnings of a new function that just passes input to output until
;; a given "release time" at which point the output decays exponentially to zero.
;; this is hard to do in Nyquist without a new primitive because the amplitude of
;; the exponential decay depends on the value of the input at some given time.
;; (Yes, you can evaluate that point, but then you have to compute all the samples,
;; and they will be held in memory, which might not be a good thing.)

(EXPREL-ALG
(NAME "exprel")
(ARGUMENTS ("sound_type" "signal") ("time_type" "release_time") ("double" "fall_time"))
(SUPPORT-FUNCTIONS "#define ST_HOLD 0
#define ST_FALL 1
#define ST_FALL_UNTIL 2
#define ST_OFF 3
#define ST_OFF_UNTIL 4
#define ST_RISE 5

/* Overview:
This operation passes its input to its output until the release time. Then, it takes
the last sample output as a starting point for an exponential decay, with a duration
of falltime.
*/

")
(STATE 
       ("long" "release_time" "signal->sr * release_time + 0.5")
       ("double" "fall_time" "signal->sr * falltime + 0.5")
       ("sample_type" "value" "0")
       ("bool" "falling" "0"))
(TERMINATE (MIN signal))
(LOGICAL-STOP "release_time")
(LINEAR signal)
(INNER-LOOP "{
        sample_type result;
        if (falling) {
            value = value * decay;
            result = value;
        } else {
            result = signal;
            if (release_time <= susp->susp.current + cnt + togo - n) {
                value = result;
                falling = 1;
            }
        }
        output = (sample_type) value;
      }")
)

need to do logical stop time and termination time