forked from s-e-a-m/faust-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seam.lib
134 lines (121 loc) · 7.01 KB
/
seam.lib
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//################################################################# seam.lib ###
//
// The SEAM main library.
//
// * BASIC FUNCTIONS
// * MATH
// * UNDER FINGERS VARIABLES
//
//##############################################################################
/*******************************************************************************
Except where noted otherwise, Copyright (C) 2019-2020 by SEAM
GRAME LICENSE
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a larger
FAUST program which directly or indirectly imports this library file and still
distribute the compiled code generated by the FAUST compiler, or a modified
version of this compiled code, under your own copyright and license. This
EXCEPTION TO THE LGPL LICENSE explicitly grants you the right to freely choose
the license for the resulting compiled code. In particular the resulting compiled
code has no obligation to be LGPL or GPL. For example you are free to choose a
commercial or closed source license or any other license if you decide so.
*******************************************************************************/
declare name "Faust SEAM main lib";
declare version "0.2";
declare author "Giuseppe Silvi";
declare author "Davide Tedesco";
declare license "CC4";
import("ambisonic.lib");
import("csound.lib");
import("cyclone.lib");
import("gerzon.lib");
import("hardware.lib");
import("measurement.lib");
import("nono.lib");
import("nottoli.lib");
import("stereophony.lib");
import("vcs3.lib");
//========================================================== BASIC FUNCTIONS ===
//==============================================================================
//----------------------------------------------- LINEAR SWEEP UP TO NYQUIST ---
lsweep = ba.sweep((ma.SR/2)-1,1);
//----------------------------------------- ONE SAMPLE PULSE @ ZERO CROSSING ---
zerox(x) = (x'<0) & (x>=0);//(x<0) | (x>0);
//process = os.lf_saw(100) <: _,zerox;
//===================================================================== MATH ===
//==============================================================================
//------------------------------------------------------------- SPEEDOFSOUND ---
speedofsound = 344; // m/s
//----------------------------------------------------------------------- PI ---
//----------------------------------------------------------- QUAD PRECISION ---
//--- 81 decimals
PIq = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998;
//------------------------------------------------------- DEGREES TO RADIANS ---
d2r = *(PIq/180);
//------------------------------------------------------- RADIANS TO DEGREES ---
r2d = /(PIq*180);
//------------------------------------------------------- BILINEAR TRANSFORM ---
g(fc) = tan(PIq*(fc/ma.SR));
//---------------------------------------------------- -3dB Cutoff Frequency ---
//----------------------------------------------- of an Exponential Averager ---
// https://www.dsprelated.com/showarticle/182.php
a(fc) = cos((2*PIq*fc)/ma.SR)-1+sqrt((0.5*(1+cos(2*((2*PIq*fc)/ma.SR))))-4*cos((2*PIq*fc)/ma.SR)+3);
//------------------------------------------------------ MILLER PUCKETTE T60 ---
// Next comes the recirculating part of the reverberator. After the initial
// thickening, the input signal is fed into a bank of parallel delay lines,
// and their outputs are again mixed using a rotation matrix. The mixed outputs
// are attenuated by a gain g ≤ 1, and fed back into the delay lines to make a
// recirculating network.
// The value g controls the reverberation time. If the average length of the
// recirculating delay lines is d, then any incoming sound is attenuated by a
// factor of g after a time delay of d. After time t the signal has recirculated
// t/d times, losing 20log10(g) decibels each time around, so the total gain,
// in decibels, is:
RT(g,d) = (-3*d)/(log10(g));
t60(RT,d,g) = 20*(RT/d)*log10(g);
//----------------------------------------------------- EUGENIO GIORDANI T60 ---
t60(g,d) = -3/(log10(1/g))*d;
t60(g,d) = 1/((3/(log10(1/g)))*(d)) : ba.sec2samp;
//g(t60) = pow;
// T60 = [60 / (-20 log g)] τ, da cui si trae:
// T60 = (3/log(1/g)) τ (1.6)
// g = 10^ (-3 τ / T60)
//--------------------------------------------------------- SC SCALE LINENAR ---
scalin(a,b,c,d,x) = ((x-a)/b-a))*(d-c);
//----------------------------------------------------- SC SCALE EXPONENTIAL ---
scalexp(a,b,c,d,x) = c*((d/c)^((x-a)/b-a));
//================================================================== FILTERS ===
//==============================================================================
//------------------------------------------ COMPUTER MUSIC TUTORIAL ALLPASS ---
cmtap(D,g) = (+ <: de.delay((ma.SR/2),int(D-1)),*(-g)) ~ *(g) : +;
cmtapm(D,g) = (+ <: de.delay((ma.SR/2),int(D-1)),*(-g)) ~ *(g) : mem,_ : +;
//================================================== UNDER FINGERS VARIABLES ===
//==============================================================================
//------------------------------------------------------------------ RADIANS --–
// Radians expressed by degrees from -180 (sx) to 180 (dx) by decimal steps
//------------------------------------------------------------------------------
rad = vslider("[02]Azimuth[style:knob]",0,-180,180,0.1) : deg2rad : si.smoo;
//------------------------------------------------------------------ RADIANS --–
// Radians expressed by degrees from -180 (sx) to 180 (dx) by decimal steps
//------------------------------------------------------------------------------
frontrad = vslider("[02]Frontal Azimuth[style:knob]",0,-45,45,0.1) : deg2rad : si.smoo;
//----------------------------------------------------------------- P FACTOR --–
// P coefficient slider from 0 to 1 by centesimal steps
//------------------------------------------------------------------------------
p = vslider("[01]P[style:knob]", 0.5, 0, 1, 0.01) : si.smoo;
//==================================================================== LOGIC ===
//==============================================================================
//-------------------------------------------- INPUT CHANNEL GENERIC CONTROL ---
//-------------------------------------------- SELECT THE HARDWARE INTERFACE ---
chstrip = vgroup("[01] INPUT CHANNEL", ff800 : inpeq);
lrstrip = vgroup("[01] STEREO INPUT CHANNEL", ff800_ST : inpeq, inpeq);
wxyzrip = vgroup("[01] B-FORMAT INPUT CHANNEL", ff800_WXYZ : inpeq, inpeq, inpeq, inpeq);