aboutsummaryrefslogtreecommitdiff
path: root/formant~
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 17:08:55 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 17:08:55 +0000
commit506b8e7dedb80d79bf015e47d92e8b8dd8284584 (patch)
tree6393e98add0a0ae7f92388665b3b6242977f5b64 /formant~
parent856eaf396d9a4d371a458a2c373a052bb72c8057 (diff)
added files straight from Yves' sources
svn path=/trunk/externals/unauthorized/; revision=864
Diffstat (limited to 'formant~')
-rw-r--r--formant~/INSTALL9
-rw-r--r--formant~/Makefile82
-rw-r--r--formant~/README21
-rw-r--r--formant~/formant~.c252
-rw-r--r--formant~/help-formant~.pd56
5 files changed, 420 insertions, 0 deletions
diff --git a/formant~/INSTALL b/formant~/INSTALL
new file mode 100644
index 0000000..bcbc08b
--- /dev/null
+++ b/formant~/INSTALL
@@ -0,0 +1,9 @@
+untar in /my/pd/dir/externs
+
+cd /my/pd/dir/externs/formant~
+
+make
+
+make install
+
+you're set !!
diff --git a/formant~/Makefile b/formant~/Makefile
new file mode 100644
index 0000000..6ebad5a
--- /dev/null
+++ b/formant~/Makefile
@@ -0,0 +1,82 @@
+NAME=formant~
+CSYM=formant_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 -DUNIX -DICECAST -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 $*.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 ..
+
+# ----------------------------------------------------------
+
+install:
+ cp help-*.pd ../../doc/5.reference
+
+clean:
+ rm -f *.o *.pd_* so_locations
diff --git a/formant~/README b/formant~/README
new file mode 100644
index 0000000..41526cb
--- /dev/null
+++ b/formant~/README
@@ -0,0 +1,21 @@
+Version 0.01
+copyleft 2001 by Yves Degoyon
+
+formant~.dll is a formant synthesis generator external for pd (by Miller
+Puckette).
+
+To install formant~, 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.
+
+*****************************************************************************
+
+thruth is here.
+trust is in another world.
+
diff --git a/formant~/formant~.c b/formant~/formant~.c
new file mode 100644
index 0000000..eba7db5
--- /dev/null
+++ b/formant~/formant~.c
@@ -0,0 +1,252 @@
+/* ------------------------ formant~ ------------------------------------------ */
+/* */
+/* Tilde object to produce formant synthesis. */
+/* By using several ones, you should be able to generate voice sounds. */
+/* Written by Yves Degoyon ( ydegoyon@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. */
+/* */
+/* See file LICENSE for further informations on licensing terms. */
+/* */
+/* 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. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* Also inspired by an article by Jean-Paul Smets - Solanes */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+
+
+#include <sys/types.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <malloc.h>
+#include <ctype.h>
+#ifdef UNIX
+#include <unistd.h>
+#endif
+#ifdef NT
+#define M_PI 3.14159265358979323846
+#endif
+#include <math.h>
+
+#include "m_pd.h" /* standard pd stuff */
+
+static char *formant_version = "formant~: formant synthesis version 0.1, written by Yves Degoyon";
+
+
+static t_class *formant_class;
+
+typedef struct _formant
+{
+ t_object x_obj;
+
+ t_int x_size; /* size of the sample */
+ t_float x_central_freq; /* central frequency of the filter */
+ t_float x_filter_width; /* width of the filter */
+ t_float x_skirt_width; /* width of the skirt */
+ t_float x_samplerate; /* sample rate */
+ t_float x_time_stretch; /* time stretch */
+ t_int x_readpos; /* data's reading position */
+ t_int x_play; /* playing on/off flag */
+ t_outlet *x_end; /* outlet for outputing a bang at the end */
+ t_float x_gendata; /* flag to avoid reading data during generation ( might be null )*/
+ t_float* x_data; /* sample containing formant synthesis*/
+
+} t_formant;
+
+ /* clean up */
+static void formant_free(t_formant *x)
+{
+ if ( x->x_data != NULL ) {
+ freebytes(x->x_data, x->x_size*sizeof(float) );
+ x->x_data = NULL;
+ }
+}
+
+ /* generate sample data */
+static t_int formant_gendata(t_formant *x)
+{
+ t_float t, b, fs;
+
+ if ( x->x_size <= 0 || x->x_central_freq <= 0 || x->x_filter_width <= 0 || x->x_skirt_width <= 0 ) {
+ error( "formant~ : error generating data : negative or null parameter(s)" );
+ return -1;
+ }
+
+ x->x_gendata = 1;
+
+ /* freeing data */
+ formant_free( x );
+ if ( !( x->x_data = (float*) getbytes( x->x_size*sizeof(float) ) ) ) {
+ post( "formant~ : error generating data : cannot allocate table" );
+ return -1;
+ }
+
+ fs = 0;
+ while( fs < x->x_size-1 ) {
+ t = (fs/x->x_samplerate) * x->x_time_stretch; /* time taken from zero */
+ b = M_PI / x->x_skirt_width ;
+ if ( t < b ) {
+ *(x->x_data+(int)fs) = 0.5*(1-cos(x->x_skirt_width*t))*exp(- x->x_filter_width*t )*sin( x->x_central_freq*t);
+ } else {
+ *(x->x_data+(int)fs) = exp(- x->x_filter_width*t )*sin( x->x_central_freq*t);
+ }
+ fs++;
+ }
+
+ /* everything went fine */
+ x->x_gendata = 0;
+ return 0;
+}
+
+ /* generates a formant */
+static t_int *formant_perform(t_int *w)
+{
+ t_formant *x = (t_formant *)(w[1]);
+ t_float *out = (t_float *)(w[2]);
+ int n = (int)(w[3]); /* number of samples */
+
+ while (n--) {
+ if ( !x->x_gendata && x->x_play) {
+ *out=*(x->x_data+x->x_readpos);
+ x->x_readpos = (x->x_readpos+1)%x->x_size;
+ if ( x->x_readpos == 0 ) {
+ x->x_play=0;
+ outlet_bang(x->x_end);
+ }
+ } else {
+ *out=0.0;
+ }
+ out++;
+ }
+ return (w+4);
+}
+
+static void formant_dsp(t_formant *x, t_signal **sp)
+{
+ dsp_add(formant_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+ /* replay the sample */
+static void formant_bang(t_formant *x, t_floatarg fsize)
+{
+ x->x_play=1;
+ x->x_readpos=0;
+}
+
+ /* set size of the sample */
+static void formant_size(t_formant *x, t_floatarg fsize)
+{
+ if ( fsize <= 0 ) {
+ post( "formant~ : error : sample size should be >0" );
+ return;
+ }
+ x->x_size = fsize;
+ formant_gendata( x );
+}
+
+ /* set central frequency of the formant */
+static void formant_central_freq(t_formant *x, t_floatarg ffreq)
+{
+ if ( ffreq <= 0 ) {
+ post( "formant~ : error : filter central frequency should be >0" );
+ return;
+ }
+ x->x_central_freq = ffreq;
+ formant_gendata( x );
+}
+
+ /* set filter width of the formant */
+static void formant_filter_width(t_formant *x, t_floatarg fwidth)
+{
+ if ( fwidth <= 0 ) {
+ post( "formant~ : error : filter width should be >0" );
+ return;
+ }
+ x->x_filter_width = fwidth;
+ formant_gendata( x );
+}
+
+ /* set skirt width of the formant */
+static void formant_skirt_width(t_formant *x, t_floatarg swidth)
+{
+ if ( swidth <= 0 ) {
+ post( "formant~ : error : skirt width should be >0" );
+ return;
+ }
+ x->x_skirt_width = swidth;
+ formant_gendata( x );
+}
+
+ /* set time stretch factor */
+static void formant_time_stretch(t_formant *x, t_floatarg fstretch)
+{
+ if ( fstretch <= 0 ) {
+ post( "formant~ : error : time stretch should be >0" );
+ return;
+ }
+ x->x_time_stretch = fstretch;
+ formant_gendata( x );
+}
+
+static void *formant_new(t_floatarg fsize, t_floatarg ffreq, t_floatarg ffwidth, t_floatarg fswidth)
+{
+ t_formant *x = (t_formant *)pd_new(formant_class);
+ outlet_new(&x->x_obj, &s_signal);
+
+ if ( fsize <= 0 || ffreq <= 0 || ffwidth <= 0 || fswidth <= 0 ) {
+ error( "formant~ : missing or negative creation arguments" );
+ return NULL;
+ }
+
+ x->x_size = fsize;
+ x->x_central_freq = ffreq;
+ x->x_filter_width = ffwidth;
+ x->x_skirt_width = fswidth;
+ x->x_readpos = 0;
+ x->x_data = NULL;
+ x->x_time_stretch = 1.0;
+ x->x_samplerate = sys_getsr();
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("size"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("freq"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fwidth"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("swidth"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("stretch"));
+ x->x_end = outlet_new( &x->x_obj, &s_bang );
+ if ( formant_gendata( x ) ) {
+ post( "formant~ : error generating data" );
+ return NULL;
+ } else {
+ return(x);
+ }
+}
+
+void formant_tilde_setup(void)
+{
+ post(formant_version);
+ formant_class = class_new(gensym("formant~"), (t_newmethod)formant_new, (t_method)formant_free,
+ sizeof(t_formant), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_sethelpsymbol( formant_class, gensym("help-formant~") );
+ class_addmethod(formant_class, (t_method)formant_dsp, gensym("dsp"), 0);
+ class_addmethod(formant_class, (t_method)formant_size, gensym("size"), A_FLOAT, 0);
+ class_addmethod(formant_class, (t_method)formant_bang, gensym("bang"), 0);
+ class_addmethod(formant_class, (t_method)formant_central_freq, gensym("freq"), A_FLOAT, 0);
+ class_addmethod(formant_class, (t_method)formant_filter_width, gensym("fwidth"), A_FLOAT, 0);
+ class_addmethod(formant_class, (t_method)formant_skirt_width, gensym("swidth"), A_FLOAT, 0);
+ class_addmethod(formant_class, (t_method)formant_time_stretch, gensym("stretch"), A_FLOAT, 0);
+}
diff --git a/formant~/help-formant~.pd b/formant~/help-formant~.pd
new file mode 100644
index 0000000..c8102b4
--- /dev/null
+++ b/formant~/help-formant~.pd
@@ -0,0 +1,56 @@
+#N canvas 190 63 711 524 10;
+#X msg 172 385 \; pd dsp 1;
+#X msg 238 385 \; pd dsp 0;
+#X floatatom 150 58 10 0 0;
+#X floatatom 232 121 5 0 0;
+#X floatatom 190 93 5 0 0;
+#X floatatom 295 140 5 0 0;
+#X text 149 42 Size of the synthetized sound;
+#X text 189 78 Central frequency;
+#X text 232 104 Filter width;
+#X text 294 125 Skirt width ( "largeur de jupe" in french );
+#X msg 114 136 bang;
+#X text 99 13 Formant synthesis as described by JP Smets;
+#X floatatom 340 159 5 0 0;
+#X text 382 158 Time Stretch;
+#X obj 333 390 dac~;
+#X obj 303 244 delay 200;
+#X floatatom 364 244 5 0 0;
+#X obj 368 298 f;
+#X floatatom 367 343 5 0 0;
+#X obj 446 297 loadbang;
+#X text 323 217 Theoretically \, a singing voice is a combination of
+formants but you have to set right frequencies;
+#X msg 406 298 2500;
+#X obj 367 320 + 100;
+#X obj 121 263 formant~ 10000 2600 50 25;
+#X obj 303 263 formant~ 10000 1750 70 25;
+#X obj 199 319 formant~ 20000 4500 60 25;
+#X obj 466 263 formant~ 10000 1200 30 45;
+#X connect 2 0 23 1;
+#X connect 3 0 23 3;
+#X connect 4 0 23 2;
+#X connect 5 0 23 4;
+#X connect 10 0 15 0;
+#X connect 10 0 23 0;
+#X connect 10 0 26 0;
+#X connect 12 0 23 5;
+#X connect 15 0 24 0;
+#X connect 16 0 15 1;
+#X connect 17 0 22 0;
+#X connect 17 0 25 2;
+#X connect 19 0 21 0;
+#X connect 21 0 17 1;
+#X connect 22 0 17 1;
+#X connect 22 0 18 0;
+#X connect 23 0 14 0;
+#X connect 23 0 14 1;
+#X connect 23 1 17 0;
+#X connect 23 1 25 0;
+#X connect 24 0 14 1;
+#X connect 24 0 14 0;
+#X connect 25 0 14 1;
+#X connect 25 0 14 0;
+#X connect 25 1 10 0;
+#X connect 26 0 14 1;
+#X connect 26 0 14 0;