aboutsummaryrefslogtreecommitdiff
path: root/vocoder~
diff options
context:
space:
mode:
Diffstat (limited to 'vocoder~')
-rw-r--r--vocoder~/CHANGES.LOG2
-rw-r--r--vocoder~/INSTALL15
-rw-r--r--vocoder~/Makefile86
-rw-r--r--vocoder~/README22
-rw-r--r--vocoder~/filters.c49
-rw-r--r--vocoder~/filters.h27
-rw-r--r--vocoder~/filters.obin0 -> 1163 bytes
-rw-r--r--vocoder~/help-vocoder~.pd55
-rw-r--r--vocoder~/lpc.c252
-rw-r--r--vocoder~/lpc.h33
-rw-r--r--vocoder~/lpc.obin0 -> 5500 bytes
-rw-r--r--vocoder~/rs-vocoder~.pd13
-rw-r--r--vocoder~/tables.c311
-rw-r--r--vocoder~/tables.h24
-rw-r--r--vocoder~/tables.obin0 -> 6168 bytes
-rw-r--r--vocoder~/vocoder~.c163
16 files changed, 1052 insertions, 0 deletions
diff --git a/vocoder~/CHANGES.LOG b/vocoder~/CHANGES.LOG
new file mode 100644
index 0000000..6f7036d
--- /dev/null
+++ b/vocoder~/CHANGES.LOG
@@ -0,0 +1,2 @@
+0.1
+ first implementation
diff --git a/vocoder~/INSTALL b/vocoder~/INSTALL
new file mode 100644
index 0000000..37c9567
--- /dev/null
+++ b/vocoder~/INSTALL
@@ -0,0 +1,15 @@
+untar in /my/pd/dir/externs
+
+cd /my/pd/dir/externs/vocoder~
+
+make clean
+
+make
+
+make install
+
+open help-vocoder~.pd
+
+Thanx for getting here.
+Yves/
+comments and bugs @ ydegoyon@free.fr
diff --git a/vocoder~/Makefile b/vocoder~/Makefile
new file mode 100644
index 0000000..857530b
--- /dev/null
+++ b/vocoder~/Makefile
@@ -0,0 +1,86 @@
+NAME=vocoder~
+CSYM=vocoder_tilde
+
+current: pd_linux
+
+# ----------------------- NT -----------------------
+
+pd_nt: $(NAME).dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ \ftp\pd\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: $(NAME).pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I../../src
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 6.x -----------------------
+
+pd_irix6: $(NAME).pd_irix6
+
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+.c.pd_irix6:
+ cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: $(NAME).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../../src
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o filters.o -c filters.c
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o lpc.o -c lpc.c
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o tables.o -c tables.c
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux *.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm -f $*.o ../$*.pd_linux
+ ln -s $*/$*.pd_linux ..
+
+# ----------------------------------------------------------
+
+clean:
+ rm -f *.o *.pd_* so_locations
+
+install:
+ cp *.pd ../../doc/5.reference
+
diff --git a/vocoder~/README b/vocoder~/README
new file mode 100644
index 0000000..767151c
--- /dev/null
+++ b/vocoder~/README
@@ -0,0 +1,22 @@
+*****************************************************************************
+Version 0.1
+copyleft 2002 by Yves Degoyon
+tarballs and updates available @ http://ydegoyon.free.fr
+
+vocoder~ : vocoder filter for PD inspired by xvox ( http://simon.morlat.free.fr )
+i used xvox version 0.2.1, but you don't need to install it,
+everything needed is bundled here.
+
+To install cooled~, follow the steps from INSTALL
+
+This software is published under GPL terms.
+
+This is software with ABSOLUTELY NO WARRANTY.
+Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing
+due to a bug or for other reasons.
+We do not warrant that the program is free of infringement of any third-party
+patents.
+
+*****************************************************************************
+
+
diff --git a/vocoder~/filters.c b/vocoder~/filters.c
new file mode 100644
index 0000000..2bf9253
--- /dev/null
+++ b/vocoder~/filters.c
@@ -0,0 +1,49 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+
+void lpc_filter(double *buf_ppf, double *lpc_coef, double *buf_sy, int n)
+{
+ int i,j;
+ double acc;
+
+ for(i=0;i<n;i++)
+ {
+ acc=buf_ppf[i]*lpc_coef[0];
+ for(j=1;j<11;j++)
+ {
+ acc=acc-lpc_coef[j]*buf_sy[i-j];
+ };
+ buf_sy[i]=acc;
+ };
+}
+
+void hp_filter(double *in,double cut,int n)
+{
+ int i;
+ double prev_e,s_out;
+ prev_e=s_out=0;
+ for(i=0;i<n;i++)
+ {
+ s_out=in[i]-prev_e+cut*s_out;
+ prev_e=in[i];
+ in[i]=s_out;
+ };
+}
diff --git a/vocoder~/filters.h b/vocoder~/filters.h
new file mode 100644
index 0000000..534f881
--- /dev/null
+++ b/vocoder~/filters.h
@@ -0,0 +1,27 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#ifndef __FILTERS_H__
+#define __FILTERS_H__
+
+void lpc_filter(double *buf_ppf, double *lpc_coef, double *buf_sy,int n);
+void hp_filter(double *in,double cut,int n);
+
+#endif
diff --git a/vocoder~/filters.o b/vocoder~/filters.o
new file mode 100644
index 0000000..c0a0e89
--- /dev/null
+++ b/vocoder~/filters.o
Binary files differ
diff --git a/vocoder~/help-vocoder~.pd b/vocoder~/help-vocoder~.pd
new file mode 100644
index 0000000..7bbf3b2
--- /dev/null
+++ b/vocoder~/help-vocoder~.pd
@@ -0,0 +1,55 @@
+#N canvas 123 129 764 525 10;
+#X obj 201 393 dac~;
+#X obj 153 330 adc~;
+#X obj 204 355 rs-vocoder~;
+#X text 356 457 vocoder~ : vocoder effect;
+#X text 356 469 inspired by xvox written by;
+#X text 357 483 Simon Morlat ( http://simon.morlat.free.fr );
+#X text 357 497 Part of unauthorized PD ( http://ydegoyon.free.fr )
+;
+#X obj 125 406 env~;
+#X floatatom 124 435 5 0 0;
+#X obj 265 301 hsl 128 15 0 1000 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 11500 1;
+#X text 409 299 Cutoff Frequency;
+#X obj 295 327 hsl 128 15 0 100 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 10500 1;
+#X text 439 325 Voice Feedback [ 0 - 100 ];
+#X msg 49 39 bang;
+#X obj 48 61 openpanel;
+#X obj 48 81 t s b;
+#X obj 105 83 float \$0;
+#X text 56 16 Step 1 : Load a sound file;
+#X obj 48 104 route float;
+#X obj 49 196 soundfiler;
+#X text 106 32 ( maybe \, a guitar sound ? );
+#X obj 48 127 makefilename %d-sample;
+#X msg 49 174 read -resize \$1 \$2;
+#X obj 50 153 pack s s;
+#X msg 237 207 bang;
+#X text 282 207 Step 2 : Start playing;
+#X obj 237 254 tabplay~ \$0-sample;
+#X msg 308 230 stop;
+#X obj 237 230 metro 250;
+#X text 49 300 Step 3 : Grab the mike !!!;
+#X obj 333 90 table \$0-sample;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 2 0 0 1;
+#X connect 2 0 7 0;
+#X connect 7 0 8 0;
+#X connect 9 0 2 2;
+#X connect 11 0 2 3;
+#X connect 13 0 14 0;
+#X connect 14 0 15 0;
+#X connect 15 0 23 0;
+#X connect 15 1 16 0;
+#X connect 16 0 18 0;
+#X connect 18 0 21 0;
+#X connect 21 0 23 1;
+#X connect 22 0 19 0;
+#X connect 23 0 22 0;
+#X connect 24 0 28 0;
+#X connect 26 0 2 1;
+#X connect 27 0 28 0;
+#X connect 28 0 26 0;
diff --git a/vocoder~/lpc.c b/vocoder~/lpc.c
new file mode 100644
index 0000000..33159d4
--- /dev/null
+++ b/vocoder~/lpc.c
@@ -0,0 +1,252 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "tables.h"
+#include "lpc.h"
+#define THRES 0.06
+#define Dmin 10.81e-3
+
+/* Levinson Durbin algorithm for computing LPC coefficients using
+autocorrelation fonction */
+void lev_durb(double *corr,double *lpc_coef)
+{
+ double k[11],tab[11];
+ double err,acc;
+ int i,j;
+ double *a=tab;
+ double *prev_a=lpc_coef;
+ double *exch;
+
+
+ /*init vectors*/
+ for (i=0;i<11;i++)
+ {
+ prev_a[i]=0;
+ a[i]=0;
+ };
+ err=corr[0];
+ for(i=1;i<11;i++)
+ {
+ prev_a[0]=1;
+ acc=0;
+ for(j=0;j<i;j++)
+ {
+ acc=acc+prev_a[j]*corr[i-j];
+ };
+ a[i]=k[i]=-acc/err;
+ for(j=1;j<i;j++)
+ {
+ a[j]=prev_a[j]+k[i]*prev_a[i-j];
+ };
+ err=(1-k[i]*k[i])*err;
+ exch=prev_a;
+ prev_a=a;
+ a=exch;
+ };
+}
+
+void comp_lpc(double *buf_x,double *corr,double *lpc_coef,int n)
+{
+ double buffer[n*3];
+ double acc,max=0;
+ int i,j;
+ /* computes LPC analysis for one subframe */
+ /* hamming windowing*/
+ acc=0;
+ for(i=0;i<2*n;i++)
+ {
+ acc+=buf_x[i]*buf_x[i];
+ };
+ if (acc>THRES)
+ {
+ for(i=0;i<3*n;i++)
+ {
+ buffer[i]=buf_x[i-n]*HammingWindowTable[i];
+ };
+ /* autocorrelation computation*/
+ for(i=0;i<11;i++)
+ {
+ acc=0;
+ for(j=i;j<n*3;j++)
+ {
+ acc=acc+buffer[j]*buffer[j-i];
+ };
+ /* correction with binomial coeffs */
+ corr[i]=acc;//*BinomialWindowTable[i];
+ };
+ corr[0]=corr[0]*(1.0+1.0/1024.0);
+ lev_durb(corr,lpc_coef);
+ }
+ else
+ {
+ for(i=0;i<11;i++)
+ {
+ lpc_coef[i]=0;
+ };
+ }
+}
+
+
+
+/* LPC to LSP coefficients conversion */
+
+/* evaluate function C(x) (whose roots are LSP coeffs)*/
+
+double evalc(double cw,double *fonc)
+{
+ double b[7];
+ double x,res;
+ int k;
+
+ x=cw;
+ b[5]=1;
+ b[6]=0;
+ for(k=4;k>0;k--)
+ {
+ b[k]=2*x*b[k+1]-b[k+2]+fonc[5-k];
+ };
+ res=x*b[1]-b[2]+fonc[5]/2;
+ return(res);
+}
+
+
+
+/* converts LPC vector into LSP frequency vector */
+/* all LSP frenquencies are in [0;PI] but are normalized to be in [0;1] */
+void lpc2lsp(double lpc_coef[],double *f1,double *f2,double lsp_coef[])
+{
+
+ int i,k=1;
+ double *fonc,*prev_f,*f_exch;
+ double prev_sign1,sign,prev_sign2;
+ double *s, *prev_s,*s_exch;
+ double lpc_exp[11];
+
+ /* first computes an additional bandwidth expansion on LPC coeffs*/
+ for(i=1;i<11;i++)
+ {
+ lpc_exp[i]=lpc_coef[i]*BandExpTable[i];
+ };
+ /* computes the F1 and F2 coeffs*/
+ f1[0]=f2[0]=1;
+ for(i=0;i<5;i++)
+ {
+ f1[i+1]=lpc_exp[i+1]+lpc_exp[10-i]-f1[i];
+ f2[i+1]=lpc_exp[i+1]-lpc_exp[10-i]+f2[i];
+ };
+
+ /*find the roots of C(x) alternatively for F1 and F2*/
+ fonc=f1;
+ prev_f=f2;
+ prev_sign1=evalc(1.0,f1);
+ prev_sign2=evalc(1.0,f2);
+ s=&prev_sign1;
+ prev_s=&prev_sign2;
+ for(i=1;i<256;i++)
+ {
+ sign=evalc(CosineTable[i],fonc);
+ if ((sign)*(*s)<0)
+ {
+ /* interpolate to find root*/
+ lsp_coef[k]=((double)i-(*s)/(sign-(*s)))/256.0;
+ k++;
+ /* chek if all roots are found */
+ if (k==11) i=257;
+ (*s)=sign;
+ /* pointers exchange */
+ s_exch=s;
+ s=prev_s;
+ prev_s=s_exch;
+ f_exch=fonc;
+ fonc=prev_f;
+ prev_f=f_exch;
+ }
+ else (*s)=sign;
+ }
+ /* if here all roots are not found , use lspDC vector */
+ if (k!=11)
+ {
+ for(i=1;i<11;i++)
+ {
+ lsp_coef[i]=LspDcTable[i];
+ };
+ };
+}
+
+
+/* converts lsp frequencies to lpc coeffs */
+
+void lsp2lpc(double *lsp_coef,double *lpc_coef)
+{
+ int i,j=0,index,ok=1;
+ double lspcos[11],delta,tmp,p_avg;
+ double F1[12],F2[12]; /* begin at indice two*/
+
+ F1[0]=0;F1[1]=1;
+ F2[0]=0;F2[1]=1;
+ /* stability check */
+ while(ok && (j<11))
+ {
+ ok=0;
+ for(i=1;i<10;i++)
+ {
+ if( (lsp_coef[i+1]-lsp_coef[i]) < Dmin)
+ {
+ ok=1;
+ p_avg=(lsp_coef[i]+lsp_coef[i+1])/2.0;
+ lsp_coef[i]=p_avg-Dmin/2.0;
+ lsp_coef[i+1]=p_avg+Dmin/2.0;
+ };
+ };
+ j++;
+ }
+
+ /* first converts lsp frequencies to lsp coefficients */
+ for (i=1;i<11;i++)
+ {
+ /* interpolation */
+ tmp=lsp_coef[i]*255.0;
+ index=(int)tmp;
+ delta=CosineTable[index+1]-CosineTable[index];
+ lspcos[i]=CosineTable[index]+delta*(tmp-index);
+ };
+
+ for(i=2;i<7;i++)
+ {
+ F1[i]=-2*lspcos[2*i-3]*F1[i-1]+2*F1[i-2];
+ F2[i]=-2*lspcos[2*i-2]*F2[i-1]+2*F2[i-2];
+ for(j=i-1;j>1;j--)
+ {
+ F1[j]=F1[j]-2*lspcos[2*i-3]*F1[j-1]+F1[j-2];
+ F2[j]=F2[j]-2*lspcos[2*i-2]*F2[j-1]+F2[j-2];
+ };
+ };
+ for(i=6;i>1;i--)
+ {
+ F1[i]=F1[i]+F1[i-1];
+ F2[i]=F2[i]-F2[i-1];
+ };
+ for(i=2;i<7;i++)
+ {
+ lpc_coef[i-1]=(F1[i]+F2[i])*0.5;
+ lpc_coef[i+4]=(F1[8-i]-F2[8-i])*0.5;
+ };
+ lpc_coef[0]=1;
+}
+
diff --git a/vocoder~/lpc.h b/vocoder~/lpc.h
new file mode 100644
index 0000000..c8d5d63
--- /dev/null
+++ b/vocoder~/lpc.h
@@ -0,0 +1,33 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* variables globales */
+extern int dsp_fd;
+extern int bsize;
+extern double voix[512+256];
+extern double synth[512+256];
+extern double sortie[512+12];
+extern double *out;
+
+void lev_durb(double *corr,double *lpc_coef);
+void comp_lpc(double *buf_x,double *corr,double *lpc_coef,int n);
+void lpc_filter(double *buf_ppf, double *lpc_coef, double *buf_sy,int n);
+void lsp2lpc(double *lsp_coef,double *lpc_coef);
+void lpc2lsp(double lpc_coef[],double *f1,double *f2,double lsp_coef[]);
+double evalc(double cw,double *fonc);
diff --git a/vocoder~/lpc.o b/vocoder~/lpc.o
new file mode 100644
index 0000000..c150a14
--- /dev/null
+++ b/vocoder~/lpc.o
Binary files differ
diff --git a/vocoder~/rs-vocoder~.pd b/vocoder~/rs-vocoder~.pd
new file mode 100644
index 0000000..65dfc0d
--- /dev/null
+++ b/vocoder~/rs-vocoder~.pd
@@ -0,0 +1,13 @@
+#N canvas 0 0 450 300 10;
+#X obj 39 146 block~ 512;
+#X obj 89 36 inlet~;
+#X obj 151 34 inlet~;
+#X obj 129 77 vocoder~;
+#X obj 207 33 inlet;
+#X obj 261 33 inlet;
+#X obj 129 108 outlet~;
+#X connect 1 0 3 0;
+#X connect 2 0 3 1;
+#X connect 3 0 6 0;
+#X connect 4 0 3 2;
+#X connect 5 0 3 3;
diff --git a/vocoder~/tables.c b/vocoder~/tables.c
new file mode 100644
index 0000000..049a523
--- /dev/null
+++ b/vocoder~/tables.c
@@ -0,0 +1,311 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+double LspDcTable[11] = {
+ 0,
+ 0.0955505 ,
+ 0.144073 ,
+ 0.23468 ,
+ 0.329773 ,
+ 0.42334 ,
+ 0.503387 ,
+ 0.602783 ,
+ 0.679321 ,
+ 0.77771 ,
+ 0.845886
+};
+
+double CosineTable[257] = {
+ 1 ,
+ 0.999939 ,
+ 0.999695 ,
+ 0.999329 ,
+ 0.998779 ,
+ 0.998108 ,
+ 0.997314 ,
+ 0.996338 ,
+ 0.995178 ,
+ 0.993896 ,
+ 0.992493 ,
+ 0.990906 ,
+ 0.989197 ,
+ 0.987305 ,
+ 0.985291 ,
+ 0.983093 ,
+ 0.980774 ,
+ 0.978333 ,
+ 0.975708 ,
+ 0.972961 ,
+ 0.970032 ,
+ 0.96698 ,
+ 0.963806 ,
+ 0.960449 ,
+ 0.95697 ,
+ 0.953308 ,
+ 0.949524 ,
+ 0.945618 ,
+ 0.941528 ,
+ 0.937317 ,
+ 0.932983 ,
+ 0.928528 ,
+ 0.923889 ,
+ 0.919128 ,
+ 0.914185 ,
+ 0.90918 ,
+ 0.903992 ,
+ 0.898682 ,
+ 0.89325 ,
+ 0.887634 ,
+ 0.881897 ,
+ 0.876099 ,
+ 0.870117 ,
+ 0.863953 ,
+ 0.857727 ,
+ 0.851379 ,
+ 0.844849 ,
+ 0.838196 ,
+ 0.831482 ,
+ 0.824585 ,
+ 0.817566 ,
+ 0.810486 ,
+ 0.803223 ,
+ 0.795837 ,
+ 0.78833 ,
+ 0.780762 ,
+ 0.77301 ,
+ 0.765198 ,
+ 0.757202 ,
+ 0.749146 ,
+ 0.740967 ,
+ 0.732666 ,
+ 0.724243 ,
+ 0.715759 ,
+ 0.707092 ,
+ 0.698364 ,
+ 0.689514 ,
+ 0.680603 ,
+ 0.67157 ,
+ 0.662415 ,
+ 0.653198 ,
+ 0.64386 ,
+ 0.634399 ,
+ 0.624878 ,
+ 0.615234 ,
+ 0.60553 ,
+ 0.595703 ,
+ 0.585815 ,
+ 0.575806 ,
+ 0.565735 ,
+ 0.555542 ,
+ 0.545349 ,
+ 0.534973 ,
+ 0.524597 ,
+ 0.514099 ,
+ 0.50354 ,
+ 0.49292 ,
+ 0.482178 ,
+ 0.471375 ,
+ 0.46051 ,
+ 0.449585 ,
+ 0.438599 ,
+ 0.427551 ,
+ 0.416443 ,
+ 0.405212 ,
+ 0.393982 ,
+ 0.38269 ,
+ 0.371338 ,
+ 0.359924 ,
+ 0.348389 ,
+ 0.336914 ,
+ 0.325317 ,
+ 0.31366 ,
+ 0.302002 ,
+ 0.290283 ,
+ 0.278503 ,
+ 0.266724 ,
+ 0.254883 ,
+ 0.242981 ,
+ 0.231079 ,
+ 0.219116 ,
+ 0.207092 ,
+ 0.195068 ,
+ 0.183044 ,
+ 0.170959 ,
+ 0.158875 ,
+ 0.146729 ,
+ 0.134583 ,
+ 0.122437 ,
+ 0.110229 ,
+ 0.0980225 ,
+ 0.0858154 ,
+ 0.0735474 ,
+ 0.0613403 ,
+ 0.0490723 ,
+ 0.0368042 ,
+ 0.0245361 ,
+ 0.0122681 ,
+ 0 ,
+ -0.0122681 ,
+ -0.0245361 ,
+ -0.0368042 ,
+ -0.0490723 ,
+ -0.0613403 ,
+ -0.0735474 ,
+ -0.0858154 ,
+ -0.0980225 ,
+ -0.110229 ,
+ -0.122437 ,
+ -0.134583 ,
+ -0.146729 ,
+ -0.158875 ,
+ -0.170959 ,
+ -0.183044 ,
+ -0.195068 ,
+ -0.207092 ,
+ -0.219116 ,
+ -0.231079 ,
+ -0.242981 ,
+ -0.254883 ,
+ -0.266724 ,
+ -0.278503 ,
+ -0.290283 ,
+ -0.302002 ,
+ -0.31366 ,
+ -0.325317 ,
+ -0.336914 ,
+ -0.348389 ,
+ -0.359924 ,
+ -0.371338 ,
+ -0.38269 ,
+ -0.393982 ,
+ -0.405212 ,
+ -0.416443 ,
+ -0.427551 ,
+ -0.438599 ,
+ -0.449585 ,
+ -0.46051 ,
+ -0.471375 ,
+ -0.482178 ,
+ -0.49292 ,
+ -0.50354 ,
+ -0.514099 ,
+ -0.524597 ,
+ -0.534973 ,
+ -0.545349 ,
+ -0.555542 ,
+ -0.565735 ,
+ -0.575806 ,
+ -0.585815 ,
+ -0.595703 ,
+ -0.60553 ,
+ -0.615234 ,
+ -0.624878 ,
+ -0.634399 ,
+ -0.64386 ,
+ -0.653198 ,
+ -0.662415 ,
+ -0.67157 ,
+ -0.680603 ,
+ -0.689514 ,
+ -0.698364 ,
+ -0.707092 ,
+ -0.715759 ,
+ -0.724243 ,
+ -0.732666 ,
+ -0.740967 ,
+ -0.749146 ,
+ -0.757202 ,
+ -0.765198 ,
+ -0.77301 ,
+ -0.780762 ,
+ -0.78833 ,
+ -0.795837 ,
+ -0.803223 ,
+ -0.810486 ,
+ -0.817566 ,
+ -0.824585 ,
+ -0.831482 ,
+ -0.838196 ,
+ -0.844849 ,
+ -0.851379 ,
+ -0.857727 ,
+ -0.863953 ,
+ -0.870117 ,
+ -0.876099 ,
+ -0.881897 ,
+ -0.887634 ,
+ -0.89325 ,
+ -0.898682 ,
+ -0.903992 ,
+ -0.90918 ,
+ -0.914185 ,
+ -0.919128 ,
+ -0.923889 ,
+ -0.928528 ,
+ -0.932983 ,
+ -0.937317 ,
+ -0.941528 ,
+ -0.945618 ,
+ -0.949524 ,
+ -0.953308 ,
+ -0.95697 ,
+ -0.960449 ,
+ -0.963806 ,
+ -0.96698 ,
+ -0.970032 ,
+ -0.972961 ,
+ -0.975708 ,
+ -0.978333 ,
+ -0.980774 ,
+ -0.983093 ,
+ -0.985291 ,
+ -0.987305 ,
+ -0.989197 ,
+ -0.990906 ,
+ -0.992493 ,
+ -0.993896 ,
+ -0.995178 ,
+ -0.996338 ,
+ -0.997314 ,
+ -0.998108 ,
+ -0.998779 ,
+ -0.999329 ,
+ -0.999695 ,
+ -0.999939 ,
+ -1
+};
+
+double BandExpTable[11] = {
+ 1,
+ 0.993988 ,
+ 0.988037 ,
+ 0.982117 ,
+ 0.976227 ,
+ 0.970367 ,
+ 0.964539 ,
+ 0.95874 ,
+ 0.953003 ,
+ 0.947266 ,
+ 0.941589
+};
+
+
+double HammingWindowTable[128*3]={
+5.38469e-16, 6.69307e-05, 0.000267706, 0.000602271, 0.00107054, 0.00167238, 0.00240763, 0.00327611, 0.00427757, 0.00541174, 0.00667833, 0.00807699, 0.00960736, 0.011269, 0.0130615, 0.0149844, 0.0170371, 0.0192191, 0.0215298, 0.0239687, 0.0265349, 0.029228, 0.032047, 0.0349914, 0.0380602, 0.0412527, 0.0445681, 0.0480053, 0.0515636, 0.055242, 0.0590394, 0.0629548, 0.0669873, 0.0711357, 0.0753989, 0.0797758, 0.0842652, 0.0888659, 0.0935766, 0.0983962, 0.103323, 0.108357, 0.113495, 0.118736, 0.12408, 0.129524, 0.135068, 0.140709, 0.146447, 0.152279, 0.158204, 0.164221, 0.170327, 0.176522, 0.182803, 0.18917, 0.195619, 0.20215, 0.208761, 0.21545, 0.222215, 0.229054, 0.235966, 0.242949, 0.25, 0.257118, 0.264302, 0.271548, 0.278856, 0.286222, 0.293646, 0.301126, 0.308658, 0.316242, 0.323875, 0.331555, 0.33928, 0.347048, 0.354858, 0.362706, 0.37059, 0.37851, 0.386462, 0.394444, 0.402455, 0.410492, 0.418552, 0.426635, 0.434737, 0.442857, 0.450991, 0.459139, 0.467298, 0.475466, 0.48364, 0.491819, 0.5, 0.508181, 0.51636, 0.524534, 0.532702, 0.540861, 0.549009, 0.557143, 0.565263, 0.573365, 0.581448, 0.589508, 0.597545, 0.605556, 0.613538, 0.62149, 0.62941, 0.637294, 0.645142, 0.652952, 0.66072, 0.668445, 0.676125, 0.683758, 0.691342, 0.698874, 0.706354, 0.713778, 0.721144, 0.728452, 0.735698, 0.742882, 0.75, 0.757051, 0.764034, 0.770946, 0.777785, 0.78455, 0.791239, 0.79785, 0.804381, 0.81083, 0.817197, 0.823478, 0.829673, 0.835779, 0.841796, 0.847721, 0.853553, 0.859291, 0.864932, 0.870476, 0.87592, 0.881264, 0.886505, 0.891643, 0.896677, 0.901604, 0.906423, 0.911134, 0.915735, 0.920224, 0.924601, 0.928864, 0.933013, 0.937045, 0.940961, 0.944758, 0.948436, 0.951995, 0.955432, 0.958747, 0.96194, 0.965009, 0.967953, 0.970772, 0.973465, 0.976031, 0.97847, 0.980781, 0.982963, 0.985016, 0.986938, 0.988731, 0.990393, 0.991923, 0.993322, 0.994588, 0.995722, 0.996724, 0.997592, 0.998328, 0.998929, 0.999398, 0.999732, 0.999933, 1, 0.999933, 0.999732, 0.999398, 0.998929, 0.998328, 0.997592, 0.996724, 0.995722, 0.994588, 0.993322, 0.991923, 0.990393, 0.988731, 0.986938, 0.985016, 0.982963, 0.980781, 0.97847, 0.976031, 0.973465, 0.970772, 0.967953, 0.965009, 0.96194, 0.958747, 0.955432, 0.951995, 0.948436, 0.944758, 0.940961, 0.937045, 0.933013, 0.928864, 0.924601, 0.920224, 0.915735, 0.911134, 0.906423, 0.901604, 0.896677, 0.891643, 0.886505, 0.881264, 0.87592, 0.870476, 0.864932, 0.859291, 0.853553, 0.847721, 0.841796, 0.835779, 0.829673, 0.823478, 0.817197, 0.81083, 0.804381, 0.79785, 0.791239, 0.78455, 0.777785, 0.770946, 0.764034, 0.757051, 0.75, 0.742882, 0.735698, 0.728452, 0.721144, 0.713778, 0.706354, 0.698874, 0.691342, 0.683758, 0.676125, 0.668445, 0.66072, 0.652952, 0.645142, 0.637294, 0.62941, 0.62149, 0.613538, 0.605556, 0.597545, 0.589508, 0.581448, 0.573365, 0.565263, 0.557143, 0.549009, 0.540861, 0.532702, 0.524534, 0.51636, 0.508181, 0.5, 0.491819, 0.48364, 0.475466, 0.467298, 0.459139, 0.450991, 0.442857, 0.434737, 0.426635, 0.418552, 0.410492, 0.402455, 0.394444, 0.386462, 0.37851, 0.37059, 0.362706, 0.354858, 0.347048, 0.33928, 0.331555, 0.323875, 0.316242, 0.308658, 0.301126, 0.293646, 0.286222, 0.278856, 0.271548, 0.264302, 0.257118, 0.25, 0.242949, 0.235966, 0.229054, 0.222215, 0.21545, 0.208761, 0.20215, 0.195619, 0.18917, 0.182803, 0.176522, 0.170327, 0.164221, 0.158204, 0.152279, 0.146447, 0.140709, 0.135068, 0.129524, 0.12408, 0.118736, 0.113495, 0.108357, 0.103323, 0.0983962, 0.0935766, 0.0888659, 0.0842652, 0.0797758, 0.0753989, 0.0711357, 0.0669873, 0.0629548, 0.0590394, 0.055242, 0.0515636, 0.0480053, 0.0445681, 0.0412527, 0.0380602, 0.0349914, 0.032047, 0.029228, 0.0265349, 0.0239687, 0.0215298, 0.0192191, 0.0170371, 0.0149844, 0.0130615, 0.011269, 0.00960736, 0.00807699, 0.00667833, 0.00541174, 0.00427757, 0.00327611, 0.00240763, 0.00167238, 0.00107054, 0.000602271, 0.000267706, 6.69307e-05,
+ };
diff --git a/vocoder~/tables.h b/vocoder~/tables.h
new file mode 100644
index 0000000..6f500fc
--- /dev/null
+++ b/vocoder~/tables.h
@@ -0,0 +1,24 @@
+/*
+vox - a musical real-time vocoder. version 1.0
+Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr)
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+extern double BandExpTable[11];
+extern double BinomialWindowTable[11];
+extern double HammingWindowTable[128*3];
+extern double CosineTable[257];
+extern double LspDcTable[11];
diff --git a/vocoder~/tables.o b/vocoder~/tables.o
new file mode 100644
index 0000000..a31acab
--- /dev/null
+++ b/vocoder~/tables.o
Binary files differ
diff --git a/vocoder~/vocoder~.c b/vocoder~/vocoder~.c
new file mode 100644
index 0000000..08dbe3d
--- /dev/null
+++ b/vocoder~/vocoder~.c
@@ -0,0 +1,163 @@
+/* vocoder~ -- vocoder effect inspired by xvox
+ * written by Simon Morlat ( http://simon.morlat.free.fr )
+ *
+ * Copyleft 2001 Yves Degoyon.
+ * Permission is granted to use this software for any purpose provided you
+ * keep this copyright notice intact.
+ *
+ * THE AUTHOR AND HIS EXPLOITERS MAKE NO WARRANTY, EXPRESS OR IMPLIED,
+ * IN CONNECTION WITH THIS SOFTWARE.
+ *
+ */
+
+#include "m_pd.h"
+#include "filters.h"
+#include "lpc.h"
+
+#define OUTPUT_DELAY 50
+
+typedef struct _vocoder
+{
+ t_object x_obj;
+ t_float x_f;
+ t_float x_cutoff;
+ t_int x_vfeedback;
+ double *x_in1buf;
+ double *x_in2buf;
+ double *x_outbuf;
+ t_int x_blocksize;
+ t_int x_process;
+} t_vocoder;
+
+static t_class *vocoder_class;
+
+static char *vocoder_version = "vocoder~: version 0.1, written by ydegoyon@free.fr, inspired by xvox (Simon Morlat)";
+
+static void vocoder_cutoff(t_vocoder *x, t_floatarg fcutoff )
+{
+ if ( fcutoff > 128.0 )
+ {
+ fcutoff = 128.0;
+ }
+ if ( fcutoff < 0.0 )
+ {
+ fcutoff = 0.0;
+ }
+ x->x_cutoff = fcutoff;
+}
+
+static void vocoder_vfeedback(t_vocoder *x, t_floatarg fvfeedback )
+{
+ if ( fvfeedback > 100.0 )
+ {
+ fvfeedback = 100.0;
+ }
+ if ( fvfeedback < 0.0 )
+ {
+ fvfeedback = 0.0;
+ }
+ x->x_vfeedback = fvfeedback;
+}
+
+static t_int *vocoder_perform(t_int *w)
+{
+ t_vocoder *x = (t_vocoder *)(w[1]);
+ t_float *in1 = (t_float *)(w[2]);
+ t_float *fin1 = (t_float *)(w[2]);
+ t_float *in2 = (t_float *)(w[3]);
+ t_float *out1 = (t_float *)(w[4]);
+ double correls[12], lpc_coef[11], f1[12], f2[12], lsp_coef[11];
+ int offset=0;
+ int n = (int)(w[5]), i;
+
+ if ( !x->x_process ) return (w+6);
+ if ( x->x_blocksize != n )
+ {
+ if ( x->x_in1buf ) freebytes( x->x_in1buf, 3*x->x_blocksize/2*sizeof( double ) );
+ if ( x->x_in2buf ) freebytes( x->x_in2buf, 3*x->x_blocksize/2*sizeof( double ) );
+ if ( x->x_outbuf ) freebytes( x->x_outbuf, (x->x_blocksize+OUTPUT_DELAY)*sizeof( double ) );
+ x->x_blocksize = n;
+ x->x_in1buf = (double*) getbytes( 3*x->x_blocksize/2*sizeof( double ) );
+ x->x_in2buf = (double*) getbytes( 3*x->x_blocksize/2*sizeof( double ) );
+ x->x_outbuf = (double*) getbytes( (x->x_blocksize+OUTPUT_DELAY)*sizeof( double ) );
+ if ( !x->x_in1buf || !x->x_in2buf || !x->x_outbuf )
+ {
+ post( "vocoder~ : allocations failed : stop processing" );
+ x->x_process = 0;
+ }
+ }
+
+ for(i=0;i<x->x_blocksize/2;i++)
+ {
+ x->x_in1buf[i]=x->x_in1buf[i+x->x_blocksize];
+ };
+ for(i=0;i<OUTPUT_DELAY;i++) x->x_outbuf[i]=x->x_outbuf[i+x->x_blocksize];
+ for(i=0;i<x->x_blocksize;i++)
+ {
+ x->x_in1buf[x->x_blocksize/2+i]=(double)(*(in1++));
+ x->x_in2buf[x->x_blocksize/2+i]=(double)(*(in2++));
+ }
+
+ hp_filter(x->x_in2buf,x->x_cutoff/128.,n);
+ for(i=0;i<4;i++)
+ {
+ comp_lpc(x->x_in1buf+offset,correls,lpc_coef,x->x_blocksize/4);
+ if (lpc_coef[0]!=0)
+ {
+ lpc2lsp(lpc_coef,f1,f2,lsp_coef);
+ lsp2lpc(lsp_coef,lpc_coef);
+ };
+ lpc_filter(x->x_in2buf+offset,lpc_coef,x->x_outbuf+OUTPUT_DELAY+offset,x->x_blocksize/4);
+ offset+=x->x_blocksize/4;
+ };
+ for(i=0;i<x->x_blocksize;i++)
+ {
+ if ( x->x_outbuf[OUTPUT_DELAY+i] > 1.0 ) x->x_outbuf[OUTPUT_DELAY+i]=1.0;
+ if ( x->x_outbuf[OUTPUT_DELAY+i] < -1.0 ) x->x_outbuf[OUTPUT_DELAY+i]=-1.0;
+ *(out1++)=(t_float)(((100-x->x_vfeedback)*x->x_outbuf[OUTPUT_DELAY+i]
+ + x->x_vfeedback*(*fin1++))/100.0);
+ };
+
+ return (w+6);
+}
+
+static void vocoder_dsp(t_vocoder *x, t_signal **sp)
+{
+ dsp_add(vocoder_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
+}
+
+static void *vocoder_new(void)
+{
+ t_vocoder *x = (t_vocoder *)pd_new(vocoder_class);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("cutoff"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("vfeedback"));
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_cutoff = 60.;
+ x->x_vfeedback = 50;
+ x->x_blocksize=-1;
+ x->x_in1buf = NULL;
+ x->x_in2buf = NULL;
+ x->x_outbuf = NULL;
+ x->x_process = 1;
+ return (x);
+}
+
+ /* clean up */
+static void vocoder_free(t_vocoder *x)
+{
+ if ( x->x_in1buf ) freebytes( x->x_in1buf, 3*x->x_blocksize/2*sizeof( double ) );
+ if ( x->x_in2buf ) freebytes( x->x_in2buf, 3*x->x_blocksize/2*sizeof( double ) );
+ if ( x->x_outbuf ) freebytes( x->x_outbuf, (x->x_blocksize+OUTPUT_DELAY)*sizeof( double ) );
+}
+
+void vocoder_tilde_setup(void)
+{
+ post(vocoder_version);
+ vocoder_class = class_new(gensym("vocoder~"), (t_newmethod)vocoder_new, (t_method)vocoder_free,
+ sizeof(t_vocoder), 0, 0);
+ CLASS_MAINSIGNALIN( vocoder_class, t_vocoder, x_f );
+ class_addmethod(vocoder_class, (t_method)vocoder_dsp, gensym("dsp"), 0);
+ class_addmethod(vocoder_class, (t_method)vocoder_cutoff, gensym("cutoff"), A_FLOAT, 0);
+ class_addmethod(vocoder_class, (t_method)vocoder_vfeedback, gensym("vfeedback"), A_FLOAT, 0);
+}