diff options
Diffstat (limited to 'pd')
-rw-r--r-- | pd/extra/help-paf~.pd | 165 | ||||
-rw-r--r-- | pd/extra/help-rev1.pd | 119 | ||||
-rw-r--r-- | pd/extra/paf~/README.txt | 12 | ||||
-rw-r--r-- | pd/extra/paf~/makefile | 97 | ||||
-rw-r--r-- | pd/extra/paf~/paf~.c | 927 |
5 files changed, 0 insertions, 1320 deletions
diff --git a/pd/extra/help-paf~.pd b/pd/extra/help-paf~.pd deleted file mode 100644 index b36a7597..00000000 --- a/pd/extra/help-paf~.pd +++ /dev/null @@ -1,165 +0,0 @@ -#N canvas 19 4 745 493 12; -#X msg 37 311 freq \$1 100; -#X obj 37 286 mtof; -#X msg 127 311 amp \$1 100; -#X obj 127 261 r amp; -#X obj 212 262 r cf; -#X obj 212 287 mtof; -#X msg 212 312 cf \$1 100; -#X obj 37 261 r pit; -#X msg 149 426 bang; -#X obj 80 455 dac~; -#X obj 535 161 s vfr; -#X obj 535 86 r vfr; -#X obj 483 161 s vib; -#X obj 483 86 r vib; -#X msg 535 111 set \$1; -#X floatatom 535 136 0 0 0; -#X msg 483 111 set \$1; -#X floatatom 483 136 0 0 0; -#X obj 434 161 s bw; -#X obj 385 161 s cf; -#X obj 266 160 s amp; -#X obj 325 159 s pit; -#X obj 325 84 r pit; -#X msg 325 109 set \$1; -#X floatatom 325 134 0 0 0; -#X obj 266 85 r amp; -#X msg 266 110 set \$1; -#X floatatom 266 135 0 0 0; -#X msg 385 111 set \$1; -#X floatatom 385 136 0 0 0; -#X obj 385 86 r cf; -#X msg 434 111 set \$1; -#X floatatom 434 136 0 0 0; -#X obj 434 86 r bw; -#X msg 286 312 bw \$1 100; -#X obj 286 262 r bw; -#X obj 286 287 mtof; -#X obj 365 262 r vib; -#X msg 365 312 vib \$1 100; -#X msg 445 312 vfr \$1 100; -#X obj 445 287 / 8; -#X obj 445 262 r vfr; -#X obj 365 287 / 660; -#X msg 589 111 set \$1; -#X floatatom 589 136 0 0 0; -#X obj 589 86 r shift; -#X obj 589 161 s shift; -#X obj 530 262 r shift; -#X msg 530 312 shift \$1 100; -#X obj 127 286 dbtorms; -#X obj 94 400 paf~; -#X obj 30 432 s~ foo; -#X msg 627 313 phase 0 0 0; -#X obj 149 451 print~ output; -#N canvas 447 311 726 483 spectrum 0; -#X graph graph1 0 -1.02 882 1.02 405 401 605 271; -#X array pulse-output 882 float; -#X pop; -#X text 405 403 --------- 0.02 seconds ------; -#X graph graph1 0 0 128 500 391 208 647 78; -#X array spectrum 128 float; -#X pop; -#X obj 137 257 tabwrite~ pulse-output; -#X msg 106 174 bang; -#N canvas 204 17 358 238 fft 0; -#X obj 46 48 inlet~; -#X obj 159 181 tabwrite~ spectrum; -#X obj 159 145 inlet; -#X obj 46 78 rfft~; -#X obj 46 111 *~; -#X obj 77 111 *~; -#X obj 46 141 sqrt~; -#X obj 191 45 block~ 1024 1; -#X connect 0 0 3 0; -#X connect 2 0 1 0; -#X connect 3 0 4 0; -#X connect 3 0 4 1; -#X connect 3 1 5 0; -#X connect 3 1 5 1; -#X connect 4 0 6 0; -#X connect 5 0 6 0; -#X connect 6 0 1 0; -#X restore 46 228 pd fft; -#X text 33 8 PULSE SPECTRUM MEASUREMENT; -#X text 379 221 0; -#X text 627 218 5512; -#X obj 94 123 r~ foo; -#X obj 41 160 *~ 1; -#X floatatom 44 113 0 0 0; -#X obj 179 136 metro 1000; -#X floatatom 178 108 0 0 0; -#X obj 56 44 r graph; -#X obj 140 205 *~ 10; -#X connect 4 0 3 0; -#X connect 4 0 5 1; -#X connect 9 0 10 0; -#X connect 9 0 15 0; -#X connect 10 0 5 0; -#X connect 11 0 10 1; -#X connect 12 0 4 0; -#X connect 13 0 12 0; -#X connect 14 0 11 0; -#X connect 14 0 13 0; -#X connect 15 0 3 0; -#X restore 438 413 pd spectrum; -#X msg 42 133 \; pd dsp 1 \; pit 60 \; cf 60 \; graph 20; -#X text 48 10 The "PAF" generator \, described in a paper in JAES 43/1 pp. 40-47 \, reprinted on Miller Puckette's web page. Often used in Philippe Manoury's music. The important controls are center frequency ("cf") and bandwidth ("bw") here controlled as MIDI values.; -#X text 37 88 clich here to test; -#X text 34 106 (then set amplitude); -#X text 423 390 click here to see spectrum; -#X msg 343 383 bw 0; -#X msg 367 418 bw 0; -#X msg 295 418 bw 80 100; -#X msg 295 384 bw 700; -#X connect 0 0 50 0; -#X connect 1 0 0 0; -#X connect 2 0 50 0; -#X connect 3 0 49 0; -#X connect 4 0 5 0; -#X connect 5 0 6 0; -#X connect 6 0 50 0; -#X connect 7 0 1 0; -#X connect 8 0 53 0; -#X connect 11 0 14 0; -#X connect 13 0 16 0; -#X connect 14 0 15 0; -#X connect 15 0 10 0; -#X connect 16 0 17 0; -#X connect 17 0 12 0; -#X connect 22 0 23 0; -#X connect 23 0 24 0; -#X connect 24 0 21 0; -#X connect 25 0 26 0; -#X connect 26 0 27 0; -#X connect 27 0 20 0; -#X connect 28 0 29 0; -#X connect 29 0 19 0; -#X connect 30 0 28 0; -#X connect 31 0 32 0; -#X connect 32 0 18 0; -#X connect 33 0 31 0; -#X connect 34 0 50 0; -#X connect 35 0 36 0; -#X connect 36 0 34 0; -#X connect 37 0 42 0; -#X connect 38 0 50 0; -#X connect 39 0 50 0; -#X connect 40 0 39 0; -#X connect 41 0 40 0; -#X connect 42 0 38 0; -#X connect 43 0 44 0; -#X connect 44 0 46 0; -#X connect 45 0 43 0; -#X connect 47 0 48 0; -#X connect 48 0 50 0; -#X connect 49 0 2 0; -#X connect 50 0 9 0; -#X connect 50 0 51 0; -#X connect 50 0 9 1; -#X connect 50 0 53 0; -#X connect 52 0 50 0; -#X connect 60 0 50 0; -#X connect 62 0 50 0; -#X connect 63 0 50 0; diff --git a/pd/extra/help-rev1.pd b/pd/extra/help-rev1.pd deleted file mode 100644 index 55580bd5..00000000 --- a/pd/extra/help-rev1.pd +++ /dev/null @@ -1,119 +0,0 @@ -#N canvas 55 21 1008 526 12; -#X obj 148 439 dac~; -#X obj 58 72 line~; -#X msg 58 49 0 \, 10000 5; -#X obj 58 118 cos~; -#X msg 146 70 1; -#X obj 146 47 loadbang; -#X obj 58 95 clip~ 0 0.25; -#X floatatom 173 264 0 0 0; -#X obj 251 134 line~; -#X obj 251 157 cos~; -#X msg 324 54 -0.25 \, 0.25 100; -#X obj 251 8 loadbang; -#X msg 251 31 -0.25; -#X obj 251 203 *~; -#X obj 58 140 hip~ 5; -#X floatatom 162 328 0 0 0; -#X obj 162 373 pack 0 100; -#X obj 162 396 line~; -#X obj 148 416 *~; -#X obj 162 350 dbtorms; -#X msg 324 77 -0.25 \, 0.25 400; -#X floatatom 324 145 0 0 0; -#X obj 324 191 osc~ 440; -#X obj 324 168 mtof; -#X msg 324 31 -0.25 \, 0.25 20; -#X obj 251 180 *~ 0.1; -#X msg 324 100 -0.25 \, 0.25 1000; -#X msg 324 122 -0.25 \, 0.25 2000; -#X obj 324 226 *~; -#X obj 342 252 *~; -#X obj 58 439 dac~; -#X floatatom 68 323 0 0 0; -#X obj 68 368 pack 0 100; -#X obj 68 391 line~; -#X obj 58 416 *~; -#X obj 68 346 dbtorms; -#X msg 324 8 0; -#X obj 308 257 *~; -#X obj 58 26 metro 2000; -#X floatatom 58 4 0 0 0; -#X msg 220 265 bang; -#X obj 284 322 env~ 32768; -#X floatatom 284 344 0 0 0; -#X text 166 244 1 sec; -#X text 143 226 dB after; -#X text 220 245 clear; -#X text 1 51 impulse; -#X text 362 7 tone; -#X text 484 31 beeps; -#X text 428 167 This is an experimental reverberator design composed -of a series of allpass filters with exponentially growing delay times. -Each allpass filter has a gain of 0.7. The reverb time is adjusted -by adjusting the input gains of the allpass filters. The last unit -is modified so that its first two "echos" mimic those of an allpass -but its loop gain depends on reverb time.; -#X text 430 299 Reverb time is controlled by specifying the dB gain -(100 normal) after one second \, so that 100 corresponds to infinite -reverb time \, 70 to two seconds \, 40 to one second \, and 0 to 0 -; -#X text 671 499 modified for Pd version 0.30.; -#X msg 560 34 \; pd dsp 1; -#X text 427 475 The rev1~ module eats about 18% of my 300mHz P2 machine. -; -#X obj 148 289 rev1~; -#X text 428 381 The "clear" button impolitely clears out all the delay -lines \, You may immediately resume pumping the reverberator \, but -the input signal should be cleanly enveloped. The output \, too \, -must be enveloped and may not be opened until 5 msec after the "clear" -message is sent.; -#X connect 1 0 6 0; -#X connect 2 0 1 0; -#X connect 3 0 14 0; -#X connect 4 0 1 0; -#X connect 5 0 4 0; -#X connect 6 0 3 0; -#X connect 7 0 54 1; -#X connect 8 0 9 0; -#X connect 9 0 25 0; -#X connect 10 0 8 0; -#X connect 11 0 12 0; -#X connect 12 0 8 0; -#X connect 13 0 14 0; -#X connect 14 0 34 0; -#X connect 14 0 54 0; -#X connect 15 0 19 0; -#X connect 16 0 17 0; -#X connect 17 0 18 1; -#X connect 18 0 0 0; -#X connect 19 0 16 0; -#X connect 20 0 8 0; -#X connect 21 0 23 0; -#X connect 22 0 13 1; -#X connect 22 0 28 0; -#X connect 22 0 28 1; -#X connect 22 0 29 0; -#X connect 23 0 22 0; -#X connect 24 0 8 0; -#X connect 25 0 13 0; -#X connect 26 0 8 0; -#X connect 27 0 8 0; -#X connect 28 0 29 1; -#X connect 28 0 13 1; -#X connect 28 0 37 0; -#X connect 28 0 37 1; -#X connect 29 0 13 1; -#X connect 31 0 35 0; -#X connect 32 0 33 0; -#X connect 33 0 34 1; -#X connect 34 0 30 0; -#X connect 35 0 32 0; -#X connect 36 0 8 0; -#X connect 37 0 13 1; -#X connect 38 0 2 0; -#X connect 39 0 38 0; -#X connect 40 0 54 2; -#X connect 41 0 42 0; -#X connect 54 0 18 0; -#X connect 54 0 41 0; diff --git a/pd/extra/paf~/README.txt b/pd/extra/paf~/README.txt deleted file mode 100644 index 9bd41879..00000000 --- a/pd/extra/paf~/README.txt +++ /dev/null @@ -1,12 +0,0 @@ -Paf is copyright (C) 1999 Miller Puckette. -Permission is granted to use this software for any purpose, commercial -or noncommercial, as long as this notice is included with all copies. - -NEITHER THE AUTHORS NOR THEIR EMPLOYERS MAKE ANY WARRANTY, EXPRESS OR IMPLIED, -IN CONNECTION WITH THIS SOFTWARE! - ----------------------------------------------------------------------------- - -This is the README file for the "paf" percussion detector. This software -is available from http://www.crca.ucsd.edu/~msp as part of the "toys" -library. - msp@ucsd.edu diff --git a/pd/extra/paf~/makefile b/pd/extra/paf~/makefile deleted file mode 100644 index cb06b555..00000000 --- a/pd/extra/paf~/makefile +++ /dev/null @@ -1,97 +0,0 @@ -NAME=paf~ -CSYM=paf_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 -f $*.o ../$*.pd_linux - ln -s $*.pd_linux .. - -# ----------------------- 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 = -fPIC -DPD -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -LSTRIP = strip --strip-unneeded -R .note -R .comment - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - cc -Wl,-export_dynamic --shared -o $*.pd_linux $*.o -lm - $(LSTRIP) $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ----------------------- Mac OSX ----------------------- - -pd_darwin: $(NAME).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 ../$*.pd_darwin - ln -s $*/$*.pd_darwin .. - -# ---------------------------------------------------------- - -clean: - rm -f *.o *.pd_* so_locations diff --git a/pd/extra/paf~/paf~.c b/pd/extra/paf~/paf~.c deleted file mode 100644 index 4a1fec07..00000000 --- a/pd/extra/paf~/paf~.c +++ /dev/null @@ -1,927 +0,0 @@ -/* paf -- version of the paf generator derived from "jupiterpaf", from -Manoury's Jupiter, 1997 version. Can be compiled as a standalone test program, -or as an object in Max 0.26, JMAX, or Pd. */ - -/* Copyright 1997-1999 Miller Puckette. -Permission is granted to use this software for any purpose provided you -keep this copyright notice intact. - -THE AUTHOR AND HIS EMPLOYERS MAKE NO WARRANTY, EXPRESS OR IMPLIED, -IN CONNECTION WITH THIS SOFTWARE. - -This file is downloadable from http://www.crca.ucsd.edu/~msp . - -Warning: the algorithms implemented here are covered by patents held by -IRCAM. While this probably does not restrict anyone from distributing -software implementing the paf, any hardware implementor should obtain a -license from IRCAM. -*/ - -static char *paf_version = "paf version 0.06"; - -#ifdef NT -#pragma warning (disable: 4305 4244) -#endif - -#ifdef TESTME -#include <stdio.h> -#endif -#ifdef FTS15 -#include "mess.h" -#include "dsp.h" -#endif -#ifdef V26SGI -#include "m_extern.h" -#include "d_graph.h" -#include "d_ugen.h" -#endif -#ifdef PD -#include "m_pd.h" -#endif -#include <math.h> - -#define LOGTABSIZE 9 -#define TABSIZE (1 << LOGTABSIZE) -#define TABRANGE 3 - -typedef struct _tabpoint -{ - float p_y; - float p_diff; -} t_tabpoint; - -static t_tabpoint paf_gauss[TABSIZE]; -static t_tabpoint paf_cauchy[TABSIZE]; - -typedef struct _linenv -{ - double l_current; - double l_biginc; - float l_1overn; - float l_target; - float l_msectodsptick; - int l_ticks; -} t_linenv; - -typedef struct _pafctl -{ - t_linenv x_freqenv; - t_linenv x_cfenv; - t_linenv x_bwenv; - t_linenv x_ampenv; - t_linenv x_vibenv; - t_linenv x_vfrenv; - t_linenv x_shiftenv; - float x_isr; - float x_held_freq; - float x_held_intcar; - float x_held_fraccar; - float x_held_bwquotient; - double x_phase; - double x_shiftphase; - double x_vibphase; - int x_triggerme; - int x_cauchy; -} t_pafctl; - -static void linenv_debug(t_linenv *l, char *s) -{ -#ifdef DEBUG - post("%s: current %f, target %f", s, l->l_current, l->l_target); -#endif -} - -static void linenv_init(t_linenv *l) -{ - l->l_current = l->l_biginc = 0; - l->l_1overn = l->l_target = l->l_msectodsptick = 0; - l->l_ticks = 0; -} - -static void linenv_setsr(t_linenv *l, float sr, int vecsize) -{ - l->l_msectodsptick = sr / (1000.f * ((float)vecsize)); - l->l_1overn = 1.f/(float)vecsize; -} - -static void linenv_set(t_linenv *l, float target, long timdel) -{ - if (timdel > 0) - { - l->l_ticks = ((float)timdel) * l->l_msectodsptick; - if (!l->l_ticks) l->l_ticks = 1; - l->l_target = target; - l->l_biginc = (l->l_target - l->l_current)/l->l_ticks; - } - else - { - l->l_ticks = 0; - l->l_current = l->l_target = target; - l->l_biginc = 0; - } -} - -#define LINENV_RUN(linenv, current, incr) \ - if (linenv.l_ticks > 0) \ - { \ - current = linenv.l_current; \ - incr = linenv.l_biginc * linenv.l_1overn; \ - linenv.l_ticks--; \ - linenv.l_current += linenv.l_biginc; \ - } \ - else \ - { \ - linenv.l_current = current = linenv.l_target; \ - incr = 0; \ - } - -#define UNITBIT32 1572864. /* 3*2^19 -- bit 32 has value 1 */ -#define TABFRACSHIFT (UNITBIT32/TABSIZE) - -#ifdef __sgi - /* machine-dependent definitions: */ -#define HIOFFSET 0 /* word offset to find MSB; endianness-dependent */ -#define LOWOFFSET 0 /* word offset to find MSB; endianness-dependent */ -#define int32 unsigned long /* a data type that has 32 bits */ -#define DONE_MACHINE_TYPE -#endif /* __sgi */ - -#ifdef NT - /* little-endian; most significant byte is at highest address */ -#define HIOFFSET 1 -#define LOWOFFSET 0 -#define int32 unsigned long -#define DONE_MACHINE_TYPE -#endif /* NT */ - -#ifdef MACOSX -#define HIOFFSET 0 /* word offset to find MSB */ -#define LOWOFFSET 1 /* word offset to find LSB */ -#define int32 int /* a data type that has 32 bits */ -#define DONE_MACHINE_TYPE -#endif /* MACOSX */ - -#ifdef __FreeBSD__ -#include <machine/endian.h> -#if BYTE_ORDER == LITTLE_ENDIAN -#define HIOFFSET 1 -#define LOWOFFSET 0 -#else -#define HIOFFSET 0 /* word offset to find MSB */ -#define LOWOFFSET 1 /* word offset to find LSB */ -#endif /* BYTE_ORDER */ -#include <sys/types.h> -#define int32 int32_t -#define DONE_MACHINE_TYPE -#endif /* __FreeBSD__ */ - -#ifdef __linux__ - -#include <endian.h> - -#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) -#error No byte order defined -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define HIOFFSET 1 -#define LOWOFFSET 0 -#else -#define HIOFFSET 0 /* word offset to find MSB */ -#define LOWOFFSET 1 /* word offset to find LSB */ -#endif /* __BYTE_ORDER */ - -#include <sys/types.h> -#define int32 u_int32_t - -#define DONE_MACHINE_TYPE -#endif /* __linux__ */ - -#ifndef DONE_MACHINE_TYPE -#error -- no machine architecture definition? -#endif - -#define A1 ((float)(4 * (3.14159265/2))) -#define A3 ((float)(64 * (2.5 - 3.14159265))) -#define A5 ((float)(1024 * ((3.14159265/2) - 1.5))) - -static void pafctl_run(t_pafctl *x, float *out1, int n) -{ - float freqval, freqinc; - float cfval, cfinc; - float bwval, bwinc; - float ampval, ampinc; - float vibval, vibinc; - float vfrval, vfrinc; - float shiftval, shiftinc; - float bwquotient, bwqincr; - double ub32 = UNITBIT32; - double phase = x->x_phase + ub32; - double phasehack; - volatile double *phasehackp = &phasehack; - double shiftphase = x->x_shiftphase + ub32; - volatile int32 *hackptr = ((int32 *)(phasehackp)) + HIOFFSET, hackval; - volatile int32 *lowptr = ((int32 *)(phasehackp)) + LOWOFFSET, lowbits; - float held_freq = x->x_held_freq; - float held_intcar = x->x_held_intcar; - float held_fraccar = x->x_held_fraccar; - float held_bwquotient = x->x_held_bwquotient; - float sinvib, vibphase; - t_tabpoint *paf_table = (x->x_cauchy ? paf_cauchy : paf_gauss); - *phasehackp = ub32; - hackval = *hackptr; - - /* fractional part of shift phase */ - *phasehackp = shiftphase; - *hackptr = hackval; - shiftphase = *phasehackp; - - /* propagate line envelopes */ - LINENV_RUN(x->x_freqenv, freqval, freqinc); - LINENV_RUN(x->x_cfenv, cfval, cfinc); - LINENV_RUN(x->x_bwenv, bwval, bwinc); - LINENV_RUN(x->x_ampenv, ampval, ampinc); - LINENV_RUN(x->x_vibenv, vibval, vibinc); - LINENV_RUN(x->x_vfrenv, vfrval, vfrinc); - LINENV_RUN(x->x_shiftenv, shiftval, shiftinc); - - /* fake line envelope for quotient of bw and frequency */ - bwquotient = bwval/freqval; - bwqincr = (((float)(x->x_bwenv.l_current))/ - ((float)(x->x_freqenv.l_current)) - bwquotient) * - x->x_freqenv.l_1overn; - - /* run the vibrato oscillator */ - - *phasehackp = ub32 + (x->x_vibphase + n * x->x_isr * vfrval); - *hackptr = hackval; - vibphase = (x->x_vibphase = *phasehackp - ub32); - if (vibphase > 0.5) - sinvib = 1.0f - 16.0f * (0.75f-vibphase) * (0.75f - vibphase); - else sinvib = -1.0f + 16.0f * (0.25f-vibphase) * (0.25f - vibphase); - freqval = freqval * (1.0f + vibval * sinvib); - - shiftval *= x->x_isr; - shiftinc *= x->x_isr; - - /* if phase or amplitude is zero, load in new params */ - if (ampval == 0 || phase == ub32 || x->x_triggerme) - { - float cf_over_freq = cfval/freqval; - held_freq = freqval * x->x_isr; - held_intcar = (float)((int)cf_over_freq); - held_fraccar = cf_over_freq - held_intcar; - held_bwquotient = bwquotient; - x->x_triggerme = 0; - } - while (n--) - { - double newphase = phase + held_freq; - double carphase1, carphase2, fracnewphase; - float fphase, fcarphase1, fcarphase2, carrier; - float g, g2, g3, cosine1, cosine2, halfsine, mod, tabfrac; - t_tabpoint *p; - /* put new phase into 64-bit memory location. Bash upper - 32 bits to get fractional part (plus "ub32"). */ - - *phasehackp = newphase; - *hackptr = hackval; - newphase = *phasehackp; - fracnewphase = newphase-ub32; - fphase = 2.0f * ((float)(fracnewphase)) - 1.0f; - if (newphase < phase) - { - float cf_over_freq = cfval/freqval; - held_freq = freqval * x->x_isr; - held_intcar = (float)((int)cf_over_freq); - held_fraccar = cf_over_freq - held_intcar; - held_bwquotient = bwquotient; - } - phase = newphase; - *phasehackp = fracnewphase * held_intcar + shiftphase; - *hackptr = hackval; - carphase1 = *phasehackp; - fcarphase1 = carphase1 - ub32; - *phasehackp = carphase1 + fracnewphase; - *hackptr = hackval; - carphase2 = *phasehackp; - fcarphase2 = carphase2 - ub32; - - shiftphase += shiftval; - - if (fcarphase1 > 0.5f) g = fcarphase1 - 0.75f; - else g = 0.25f - fcarphase1; - g2 = g * g; - g3 = g * g2; - cosine1 = g * A1 + g3 * A3 + g2 * g3 * A5; - - if (fcarphase2 > 0.5f) g = fcarphase2 - 0.75f; - else g = 0.25f - fcarphase2; - g2 = g * g; - g3 = g * g2; - cosine2 = g * A1 + g3 * A3 + g2 * g3 * A5; - - carrier = cosine1 + held_fraccar * (cosine2-cosine1); - - ampval += ampinc; - bwquotient += bwqincr; - - /* printf("bwquotient %f\n", bwquotient); */ - - halfsine = held_bwquotient * (1.0f - fphase * fphase); - if (halfsine >= (float)(0.997 * TABRANGE)) - halfsine = (float)(0.997 * TABRANGE); - -#if 0 - shape = halfsine * halfsine; - mod = ampval * carrier * - (1 - bluntval * shape) / (1 + (1 - bluntval) * shape); -#endif -#if 0 - shape = halfsine * halfsine; - mod = ampval * carrier * - exp(-shape); -#endif - halfsine *= (float)(1./TABRANGE); - - /* Get table index for "halfsine". Bash upper - 32 bits to get fractional part (plus "ub32"). Also grab - fractional part as a fixed-point number to use as table - address later. */ - - *phasehackp = halfsine + ub32; - lowbits = *lowptr; - - /* now shift again so that the fractional table address - appears in the low 32 bits, bash again, and extract this as - a floating point number from 0 to 1. */ - *phasehackp = halfsine + TABFRACSHIFT; - *hackptr = hackval; - tabfrac = *phasehackp - ub32; - - p = paf_table + (lowbits >> (32 - LOGTABSIZE)); - mod = ampval * carrier * (p->p_y + tabfrac * p->p_diff); - - *out1++ = mod; - } - x->x_phase = phase - ub32; - x->x_shiftphase = shiftphase - ub32; - x->x_held_freq = held_freq; - x->x_held_intcar = held_intcar; - x->x_held_fraccar = held_fraccar; - x->x_held_bwquotient = held_bwquotient; -} - -static void pafctl_init(t_pafctl *x) -{ - linenv_init(&x->x_freqenv); - linenv_init(&x->x_cfenv); - linenv_init(&x->x_bwenv); - linenv_init(&x->x_ampenv); - linenv_init(&x->x_vibenv); - linenv_init(&x->x_vfrenv); - linenv_init(&x->x_shiftenv); - x->x_freqenv.l_target = x->x_freqenv.l_current = 1.0; - x->x_isr = (float)(1./44100.); - x->x_held_freq = 1.f; - x->x_held_intcar = 0.f; - x->x_held_fraccar = 0.f; - x->x_held_bwquotient = 0.f; - x->x_phase = 0.; - x->x_shiftphase = 0.; - x->x_vibphase = 0.; - x->x_triggerme = 0; - x->x_cauchy = 0; -} - -static void pafctl_setsr(t_pafctl *x, float sr, int vecsize) -{ - x->x_isr = 1.f/sr; - linenv_setsr(&x->x_freqenv, sr, vecsize); - linenv_setsr(&x->x_cfenv, sr, vecsize); - linenv_setsr(&x->x_bwenv, sr, vecsize); - linenv_setsr(&x->x_ampenv, sr, vecsize); - linenv_setsr(&x->x_vibenv, sr, vecsize); - linenv_setsr(&x->x_vfrenv, sr, vecsize); - linenv_setsr(&x->x_shiftenv, sr, vecsize); -} - -static void pafctl_freq(t_pafctl *x, float val, int time) -{ - if (val < 1.f) val = 1.f; - if (val > 10000000.f) val = 1000000.f; - linenv_set(&x->x_freqenv, val, time); -} - -static void pafctl_cf(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_cfenv, val, time); -} - -static void pafctl_bw(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_bwenv, val, time); -} - -static void pafctl_amp(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_ampenv, val, time); -} - -static void pafctl_vib(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_vibenv, val, time); -} - -static void pafctl_vfr(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_vfrenv, val, time); -} - -static void pafctl_shift(t_pafctl *x, float val, int time) -{ - linenv_set(&x->x_shiftenv, val, time); -} - -static void pafctl_phase(t_pafctl *x, float mainphase, float shiftphase, - float vibphase) -{ - x->x_phase = mainphase; - x->x_shiftphase = shiftphase; - x->x_vibphase = vibphase; - x->x_triggerme = 1; -} - - /* value of Cauchy distribution at TABRANGE */ -#define CAUCHYVAL (1./ (1. + TABRANGE * TABRANGE)) - /* first derivative of Cauchy distribution at TABRANGE */ -#define CAUCHYSLOPE ((-2. * TABRANGE) * CAUCHYVAL * CAUCHYVAL) -#define ADDSQ (- CAUCHYSLOPE / (2 * TABRANGE)) - -static void paf_dosetup(void) -{ - int i; - float CAUCHYFAKEAT3 = - (CAUCHYVAL + ADDSQ * TABRANGE * TABRANGE); - float CAUCHYRESIZE = (1./ (1. - CAUCHYFAKEAT3)); - for (i = 0; i <= TABSIZE; i++) - { - float f = i * ((float)TABRANGE/(float)TABSIZE); - float gauss = exp(-f * f); - float cauchygenuine = 1. / (1. + f * f); - float cauchyfake = cauchygenuine + ADDSQ * f * f; - float cauchyrenorm = (cauchyfake - 1.) * CAUCHYRESIZE + 1.; - if (i != TABSIZE) - { - paf_gauss[i].p_y = gauss; - paf_cauchy[i].p_y = cauchyrenorm; - /* post("%f", cauchyrenorm); */ - } - if (i != 0) - { - paf_gauss[i-1].p_diff = gauss - paf_gauss[i-1].p_y; - paf_cauchy[i-1].p_diff = cauchyrenorm - paf_cauchy[i-1].p_y; - } - } -} - -#ifdef TESTME - -#define BS 64 -main() -{ - t_pafctl x; - float x1[BS]; - int i; - paf_dosetup(); - pafctl_init(&x); - pafctl_setsr(&x, 16000., BS); - pafctl_freq(&x, 1000, 0); - pafctl_bw(&x, 2000, 0); - pafctl_amp(&x, 1000, 0); - pafctl_run(&x, x1, BS); - for (i = 0; i < BS/4; i++) - { - printf("%15.5f %15.5f %15.5f %15.5f\n", - x1[4*i], x1[4*i+1], x1[4*i+2], x1[4*i+3]); - } -#if 0 - printf("\n"); - pafctl_bw(&x, 2000, 0); - pafctl_run(&x, x1, BS); - for (i = 0; i < BS/4; i++) - { - printf("%15.5f %15.5f %15.5f %15.5f\n", - x1[4*i], x1[4*i+1], x1[4*i+2], x1[4*i+3]); - } -#endif -} - -#endif -#ifdef FTS1X - -static fts_symbol_t *paf_dspname; - -typedef struct _paf -{ - fts_object_t ob; /* object header */ - t_pafctl pafctl; -} paf_t; - -/* ---------------------------------------- */ -/* Methods */ -/* ---------------------------------------- */ - - /* formalities... */ - -static void paf_dspfun(fts_word_t *a) -{ - paf_t *x = (paf_t *)fts_word_get_obj(a); - float *out1 = (float *)fts_word_get_obj(a + 1); - long n = fts_word_get_long(a + 3); - - pafctl_run(&x->pafctl, out1, n); -} - -void paf_put(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *x = (paf_t *)o; - fts_dsp_descr_t *dsp = (fts_dsp_descr_t *)fts_get_obj_arg(at, ac, 0, 0); - fts_atom_t a[4]; - float sr = fts_dsp_get_output_srate(dsp, 0); - int vecsize = fts_dsp_get_output_size(dsp, 0); - - pafctl_setsr(&x->pafctl, sr, vecsize); - fts_set_obj(a, x); - fts_set_symbol(a+1, fts_dsp_get_output_name(dsp, 0)); - fts_set_long(a+2, fts_dsp_get_output_size(dsp, 0)); - dsp_add_funcall(paf_dspname, 3, a); -} - -static void paf_freq(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_freq(&this->pafctl, val, time); -} - -static void paf_cf(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_cf(&this->pafctl, val, time); -} - -static void paf_bw(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_bw(&this->pafctl, val, time); -} - -static void paf_amp(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_amp(&this->pafctl, val, time); -} - -static void paf_vib(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_vib(&this->pafctl, val, time); -} - -static void paf_vfr(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_vfr(&this->pafctl, val, time); -} - -static void paf_shift(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float val = fts_get_float_long_arg( at, ac, 0, 0.0f); - int time = fts_get_long_arg(at, ac, 1, 0); - pafctl_shift(&this->pafctl, val, time); -} - -static void paf_phase(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - float phase = fts_get_float_long_arg( at, ac, 0, 0.0f); - float shiftphase = fts_get_long_arg(at, ac, 1, 0); - float vibphase = fts_get_long_arg(at, ac, 2, 0); - pafctl_shift(&this->pafctl, phase, shiftphase, vibphase); -} - -static void -paf_print(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) -{ -} - -static void -paf_init(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - int i; - - dsp_list_insert(o); /* put object in list */ - pafctl_init(&this->pafctl); -} - -static void paf_delete(fts_object_t *o, int winlet, fts_symbol_t *s, - int ac, const fts_atom_t *at) -{ - paf_t *this = (paf_t *)o; - - dsp_list_remove(o); -} - -static fts_status_t paf_instantiate( fts_class_t *cl, - int ac, const fts_atom_t *at) -{ - fts_atom_type_t a[3]; - - fts_class_init( cl, sizeof(paf_t), 1, 2, 0); - - a[0] = fts_Symbol; - fts_method_define( cl, fts_SystemInlet, fts_s_init, paf_init, 1, a); - fts_method_define( cl, fts_SystemInlet, fts_s_delete, paf_delete, 1, a); - - a[0] = fts_Float|fts_Long; - a[1] = fts_Long; - fts_method_define( cl, 0, fts_new_symbol("freq"), paf_freq, 2, a); - fts_method_define( cl, 0, fts_new_symbol("cf"), paf_cf, 2, a); - fts_method_define( cl, 0, fts_new_symbol("bw"), paf_bw, 2, a); - fts_method_define( cl, 0, fts_new_symbol("amp"), paf_amp, 2, a); - fts_method_define( cl, 0, fts_new_symbol("vib"), paf_vib, 2, a); - fts_method_define( cl, 0, fts_new_symbol("vfr"), paf_vfr, 2, a); - fts_method_define( cl, 0, fts_new_symbol("shift"), paf_shift, 2, a); - fts_method_define( cl, 0, fts_new_symbol("phase"), paf_phase, 3, a); - - fts_method_define( cl, 0, fts_new_symbol("print"), paf_print, 0, 0); - - a[0] = fts_Object; - fts_method_define(cl, fts_SystemInlet, fts_new_symbol("put"), - paf_put, 1, a); - - dsp_sig_inlet(cl, 0); /* order forcing only */ - - dsp_sig_outlet(cl, 0); - - return fts_Success; -} - -fts_symbol_t *paf_qui; - -void paf_config(void) -{ - sys_log(paf_version); - paf_dspname = fts_new_symbol("paf"); - dsp_declare_function(paf_dspname, paf_dspfun); - fts_metaclass_create(fts_new_symbol("paf"), - paf_instantiate, fts_always_equiv); - paf_dosetup(); -} - -fts_module_t paf_module = - {"paf", "paf", paf_config, 0}; - -#endif /* FTS1X */ - -#ifdef V26 - -typedef struct _paf -{ - t_head x_h; - t_sig *x_io[IN1+OUT1]; - t_pafctl x_pafctl; -} t_paf; - -static void paf_put(t_paf *x, long int whether) -{ - if (whether) - { - float sr = x->x_io[0]->s_sr; - int vecsize = x->x_io[0]->s_n; - u_stdout((t_ugen *)x); - pafctl_setsr(&x->x_pafctl, sr, vecsize); - dspchain_addc(pafctl_run, 3, - &x->x_pafctl, x->x_io[1]->s_shit, x->x_io[1]->s_n); - } -} - -static void paf_freq(t_paf *x, double val, int time) -{ - pafctl_freq(&x->x_pafctl, val, time); -} - -static void paf_cf(t_paf *x, double val, int time) -{ - pafctl_cf(&x->x_pafctl, val, time); -} - -static void paf_bw(t_paf *x, double val, int time) -{ - pafctl_bw(&x->x_pafctl, val, time); -} - -static void paf_amp(t_paf *x, double val, int time) -{ - pafctl_amp(&x->x_pafctl, val, time); -} - -static void paf_vib(t_paf *x, double val, int time) -{ - pafctl_vib(&x->x_pafctl, val, time); -} - -static void paf_vfr(t_paf *x, double val, int time) -{ - pafctl_vfr(&x->x_pafctl, val, time); -} - -static void paf_shift(t_paf *x, double val, int time) -{ - pafctl_shift(&x->x_pafctl, val, time); -} - -static void paf_phase(t_paf *x, double phase, double shiftphase, - double vibphase) -{ - pafctl_phase(&x->x_pafctl, phase, shiftphase, vibphase); -} - -static void paf_debug(t_paf *x) -{ - linenv_debug( &x->x_pafctl.x_ampenv, "amp"); - linenv_debug(&x->x_pafctl.x_freqenv, "fre"); -} - -t_externclass *paf_class; - -static void *paf_new() -{ - t_paf *x = (t_paf *)obj_new(&paf_class, 0); - u_setup((t_ugen *)x, IN1, OUT1); - u_setforcer(x); - pafctl_init(&x->x_pafctl); - return (x); -} - -void sigpaf_setup() -{ - post(paf_version); - c_extern(&paf_class, paf_new, u_clean, - gensym("paf"), sizeof(t_paf), 0, 0); - c_addmess(paf_put, gensym("put"), A_CANT, 0); - c_addmess(paf_freq, gensym("freq"), A_FLOAT, A_LONG, 0); - c_addmess(paf_cf, gensym("cf"), A_FLOAT, A_LONG, 0); - c_addmess(paf_bw, gensym("bw"), A_FLOAT, A_LONG, 0); - c_addmess(paf_amp, gensym("amp"), A_FLOAT, A_LONG, 0); - c_addmess(paf_vib, gensym("vib"), A_FLOAT, A_LONG, 0); - c_addmess(paf_vfr, gensym("vfr"), A_FLOAT, A_LONG, 0); - c_addmess(paf_shift, gensym("shift"), A_FLOAT, A_LONG, 0); - c_addmess(paf_phase, gensym("phase"), A_FLOAT, A_FLOAT, A_FLOAT, 0); - c_addmess(paf_debug, gensym("debug"), 0); - u_inletmethod(0); - paf_dosetup(); -} - -#endif /* V26 */ - -#ifdef PD - -typedef struct _paf -{ - t_object x_obj; - t_pafctl x_pafctl; -} t_paf; - -static t_class *paf_class; - -static void *paf_new(void) -{ - t_paf *x = (t_paf *)pd_new(paf_class); - pafctl_init(&x->x_pafctl); - outlet_new(&x->x_obj, gensym("signal")); - return (x); -} - -static t_int *paf_perform(t_int *w) -{ - t_pafctl *ctl = (t_pafctl *)(w[1]); - t_float *out1 = (t_float *)(w[2]); - int n = (int)(w[3]); - pafctl_run(ctl, out1, n); - return (w+4); -} - -static void paf_dsp(t_paf *x, t_signal **sp) -{ - float sr = sp[0]->s_sr; - int vecsize = sp[0]->s_n; - pafctl_setsr(&x->x_pafctl, sr, vecsize); - dsp_add(paf_perform, 3, - &x->x_pafctl, sp[0]->s_vec, sp[0]->s_n); -} - -static void paf_freq(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_freq(&x->x_pafctl, val, time); -} - -static void paf_cf(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_cf(&x->x_pafctl, val, time); -} - -static void paf_bw(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_bw(&x->x_pafctl, val, time); -} - -static void paf_amp(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_amp(&x->x_pafctl, val, time); -} - -static void paf_vib(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_vib(&x->x_pafctl, val, time); -} - -static void paf_vfr(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_vfr(&x->x_pafctl, val, time); -} - -static void paf_shift(t_paf *x, t_floatarg val, t_floatarg time) -{ - pafctl_shift(&x->x_pafctl, val, time); -} - -static void paf_phase(t_paf *x, t_floatarg mainphase, t_floatarg shiftphase, - t_floatarg vibphase) -{ - pafctl_phase(&x->x_pafctl, mainphase, shiftphase, vibphase); -} - -static void paf_setcauchy(t_paf *x, t_floatarg f) -{ - x->x_pafctl.x_cauchy = (f != 0); -} - -static void paf_debug(t_paf *x) -{ - /* whatever you want... */ -} - -void paf_tilde_setup(void) -{ - post(paf_version); - paf_class = class_new(gensym("paf~"), (t_newmethod)paf_new, 0, - sizeof(t_paf), 0, 0); - class_addmethod(paf_class, (t_method)paf_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(paf_class, (t_method)paf_freq, gensym("freq"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_cf, gensym("cf"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_bw, gensym("bw"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_amp, gensym("amp"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_vib, gensym("vib"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_vfr, gensym("vfr"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_shift, gensym("shift"), - A_FLOAT, A_DEFFLOAT, 0); - class_addmethod(paf_class, (t_method)paf_phase, gensym("phase"), - A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(paf_class, (t_method)paf_setcauchy, gensym("cauchy"), - A_FLOAT, 0); - class_addmethod(paf_class, (t_method)paf_debug, gensym("debug"), 0); - paf_dosetup(); -} - -#endif /* PD */ |