aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Kelly <edkelly@users.sourceforge.net>2005-11-01 14:28:57 +0000
committerEd Kelly <edkelly@users.sourceforge.net>2005-11-01 14:28:57 +0000
commit94c8ac7a5d633a8d7d94a6b9c85f7423c2da6f13 (patch)
treee2973e64d2728879e2efbdfdbb578ed7a2f87185
parenteb8173324e5611defc3403d35b49d52dab86bc1c (diff)
This commit was generated by cvs2svn to compensate for changes in r3802,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ekext/; revision=3803
-rw-r--r--peakit~/README.txt8
-rw-r--r--peakit~/license.txt31
-rw-r--r--peakit~/makefile105
-rw-r--r--peakit~/peakit-listmoses.pd362
-rw-r--r--peakit~/peakit~.c138
5 files changed, 644 insertions, 0 deletions
diff --git a/peakit~/README.txt b/peakit~/README.txt
new file mode 100644
index 0000000..427e349
--- /dev/null
+++ b/peakit~/README.txt
@@ -0,0 +1,8 @@
+peakit~ - find frequency peaks of an FFT and output lists of frequencies and magnitudes.
+
+(c) Edward Kelly 2005. This software is subject to the GNU General Public License, and may be freely copied, distributed and modified.
+
+You will need the listmoses external to make the best use of this software, and to run the peakit-listmoses demonstration patches in the help file.
+
+Have fun!
+Ed Kelly <morph_2016@yahoo.co.uk>
diff --git a/peakit~/license.txt b/peakit~/license.txt
new file mode 100644
index 0000000..353aef4
--- /dev/null
+++ b/peakit~/license.txt
@@ -0,0 +1,31 @@
+This software is copyrighted by Edward Kelly. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
diff --git a/peakit~/makefile b/peakit~/makefile
new file mode 100644
index 0000000..e6588a6
--- /dev/null
+++ b/peakit~/makefile
@@ -0,0 +1,105 @@
+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: peakit~.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: peakit~.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: peakit~.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: peakit~.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: peakit~.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 peakit~.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra
+ install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference
diff --git a/peakit~/peakit-listmoses.pd b/peakit~/peakit-listmoses.pd
new file mode 100644
index 0000000..0075dc6
--- /dev/null
+++ b/peakit~/peakit-listmoses.pd
@@ -0,0 +1,362 @@
+#N canvas 0 0 769 391 10;
+#N canvas 0 0 450 300 peakit 0;
+#X obj 183 102 rfft~;
+#X obj 184 57 inlet~;
+#X obj 183 157 outlet;
+#X obj 227 157 outlet;
+#X obj 242 90 inlet;
+#X obj 183 140 peakit~ 0;
+#X text 89 185 argument sets minimum magnitude to report;
+#X obj 315 76 switch~ 1024 1 1;
+#X obj 315 51 inlet;
+#X connect 0 0 5 0;
+#X connect 0 1 5 1;
+#X connect 1 0 0 0;
+#X connect 4 0 5 2;
+#X connect 5 0 2 0;
+#X connect 5 1 3 0;
+#X connect 8 0 7 0;
+#X restore 447 134 pd peakit;
+#X floatatom 447 69 5 0 0 0 - - -;
+#X floatatom 237 168 0 0 0 0 - - -;
+#X floatatom 288 168 0 0 0 0 - - -;
+#X floatatom 339 168 0 0 0 0 - - -;
+#X floatatom 390 168 0 0 0 0 - - -;
+#X floatatom 441 168 0 0 0 0 - - -;
+#X floatatom 492 168 0 0 0 0 - - -;
+#X floatatom 529 168 0 0 0 0 - - -;
+#X floatatom 580 168 0 0 0 0 - - -;
+#X obj 367 256 listmoses;
+#X floatatom 458 242 5 0 0 0 - - -;
+#X floatatom 523 242 5 0 0 0 - - -;
+#X obj 458 225 unpack f f;
+#X floatatom 476 120 3 0 500 2 magnitude-threshold - -;
+#X obj 458 191 loadbang;
+#X msg 447 52 440;
+#X obj 447 35 loadbang;
+#X text 13 58 peakit~ finds the frequencies of each peak in an FFT
+vector \, which it outputs as a list from the left outlet. It separates
+out the magnitudes of those peaks also \, which it outputs from it's
+right output. Right-to-left order is preserved so that the object may
+be used with the listmoses external.;
+#X msg 458 208 300 800;
+#N canvas 0 0 615 349 sources 0;
+#X obj 37 99 osc~ 440;
+#X obj 135 82 sig~;
+#X obj 135 99 phasor~ 440;
+#X obj 134 121 -~ 0.5;
+#X obj 244 100 tabplay~ testinput;
+#X obj 65 35 inlet;
+#X obj 302 22 inlet;
+#X obj 372 100 spigot;
+#X obj 302 39 route bang float;
+#X obj 31 210 *~ 1;
+#X obj 75 210 *~ 0;
+#X msg 209 174 1;
+#X msg 209 193 0;
+#X obj 209 155 sel 0 1 2;
+#X msg 232 174 1;
+#X msg 232 193 0;
+#X msg 255 174 1;
+#X msg 255 193 0;
+#X obj 119 210 *~ 0;
+#X obj 75 251 outlet~;
+#X obj 209 138 r \$0-select-input;
+#X msg 160 245 set sine;
+#X msg 218 245 set sawtooth;
+#X msg 304 245 set sample;
+#X obj 197 290 s \$0-label;
+#X msg 413 67 bang;
+#X obj 436 102 openpanel;
+#X msg 436 119 read -resize \$1 testinput;
+#X obj 436 136 soundfiler;
+#X obj 452 203 loadbang;
+#X obj 452 248 s \$0-main-on;
+#X msg 452 225 1;
+#X connect 0 0 9 0;
+#X connect 1 0 2 0;
+#X connect 2 0 3 0;
+#X connect 3 0 10 0;
+#X connect 4 0 18 0;
+#X connect 4 1 7 0;
+#X connect 5 0 0 0;
+#X connect 5 0 1 0;
+#X connect 6 0 8 0;
+#X connect 7 0 4 0;
+#X connect 8 0 4 0;
+#X connect 8 1 7 1;
+#X connect 8 2 25 0;
+#X connect 9 0 19 0;
+#X connect 10 0 19 0;
+#X connect 11 0 9 1;
+#X connect 12 0 9 1;
+#X connect 13 0 11 0;
+#X connect 13 0 15 0;
+#X connect 13 0 17 0;
+#X connect 13 0 21 0;
+#X connect 13 1 12 0;
+#X connect 13 1 14 0;
+#X connect 13 1 17 0;
+#X connect 13 1 22 0;
+#X connect 13 2 12 0;
+#X connect 13 2 15 0;
+#X connect 13 2 16 0;
+#X connect 13 2 23 0;
+#X connect 14 0 10 1;
+#X connect 15 0 10 1;
+#X connect 16 0 18 1;
+#X connect 17 0 18 1;
+#X connect 18 0 19 0;
+#X connect 20 0 13 0;
+#X connect 21 0 24 0;
+#X connect 22 0 24 0;
+#X connect 23 0 24 0;
+#X connect 25 0 26 0;
+#X connect 26 0 27 0;
+#X connect 27 0 28 0;
+#X connect 29 0 31 0;
+#X connect 31 0 30 0;
+#X restore 447 86 pd sources;
+#X obj 546 69 tgl 17 0 empty empty loop-sample 0 -6 0 8 -262144 -1
+-1 0 1;
+#N canvas 0 0 450 300 graph1 0;
+#X array testinput 100 float 3;
+#A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0;
+#X coords 0 1 99 -1 100 70 1;
+#X restore 642 130 graph;
+#X obj 513 27 hradio 15 1 0 3 \$0-select-input empty source 0 -6 0
+8 -262144 -1 -1 0;
+#X obj 521 69 bng 17 250 50 0 empty empty play 0 -6 0 8 -262144 -1
+-1;
+#X symbolatom 513 42 8 0 0 0 - #0-label -;
+#X msg 570 69 load;
+#N canvas 0 0 763 487 amp-segregation 0;
+#X obj 36 148 listswap;
+#X obj 37 49 tabplay~ testinput;
+#N canvas 0 0 450 300 peakit 0;
+#X obj 70 58 inlet~;
+#X obj 67 95 rfft~;
+#X obj 67 122 peakit~;
+#X obj 67 152 outlet;
+#X obj 116 152 outlet;
+#X obj 200 125 switch~ 1024 1 1;
+#X obj 201 95 inlet;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 1 2 1;
+#X connect 2 0 3 0;
+#X connect 2 1 4 0;
+#X connect 6 0 5 0;
+#X restore 36 118 pd peakit;
+#X obj 118 92 tgl 15 0 empty empty on 0 -6 0 12 -262144 -1 -1 0 1;
+#X obj 171 49 spigot;
+#X obj 222 49 tgl 15 0 empty empty loop 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 37 34 bng 15 250 50 0 empty empty play 0 -6 0 8 -262144 -1 -1
+;
+#X obj 36 207 listmoses;
+#X msg 113 138 10 100;
+#X obj 113 155 unpack f f;
+#X floatatom 113 172 5 0 0 0 - - -;
+#X floatatom 178 172 5 0 0 0 - - -;
+#X obj 113 121 loadbang;
+#X floatatom 393 319 0 0 0 0 - - -;
+#X floatatom 424 302 0 0 0 0 - - -;
+#X floatatom 455 285 0 0 0 0 - - -;
+#X floatatom 486 268 0 0 0 0 - - -;
+#X floatatom 541 319 0 0 0 0 - - -;
+#X floatatom 572 302 0 0 0 0 - - -;
+#X floatatom 603 285 0 0 0 0 - - -;
+#X floatatom 634 268 0 0 0 0 - - -;
+#X floatatom 245 320 0 0 0 0 - - -;
+#X floatatom 276 302 0 0 0 0 - - -;
+#X floatatom 307 285 0 0 0 0 - - -;
+#X floatatom 338 268 0 0 0 0 - - -;
+#X text 413 235 freqs-MID;
+#X obj 245 251 unpack f f f f;
+#X obj 393 251 unpack f f f f;
+#X obj 541 251 unpack f f f f;
+#X text 560 234 freqs-LOUD;
+#X text 260 235 freqs-QUIET;
+#X floatatom 184 423 0 0 0 0 - - -;
+#X floatatom 215 406 0 0 0 0 - - -;
+#X floatatom 246 389 0 0 0 0 - - -;
+#X floatatom 277 372 0 0 0 0 - - -;
+#X floatatom 332 423 0 0 0 0 - - -;
+#X floatatom 363 406 0 0 0 0 - - -;
+#X floatatom 394 389 0 0 0 0 - - -;
+#X floatatom 425 372 0 0 0 0 - - -;
+#X floatatom 36 424 0 0 0 0 - - -;
+#X floatatom 67 406 0 0 0 0 - - -;
+#X floatatom 98 389 0 0 0 0 - - -;
+#X floatatom 129 372 0 0 0 0 - - -;
+#X obj 36 355 unpack f f f f;
+#X obj 184 355 unpack f f f f;
+#X obj 332 355 unpack f f f f;
+#X text 51 339 mags-QUIET;
+#X text 204 339 mags-MID;
+#X text 351 338 mags-LOUD;
+#X text 336 251 f...;
+#X text 484 251 f...;
+#X text 632 251 f...;
+#X text 127 355 f...;
+#X text 275 355 f...;
+#X text 423 355 f...;
+#X text 243 85 peakit~ / listmoses can also be used to segregate frequencies
+according to their power. You nee the listswap abstraction for this.
+1st 4 elements of each list shown...;
+#X connect 0 0 7 0;
+#X connect 0 1 7 1;
+#X connect 1 0 2 0;
+#X connect 1 1 4 0;
+#X connect 2 0 0 0;
+#X connect 2 1 0 1;
+#X connect 3 0 2 1;
+#X connect 4 0 1 0;
+#X connect 5 0 4 1;
+#X connect 6 0 1 0;
+#X connect 7 0 43 0;
+#X connect 7 1 44 0;
+#X connect 7 2 45 0;
+#X connect 7 3 26 0;
+#X connect 7 4 27 0;
+#X connect 7 5 28 0;
+#X connect 8 0 9 0;
+#X connect 9 0 10 0;
+#X connect 9 1 11 0;
+#X connect 10 0 7 2;
+#X connect 11 0 7 3;
+#X connect 12 0 8 0;
+#X connect 26 0 21 0;
+#X connect 26 1 22 0;
+#X connect 26 2 23 0;
+#X connect 26 3 24 0;
+#X connect 27 0 13 0;
+#X connect 27 1 14 0;
+#X connect 27 2 15 0;
+#X connect 27 3 16 0;
+#X connect 28 0 17 0;
+#X connect 28 1 18 0;
+#X connect 28 2 19 0;
+#X connect 28 3 20 0;
+#X connect 43 0 39 0;
+#X connect 43 1 40 0;
+#X connect 43 2 41 0;
+#X connect 43 3 42 0;
+#X connect 44 0 31 0;
+#X connect 44 1 32 0;
+#X connect 44 2 33 0;
+#X connect 44 3 34 0;
+#X connect 45 0 35 0;
+#X connect 45 1 36 0;
+#X connect 45 2 37 0;
+#X connect 45 3 38 0;
+#X restore 69 235 pd amp-segregation;
+#X obj 613 119 tgl 15 0 empty \$0-main-on on 0 -6 0 8 -262144 -1 -1
+0 1;
+#X floatatom 146 389 0 0 0 0 - - -;
+#X floatatom 177 372 0 0 0 0 - - -;
+#X floatatom 208 355 0 0 0 0 - - -;
+#X floatatom 239 338 0 0 0 0 - - -;
+#X floatatom 269 389 0 0 0 0 - - -;
+#X floatatom 300 372 0 0 0 0 - - -;
+#X floatatom 331 355 0 0 0 0 - - -;
+#X floatatom 362 338 0 0 0 0 - - -;
+#X floatatom 23 390 0 0 0 0 - - -;
+#X floatatom 54 372 0 0 0 0 - - -;
+#X floatatom 85 355 0 0 0 0 - - -;
+#X floatatom 116 338 0 0 0 0 - - -;
+#X text 166 305 freqs-MID;
+#X obj 23 321 unpack f f f f;
+#X obj 146 321 unpack f f f f;
+#X obj 269 321 unpack f f f f;
+#X floatatom 516 389 0 0 0 0 - - -;
+#X floatatom 547 372 0 0 0 0 - - -;
+#X floatatom 578 355 0 0 0 0 - - -;
+#X floatatom 609 338 0 0 0 0 - - -;
+#X floatatom 640 389 0 0 0 0 - - -;
+#X floatatom 671 372 0 0 0 0 - - -;
+#X floatatom 702 355 0 0 0 0 - - -;
+#X floatatom 733 338 0 0 0 0 - - -;
+#X floatatom 392 390 0 0 0 0 - - -;
+#X floatatom 423 372 0 0 0 0 - - -;
+#X floatatom 454 355 0 0 0 0 - - -;
+#X floatatom 485 338 0 0 0 0 - - -;
+#X obj 392 321 unpack f f f f;
+#X obj 516 321 unpack f f f f;
+#X obj 640 321 unpack f f f f;
+#X text 536 305 mags-MID;
+#X text 114 321 f...;
+#X text 237 321 f...;
+#X text 360 321 f...;
+#X text 483 321 f...;
+#X text 607 321 f...;
+#X text 731 321 f...;
+#X text 407 305 mags-LOW;
+#X text 659 305 mags-HIGH;
+#X text 38 305 freqs-LOW;
+#X text 288 304 freqs-HIGH;
+#X obj 313 151 unpack f f f f f f f f;
+#X text 329 133 it's in here--->;
+#X obj 17 21 peakit~;
+#X text 17 21 peakit~ - FFT peak frequencies and magnitudes;
+#X text 85 37 (c) Edward Kelly 2005 - GNU GPL;
+#X connect 0 0 10 0;
+#X connect 0 0 71 0;
+#X connect 0 1 10 1;
+#X connect 1 0 20 0;
+#X connect 10 0 42 0;
+#X connect 10 1 43 0;
+#X connect 10 2 44 0;
+#X connect 10 3 57 0;
+#X connect 10 4 58 0;
+#X connect 10 5 59 0;
+#X connect 11 0 10 2;
+#X connect 12 0 10 3;
+#X connect 13 0 11 0;
+#X connect 13 1 12 0;
+#X connect 14 0 0 1;
+#X connect 15 0 19 0;
+#X connect 16 0 1 0;
+#X connect 17 0 16 0;
+#X connect 19 0 13 0;
+#X connect 20 0 0 0;
+#X connect 21 0 20 1;
+#X connect 24 0 20 1;
+#X connect 26 0 20 1;
+#X connect 28 0 0 2;
+#X connect 42 0 37 0;
+#X connect 42 1 38 0;
+#X connect 42 2 39 0;
+#X connect 42 3 40 0;
+#X connect 43 0 29 0;
+#X connect 43 1 30 0;
+#X connect 43 2 31 0;
+#X connect 43 3 32 0;
+#X connect 44 0 33 0;
+#X connect 44 1 34 0;
+#X connect 44 2 35 0;
+#X connect 44 3 36 0;
+#X connect 57 0 53 0;
+#X connect 57 1 54 0;
+#X connect 57 2 55 0;
+#X connect 57 3 56 0;
+#X connect 58 0 45 0;
+#X connect 58 1 46 0;
+#X connect 58 2 47 0;
+#X connect 58 3 48 0;
+#X connect 59 0 49 0;
+#X connect 59 1 50 0;
+#X connect 59 2 51 0;
+#X connect 59 3 52 0;
+#X connect 71 0 2 0;
+#X connect 71 1 3 0;
+#X connect 71 2 4 0;
+#X connect 71 3 5 0;
+#X connect 71 4 6 0;
+#X connect 71 5 7 0;
+#X connect 71 6 8 0;
+#X connect 71 7 9 0;
diff --git a/peakit~/peakit~.c b/peakit~/peakit~.c
new file mode 100644
index 0000000..09cf787
--- /dev/null
+++ b/peakit~/peakit~.c
@@ -0,0 +1,138 @@
+/* peakit~ - find frequencies and magnitudes of FFT peaks
+ * Copyright (C) 2005 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>
+#include <string.h>
+
+static t_class *peakit_tilde_class;
+
+typedef struct _bin_store
+{
+ t_atom peaks[2048];
+ t_atom indices[2048];
+ t_atom theta[4096];
+ t_atom t_prev[4096];
+ t_atom t_delta[4096];
+ t_atom peakfreqs[2048];
+ t_float *f_real, *f_imag;
+} t_bin_store;
+
+typedef struct _peakit_tilde
+{
+ t_object x_obj;
+ t_bin_store x_ctl;
+ t_outlet *peaks_list, *mags_list;
+ t_float f_npeaks, f_minmag, f_dummy;
+} t_peakit_tilde;
+
+t_int *peakit_tilde_perform(t_int *w)
+{
+ t_peakit_tilde *x = (t_peakit_tilde *)(w[1]);
+ t_bin_store *store = (t_bin_store *)(w[2]);
+ t_sample *profile = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
+ t_float *real = store->f_real;
+ t_float *imag = store->f_imag;
+ int vector = n;
+ float s_rate = sys_getsr();
+ float bin = s_rate/n;
+ float boff = bin/2;
+ float interp;
+ float minus_two = 0;
+ float minus_one = 0;
+ float alpha = 0;
+ float peakfreq;
+ float theta = 0;
+ float t_prev = 0;
+ float t_delta;
+ float pi=M_PI;
+ float twopi=2*pi;
+ t_int npeaks = 0;
+ int i, ndx;
+
+ /* find peaks in fourier series */
+ for (i = 0; i < n; i++)
+ {
+ alpha = sqrt(real[i] * real[i] + imag[i] * imag[i]);
+ theta = atan2(real[i], imag[i]);
+ t_prev = atom_getfloatarg(i, 16384, store->theta);
+ SETFLOAT (&store->t_prev[i], t_prev);
+ SETFLOAT (&store->theta[i], theta);
+ t_delta = (atom_getfloatarg(i, 16384, store->theta))-(atom_getfloatarg(i, 16384, store->t_prev));
+ SETFLOAT (&store->t_delta[i], t_delta);
+ if (minus_two<minus_one && alpha<minus_one && minus_one>(x->f_minmag/1000))
+ {
+ SETFLOAT (&store->peaks[npeaks],minus_one);
+ SETFLOAT (&store->indices[npeaks],i-1);
+ npeaks++;
+ }
+ minus_two = minus_one;
+ minus_one = alpha;
+ }
+ for (i = 0; i < npeaks; i++)
+ {
+ ndx = atom_getfloatarg(i, 8192, store->indices);
+ t_delta = atom_getfloatarg(ndx, 16384, store->t_delta);
+ theta = atom_getfloatarg(ndx, 8192, store->theta);
+ t_prev = atom_getfloatarg(ndx, 8192, store->t_prev);
+ t_delta = (t_delta < -pi) ? (theta+twopi)-t_prev : (t_delta > pi) ? theta-(t_prev+twopi) : t_delta;
+ // t_delta = (t_delta < -pi) ? (theta+twopi)-t_prev : (t_delta > pi) ? theta-(t_prev+twopi) : t_delta;
+ peakfreq = (ndx * bin + (boff * (t_delta/pi)));
+ SETFLOAT (&store->peakfreqs[i], peakfreq);
+ }
+ outlet_list(x->mags_list, gensym("list"), (npeaks - 1), store->peaks);
+ outlet_list(x->peaks_list, gensym("list"), (npeaks - 1), store->peakfreqs);
+ return(w+5);
+}
+
+void *peakit_tilde_dsp(t_peakit_tilde *x, t_signal **sp)
+{
+ x->x_ctl.f_real = sp[0]->s_vec;
+ x->x_ctl.f_imag = sp[1]->s_vec;
+ dsp_add(peakit_tilde_perform, 4, x, &x->x_ctl, sp[0]->s_vec, sp[0]->s_n);
+ return (void *)x;
+}
+
+void *peakit_tilde_new(t_floatarg f)
+{
+ t_peakit_tilde *x = (t_peakit_tilde *)pd_new(peakit_tilde_class);
+ x->f_minmag = f;
+ memset(x->x_ctl.theta, 0, 8192);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ floatinlet_new(&x->x_obj, &x->f_minmag);
+ x->peaks_list = outlet_new(&x->x_obj, &s_list);
+ x->mags_list = outlet_new(&x->x_obj, &s_list);
+ return (void *)x;
+}
+
+void peakit_tilde_setup(void)
+{
+ peakit_tilde_class = class_new(gensym("peakit~"),
+ (t_newmethod)peakit_tilde_new,
+ 0, sizeof(t_peakit_tilde),
+ CLASS_DEFAULT, A_DEFFLOAT, 0);
+
+ post("|--<>---<>--<peakit~>-<>--<>----<>--|");
+ post("|--<FFT peaks list>-<>---<>--<>-----|");
+ post("|---<>-<frequencies and magnitudes>-|");
+ post("|-<>-<edward>-<kelly>--<>---<2005>--|");
+
+ class_sethelpsymbol(peakit_tilde_class, gensym("help-peakit~"));
+ class_addmethod(peakit_tilde_class, (t_method)peakit_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(peakit_tilde_class, t_peakit_tilde, f_dummy);
+}