-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move 'Averaging Functions' from maths.lib to filters.lib, cleanup.
- Loading branch information
Showing
6 changed files
with
129 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ declare abs_envelope_rect copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare abs_envelope_rect license "MIT-style STK-4.3 license"; | ||
abs_envelope_rect(period, x) = abs(x) : ma.avg_rect(period); | ||
abs_envelope_rect(period, x) = abs(x) : fi.avg_rect(period); | ||
|
||
|
||
|
||
|
@@ -70,7 +70,7 @@ declare abs_envelope_tau copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare abs_envelope_tau license "MIT-style STK-4.3 license"; | ||
abs_envelope_tau(period, x) = abs(x) : ma.avg_tau(period); | ||
abs_envelope_tau(period, x) = abs(x) : fi.avg_tau(period); | ||
|
||
|
||
//------------------`(an.)abs_envelope_t60`------------------------------------ | ||
|
@@ -92,7 +92,7 @@ declare abs_envelope_t60 copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare abs_envelope_t60 license "MIT-style STK-4.3 license"; | ||
abs_envelope_t60(period, x) = abs(x) : ma.avg_t60(period); | ||
abs_envelope_t60(period, x) = abs(x) : fi.avg_t60(period); | ||
|
||
|
||
//------------------`(an.)abs_envelope_t19`------------------------------------ | ||
|
@@ -114,7 +114,7 @@ declare abs_envelope_t19 copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare abs_envelope_t19 license "MIT-style STK-4.3 license"; | ||
abs_envelope_t19(period, x) = abs(x) : ma.avg_t19(period); | ||
abs_envelope_t19(period, x) = abs(x) : fi.avg_t19(period); | ||
|
||
|
||
//---------------------------`(an.)amp_follower`--------------------------- | ||
|
@@ -210,7 +210,7 @@ declare ms_envelope_rect copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare ms_envelope_rect license "MIT-style STK-4.3 license"; | ||
ms_envelope_rect(period, x) = x * x : ma.avg_rect(period); | ||
ms_envelope_rect(period, x) = x * x : fi.avg_rect(period); | ||
|
||
|
||
//------------------`(an.)ms_envelope_tau`------------------------------------- | ||
|
@@ -232,7 +232,7 @@ declare ms_envelope_tau copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare ms_envelope_tau license "MIT-style STK-4.3 license"; | ||
ms_envelope_tau(period, x) = x * x : ma.avg_tau(period); | ||
ms_envelope_tau(period, x) = x * x : fi.avg_tau(period); | ||
|
||
|
||
//------------------`(an.)ms_envelope_t60`------------------------------------- | ||
|
@@ -254,7 +254,7 @@ declare ms_envelope_t60 copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare ms_envelope_t60 license "MIT-style STK-4.3 license"; | ||
ms_envelope_t60(period, x) = x * x : ma.avg_t60(period); | ||
ms_envelope_t60(period, x) = x * x : fi.avg_t60(period); | ||
|
||
|
||
//------------------`(an.)ms_envelope_t19`------------------------------------- | ||
|
@@ -276,7 +276,7 @@ declare ms_envelope_t19 copyright "Copyright (C) 2020 Dario Sanfilippo | |
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare ms_envelope_t19 license "MIT-style STK-4.3 license"; | ||
ms_envelope_t19(period, x) = x * x : ma.avg_t19(period); | ||
ms_envelope_t19(period, x) = x * x : fi.avg_t19(period); | ||
|
||
|
||
//------------------`(an.)rms_envelope_rect`----------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ si = library("signals.lib"); | |
fi = library("filters.lib"); // for compatible copy/paste out of this file | ||
|
||
declare name "Faust Filters Library"; | ||
declare version "0.2"; | ||
declare version "0.3"; | ||
|
||
//===============================Basic Filters============================================ | ||
//======================================================================================== | ||
|
@@ -2660,6 +2660,119 @@ svf = environment { | |
}; | ||
|
||
|
||
//============================Averaging Functions============================== | ||
//============================================================================= | ||
// | ||
// These are a set of samplerate independent averaging functions based on | ||
// moving-average and one-pole filters with specific response characteristics. | ||
|
||
//----------------------------`(fi.)avg_rect`---------------------------------- | ||
// Moving average. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ : avg_rect(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the averaging frame in seconds | ||
//----------------------------------------------------------------------------- | ||
declare avg_rect author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_rect copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_rect license "MIT-style STK-4.3 license"; | ||
avg_rect(period, x) = x : ba.slidingMean(rint(period * ma.SR)); | ||
|
||
|
||
//----------------------------(fi.)avg_tau------------------------------------- | ||
// Averaging function based on a one-pole filter and the tau response time. | ||
// Tau represents the effective length of the one-pole impulse response, | ||
// that is, tau is the integral of the filter's impulse response. This | ||
// response is slower to reach the final value but has less ripples in | ||
// non-steady signals. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_tau(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/e, | ||
// or to reach 1-1/e of its final value. | ||
// | ||
// #### Reference | ||
// | ||
// <https://ccrma.stanford.edu/~jos/mdft/Exponentials.html> | ||
//----------------------------------------------------------------------------- | ||
declare avg_tau author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_tau copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_tau license "MIT-style STK-4.3 license"; | ||
avg_tau(period, x) = fi.lptau(period, x); | ||
|
||
|
||
//----------------------------(fi.)avg_t60------------------------------------- | ||
// Averaging function based on a one-pole filter and the t60 response time. | ||
// This response is particularly useful when the system is required to | ||
// reach the final value after about `period` seconds. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_t60(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/1000, | ||
// or to reach 1-1/1000 of its final value. | ||
// | ||
// #### Reference | ||
// | ||
// <https://ccrma.stanford.edu/~jos/mdft/Audio_Decay_Time_T60.html> | ||
//----------------------------------------------------------------------------- | ||
declare avg_t60 author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_t60 copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_t60 license "MIT-style STK-4.3 license"; | ||
avg_t60(period, x) = fi.lpt60(period, x); | ||
|
||
|
||
//----------------------------(fi.)avg_t19------------------------------------- | ||
// Averaging function based on a one-pole filter and the t19 response time. | ||
// This response is close to the moving-average algorithm as it roughly reaches | ||
// the final value after `period` seconds and shows about the same | ||
// oscillations for non-steady signals. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_t19(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/e^2.2, | ||
// or to reach 1-1/e^2.2 of its final value. | ||
// | ||
// #### Reference | ||
// Zölzer, U. (2008). Digital audio signal processing (Vol. 9). New York: Wiley. | ||
//----------------------------------------------------------------------------- | ||
declare avg_t19 author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_t19 copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_t19 license "MIT-style STK-4.3 license"; | ||
avg_t19(period, x) = fi.lpt19(period, x); | ||
|
||
|
||
/******************************************************************************* | ||
# Licenses | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,9 +54,6 @@ declare license "LGPL with exception"; | |
|
||
// This library contains platform specific constants | ||
pl = library("platform.lib"); | ||
ba = library("basics.lib"); | ||
si = library("signals.lib"); | ||
fi = library("filters.lib"); | ||
ma = library("maths.lib"); // for compatible copy/paste out of this file | ||
|
||
//=============================Functions Reference======================================== | ||
|
@@ -723,115 +720,3 @@ nextpow2(x) = ceil(log(x)/log(2.0)); | |
//----------------------------------------------------------------------------- | ||
zc(x) = x * x' < 0; | ||
|
||
|
||
//============================Averaging Functions============================== | ||
//============================================================================= | ||
// | ||
// These are a set of samplerate independent averaging functions based on | ||
// moving-average and one-pole filters with specific response characteristics. | ||
|
||
//----------------------------`(ma.)avg_rect`---------------------------------- | ||
// Moving average. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ : avg_rect(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the averaging frame in seconds | ||
//----------------------------------------------------------------------------- | ||
declare avg_rect author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_rect copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_rect license "MIT-style STK-4.3 license"; | ||
avg_rect(period, x) = x : ba.slidingMean(rint(period * ma.SR)); | ||
|
||
|
||
//----------------------------(ma.)avg_tau------------------------------------- | ||
// Averaging function based on a one-pole filter and the tau response time. | ||
// Tau represents the effective length of the one-pole impulse response, | ||
// that is, tau is the integral of the filter's impulse response. This | ||
// response is slower to reach the final value but has less ripples in | ||
// non-steady signals. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_tau(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/e, | ||
// or to reach 1-1/e of its final value. | ||
// | ||
// #### Reference | ||
// | ||
// <https://ccrma.stanford.edu/~jos/mdft/Exponentials.html> | ||
//----------------------------------------------------------------------------- | ||
declare avg_tau author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_tau copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_tau license "MIT-style STK-4.3 license"; | ||
avg_tau(period, x) = fi.lptau(period, x); | ||
|
||
|
||
//----------------------------(ma.)avg_t60------------------------------------- | ||
// Averaging function based on a one-pole filter and the t60 response time. | ||
// This response is particularly useful when the system is required to | ||
// reach the final value after about `period` seconds. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_t60(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/1000, | ||
// or to reach 1-1/1000 of its final value. | ||
// | ||
// #### Reference | ||
// | ||
// <https://ccrma.stanford.edu/~jos/mdft/Audio_Decay_Time_T60.html> | ||
//----------------------------------------------------------------------------- | ||
declare avg_t60 author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_t60 copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_t60 license "MIT-style STK-4.3 license"; | ||
avg_t60(period, x) = fi.lpt60(period, x); | ||
|
||
|
||
//----------------------------(ma.)avg_t19------------------------------------- | ||
// Averaging function based on a one-pole filter and the t19 response time. | ||
// This response is close to the moving-average algorithm as it roughly reaches | ||
// the final value after `period` seconds and shows about the same | ||
// oscillations for non-steady signals. | ||
// | ||
// #### Usage | ||
// | ||
// ``` | ||
// _ avg_t19(period) : _ | ||
// ``` | ||
// | ||
// Where: | ||
// | ||
// * `period` is the time, in seconds, for the system to decay by 1/e^2.2, | ||
// or to reach 1-1/e^2.2 of its final value. | ||
// | ||
// #### Reference | ||
// Zölzer, U. (2008). Digital audio signal processing (Vol. 9). New York: Wiley. | ||
//----------------------------------------------------------------------------- | ||
declare avg_t19 author "Dario Sanfilippo and Julius O. Smith III"; | ||
declare avg_t19 copyright "Copyright (C) 2020 Dario Sanfilippo | ||
<[email protected]> and | ||
2003-2020 by Julius O. Smith III <[email protected]>"; | ||
declare avg_t19 license "MIT-style STK-4.3 license"; | ||
avg_t19(period, x) = fi.lpt19(period, x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters