summaryrefslogtreecommitdiff
path: root/tran/congen.alg
diff options
context:
space:
mode:
Diffstat (limited to 'tran/congen.alg')
-rw-r--r--tran/congen.alg17
1 files changed, 17 insertions, 0 deletions
diff --git a/tran/congen.alg b/tran/congen.alg
new file mode 100644
index 0000000..9ff02d2
--- /dev/null
+++ b/tran/congen.alg
@@ -0,0 +1,17 @@
+(CONGEN
+(NAME "congen")
+(ARGUMENTS ("sound_type" "sndin") ("double" "risetime") ("double" "falltime"))
+(START (MIN sndin))
+(STATE ("double" "value" "0")
+ ("double" "rise_factor" "exp(log(0.5) / (sndin->sr * risetime))")
+ ("double" "fall_factor" "exp(log(0.5) / (sndin->sr * falltime))"))
+(CONSTANT "fall_factor" "rise_factor")
+(ALWAYS-SCALE sndin)
+(TERMINATE (MIN sndin))
+(INNER-LOOP " sample_type current = sndin;
+ if (current > value) {
+ value = current - (current - value) * rise_factor;
+ } else {
+ value = current - (current - value) * fall_factor;
+ }
+ output = (sample_type) value;"))