aboutsummaryrefslogtreecommitdiff
path: root/lpc~/lpc_anal
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-08-19 05:04:28 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-08-19 05:04:28 +0000
commit79096fd626b946efd6947fa94ab15d30bf003ba0 (patch)
tree9a10305d0ade28bb3f5139c37ab8fa76f4e603d4 /lpc~/lpc_anal
parent633eaa4b2350c00ddc1b338c357096a441944784 (diff)
converted to new library template and debianized
svn path=/trunk/externals/ekext/; revision=13835
Diffstat (limited to 'lpc~/lpc_anal')
-rw-r--r--lpc~/lpc_anal/lpc_test.pd53
-rw-r--r--lpc~/lpc_anal/lpc~.c203
-rw-r--r--lpc~/lpc_anal/makefile105
3 files changed, 0 insertions, 361 deletions
diff --git a/lpc~/lpc_anal/lpc_test.pd b/lpc~/lpc_anal/lpc_test.pd
deleted file mode 100644
index 7c9faea..0000000
--- a/lpc~/lpc_anal/lpc_test.pd
+++ /dev/null
@@ -1,53 +0,0 @@
-#N canvas 0 0 917 300 10;
-#X obj 185 160 lpc~ 10;
-#N canvas 0 0 450 300 playsound 0;
-#X obj 68 74 inlet;
-#X obj 163 76 inlet;
-#X obj 163 93 openpanel;
-#X msg 163 110 read -resize \$1 testfile;
-#X obj 26 91 tabplay~ testfile;
-#X obj 163 127 soundfiler;
-#X obj 163 144 / 44.1;
-#X obj 163 161 outlet;
-#X obj 26 108 outlet~;
-#X obj 99 149 outlet;
-#X connect 0 0 4 0;
-#X connect 0 0 9 0;
-#X connect 1 0 2 0;
-#X connect 2 0 3 0;
-#X connect 3 0 5 0;
-#X connect 4 0 8 0;
-#X connect 5 0 6 0;
-#X connect 6 0 7 0;
-#X restore 185 119 pd playsound;
-#N canvas 0 0 450 300 graph1 0;
-#X array testfile 1.7683e+06 float 0;
-#X coords 0 1 1.7683e+06 -1 200 140 1;
-#X restore 516 19 graph;
-#X obj 264 104 bng 15 250 50 0 empty empty load 0 -6 0 8 -262144 -1
--1;
-#X obj 185 104 bng 15 250 50 0 empty empty play 0 -6 0 8 -262144 -1
--1;
-#X obj 134 118 metro;
-#X obj 134 103 tgl 15 0 empty empty loop 0 -6 0 8 -262144 -1 -1 0 1
-;
-#X obj 185 230 dac~;
-#X obj 329 37 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
-;
-#X msg 329 68 \; pd dsp \$1;
-#X floatatom 242 142 5 1 100 0 poles - -;
-#X obj 184 183 lpreson~;
-#X obj 185 206 hip~ 18;
-#X connect 0 0 11 0;
-#X connect 0 1 11 0;
-#X connect 1 0 0 0;
-#X connect 1 2 5 1;
-#X connect 3 0 1 1;
-#X connect 4 0 1 0;
-#X connect 5 0 1 0;
-#X connect 6 0 5 0;
-#X connect 8 0 9 0;
-#X connect 10 0 0 1;
-#X connect 11 0 12 0;
-#X connect 12 0 7 0;
-#X connect 12 0 7 1;
diff --git a/lpc~/lpc_anal/lpc~.c b/lpc~/lpc_anal/lpc~.c
deleted file mode 100644
index ce6bdbb..0000000
--- a/lpc~/lpc_anal/lpc~.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Linear Predictive Coding - PARCOR and residual generation
- * Copyright (C) 2005 Nicolas Chetry <okin@altern.org>
- * and Edward Kelly <morph_2016@yahoo.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 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 General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "m_pd.h"
-#include <math.h>
-#define MAXPOLES 100
-
-static t_class *lpc_tilde_class;
-
-typedef struct _lpc_schur
-{
- t_float *c_input, *c_residual;
- /* just so we don't get clicks */
- t_atom x_last_parcors[MAXPOLES];
- t_atom x_parcors[MAXPOLES];
-} t_lpc_schur;
-
-typedef struct _lpc_tilde
-{
- t_object x_obj;
- t_float f_dummy;
- t_float x_order, x_lastorder;
- t_outlet *parcor_list;
- t_lpc_schur x_schur;
-} t_lpc_tilde;
-
-t_int *lpc_tilde_perform(t_int *w)
-{
- t_lpc_tilde *x = (t_lpc_tilde *)(w[1]);
- t_lpc_schur *schur = (t_lpc_schur *)(w[2]);
- int n = (int)(w[3]);
- t_float *in = schur->c_input;
- t_float *res = schur->c_residual;
-// t_float *parcors = schur->PARCORS;
-// t_float *acf = schur->ACF;
-// t_float *k = schur->K;
-// t_float *p = schur->P;
-// t_float *r = schur->r;
- t_int ord = (int)x->x_order;
- t_int l_ord = (int)x->x_lastorder;
-// t_float parcors[ord];
- float acf[ord+1];
- float k[ord+1];
- float p[ord+1];
- float r[ord+1];
- float mem[ord];
- int i, j, bid, y, z;
- int g, h;
- float tmp, temp, sav, di;
- float parcor_1;
- for (i=0; i<ord; i++)
- {
- SETFLOAT (&schur->x_parcors[i],0);
- mem[i] = 0.0;
- }
- for (j=0; j<=ord; j++)
- {
- acf[j] = 0;
- for (i=j; i<n; i++)
- {
- acf[j] += in[i]*in[i-j];
- }
- }
- if (acf[0] == 0)
- {
- for (i=0; i<ord; i++)
- {
- SETFLOAT (&schur->x_parcors[i],0);
- }
- }
- for (i=0; i<=ord; i++)
- {
- p[i]=acf[i];
- if (i > 0 && i < ord)
- {
- k[ord+1-i] = acf[i];
- }
- }
- /* Schurr recursion */
- for (y=1; y<=ord; y++)
- {
- if (p[0] < fabs (p[1]))
- {
- for (i=y; i<=ord; i++)
- {
- r[i] = 0;
- }
- for (bid=1; bid <=ord; bid++)
- {
- SETFLOAT (&schur->x_parcors[bid-1],r[bid]);
- // x->x_parcors[bid-1] = r[bid];
- }
- }
- r[y] = fabs(p[1])/p[0];
-
- if (p[1] >0)
- {
- r[y] = -1.*r[y];
- }
- if (y==ord)
- {
- for (bid=1; bid <=ord; bid++)
- {
- SETFLOAT (&schur->x_parcors[bid-1],r[bid]);
- // x->x_parcors[bid-1] = r[bid];
- }
- }
- p[0] += p[1]*r[y];
-
- for (z=1; z <=ord-y; z++)
- {
- p[z] = p[z+1] + k[ord+1-z]*r[y];
- k[ord+1-z] += p[z+1] * r[y];
- }
- }
- for (bid=1; bid <=ord; bid++)
- {
- SETFLOAT (&schur->x_parcors[bid-1],r[bid]);
- }
- parcor_1 = atom_getfloatarg(0,ord,schur->x_parcors); /* in order to avoid nil coefficients */
- if (parcor_1 > 1e-5 || parcor_1 < -1e-5)
- {
- outlet_list(x->parcor_list,gensym("list"),ord,schur->x_parcors);
-
- /* Analysis FIR lattice filtering */
- for (g=0; g<n; g++)
- {
-
- /* Analysis - Lattice structure */
- sav = di = in[g];
- for (i=0; i<ord; i++)
- {
- t_float parcor = atom_getfloatarg (i,ord,schur->x_parcors);
- SETFLOAT (&schur->x_last_parcors[i],parcor);
- x->x_lastorder = ord;
- temp = mem[i] + parcor*di;
- di += parcor*mem[i];
- mem[i] = sav;
- sav = temp;
- }
- res[g] = di;
-
- } /* next g */
- }
- else
- {
- outlet_list(x->parcor_list,gensym("list"),l_ord,schur->x_last_parcors);
- for (g=0; g<n; g++)
- {
- res[g] = 0;
- }
- }
- return(w+4);
-}
-
-void *lpc_tilde_dsp(t_lpc_tilde *x, t_signal **sp)
-{
- x->x_schur.c_input = sp[0]->s_vec;
- x->x_schur.c_residual = sp[1]->s_vec;
- dsp_add(lpc_tilde_perform, 3, x, &x->x_schur, sp[0]->s_n);
- return (void *)x;
-}
-
-void *lpc_tilde_new(t_floatarg f)
-{
- t_lpc_tilde *x = (t_lpc_tilde *)pd_new(lpc_tilde_class);
- x->x_order = f >= 1 ? (int)f : 5;
-
- floatinlet_new(&x->x_obj,&x->x_order);
- outlet_new(&x->x_obj, &s_signal);
- x->parcor_list = outlet_new(&x->x_obj, &s_list);
- return (void *)x;
-}
-
-void lpc_tilde_setup(void)
-{
- lpc_tilde_class = class_new(gensym("lpc~"), (t_newmethod)lpc_tilde_new, 0, sizeof(t_lpc_tilde), CLASS_DEFAULT, A_DEFFLOAT, 0);
-
- post("\n. . Linear Predictive Coding. . . . . . . .");
- post(". . PARCOR coefficients from input. . . . .");
- post(". . by Nicolas Chetry <okin@altern.org> . .");
- post(". & Edward Kelly <morph_2016@yahoo.co.uk> .");
-
- class_addmethod(lpc_tilde_class, (t_method)lpc_tilde_dsp, gensym("dsp"), 0);
-
-
- CLASS_MAINSIGNALIN(lpc_tilde_class, t_lpc_tilde, f_dummy);
-}
diff --git a/lpc~/lpc_anal/makefile b/lpc~/lpc_anal/makefile
deleted file mode 100644
index 5fe80c8..0000000
--- a/lpc~/lpc_anal/makefile
+++ /dev/null
@@ -1,105 +0,0 @@
-current:
- echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin, then make install
-
-clean: ; rm -f *.pd_* *.o
-
-# ----------------------- NT -----------------------
-
-pd_nt: lpc~.dll
-
-INSTALL_PREFIX="C:\pd\extra"
-EXT=dll
-.SUFFIXES: .obj .dll
-
-PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
-VC="D:\Program Files\Microsoft Visual Studio\Vc98"
-
-PDNTINCLUDE = /I. /I\tcl\include /I..\..\src /I$(VC)\include
-
-PDNTLDIR = $(VC)\lib
-PDNTLIB = $(PDNTLDIR)\libc.lib \
- $(PDNTLDIR)\oldnames.lib \
- $(PDNTLDIR)\kernel32.lib \
- ..\..\bin\pd.lib
-
-.c.dll:
- cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
- link /dll /export:$*_setup $*.obj $(PDNTLIB)
-
-# ----------------------- IRIX 5.x -----------------------
-
-pd_irix5: lpc~.pd_irix5
-
-INSTALL_PREFIX=/usr/local
-EXT=pd_irix5
-.SUFFIXES: .pd_irix5
-
-SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
-
-SGIINCLUDE = -I/usr/local/include
-
-.c.pd_irix5:
- cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
- ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
- rm $*.o
-
-# ----------------------- IRIX 5.x -----------------------
-
-pd_irix6: lpc~.pd_irix6
-
-INSTALL_PREFIX=/usr/local
-EXT=pd_irix6
-.SUFFIXES: .pd_irix6
-
-SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
-
-SGIINCLUDE = -I/usr/local/include
-
-.c.pd_irix6:
- cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
- ld -elf -shared -rdata_shared -o $*.pd_irix6 $*.o
- rm $*.o
-
-# ----------------------- LINUX i386 -----------------------
-
-pd_linux: lpc~.pd_linux
-
-INSTALL_PREFIX=/usr/local
-EXT=pd_linux
-.SUFFIXES: .pd_linux
-
-LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
- -Wall -W -Wshadow -Wstrict-prototypes -Werror \
- -Wno-unused -Wno-parentheses -Wno-switch
-
-LINUXINCLUDE = -I/usr/local/include
-
-.c.pd_linux:
- cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
- ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm
- strip --strip-unneeded $*.pd_linux
- rm $*.o
-
-# ----------------------- Mac OSX -----------------------
-
-pd_darwin: lpc~.pd_darwin
-
-INSTALL_PREFIX=/usr/local
-EXT=pd_darwin
-.SUFFIXES: .pd_darwin
-
-DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
- -Wno-unused -Wno-parentheses -Wno-switch
-
-.c.pd_darwin:
- cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
- cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
- rm -f $*.o
-
-# ----------------------------------------------
-
-install::
- install -d $(INSTALL_PREFIX)/lib/pd/extra
-# install -m 644 *.$(EXT) $(INSTALL_PREFIX)/lib/pd/externs
- -install -m 644 lpc~.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra
- install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference