diff --git a/basics.lib b/basics.lib index 200fb107..c16db574 100644 --- a/basics.lib +++ b/basics.lib @@ -72,7 +72,7 @@ declare version "0.1"; // // * `n`: number of samples //---------------------------- -samp2sec = /(ma.SR); +samp2sec(n) = n/ma.SR; //-------`(ba.)sec2samp`---------- @@ -89,7 +89,7 @@ samp2sec = /(ma.SR); // // * `d`: duration in seconds //---------------------------- -sec2samp = *(ma.SR); +sec2samp(d) = d*ma.SR; //-------`(ba.)db2linear`---------- @@ -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`------------------ @@ -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 @@ -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 @@ -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 // @@ -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. // @@ -1469,6 +1472,7 @@ with { //------------------------------------------------------------------------------ slidingSum(n) = fi.integrator <: _, _@int(max(0,n)) :> -; + //------------------------------`(ba.)slidingSump`------------------------------ // The sliding sum of the last n input samples. // @@ -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. // @@ -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. // @@ -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. @@ -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 diff --git a/delays.lib b/delays.lib index 0597fc2b..4801ae5a 100644 --- a/delays.lib +++ b/delays.lib @@ -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); diff --git a/interpolators.lib b/interpolators.lib index b3ffbfdc..a4f970a0 100644 --- a/interpolators.lib +++ b/interpolators.lib @@ -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======================================= diff --git a/oscillators.lib b/oscillators.lib index 6f9b33a6..2debb374 100644 --- a/oscillators.lib +++ b/oscillators.lib @@ -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`------------------------ @@ -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; }; @@ -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. @@ -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); diff --git a/version.lib b/version.lib index f8366638..94ac218b 100644 --- a/version.lib +++ b/version.lib @@ -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. diff --git a/webaudio.lib b/webaudio.lib index 28d459ec..cf34c6cf 100644 --- a/webaudio.lib +++ b/webaudio.lib @@ -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 {