X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/1059e1cc0c2ecfa237406949aa26155b6a5b9154..66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83:/interpreter/preprocessor/faust-0.9.47mr3/architecture/reduce.lib diff --git a/interpreter/preprocessor/faust-0.9.47mr3/architecture/reduce.lib b/interpreter/preprocessor/faust-0.9.47mr3/architecture/reduce.lib new file mode 100644 index 0000000..5a10ea8 --- /dev/null +++ b/interpreter/preprocessor/faust-0.9.47mr3/architecture/reduce.lib @@ -0,0 +1,95 @@ +/************************************************************************ + ************************************************************************ + FAUST library file + Copyright (C) 2010-2011 GRAME, Centre National de Creation Musicale + --------------------------------------------------------------------- + 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. + ************************************************************************ + ************************************************************************/ + +declare name "Reduce Library"; +declare author "Yann Orlarey (orlarey at grame.fr)"; +declare copyright "Grame"; +declare version "0.1"; +declare license "LGPL"; + + +//--------------------------------------------------------------- +// Provides various operations on block of samples +// using a high order 'reduce(op, n)' fold-like function : +// +// sumn(n) : the sum of a block of n input samples +// maxn(n) : the max of a block of n input samples +// minn(n) : the min of a block of n input samples +// mean(n) : the mean of a block of n input samples +// RMS(n) : the RMS of a block of n input samples +//--------------------------------------------------------------- + + + +//--------------------------------------------------------------- +// reduce (op, n, x) +//--------------------------------------------------------------- +// Fold-like high order function. Apply a binary operation +// on a block of consecutive samples of a signal . +// For example : reduce(max,128) will compute the maximun of each +// block of 128 samples. Please note that the resulting +// value, while produced continuously, will be constant for +// the duration of a block. A new value is only produced +// at the end of a block. Note also that blocks should be of at +// least one sample (n>0). +reduce(op, n, x) = compute ~ (_,_,_) : (!,!,_) + with { + compute (acc, count, val) = + if(count