Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Jul 13, 2020
1 parent c3cdf03 commit 7708c7b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 37 deletions.
32 changes: 20 additions & 12 deletions basics.lib
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare version "0.1";
//
// * `n`: number of samples
//----------------------------
samp2sec = /(ma.SR);
samp2sec(n) = n/ma.SR;


//-------`(ba.)sec2samp`----------
Expand All @@ -89,7 +89,7 @@ samp2sec = /(ma.SR);
//
// * `d`: duration in seconds
//----------------------------
sec2samp = *(ma.SR);
sec2samp(d) = d*ma.SR;


//-------`(ba.)db2linear`----------
Expand Down Expand Up @@ -123,7 +123,7 @@ db2linear(l) = pow(10, l/20.0);
//
// * `g`: a linear gain
//-----------------------------
linear2db(g) = 20*log10(g);
linear2db(g) = 20.0*log10(g);


//----------`(ba.)lin2LogGain`------------------
Expand Down Expand Up @@ -1025,8 +1025,8 @@ listInterp(v) =


//-------------------`(ba.)bypass1`-------------------------
// Takes a mono input signal, route it to `e` and bypass it if `bpc = 1`. When bypassed, `e` is feed with zeros
// so that its state is cleanup up.
// Takes a mono input signal, route it to `e` and bypass it if `bpc = 1`.
// When bypassed, `e` is feed with zeros so that its state is cleanup up.
// `bypass1` is a standard Faust function.
//
// #### Usage
Expand All @@ -1049,8 +1049,8 @@ with {


//-------------------`(ba.)bypass2`-------------------------
// Takes a stereo input signal, route it to `e` and bypass it if `bpc = 1`. When bypassed, `e` is feed with zeros
// so that its state is cleanup up.
// Takes a stereo input signal, route it to `e` and bypass it if `bpc = 1`.
// When bypassed, `e` is feed with zeros so that its state is cleanup up.
// `bypass2` is a standard Faust function.
//
// #### Usage
Expand Down Expand Up @@ -1098,9 +1098,11 @@ with {


//-------------------`(ba.)bypass_fade`-------------------------
// Bypass an arbitrary (N x N) circuit with 'n' samples crossfade. Inputs and outputs signals are faded
// out when 'e' is bypassed, so that 'e' state is cleanup up.
// Once bypassed the effect is replaced by par(i,N,_). Bypassed circuits can be chained.
// Bypass an arbitrary (N x N) circuit with 'n' samples crossfade.
// Inputs and outputs signals are faded out when 'e' is bypassed,
// so that 'e' state is cleanup up.
// Once bypassed the effect is replaced by par(i,N,_).
// Bypassed circuits can be chained.
//
// #### Usage
//
Expand Down Expand Up @@ -1451,6 +1453,7 @@ with {
int2nrOfBits(maxN) = int(floor(log(maxN)/log(2))+1);
};


//------------------------------`(ba.)slidingSum`------------------------------
// The sliding sum of the last n input samples.
//
Expand All @@ -1469,6 +1472,7 @@ with {
//------------------------------------------------------------------------------
slidingSum(n) = fi.integrator <: _, _@int(max(0,n)) :> -;


//------------------------------`(ba.)slidingSump`------------------------------
// The sliding sum of the last n input samples.
//
Expand Down Expand Up @@ -1504,6 +1508,7 @@ slidingSump(n,maxn) = slidingReduce(+,n,maxn,0);
//------------------------------------------------------------------------------
slidingMax(n,maxn) = slidingReduce(max,n,maxn,-(ma.INFINITY));


//----------------------------`(ba.)slidingMin`--------------------------------
// The sliding minimum of the last n input samples.
//
Expand Down Expand Up @@ -1538,6 +1543,7 @@ slidingMin(n,maxn) = slidingReduce(min,n,maxn,ma.INFINITY);
//------------------------------------------------------------------------------
slidingMean(n) = slidingSum(n)/n;


//----------------------------`(ba.)slidingMeanp`-------------------------------
// The sliding mean of the last n input samples.
//
Expand Down Expand Up @@ -1574,7 +1580,8 @@ slidingMeanp(n,maxn) = slidingSump(n,maxn)/n;
//
// * `N`: the number of values to process
//------------------------------------------------------------------------------
slidingRMS(n) = pow(2):slidingMean(n) : sqrt;
slidingRMS(n) = pow(2) : slidingMean(n) : sqrt;


//---------------------------`(ba.)slidingRMSp`---------------------------------
// The root mean square of the last n input samples.
Expand All @@ -1592,7 +1599,8 @@ slidingRMS(n) = pow(2):slidingMean(n) : sqrt;
// * `N`: the number of values to process
// * `maxN`: the maximum number of values to process, needs to be a power of 2
//------------------------------------------------------------------------------
slidingRMSp(n,maxn) = pow(2):slidingMeanp(n,maxn) : sqrt;
slidingRMSp(n,maxn) = pow(2) : slidingMeanp(n,maxn) : sqrt;


//////////////////////////////////Deprecated Functions////////////////////////////////////
// This section implements functions that used to be in music.lib but that are now
Expand Down
26 changes: 13 additions & 13 deletions delays.lib
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,16 @@ with {
// considered as "deprecated".
//////////////////////////////////////////////////////////////////////////////////////////

delay1s(d) = delay(65536,d);
delay2s(d) = delay(131072,d);
delay5s(d) = delay(262144,d);
delay10s(d) = delay(524288,d);
delay21s(d) = delay(1048576,d);
delay43s(d) = delay(2097152,d);

fdelay1s(d) = fdelay(65536,d);
fdelay2s(d) = fdelay(131072,d);
fdelay5s(d) = fdelay(262144,d);
fdelay10s(d) = fdelay(524288,d);
fdelay21s(d) = fdelay(1048576,d);
fdelay43s(d) = fdelay(2097152,d);
delay1s(d) = delay(65536,d);
delay2s(d) = delay(131072,d);
delay5s(d) = delay(262144,d);
delay10s(d) = delay(524288,d);
delay21s(d) = delay(1048576,d);
delay43s(d) = delay(2097152,d);

fdelay1s(d) = fdelay(65536,d);
fdelay2s(d) = fdelay(131072,d);
fdelay5s(d) = fdelay(262144,d);
fdelay10s(d) = fdelay(524288,d);
fdelay21s(d) = fdelay(1048576,d);
fdelay43s(d) = fdelay(2097152,d);
2 changes: 1 addition & 1 deletion interpolators.lib
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ interpolate_cosine(dv,v0,v1) = v0 + a2*(v1-v0) with { a2 = 0.5 * (1.0 - cos(dv*m
//--------------------------------------------

interpolate_cubic(dv,v0,v1,v2,v3)
= v1 + 0.5 *dv*(v2 - v0 + dv*(2.0*v0 - 5.0*v1 + 4.0*v2 - v3 + dv*(3.0*(v1 - v2) + v3 - v0)));
= v1 + 0.5*dv*(v2 - v0 + dv*(2.0*v0 - 5.0*v1 + 4.0*v2 - v3 + dv*(3.0*(v1 - v2) + v3 - v0)));


//=========================Two points interpolators=======================================
Expand Down
16 changes: 8 additions & 8 deletions oscillators.lib
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ with {
// Author: Christophe Lebreton
hsp_phasor(tablesize,freq,p,c) = inc : (+ : d)~(-(_<:(_,*(_,clk))):+(clk*p)) : *(tablesize)
with {
clk = c>0;
d = ma.decimal;
inc = freq/float(ma.SR);
clk = c>0;
d = ma.decimal;
inc = freq/float(ma.SR);
};

//-----------------------`(os.)oscsin`------------------------
Expand Down Expand Up @@ -198,7 +198,7 @@ with {
//
// * `freq`: the frequency of the wave (Hz)
//------------------------------------------------------------
osccos(freq) = rdtable(tablesize, coswaveform(tablesize), int(phasor(tablesize,freq)) )
osccos(freq) = rdtable(tablesize, coswaveform(tablesize), int(phasor(tablesize,freq)))
with {
tablesize = pl.tablesize;
};
Expand All @@ -209,15 +209,15 @@ with {
// #### Usage
//
// ```
// oscp(freq,p) : _
// oscp(freq,phase) : _
// ```
//
// Where:
//
// * `freq`: the frequency of the wave (Hz)
// * `p`: the phase in radian
// * `phase`: the phase in radian
//------------------------------------------------------------
oscp(freq,p) = oscsin(freq) * cos(p) + osccos(freq) * sin(p);
oscp(freq,phase) = oscsin(freq) * cos(phase) + osccos(freq) * sin(phase);

//-----------------------`(os.)osci`------------------------
// Interpolated phase sine wave oscillator.
Expand Down Expand Up @@ -422,8 +422,8 @@ lf_rawsaw(periodsamps) = (_,periodsamps : fmod) ~ +(1.0);
//
// Where:
//
// * `freq`: frequency
// * `phase`: phase
// * `freq`: frequency
//---------------------------------------------------------
lf_sawpos_phase(phase,freq) = (+(phase-phase') : ma.frac) ~ +(freq/ma.SR);

Expand Down
2 changes: 1 addition & 1 deletion version.lib
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//------------------------------------------------------------
version = 1, // MAJOR version when we make incompatible API changes,
2, // MINOR version when we add functionality in a backwards compatible manner,
0; // PATCH version when we make backwards compatible bug fixes.
1; // PATCH version when we make backwards compatible bug fixes.


4 changes: 2 additions & 2 deletions webaudio.lib
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ declare license "LGPL with exception";
ma = library("maths.lib");
fi = library("filters.lib");

//----------------------------------------
//---------------------------------------------------
// biquad coeffs for various filters
// usage : BiquadFilter(f0, dBgain, Q, aDetune).xxx
//----------------------------------------
//---------------------------------------------------

BiquadFilter(f0, dBgain, Q, aDetune) = environment
{
Expand Down

0 comments on commit 7708c7b

Please sign in to comment.