pax_global_header00006660000000000000000000000064143411566540014523gustar00rootroot0000000000000052 comment=4e64813e347defa7c7b51c944e9cdbe2e903bd5d bsaylor-0.1.5/000077500000000000000000000000001434115665400132015ustar00rootroot00000000000000bsaylor-0.1.5/LICENSE.txt000066400000000000000000000432541434115665400150340ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. bsaylor-0.1.5/Makefile000066400000000000000000000021161434115665400146410ustar00rootroot00000000000000# Makefile to build library 'bsaylor' for Pure Data. # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build # settings and rules. # # use : make pdincludepath=/path/to/pure-data/src/ # # The following command will build the external and install the distributable # files into a subdirectory called build/bsaylor : # # make install pdincludepath=../pure-data/src/ objectsdir=./build lib.name = bsaylor # link statically FFTW3_CFLAGS = FFTW3_LIBS = -l:libfftw3.a FFTW3F_CFLAGS = FFTW3F_LIBS = -l:libfftw3f.a objects = aenv~ partconv~ pvoc~ susloop~ svf~ zhzxh~ pvoc~.class.ldlibs = $(FFTW3_LIBS) partconv~.class.ldlibs = $(FFTW3F_LIBS) class.sources = $(addsuffix .c,$(objects)) # all extra files to be included in binary distribution of the library datafiles = $(addsuffix -help.pd,$(objects)) LICENSE.txt README.txt datadirs = examples cflags += -Wno-unused -Wno-unused-parameter $(FFTW3_CFLAGS) $(FFTW3F_CFLAGS) # include Makefile.pdlibbuilder from submodule directory 'pd-lib-builder' PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder bsaylor-0.1.5/README.txt000066400000000000000000000023721434115665400147030ustar00rootroot00000000000000 aenv~ is a asymptotic ADSR envelope generator; The output value approaches the target values as asymptotes. partconv~ is an external that implements partitioned fast convolution, suitable for convolving input signals with long impulse responses for reverbs, etc. This release offers much improved performance, as well as independence of the partition size and your patch's blocksize. It includes Altivec code from Chris Clepper. There's also some SSE 1 code that produces almost correct results but doesn't seem to improve performance. If you are familiar with SSE and want to have a go at writing an SSE version, please do! partconv~ requires FFTW3 (http://fftw.org) pvoc~ is a phase vocoder based on Pd's 09.pvoc.pd example patch. Advantages over the abstraction include (reportedly) faster execution, instantaneous response to input, and adjustable phase locking. It requires FFTW3. bensaylor's Home susloop~: sample player with various loop methods (ping-pong, ... ) svf~: a signal-controlled port of Steve Harris' state variable filter LADSPA plugin (http://plugin.org.uk). zhzhx~: Turns the input signal into a staticky, distorted mess. Comes with tone control. Benjamin R. Saylor bsaylor-0.1.5/aenv~-help.pd000066400000000000000000000054761434115665400156170ustar00rootroot00000000000000#N canvas 1 53 762 514 10; #X floatatom 238 150 5 0 0 0 - - - 0; #X floatatom 281 150 5 0 0 0 - - - 0; #X floatatom 324 150 5 0 0 0 - - - 0; #X floatatom 367 150 5 0 0 0 - - - 0; #X msg 8 115 1; #X msg 50 115 0; #N canvas 0 0 450 300 (subpatch) 0; #X array env 88200 float 0; #X coords 0 1 88199 0 300 140 1; #X restore 455 327 graph; #X msg 8 250 bang; #X obj 142 353 tabwrite~ env; #X obj 291 335 *~; #X obj 318 444 dac~; #X obj 318 410 *~; #X obj 364 395 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 #fcfcfc #000000 #000000 4900 1; #X obj 170 211 aenv~ 100 200 0.6 500; #X obj 430 222 phasor~ 100; #X obj 430 266 lop~ 1000; #X obj 430 244 -~ 0.5; #X obj 238 75 vsl 8 64 10 2000 0 1 empty empty attack 0 -8 0 8 #fcfcfc #000000 #000000 600 1; #X obj 281 75 vsl 8 64 10 2000 0 1 empty empty decay 0 -8 0 8 #fcfcfc #000000 #000000 800 1; #X obj 367 75 vsl 8 64 10 2000 0 1 empty empty release 0 -8 0 8 #fcfcfc #000000 #000000 2600 1; #X obj 324 75 vsl 8 64 0 1 0 1 empty empty sustain 0 -8 0 8 #fcfcfc #000000 #000000 4400 1; #X obj 430 146 notein 1; #X obj 430 196 mtof; #X text 47 203 nonzero -> attack; #X text 484 81 Ben Saylor ; #X text 500 97 http://www.macalester.edu/~bsaylor; #X obj 8 20 bng 15 250 50 0 empty empty empty 0 -6 0 8 #fcfcfc #000000 #000000; #X text 27 17 <- click here; #X obj 50 70 del 800; #X text 452 6 aenv~: asymptotic ADSR envelope generator; #X msg 198 73 lina; #X msg 198 104 loga; #X text 104 73 linear attack; #X text 120 105 log attack; #X msg 198 133 zero; #X text 77 219 0 -> release; #N canvas 305 166 494 385 META 0; #X text 12 225 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 45 DESCRIPTION asymptotic ADSR envelope generator; #X text 12 5 KEYWORDS signal ramp; #X text 12 65 INLET_0 float list lina loga zero; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 INLET_3 float; #X text 12 145 INLET_4 float; #X text 12 165 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 185 AUTHOR Ben Saylor ; #X text 12 205 WEBSITE http://www.macalester.edu/~bsaylor; #X restore 643 483 pd META; #X obj 8 138 t f f; #X obj 8 45 t b b; #X connect 0 0 13 1; #X connect 1 0 13 2; #X connect 2 0 13 3; #X connect 3 0 13 4; #X connect 4 0 37 0; #X connect 5 0 13 0; #X connect 7 0 8 0; #X connect 9 0 11 0; #X connect 11 0 10 0; #X connect 11 0 10 1; #X connect 12 0 11 1; #X connect 13 0 8 0; #X connect 13 0 9 0; #X connect 14 0 16 0; #X connect 15 0 9 1; #X connect 16 0 15 0; #X connect 17 0 0 0; #X connect 18 0 1 0; #X connect 19 0 3 0; #X connect 20 0 2 0; #X connect 21 0 22 0; #X connect 21 1 13 0; #X connect 22 0 14 0; #X connect 26 0 38 0; #X connect 28 0 5 0; #X connect 30 0 13 0; #X connect 31 0 13 0; #X connect 34 0 13 0; #X connect 37 0 7 0; #X connect 37 1 13 0; #X connect 38 0 4 0; #X connect 38 1 28 0; bsaylor-0.1.5/aenv~.c000066400000000000000000000076411434115665400145040ustar00rootroot00000000000000/* Copyright 2002 Benjamin R. Saylor * * 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 "m_pd.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif enum { ATTACK, DECAY, RELEASE, LINEAR, LOGARITHMIC }; #define THRESHOLD 0.99 #define SCALE 4600.0 #define CLIP(x) ((x < 0.1) ? 0.1 : x) #define IS_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) == 0) static t_class *aenv_class; typedef struct _aenv { t_object x_obj; t_float srate; t_float a; t_float d; t_float s; t_float r; t_float lastval; int stage; int attacktype; } t_aenv; static t_int *aenv_perform(t_int *w) { t_aenv *x = (t_aenv *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); t_float lastval = x->lastval; t_float a, d, s, r; switch (x->stage) { case ATTACK: if (x->attacktype == LINEAR) { a = 1000 / (x->a * x->srate); while (n--) { *out = lastval + a; lastval = *(out++); if (lastval > THRESHOLD) { x->stage = DECAY; break; } } } else { a = SCALE / (CLIP(x->a) * x->srate); while (n--) { *out = lastval + a * (1 - lastval); lastval = *(out++); if (lastval > THRESHOLD) { x->stage = DECAY; break; } } } case DECAY: d = SCALE / (CLIP(x->d) * x->srate); s = x->s; while (n-- > 0) { *out = lastval - d * (lastval - s); if (IS_DENORMAL(*out)) *out = 0.0; lastval = *(out++); } break; case RELEASE: r = SCALE / (CLIP(x->r) * x->srate); while (n--) { *out = lastval - r * lastval; if (IS_DENORMAL(*out)) *out = 0.0; lastval = *(out++); } } x->lastval = lastval; return (w+4); } static void aenv_dsp(t_aenv *x, t_signal **sp) { dsp_add(aenv_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } static void aenv_float(t_aenv *x, t_float f) { if (f == 0) x->stage = RELEASE; else x->stage = ATTACK; } static void *aenv_new(t_symbol *s, int argc, t_atom *argv) { t_aenv *x = (t_aenv *)pd_new(aenv_class); floatinlet_new(&x->x_obj, &x->a); floatinlet_new(&x->x_obj, &x->d); floatinlet_new(&x->x_obj, &x->s); floatinlet_new(&x->x_obj, &x->r); outlet_new(&x->x_obj, gensym("signal")); x->srate = sys_getsr(); x->a = 500; x->d = 500; x->s = 0.5; x->r = 500; x->lastval = 0; x->stage = RELEASE; x->attacktype = LOGARITHMIC; if (argc == 4) { x->a = atom_getfloat(argv); x->d = atom_getfloat(argv+1); x->s = atom_getfloat(argv+2); x->r = atom_getfloat(argv+3); } return (x); } static void aenv_lina(t_aenv *x) { x->attacktype = LINEAR; } static void aenv_loga(t_aenv *x) { x->attacktype = LOGARITHMIC; } static void aenv_zero(t_aenv *x) { x->stage = RELEASE; x->lastval = 0.0; } void aenv_tilde_setup(void) { aenv_class = class_new(gensym("aenv~"), (t_newmethod)aenv_new, 0, sizeof(t_aenv), 0, A_GIMME, 0); class_addmethod(aenv_class, (t_method)aenv_dsp, gensym("dsp"), 0); class_addfloat(aenv_class, (t_method)aenv_float); class_addmethod(aenv_class, (t_method)aenv_lina, gensym("lina"), 0); class_addmethod(aenv_class, (t_method)aenv_loga, gensym("loga"), 0); class_addmethod(aenv_class, (t_method)aenv_zero, gensym("zero"), 0); } bsaylor-0.1.5/altivec-perform.inc.c000066400000000000000000000255621434115665400172260ustar00rootroot00000000000000//altivec version by Chris Clepper // static t_int *partconv_perform(t_int *w) { t_partconv *x = (t_partconv *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; int j; int k; // bin int p; // partition int endpart; fftwf_complex *cursumbuf_fd; float *sumbuf1ptr; float *sumbuf2ptr; union { unsigned char c[16]; vector unsigned char v; }permfill; union { float f[4]; vector float v; }floatfill; vector float *load_input, *load_irpart; vector float store_multbuf1,store_multbuf2; vector float vinput_fd0, vinput_fd4; //input vectors vector float virpart_fd0, virpart_fd4; //ir partition vectors vector float permtemp1357, permtemp0246; vector float vzero;// vscale; vector unsigned char input_0022, input_1133, perm_0246, perm_1357, perm_0123,perm_4567; vector float vtemp1, vtemp2, vtemp3, vtemp4, vtemp5, vtemp6, vtemp7, vtemp8; floatfill.f[0] = 0.f; floatfill.f[1] = 0.f; floatfill.f[2] = 0.f; floatfill.f[3] = 0.f; vzero = floatfill.v; //store_multbuf = vzero; floatfill.f[0] = x->scale; floatfill.f[1] = x->scale; floatfill.f[2] = x->scale; floatfill.f[3] = x->scale; //vscale = floatfill.v; //fill the permute buffer for the first input_fd multiply permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 0; permfill.c[5] = 1; permfill.c[6] = 2; permfill.c[7] = 3; //second float permfill.c[8] = 8; permfill.c[9] = 9; permfill.c[10] = 10; permfill.c[11] = 11; //third float permfill.c[12] = 8; permfill.c[13] = 9; permfill.c[14] = 10; permfill.c[15] = 11; //fourth float input_0022 = permfill.v; permfill.c[0] = 4; permfill.c[1] = 5; permfill.c[2] = 6; permfill.c[3] = 7; //first float permfill.c[4] = 4; permfill.c[5] = 5; permfill.c[6] = 6; permfill.c[7] = 7; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 12; permfill.c[13] = 13; permfill.c[14] = 14; permfill.c[15] = 15; //fourth float input_1133 = permfill.v; //perm_0246 //0,1,2,3, 8,9,10,11, 16,17,18,19, 24,25,26,27 permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 8; permfill.c[5] = 9; permfill.c[6] = 10; permfill.c[7] = 11; //second float permfill.c[8] = 16; permfill.c[9] = 17; permfill.c[10] = 18; permfill.c[11] = 19; //third float permfill.c[12] = 24; permfill.c[13] = 25; permfill.c[14] = 26; permfill.c[15] = 27; //fourth float perm_0246 = permfill.v; // perm_1357 // 4,5,6,7, 12,13,14,15, 20,21,22,23, 28,29,30,31 permfill.c[0] = 4; permfill.c[1] = 5; permfill.c[2] = 6; permfill.c[3] = 7; //first float permfill.c[4] = 12; permfill.c[5] = 13; permfill.c[6] = 14; permfill.c[7] = 15; //second float permfill.c[8] = 20; permfill.c[9] = 21; permfill.c[10] = 22; permfill.c[11] = 23; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float perm_1357 = permfill.v; // perm_0123 from [0,2,4,6] and [1,3,5,7] // 0,1,2,3 16,17,18,19 4,5,6,7 20,21,22,23 permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 16; permfill.c[5] = 17; permfill.c[6] = 18; permfill.c[7] = 19; //second float permfill.c[8] = 4; permfill.c[9] = 5; permfill.c[10] = 6; permfill.c[11] = 7; //third float permfill.c[12] = 20; permfill.c[13] = 21; permfill.c[14] = 22; permfill.c[15] = 23; //fourth float perm_0123 = permfill.v; // perm_4567 from [0,2,4,6] and [1,3,5,7] // 8.9.10.11 24,25,26,27 12,13,14,15 28,29,30,31 permfill.c[0] = 8; permfill.c[1] = 9; permfill.c[2] = 10; permfill.c[3] = 11; //first float permfill.c[4] = 24; permfill.c[5] = 25; permfill.c[6] = 26; permfill.c[7] = 27; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float // perm_4567 from [0,2,4,6] and [1,3,5,7] // 8.9.10.11 24,25,26,27 12,13,14,15 28,29,30,31 permfill.c[0] = 8; permfill.c[1] = 9; permfill.c[2] = 10; permfill.c[3] = 11; //first float permfill.c[4] = 24; permfill.c[5] = 25; permfill.c[6] = 26; permfill.c[7] = 27; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float perm_4567 = permfill.v; memcpy(&(x->inbuf[x->inbufpos]), in, n*sizeof(float)); // gather a block of input into input buffer x->inbufpos += n; if (x->inbufpos >= x->partsize) { // input buffer is full, so we begin a new cycle if (x->pd_blocksize != n) { // the patch's blocksize has change since we last dealt the work x->pd_blocksize = n; partconv_deal_work(x); } x->inbufpos = 0; x->curcall = 0; x->curpart = 0; memcpy(x->input_td, x->inbuf, x->partsize * sizeof(float)); // copy 'gathering' input buffer into 'transform' buffer memset(&(x->input_td[x->partsize]), 0, (x->paddedsize - x->partsize) * sizeof(float)); // pad fftwf_execute(x->input_plan); // transform the input // everything has been read out of prev sumbuf, so clear it memset(x->sumbuf->prev->td, 0, x->paddedsize * sizeof(float)); // advance sumbuf pointers x->sumbuf = x->sumbuf->next; x->sumbuf->readpos = 0; x->sumbuf->prev->readpos = x->partsize; } // convolve this call's portion of partitions endpart = x->curpart + x->parts_per_call[x->curcall]; if (endpart > x->nparts) // FIXME does this ever happen? endpart = x->nparts; for (p = x->curpart; p < endpart; p++) { //printf("convolving with partition %d\n", p); // // multiply the input block by the partition, accumulating the result in the appropriate sumbuf // // FIXME do this in a circular list-type fashion so we don't need "index" cursumbuf_fd = x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; for (k = 0; k < x->nbins; k+=4) { load_input = (vector float *)&x->input_fd[k][0]; vinput_fd0 = vec_ld(0, (vector float *) load_input); vtemp1 = vec_perm(load_input[0],vzero,input_0022); load_input = (vector float *)&x->input_fd[k][4]; //load input_fd[k][4] //vector will have input_fd[4,5,6,7] vinput_fd4 = vec_ld(0, (vector float *) &x->input_fd[k][4]); vtemp3 = vec_perm(load_input[0],vzero,input_0022); //vec_ld irpart[p][k][0] //vector will have irpart_fd[0,1,2,3] load_irpart = (vector float *) &x->irpart_fd[p][k][0]; virpart_fd0 = vec_ld(0,&x->irpart_fd[p][k][0]); vtemp1 = vec_madd(vtemp1,load_irpart[0],vzero); load_irpart = (vector float *) &x->irpart_fd[p][k][4]; virpart_fd4 = vec_ld(0,&x->irpart_fd[p][k][4]); vtemp3 = vec_madd(vtemp3,load_irpart[0],vzero); store_multbuf1 = vec_ld(0,&cursumbuf_fd[k][0]); store_multbuf2 = vec_ld(0,&cursumbuf_fd[k][4]); //vec_perm to line up the elements // irpart is fine // make vector of input_fd[0] [2] and [4] [6] //make vector of input_fd[1] [3] and [5] [7] // // permute only works on bytes so the first float is bytes 0,1,2,3 the second is 4,5,6,7 etc // // 0,1,2,3, 8,9,10,11, 16,17,18,19, 24,25,26,27 // // 4,5,6,7, 12,13,14,15, 20,21,22,23, 28,29,30,31 //vec_perm temp1 and temp3 into [0,2,4,6] permtemp0246 = vec_perm(vtemp1,vtemp3,perm_0246); //and [1,3,5,7] permtemp1357 = vec_perm(vtemp1,vtemp3,perm_1357); //vinput_fd[1,3,5,7] vtemp2 = vec_perm(vinput_fd0,vinput_fd4,perm_1357); //irpart[1,3,5,7] vtemp4 = vec_perm(virpart_fd0,virpart_fd4,perm_1357); //irpart[0,2,4,6] vtemp5 = vec_perm(virpart_fd0,virpart_fd4,perm_0246); //vec_nmsub input_fd[1,3,5,7] irpart[1,3,5,7] temp[0,2,4,6] vtemp6 = vec_nmsub(vtemp2,vtemp4,permtemp0246); //vec_madd input_fd[1,3,5,7] irpart[0,2,4,6] temp[1,3,5,7] vtemp7 = vec_madd(vtemp2,vtemp5,permtemp1357); //vec_madd all by scale - this is now done after the loop // vtemp6 = vec_madd(vtemp6,vscale,vzero); // vtemp7 = vec_madd(vtemp7,vscale,vzero); //vec_perm data back into place - tricky! //vec_perm nmsub_result[0,2,4,6] madd_result [1,3,5,7] // results will be [0,1,2,3] [4,5,6,7] vtemp1 = vec_perm(vtemp6,vtemp7,perm_0123); vtemp2 = vec_perm(vtemp6,vtemp7,perm_4567); //vec_st store_multbuf1 = vec_add(store_multbuf1,vtemp1); store_multbuf2 = vec_add(store_multbuf2,vtemp2); vec_st(store_multbuf1,0,&cursumbuf_fd[k][0]); vec_st(store_multbuf2,0,&cursumbuf_fd[k][4]); /* cursumbuf_fd[k][0] += ( x->input_fd[k][0] * x->irpart_fd[p][k][0] - x->input_fd[k][1] * x->irpart_fd[p][k][1]); cursumbuf_fd[k][1] += ( x->input_fd[k][0] * x->irpart_fd[p][k][1] + x->input_fd[k][1] * x->irpart_fd[p][k][0]);*/ } } x->curpart = p; // The convolution of the fresh block of input with the first partition of the IR // is the last thing that gets summed into the current sumbuf before it gets IFFTed and starts being output. // This happens during the first call of every cycle. if (x->curcall == 0) { // current sumbuf has been filled, so transform it (TD to FD). // Output loop will begin to read it and sum it with the last one fftwf_execute(x->sumbuf->plan); } // we're summing and outputting the first half of the most recently IFFTed sumbuf // and the second half of the previous one sumbuf1ptr = &(x->sumbuf->td[x->sumbuf->readpos]); sumbuf2ptr = &(x->sumbuf->prev->td[x->sumbuf->prev->readpos]); for (i = 0; i < n; i++) { *(out++) = (*(sumbuf1ptr++) + *(sumbuf2ptr++)) * x->scale; } x->sumbuf->readpos += n; x->sumbuf->prev->readpos += n; x->curcall++; return (w+5); } bsaylor-0.1.5/bsaylor-meta.pd000066400000000000000000000003201434115665400161200ustar00rootroot00000000000000#N canvas 15 49 200 200 10; #N canvas 25 49 420 300 META 1; #X text 13 41 NAME bsaylor; #X text 10 25 AUTHOR Benjamin R. Saylor ; #X text 10 10 VERSION 0.1.5; #X restore 10 10 pd META; bsaylor-0.1.5/examples/000077500000000000000000000000001434115665400150175ustar00rootroot00000000000000bsaylor-0.1.5/examples/noiseburst.wav000066400000000000000000002542541434115665400177470ustar00rootroot00000000000000RIFFXWAVEfmt DXdataX&=pyS8=u|c{1PG i\z\tAZ <#~iglRF7ss71bdJ H -Ks>P~AK00N:;I"yU{Lf3r 0_@=1F:lX;ioL mI7-{>)T]KV+Oh2VzT# #8:DAsRW~V`|:,hUQR&<;#HX[}Q\+*W BV8i7lA-#$ b RF @!> 4e XYW[V7m3J +>4)Y* GN# !_[J:+5$MmN=Q<Y1f *j @ ' PVO tr^f|*~ ;Zao  @ ,N+ozK,  b  n 4N ] o_IEHu )2 i f UY US& 7 fr X Y% 391 kP 5/ # d> s]*z  R0 ;JF<n czp _ 5LB  L HNr g 0To! g0G sS X1)) vD"E 0 e [a 0V$0J5 S u/% 2o3  Cmg LC O 0$~T%. Rh > @o  S j v  yu!H C7l WZ )8IC  (zo _d n  @ #K -F%_{ 0,t _<RQ;-O [LFa!puVu e k_e  0n F#1r Z"{wh-[U.{[- 9#%%[C} C i  I \  6aO5 k[Tf lkI? !i; No Wuc#bSt .  G  D  @g?r r( M ~H.G  P$S"@ #z h   30,  vir 1 (,^ 1_C "< 3d(+ 9l U#,[ / . ^  ? c*l N 8 bR q6- Po  )GG Jf }:1R}F4M b@A|=,(` 1v}^D `m0X<.aOG j 7)qL?N)Y;xK2 AC 1r 9CO q">l\Z&1   ) ]E F KXX'B : A e N i c Y V= RgV \ AqYlqs6t}PN ;  E#$  W-= S&R  2B1  c ^H  YX V \t+> Z~ \.L; $f,ET ] -SaW N ff mb3.h \{ ylhEC7MR[:vh+ 7;E \s f+:XZ^VD q &M ;V4'q Vf_  o  % ):4D|wuWej x]:) Rt m( UF( lH ` ie ID 5l| w +gv i{0  -wR`[uV LE  6%/ s 1= /L@d z-$I rI PO]T( .cJ }^~RtGsD^q xwooA  =j n xHd ~X X E| l T du3MaI3D/i^2 kvxQD ^ l8,+ 2 0_ 8 -NNnQF Q xL V } /h| z f l}H ]@|<W~K  4B.5,?v3 B 7 2^> | L!4  V   o - & b  G  x R(` N\ z  z*2x ) U)  -9K   5 _2u: VzX 8d f i " i_. (" `  B` a-# zl A \d: " M{C?  P % S =$ ; `    r^  f e?o{  4kZ 4 6@ N  ^N d )o ;NY + /!Q SWM ak  ]1i | F$ U\ )nx mN! [ Z 8 2 XR $ = hea \? j  x3H'B) e yF6F vK} J0FD;#' * 3K! :}Ex` * } tnFI mQ @ h   "v@,.AU`i zC :  gD`F } *1k) ',!J  ^s 0 L p; _Hwx_39#~ $N 8Ux - L s"! j}RY$g- u 5Q&UY ;UX" / UehH;w*V 0dB  lD  3g i<s /+o? ?0p} KO\B5 K-H 4G  o * RjalrtJ^  z .tBml eP   Ot m}X pE:*R _<:*#QZ-&I v O Tes2. K st,  o =d 8#{ e f b=`'U Nz *GQ&]! lywl)*I4% Q n}\  ^  0[~@ gn N L Lg ?/u  *  Ta \ W8m i  V{q|_ `n d WPKLe"vkX["/9 ; QJFy a S, y A^l1 zSF_`  Yk / 3M%C 1> = 0ZAmhW<  g~ R%g[S xg? Hc+dzX{66QvJ\> 94 Vw<RJt/ + <3Q >Y]d)+q_ Vb/. ID"3 2o,w?. d}iwb`"X  g54b*dq~ {}t d5pT.. 7 {= S]\Sna KlvXPCM7'2 }`0\J&a:h|p B g2 Go1K>u o8,U9UK=&4)O{U)P}#%;K m0LV@i z Z$r>9?Yjq!q TBeM1VGh iOh5xuf7kNR*Hww u( \ W.R'-_" 4 Tqk@=N~2#T>, iwn*aR hL*OH!qnV]\R }tDj  Sx%;ge ^'VU(aVA t[uzNs 42j| |mS;63Z(~9W, XBr;F ZZ e+56S{Ql;0jd:%I\`Cc=k  u9D;V4KJ3wE/H=!rwK&QcJPl0YsK:P\Y<e y LK<=)]$%4Gtoz]wOycK0B<Q5Ka]!vX,3F\zd-=,JIN)p N[v +6{FO/RnS]KB8p;(G O{b!lR{V%GpA 22%ZD^Gdqr{~?8DPjX\6@:\ z$^JFhUM]lE/Uj.]RHb_V_w~-YO7 'R`2y,8vmE`Qm3*WbBcV-\ &Vh .-q|lYQ3GB` 1-rH} o@#= $end-v~fxQ/Ezn!Zd'.&C {MzrR!bBikUj41s^3pE-"v6:>1n~ = lFfq X&,JXO, 6+`2\_B@[UD0$tOm{ ]AKb8%c Q@g@o;*Nv)k#Uw&"Ty4OO~.kjS\~E_m@L"P`=0k;9q\v(k1 Uhb9?&Va)]"0DAK0 *x`'g^jFceI}z7 ET Js)DY$i_,0lyvMz-`.UP0Owv,62^&uWod!F?9&Sn["  CFM[E-58NhjN{*]lzX"Vih@<+ </n7}Rd9o#i^ KK%=|W%v 9J<o&P 6v|g7KNFg(hw'\$4*G5w{_0*9\}SF1=;5n`#yo==1q?%z#j;Qu,~ <kdDfh kFu!&Sis,a<O?}kd=(&%gKk& K*>1F vAN^wyPTeRm:OI9{B'G^0UB?r#RHoFcUZ~O5WCZ0IbUC!|^wl!7Ov{h%W.~*Z:{P ^rdLwYzJlZ%C  u5*_ m09$ar jF TJt\ O8i8xM sSk@Xr}2dHxP]b)YSJ/K<<e#gY+4jR:A) eEjd 6vDm<$T|!1mI9?Gzfk~Vm}qEr$YhhmoKq/Pm@%!?9aVI>)1qe:#%>2N e ONgtCkVG5Z2pb6'JcQ4!B]@" >CV~[JFX;vt$1s.VwK#lH1&:cRHdf"O8"hO.HZ}:Z Re19T;W wIFRZ@=2;6<=SLGD0Q%y,0a3\tOqk ~RQ%<MK _zeV- jQF;%0Y]ne7*T}SU>nFuR+!RV#i. N@<;7oD00<<1H\.wv-;$-S 0Ks1v'o%35I_5UTLo LhK|$oy<YSk_F4>hG Vr/!U -'A.+2)n3+T<U>a. ?v\ITRYRg   ]"^@feyaQVe&'9K4(^]Db"t, K<&bNu5N,`^1/j-glvh*#-S)90=Ob^QN{%gKBD4f[YZUiDF9N&Wb `l PL$H&5Em'~^Q7ODpUg{\2izs Z"PzjR<4D>}nB( lZw2'x,W*-J?7cHcPJl4V%oZ7TV5y,Ks)EX1!UCg 0HJTDF,>=:o;HuYVk<Y2}*= 6@Q_jopzn[[A0K| > 0 K [(Dj2uq(Irb&Y0;6P~fLd6.h_5+CRt;I^Ks>ops3SPsJ6b5s(b]Jy1HL +Zb` W`pF+^Hilq?a ~YJ Y&f7!EFA?9hy{7U&c$V;2:UzC)!S'{^n=w5_FAc1sHok?t-[-=]#(}cr;WlBAjYkk?Ua2p>k;U<ni!\%=AM LsmoCP_ye`]G]DsZyTH`^4PZw8km]xU +kY[>k@"b03b/RIU!n&-\/FsL:QM"2Oe !N\br-8AL< -FNl"2\N1W-U(2:GH ;i`.Tl #!%2!:[;b uFtx)}%c0JqH$7Bx?]8;f=X1mv<.\dhqB@oS c]6B|}c!A6`XKGP"J PTgwqR :y[$R})6aZ+^m $[Kj[z>~{ D4'1,2CZJ]wC2 w# `"P)ekh,v+pT).SA6_f8hp^mk*XM|~7a  hv1J"bgtrYA(gEF; &D7jZYHM7v^r"M(";H}crx/?GC{5ypw1`Q!^ITjE]Mt.$ +<iI1R?s@_+)QhF~Sl8FA4V@; Jpa-B7"x*< 8)MEq9v6n)0 g*H 4Udcrmp8='vC'BMj=7 +>m:g M,}[3+7|DnQyP#MN:qA0&i}(Qw*Z/=( E$A]n f^ -_'A0Df~ q$( X?4 j$qKxLBAKS7rp(=S<ZW^3%Vc_v:t%yhpT$J"xW{diaBLbR|BI^D"R#S; KMK4q,r^CC#,H .h'i1=:*Sa{@Cg5jV$,t$')0>4?DWAG7Dgj57$a $ ,eiNa9?# 2Raiq<U.e} _+jzEBaKB? "2R~PpE)syZH<z}0m"^wx$>0[#^bXr-uyiclKEQ8% H,tW|ltlyqq]:=y* b#7_L*kK gs60(O)[8;\#hI9]K;V6VN,NHiC+;2HCtU^#i=-H5hKw-,QqC)5rg4ek11nC;9u(pz}e87P6R17]-,MqVO^^ZO} h7N>28hp7?d SNpkpDccyO'gn=;kj@YPbi>_(0fA Df[ .2TTFrJy(01a4C$x4FNJ^`benH!B@mtTS(dIiW?di\29m#o6,6Nj28: " 1Fz{O0PF#nL4sA>hS/|91OXSc|~^ +r .$wbt&jUT{]|szzebD~>8_mMb"}-a|\B{L[D)RbUNLNt'/eGBK^FmQ\pf.ebiolovtq_J{lb{ODjk7Gq-dD7ibM,|y,ls!Kh =E2--'V(Q30 B~n6'rPK>p" |b3)Az.S-0@?YOS~lEs/U  \-{/9B| hQEx[Z1<.]7%.%!nk4Y`9=SZ cWBR~{H)Q a\83L)GZy.5Ui]#J U7QR(U BQvIto.n*.X4MMr#? ;YZrSCF><[0WQ bnVt)p*B<0.KK{d5K|SzKE\CM5 :>RL \$E]u.YUnQ9ByA+?rAB(ri("gt4O-C'"&32g>Ts C)Cb`,<Ful1em1s/;)w01q ;Kyb}`4ulqf1vpW6lbz ?OTexkV#X__5UP1/bp^>sM!W7OS/!j>"#0|4Rx?0)H.HJ/"7&=1fCcu2IuBu'r.|Xd cYa]{,)g=$FS a| ?9:-4 2R/x*6dnmuS8D)p3K\xEOFb9;@M`LGz]kT @M%Ks$y%SJHuk9=qYTgK6P-vz:`_R0's'4Ic}Lbm`4 n5izIX}9TYk@KD4[."q%mN`-O4 z9;g>^/{1QDK#5i nTheg:CT;R 34ZR+RqPze_)6ZfzEgU#)* _Z.nv*p,aDlPj)LrPu@ycOX^1c>w y#|\mJ$zzVR /T~}vGE-(-TRuu~/IlJN$3:5gz{r}4hb/:%yl9\ i4JaBMwcm` NVrbDY\QD6,P`+Xk^X;VW#m':^r;yR :L:xF a>Z"IIP_enhVX%+ ]RBAQlt: :,CsNh%J[>x!C'zE^pLpn4&n Z7z'z&/1%~ZP'))`rtt%M NYW U%TN0 KKE>#A-z,YuRMXd$,D-g[kSo 5*&7`omWp&!~0MTn6ibBdwh,ki::23jOu{} <c C`8 m2:~q35}CE)f\M=TY~%D!LpdvuqH-@gmB}`%=N1}N2,ZX!y$Lt#PKH'hv[^h(BrN*sXAf2>p{v`<L_LT7rRVU)dievLE^5G?`^UoJG>Z][NVe\xcz6V8|+ WO/q*<Icf~P Y.i5{og6UNZ[)(K7XL}ln /z?~mnF81+*o_Zi"bn]t6Zrwmm2OWUx. %s/hVCn+[o4RzGrQT&*`e\wu USzQ2[GY~i:Y}dgU; VSJjDVkk@3 & _.c:f + + naT@. O\Qn1nE[aa:aya}\vv?e-h"^y9`[3>[n:nh|B.t[U[ E{?pnh| JeBK~94ogYi# HW0WRwyCqu-!gvr=Ic7J\ 4fPgdd8]IhGi/N-{Rklgp)^ ot0A~oDIrqx%=J4g~kp,KK:KJ(ixW,<G ~i-Dy-isk`n2d_l{~%n!pAs7<c]|RX jxuS-ytnn-RBp/(969xfws{Q2:yN+rs"fQ=z?2!u8x@u^qs.ra'go(Z^EyL :-OhQ":v6 G|?{^2]!w}I.~XtG1i7E |RD`b'hu@fS0q rzwDO7giOGN FOGlcEam .SX/s5y$_ T>YSc|aB`f|}cAm]SJ'M=|)\fD|mbV* Hh+|Goz(xpY=Ras#h}Qd~# d-iZbd3p=D:^-Ve2O Q4 0++M$N7`j'3!5jWf3G]@KOw( 3K{^1`v4E FJGAb/ob,O<H>w0|3Cl5{!Jt{2EBb>_Z*4d3Y$3r'& Xl A^&qc!HQBK hQ64K>tJAI2(>H#X[ cg'Kb C17;L7c5`S)$W(_7<)R8=XsRm.=THekY>$Yhe&)i@ ,>!2 /)GdSTR)'pR0 (@HS!MXfNe$R oQ1So?,SdLn#cUUe3<`'3 l2)@3=G/f:ZMM+ ,6; gFS7<,)? $P=-\+"9WhGQ>[BUOX-7 .=;c[M)= 8/$&bIS\'a' `BBJ1NSN78>`8*_][4[K6=35R>\%+bY9FP\]OTYS^G7HI P]=^NUWCI_O-RL5ZD9W81Y.`aJ5aM$:QP$6/ V@Z(AI$7G'8 KAW %;:,FW"K-6BW TC L\;1KGC=),OL394FL!WWP0X=%<3ZFH#<M/+1R 5HX =J)HRJ@A'4<C1XVN&UMXD#VF(K,2)<>XUB 8B5U41(6J 6#EOQ%  M> ;=5,+F$4-OFEML?#1;$77;>(I.B563/FG:RP<$2/7BA<O.3P)>@3J 3:,9J;!$L<L$Q5"'DFDBK(BM*L0,; E.4?;7ED,%#%'B8'$AC 0"A7/+JEF 00L@-KNKBC4:N&36?- (AFK ;G"$/ 9IM;LL;*AI 0."-&&@87.E<8## &@C?-9&E6#;#$ ,""1 ,;.2IE$5 I. +E+' (7GB06,$5><+CD2C6".B.8&G$F'E"7 ' :12 *!*+D $ F)6 <?>4#1; '4B!%#-*+7')C6; 6%, 52!A$9".%") :,  <A 1  :2 428);4? ?:1?,*4':")<(%-34,.95.>4)9-1"")=9<(7&. .+!9.*%=" ,4 #$+ +=/<0 2+43(6; ,<46 **%13<'908(&) $08 0 *6"" .:8&$ ! '1 ,869#93/ .  *%%    2-7 4%,2 *7! ' 1,+4 '#.%$ (  11  2&+22 #&$,/4%.,&-!, 5 -'-' +-1%')%&! '/ !1)04&!!&,/ & "+%!"2!+(3  ///$'  !0# 2 )  02(%( .  "  '''&.) #"   %)&+ )* /+&/ -"#!")*--& , ) (#)" ")-  )#! !$+ !++ -+,&%"((% $* %+#%,$&*"" ((%$"! " # ) +) % ('+ $& &#(!&*"  ! '  #$&!( # %$$()& " ! #' %( %# " %' "&"%" $%&  % $!  %"#    "" !!#  !!   "  $     "  ! !"  !                                                                                                                                                                                                                                                                                                                                                                                              bsaylor-0.1.5/mtosr-help.pd000066400000000000000000000014261434115665400156230ustar00rootroot00000000000000#N canvas 1 53 450 300 10; #X text 95 204 creation argument: samplerate at middle C.; #X text 46 145 takes midi note value and converts to a samplerate for sample playback.; #N canvas 256 179 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 5 KEYWORDS control abstraction MIDI conversion; #X text 12 45 DESCRIPTION takes MIDI note value and converts to a samplerate for sample playback; #X text 12 75 INLET_0 float; #X text 12 95 OUTLET_0 float; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR Benjamin R. Saylor ; #X restore 386 263 pd META; #X floatatom 177 59 5 0 0 0 - - -; #X floatatom 177 121 12 0 0 0 - - -; #X obj 177 88 mtosr 44100; #X connect 3 0 5 0; #X connect 5 0 4 0; bsaylor-0.1.5/mtosr.pd000066400000000000000000000005301434115665400146700ustar00rootroot00000000000000#N canvas 0 0 450 300 10; #X obj 38 57 mtof; #X obj 38 33 inlet; #X obj 38 82 expr \$1 / 261.626 * $f1; #X obj 38 106 outlet; #X text 74 249 creation argument: samplerate at middle C.; #X text 25 190 takes midi note value and converts to a samplerate for sample playback.; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 2 0 3 0; bsaylor-0.1.5/partconv~-help.pd000066400000000000000000000057341434115665400165170ustar00rootroot00000000000000#N canvas 1 53 680 606 10; #X obj 201 569 dac~; #X obj 177 190 osc~; #X obj 177 164 mtof; #X floatatom 177 141 5 0 0 0 - - - 0; #X obj 419 358 soundfiler; #X obj 419 259 loadbang; #X obj 201 541 *~; #X obj 302 282 openpanel; #X obj 302 240 bng 32 250 50 0 empty empty empty 0 -6 0 8 #fcac44 #000000 #000000; #X obj 331 466 vsl 15 128 0 100 0 1 empty empty empty 0 -8 0 8 #fcac44 #000000 #000000 0 1; #X text 300 219 load a soundfile to use as the impulse response; #X text 9 127 test with an impulse; #X text 431 7 Ben Saylor - bensaylor@fastmail.fm; #X text 105 7 partitioned convolution external; #X obj 437 388 table irL; #X msg 272 350 set irL; #X msg 341 350 set irR; #X obj 230 541 *~; #X obj 259 426 partconv~ irR 2048; #X msg 427 333 read -resize \$1 irL irR; #X obj 437 410 table irR; #X msg 232 190 0; #X msg 270 190 0.1; #X obj 177 212 *~ 0; #X obj 261 485 dbtorms; #X text 226 155 test with a sine; #X obj 110 187 adc~ 1; #X text 10 8 partconv~; #X text 26 44 version 0.2 \, August 12 \, 2005; #X text 258 43 [partconv~ ]; #X obj 126 426 partconv~ irL 2048; #X msg 419 283 read -resize examples/noiseburst.wav irL; #X msg 419 307 read -resize examples/noiseburst.wav irR; #X text 258 71 The partition size must be a power of 2 greater than or equal to the block size. Larger partition sizes are more efficient \, to a point \, but increase latency (the delay between input and output is equal to the partition size minus the block size).; #N canvas 380 283 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 5 KEYWORDS control abstraction MIDI conversion; #X text 12 45 DESCRIPTION partitioned convolution external; #X text 12 65 INLET_0 signal set; #X text 12 85 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 105 AUTHOR Benjamin R. Saylor ; #X restore 594 570 pd META; #N canvas 6 61 450 300 dirac~ 0; #X obj 73 46 inlet; #X obj 194 71 loadbang; #X msg 194 94 0 1; #X obj 194 117 s \$0-dirac; #X obj 194 140 table \$0-dirac 10; #X obj 73 69 t b; #X obj 73 92 tabplay~ \$0-dirac; #X obj 73 115 outlet~; #X connect 0 0 5 0; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 5 0 6 0; #X connect 6 0 7 0; #X restore 40 171 pd dirac~; #X msg 40 148 bang; #X obj 302 309 t b b s; #X obj 261 508 t a a; #X connect 1 0 23 0; #X connect 2 0 1 0; #X connect 3 0 2 0; #X connect 5 0 31 0; #X connect 5 0 32 0; #X connect 6 0 0 0; #X connect 7 0 37 0; #X connect 8 0 7 0; #X connect 9 0 24 0; #X connect 15 0 30 0; #X connect 16 0 18 0; #X connect 17 0 0 1; #X connect 18 0 17 0; #X connect 19 0 4 0; #X connect 21 0 23 1; #X connect 22 0 23 1; #X connect 23 0 18 0; #X connect 23 0 30 0; #X connect 24 0 38 0; #X connect 26 0 18 0; #X connect 26 0 30 0; #X connect 30 0 6 0; #X connect 31 0 4 0; #X connect 32 0 4 0; #X connect 35 0 30 0; #X connect 35 0 18 0; #X connect 36 0 35 0; #X connect 37 0 15 0; #X connect 37 1 16 0; #X connect 37 2 19 0; #X connect 38 0 6 1; #X connect 38 1 17 1; bsaylor-0.1.5/partconv~.c000066400000000000000000000300061434115665400153760ustar00rootroot00000000000000/* Copyright 2003-2005 Benjamin R. Saylor * * 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 */ // Thu Feb 17 22:29:27 CST 2005 - Changed outbuf loops to use comparison instead of modulo (suggested by c. clepper) - faster // Sat Jul 30 19:59:08 AKDT 2005 - Completed modification for re-blocking and dividing up the work between calls. // This has eliminated dropouts due to lots of work on large block boundaries. // Fri Aug 5 10:46:33 AKDT 2005 - accumulate in the frequency domain, so only 1 IFFT is needed per input block, // rather than IFFTs. Big performance boost. // Fri Aug 5 20:27:05 AKDT 2005 - should work properly with arbitrary (2^n) blocksize <= partsize // Fri Aug 12 00:32:29 AKDT 2005 - added altivec code by Chris Clepper // TODO // SSE version // multichannel (multiple IRs)? probably wouldn't gain much from this // divide work more evenly? (0, 15, 7, 23, 3, 11, 19, 27, ...) // someday, an SSE3 version (supposed to make complex math fast) #include #include #include #include "m_pd.h" #ifdef __VEC__ #include #endif #define MAXPARTS 256 // max number of partitions #ifdef USE_SSE typedef float v4sf __attribute__ ((vector_size (16))); #endif static t_class *partconv_class; struct sumbuffer { int index; fftwf_complex *fd; float *td; fftwf_plan plan; int readpos; struct sumbuffer *next, *prev; }; typedef struct _partconv { t_object x_obj; t_symbol *arrayname; int partsize; int fftsize; float scale; int paddedsize; int nbins; int nparts; int ir_prepared; int pd_blocksize; // partitions of impulse response fftwf_plan irpart_plan; float *irpart_td[MAXPARTS]; fftwf_complex *irpart_fd[MAXPARTS]; // input fftwf_plan input_plan; float *inbuf; int inbufpos; float *input_td; fftwf_complex *input_fd; // circular array/list of buffers for accumulating results of convolution struct sumbuffer sumbufs[MAXPARTS+2]; int nsumbufs; // number of sumbufs struct sumbuffer *sumbuf; // the current sumbuf corresponding to the first partition of the IR // dividing up the work between calls to perform() int parts_per_call[MAXPARTS]; // parts_per_call[c] is the number of partitions to convolve during perform() call c int curcall; // current call, counted from the beginning of the current cycle (input buffer full) int curpart; // current partition to convolve } t_partconv; // Determine how to divide the work as evenly as possible between calls to perform(). static void partconv_deal_work(t_partconv *x) { int calls_per_cycle; int parts_to_distribute; int i; // Like dealing cards. // One cycle is defined as the time it takes to fill the input buffer (whose size is the user-given partition size) calls_per_cycle = x->partsize / x->pd_blocksize; for (i = 0; i < calls_per_cycle; i++) { x->parts_per_call[i] = 0; } i = 0; parts_to_distribute = x->nparts; while (parts_to_distribute) { x->parts_per_call[i]++; parts_to_distribute--; i = (i + 1) % calls_per_cycle; } /* for (i = 0; i < calls_per_cycle; i++) { printf("parts_per_call[%d] = %d\n", i, x->parts_per_call[i]); } */ } #ifdef __VEC__ #include "altivec-perform.inc.c" #else static t_int *partconv_perform(t_int *w) { t_partconv *x = (t_partconv *)(w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); int i; int j; int k; // bin int p; // partition int endpart; float *fbuf; #ifdef USE_SSE int v1; int v2; int nvecs; v4sf *cursumbuf_fd; v4sf *input_fd; v4sf *irpart_fd; #else fftwf_complex *cursumbuf_fd; fftwf_complex *input_fd; fftwf_complex *irpart_fd; #endif float *sumbuf1ptr; float *sumbuf2ptr; if (!x->inbuf) { /* no convolution kernel, pass the input through */ for(i=0; iinbuf[x->inbufpos]); for(i=0; iinbufpos += n; if (x->inbufpos >= x->partsize) { // input buffer is full, so we begin a new cycle if (x->pd_blocksize != n) { // the patch's blocksize has change since we last dealt the work x->pd_blocksize = n; partconv_deal_work(x); } x->inbufpos = 0; x->curcall = 0; x->curpart = 0; memcpy(x->input_td, x->inbuf, x->partsize * sizeof(float)); // copy 'gathering' input buffer into 'transform' buffer memset(&(x->input_td[x->partsize]), 0, (x->paddedsize - x->partsize) * sizeof(float)); // pad fftwf_execute(x->input_plan); // transform the input // everything has been read out of prev sumbuf, so clear it memset(x->sumbuf->prev->td, 0, x->paddedsize * sizeof(float)); // advance sumbuf pointers x->sumbuf = x->sumbuf->next; x->sumbuf->readpos = 0; x->sumbuf->prev->readpos = x->partsize; } // convolve this call's portion of partitions endpart = x->curpart + x->parts_per_call[x->curcall]; if (endpart > x->nparts) // FIXME does this ever happen? endpart = x->nparts; for (p = x->curpart; p < endpart; p++) { // multiply the input block by the partition, accumulating the result in the appropriate sumbuf #ifdef USE_SSE #include "sse-conv.inc.c" #else cursumbuf_fd = x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; input_fd = x->input_fd; irpart_fd = x->irpart_fd[p]; for (k = 0; k < x->nbins; k++) { cursumbuf_fd[k][0] += ( input_fd[k][0] * irpart_fd[k][0] - input_fd[k][1] * irpart_fd[k][1]); cursumbuf_fd[k][1] += ( input_fd[k][0] * irpart_fd[k][1] + input_fd[k][1] * irpart_fd[k][0]); } #endif } x->curpart = p; // The convolution of the fresh block of input with the first partition of the IR // is the last thing that gets summed into the current sumbuf before it gets IFFTed and starts being output. // This happens during the first call of every cycle. if (x->curcall == 0) { // current sumbuf has been filled, so transform it // Output loop will begin to read it and sum it with the last one fftwf_execute(x->sumbuf->plan); } // we're summing and outputting the first half of the most recently IFFTed sumbuf // and the second half of the previous one sumbuf1ptr = &(x->sumbuf->td[x->sumbuf->readpos]); sumbuf2ptr = &(x->sumbuf->prev->td[x->sumbuf->prev->readpos]); for (i = 0; i < n; i++) { out[i] = (sumbuf1ptr[i] + sumbuf2ptr[i]) * x->scale; } x->sumbuf->readpos += n; x->sumbuf->prev->readpos += n; x->curcall++; return (w+5); } #endif // __VEC__ static void partconv_fftw_free(t_partconv *x) { int i; fftwf_free(x->inbuf); x->inbuf = 0; for (i = 0; i < x->nparts; i++) { fftwf_free(x->irpart_td[i]); x->irpart_td[i] = 0; } fftwf_free(x->input_td); x->input_td = 0; fftwf_destroy_plan(x->input_plan); for (i = 0; i < x->nsumbufs; i++) { fftwf_free(x->sumbufs[i].fd); fftwf_destroy_plan(x->sumbufs[i].plan); } } static void partconv_free(t_partconv *x) { partconv_fftw_free(x); } static void partconv_set(t_partconv *x, t_symbol *s) { int i; int j; t_garray *arrayobj; t_word *array; int arraysize; int arraypos; // get the array from pd x->arrayname = s; if ( ! (arrayobj = (t_garray *)pd_findbyclass(x->arrayname, garray_class))) { if (*x->arrayname->s_name) { pd_error(x, "partconv~: %s: no such array", x->arrayname->s_name); } else { pd_error(x, "partconv~: no such array"); } return; } else if ( ! garray_getfloatwords(arrayobj, &arraysize, &array)) { pd_error(x, "%s: bad template", x->arrayname->s_name); return; } // if the IR has already been prepared, free everything first if (x->ir_prepared == 1) { partconv_fftw_free(x); } // calculate number of partitions x->nparts = arraysize / x->partsize; if (arraysize % x->partsize != 0) x->nparts++; if (x->nparts > MAXPARTS) x->nparts = MAXPARTS; // allocate, fill, pad, and transform each IR partition for (arraypos = 0, i = 0; i < x->nparts; i++) { x->irpart_td[i] = fftwf_malloc(sizeof(float) * x->paddedsize); x->irpart_fd[i] = (fftwf_complex *) x->irpart_td[i]; x->irpart_plan = fftwf_plan_dft_r2c_1d(x->fftsize, x->irpart_td[i], x->irpart_fd[i], FFTW_MEASURE); for (j = 0; j < x->partsize && arraypos < arraysize; j++, arraypos++) { x->irpart_td[i][j] = array[arraypos].w_float; } for ( ; j < x->paddedsize; j++) { x->irpart_td[i][j] = 0; } fftwf_execute(x->irpart_plan); fftwf_destroy_plan(x->irpart_plan); // now, x->irpart[i] contains the DFT of the ith partition of the impulse response. } x->inbuf = fftwf_malloc(sizeof(float) * x->partsize); x->inbufpos = 0; // allocate buffer for DFT of padded input x->input_td = fftwf_malloc(sizeof(float) * x->paddedsize); // float array into which input block is copied and padded x->input_fd = (fftwf_complex *) x->input_td; // fftwf_complex pointer to the same array to facilitate in-place fft x->input_plan = fftwf_plan_dft_r2c_1d(x->fftsize, x->input_td, x->input_fd, FFTW_MEASURE); // set up circular list/array of buffers for accumulating results of convolution x->nsumbufs = x->nparts + 2; x->sumbuf = &(x->sumbufs[0]); for (i = 0; i < x->nsumbufs; i++) { x->sumbufs[i].index = i; x->sumbufs[i].fd = fftwf_malloc(sizeof(float) * x->paddedsize); memset(x->sumbufs[i].fd, 0, sizeof(float) * x->paddedsize); x->sumbufs[i].td = (float *) x->sumbufs[i].fd; x->sumbufs[i].plan = fftwf_plan_dft_c2r_1d(x->fftsize, x->sumbufs[i].fd, x->sumbufs[i].td, FFTW_MEASURE); x->sumbufs[i].readpos = 0; } x->sumbufs[0].next = &(x->sumbufs[1]); x->sumbufs[0].prev = &(x->sumbufs[x->nsumbufs - 1]); for (i = 1; i < x->nsumbufs; i++) { x->sumbufs[i].next = &(x->sumbufs[(i + 1) % x->nsumbufs]); x->sumbufs[i].prev = &(x->sumbufs[i - 1]); } partconv_deal_work(x); x->curcall = 0; x->curpart = 0; post("partconv~: using %s in %d partitions with FFT-size %d", x->arrayname->s_name, x->nparts, x->fftsize); x->ir_prepared = 1; } static void partconv_dsp(t_partconv *x, t_signal **sp) { // if the ir array has not been prepared, prepare it if (x->ir_prepared == 0) { partconv_set(x, x->arrayname); } dsp_add(partconv_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *partconv_new(t_symbol *s, int argc, t_atom *argv) { t_partconv *x = (t_partconv *)pd_new(partconv_class); outlet_new(&x->x_obj, gensym("signal")); if (argc != 2) { post("argc = %d", argc); pd_error(0, "partconv~: usage: [partconv~ ]\n\t- partition size must be a power of 2 >= blocksize"); return NULL; } x->arrayname = atom_getsymbol(argv); x->partsize = atom_getfloatarg(1, argc, argv); if (x->partsize <= 0 || x->partsize != (1 << ilog2(x->partsize))) { pd_error(0, "partconv~: partition size not a power of 2"); return NULL; } x->fftsize = 2 * x->partsize; x->scale = 1 / ((float) x->fftsize); // need 2*(n/2+1) float array for in-place transform, where n is fftsize. #ifdef USE_SSE // for sse, make it a multiple of 8, because we pull in 4 bins at a time and don't want to get a segfault x->paddedsize = 2 * (x->fftsize / 2 + 4); #else x->paddedsize = 2 * (x->fftsize / 2 + 1); #endif x->nbins = x->fftsize / 2 + 1; x->ir_prepared = 0; x->pd_blocksize = sys_getblksize(); return (x); } void partconv_tilde_setup(void) { partconv_class = class_new(gensym("partconv~"), (t_newmethod)partconv_new, (t_method)partconv_free, sizeof(t_partconv), 0, A_GIMME, 0); class_addmethod(partconv_class, nullfn, gensym("signal"), 0); class_addmethod(partconv_class, (t_method) partconv_dsp, gensym("dsp"), 0); class_addmethod(partconv_class, (t_method) partconv_set, gensym("set"), A_DEFSYMBOL, 0); } bsaylor-0.1.5/partconv~.dsp000066400000000000000000000104211434115665400157410ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="partconv" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** NICHT BEARBEITEN ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=partconv - Win32 Debug !MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "partconv.mak". !MESSAGE !MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "partconv.mak" CFG="partconv - Win32 Debug" !MESSAGE !MESSAGE Fr die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "partconv - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE "partconv - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "partconv - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "NDEBUG" # ADD RSC /l 0xc07 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "partconv - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "_DEBUG" # ADD RSC /l 0xc07 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib fftw3.lib /nologo /dll /debug /machine:I386 /out:"C:\Programme\pd_0.37\extra\partconv.dll" /pdbtype:sept !ENDIF # Begin Target # Name "partconv - Win32 Release" # Name "partconv - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\partconv.c # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\fftw3.h # End Source File # Begin Source File SOURCE=.\m_pd.h # End Source File # End Group # Begin Group "Ressourcendateien" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project bsaylor-0.1.5/partconv~.dsw000066400000000000000000000010671434115665400157560ustar00rootroot00000000000000Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELSCHT WERDEN! ############################################################################### Project: "partconv"=.\partconv.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### bsaylor-0.1.5/partconv~.vcproj000066400000000000000000000112261434115665400164620ustar00rootroot00000000000000 bsaylor-0.1.5/pd-lib-builder/000077500000000000000000000000001434115665400157745ustar00rootroot00000000000000bsaylor-0.1.5/pd-lib-builder/CHANGELOG.txt000066400000000000000000000066431434115665400200350ustar00rootroot00000000000000Changelog for Makefile.pdlibbuilder. v0.6.0, dated 2019-12-21 - detect target platform (OS and architecture) rather than build platform (#55) - introduce optional user variable 'PLATFORM' for cross compilation - no longer build OSX/MacOS fat binaries by default (#21, #50) - do build fat binaries when 'extension=d_fat' is specified for OSX/MacOS - fix bug where minimum OSX/MacOS version wasn't defined, and set it to 10.6 v0.5.1, dated 2018-03-15 Fixes and improvements for Windows builds: - properly evaluate variables 'PDDIR' and 'PDBINDIR' to find pd.dll - define default path of 32 bit Pd on 64 bit Windows - link C++ externals with standard C libs on Windows, they don't load otherwise - strip installed Windows binaries by default (issues #34, #39, #41, #42 respectively) Warning for all platforms: variable 'PD_PATH' is no longer supported, use the equivalent 'PDDIR'. v0.5.0, dated 2018-01-23 Implement target architecture detection for Windows builds, and set appropriate options for 32 and 64 bit (used to be for 32 bit only). (feature, issue #37 #38, merge commit 215bf3e) v0.4.4, dated 2016-11-22 Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}' (bugfix, issue #31, commit 2c14110) v0.4.3, dated 2016-11-02 Replace flags '-fpic' by 'fPIC'. (bugfix, issue #29, commit 426b38b) v0.4.2, dated 2016-10-30 Fix issue where incorrect message about m_pd.h is given. (bugfix, commit 2e13d8f) v0.4.1, dated 2016-10-27 Respect cflag for minimum OSX version when defined by lib makefile. (bugfix, pull request #22, commit 48c4127) v0.4.0, dated 2016-10-14 Introduced path variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR which can also be defined in environment. (feature, issue #27, commit b0dab72) v0.3.1, dated 2016-10-13 Fix bug where pd.dll wouldn't be found. (bugfix, commit a0c87be) v0.3.0, dated 2016-10-09 Variable 'PD_PATH' introduced for pd-extended / pd-l2ork compatibility. (feature, issue #26, commit 41e9743) v0.2.8, dated 2016-10-09 Allow installed files to contain weird characters (notably '$'). (bugfix, pull request #20, commit 5b920b1) v0.2.7, dated 2016-10-04 Remove all default pd search paths except vanilla's. (discussion, issue #25, commit a6a89dc) v0.2.6, dated 2016-09-20 Redefined dependency checking so it won't stall rebuilds on OSX. (bugfix, issue #16, commit 9fd1795) v0.2.5, dated 2016-06-26 Fixed dependency checking for object files in other directories. (bugfix, commit f06e550) v0.2.4, dated 2016-06-25 Fixed regression bug that disabled all dependency checking. (bugfix, commit 1d7bb5e) v0.2.3, dated 2016-03-29 Disabled dependency checking for OSX <= 10.5 because it stalled rebuilds. (bugfix, issue #16, commit eb614fd) v0.2.2, dated 2016-03-28 Removed target 'pre' because it forced rebuild of everything in 'all'. (bugfix, issue #17, commit c989c8e) v0.2.1, dated 2015-12-27 Implement / respect 'CPPFLAGS','CFLAGS'and 'LDFLAGS'. (bugfix, issue #5, commit 98f3582) v0.2.0, dated 2015-12-19 Added per-platform multiline defines 'forLinux', 'forDarwin', 'forWindows'. (feature, pull request #9, commit 3946ea5) v0.1.0, dated 2015-12-08 Added targets 'pre' and 'post' to automatically run before and after 'all'. (feature, pull request #4, commit a5678ac) v0.0.2, dated 2015-12-06 Improved methods for searching pd paths. (bugfix, commit ed37e6b) v0.0.1, dated 2015-10-31 Fixed expansion of variable 'lib.version'. (bugfix, issue #1, commit 974b617) v0.0.0, dated 2015-06-24 Initial version. (commit 16517a2) bsaylor-0.1.5/pd-lib-builder/Makefile.pdlibbuilder000066400000000000000000001266041434115665400221050ustar00rootroot00000000000000# Makefile.pdlibbuilder dated 2019-12-21 version = 0.6.0 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's # ShakeNMake. # # Grab the newest version of Makefile.pdlibbuilder from # https://github.com/pure-data/pd-lib-builder/ # # GNU make version >= 3.81 required. # # #=== characteristics =========================================================== # # # - defines build settings based on autodetected OS and architecture # - defines rules to build Pd class- or lib executables from C or C++ sources # - defines rules for libdir installation # - defines convenience targets for developer and user # - evaluates implicit dependencies for non-clean builds # # #=== basic usage =============================================================== # # # In your Makefile, define your Pd lib name and class files, and include # Makefile.pdlibbuilder at the end of the Makefile. Like so: # # ________________________________________________________________________ # # # Makefile for mylib # # lib.name = mylib # # class.sources = myclass1.c myclass2.c # # datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt # # include Makefile.pdlibbuilder # ________________________________________________________________________ # # # For files in class.sources it is assumed that class basename == source file # basename. The default target builds all classes as individual executables # with Pd's default extension for the platform. For anything more than the # most basic usage, continue reading. # # #=== list of Makefile.pdlibbuilder API variables =============================== # # # Variables available for definition in your library Makefile: # # - lib.name # - lib.setup.sources # - class.sources # - common.sources # - shared.sources # - .class.sources # - .class.ldflags # - .class.ldlibs # - cflags # - ldflags # - ldlibs # - datafiles # - datadirs # - makefiles # - makefiledirs # - externalsdir # # Optional multiline defines evaluated per operating system: # # - forLinux # - forDarwin # - forWindows # # Variables available for your makefile or make command line: # # - make-lib-executable # - suppress-wunused # # Path variables for make command line or environment: # # - PDDIR # - PDINCLUDEDIR # - PDBINDIR # - PDLIBDIR # # Standard make variables for make command line or environment: # # - CPPFLAGS # - CFLAGS # - LDFLAGS # - CC # - CXX # - INSTALL # - STRIP # - DESTDIR # # Optional user variables for make command line or environment: # # - PLATFORM # # Deprecated path variables: # # - pdincludepath # - pdbinpath # - objectsdir # # #=== descriptions of Makefile.pdlibbuilder API variables ======================= # # # lib.name: # Name of the library directory as it will be installed / distributed. Also the # name of the lib executable in the case where all classes are linked into # a single binary. # # lib.setup.sources: # Source file(s) (C or C++) which must be compiled only when linking all classes # into a single lib binary. # # class.sources: # All sources files (C or C++) for which the condition holds that # class name == source file basename. # # .class.sources: # Source file(s) (C or C++) specific to class . Use this for # multiple-source classes or when class name != source file basename. # # common.sources: # Source file(s) which must be statically linked to each class in the library. # # shared.sources: # Source file(s) (C or C++) to build a shared dynamic link lib, to be linked # with all class executables. # # cflags, ldflags, ldlibs: # Define cflags (preprocessor&compiler), ldflags (linker) and ldlibs (dynamic # link libs) for the whole library. These flags are added to platform-specific # flags defined by Makefile.pdlibbuilder. # # .class.ldflags and .class.ldlibs: # Define ldflags resp. ldlibs specific to class . These flags are # added to platform-specific flags defined by Makefile.pdlibbuilder, and flags # defined in your Makefile for the whole library. Note: cflags can not be # defined per class in the current implementation. # # datafiles and datadirs: # All extra files you want to include in binary distributions of the # library: abstractions and help patches, example patches, meta patch, readme # and license texts, manuals, sound files, etcetera. Use 'datafiles' for all # files that should go into your lib rootdir and 'datadirs' for complete # directories you want to copy from source to distribution. # # forLinux, forDarwin, forWindows: # Shorthand for 'variable definitions for Linux only' etc. Use like: # define forLinux # cflags += -DLINUX # class.sources += linuxthing.c # endef # # makefiles and makefiledirs: # Extra makefiles or directories with makefiles that should be made in sub-make # processes. # # make-lib-executable: # When this variable is defined 'yes' in your makefile or as command argument, # Makefile.pdlibbuilder will try to build all classes into a single library # executable (but it will force exit if lib.setup.sources is undefined). # If your makefile defines 'make-lib-executable=yes' as the library default, # this can still be overridden with 'make-lib-executable=no' as command argument # to build individual class executables (the Makefile.pdlibbuilder default.) # # suppress-wunused: # When this variable is defined ('yes' or any other value), -Wunused-variable, # -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, # but the other warnings from -Wall are retained. # # PDDIR: # Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and # PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. # # PDINCLUDEDIR: # Directory where Pd API m_pd.h should be found, and other Pd header files. # Overrides the default search path. # # PDBINDIR: # Directory where pd.dll should be found for linking (Windows only). Overrides # the default search path. # # PDLIBDIR: # Root directory for installation of Pd library directories. Overrides the # default install location. # # DESTDIR: # Prepended path component for staged install. # # PLATFORM: # Target platform for cross compilation in the form of GNU triplet: # cpu-vendor-os. Example: x86_64-w64-mingw32. This specifies the tool chain that # pdlibbuilder will use, if installed and locatable. System and architecture # will then be autodefined accordingly. In most cases no other variables need to # be overridden. # # CPPFLAGS: # Preprocessor flags which are not strictly required for building. # # CFLAGS: # Compiler flags which are not strictly required for building. Compiler flags # defined by Makefile.pdlibbuilder for warning, optimization and architecture # specification are overriden by CFLAGS. # # LDFLAGS: # Linker flags which are not strictly required for building. Linker flags # defined by Makefile.pdlibbuilder for architecture specification are overriden # by LDFLAGS. # # CC and CXX: # C and C++ compiler programs as defined in your build environment. # # INSTALL # Definition of install program. # # STRIP # Name of strip program. Default 'strip' can be overridden in cross compilation # environments. # # objectsdir: # Root directory for installation of Pd library directories, like PDLIBDIR but # not overridable by environment. Supported for compatibility with pd-extended # central makefile, but deprecated otherwise. # # pdincludepath, pdbinpath: # As PDINCLUDEDIR and PDBINDIR but not overridable by environment. Deprecated # as user variables. # # #=== paths ===================================================================== # # # Source files in directories other than current working directory must be # prefixed with their relative path. Do not rely on VPATH or vpath. # Object (.o) files are built in the directory of their source files. # Executables are built in current working directory. # # Default search path for m_pd.h and other API header files is platform # dependent, and overridable by PDINCLUDEDIR: # # Linux: /usr/include/pd # # OSX: /Applications/Pd*.app/Contents/Resources/src # # Windows: %PROGRAMFILES%/Pd/src # %PROGRAMFILES(X86)%/Pd/src (32 bit builds on 64 bit Windows) # # Default search path for binary pd.dll (Windows), overridable by PDBINDIR # # %PROGRAMFILES%/Pd/bin # %PROGRAMFILES(X86)%/Pd/bin (32 bit builds on 64 bit Windows) # # Default location to install pd libraries is platform dependent, and # overridable by PDLIBDIR: # # Linux: /usr/local/lib/pd-externals # OSX: ~/Library/Pd # Windows: %APPDATA%/Pd # # https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files # The rationale for not installing to ~/pd-externals by default on Linux # is that some people share the home dir between 32 and 64 bit installations. # # #=== targets =================================================================== # # # all: build $(executables) plus optional post target # post: target to build after $(executables) # alldebug: build all with -g option turned on for debug symbols # : force clean build of an individual class # .pre: make preprocessor output file in current working directory # .lst: make asm/source output file in current working directory # # install: install executables and data files # clean: remove build products from source tree # # help: print help text # vars: print makefile variables # allvars: print all variables # depend: print generated prerequisites # dumpmachine: print compiler output of option '-dumpmachine' # coffee: dummy target # # Variable $(executables) expands to class executables plus optional shared lib, # or alternatively to single lib executable when make-lib-executable=true. # Targets pre and post can be defined by library makefile. Make sure to include # Makefile.pdlibbuilder first so default target all will not be redefined. # # #=== Pd-extended libdir concept ================================================ # # # For libdir layout as conceived by Hans-Christoph Steiner, see: # # https://puredata.info/docs/developer/Libdir # # Files README.txt, LICENSE.txt and -meta.pd are part of the libdir # convention. Help patches for each class and abstraction are supposed to be # available. Makefile.pdlibbuilder does not force the presence of these files # however. It does not automatically include such files in libdir installations. # Data files you want to include in distributions must be defined explicitly in # your Makefile. # # #=== Makefile.pdlibbuilder syntax conventions ================================== # # # Makefile.pdlibbuilder variable names are lower case. Default make variables, # environment variables, and standard user variables (CC, CXX, CFLAGS, DESTDIR) # are upper case. Use target 'allvars' to print all variables and their values. # # 'Fields' in data variables are separated by dots, like in 'foo.class.sources'. # Words in variables expressing a function or command are separated by dashes, # like in 'make-lib-executable'. # # #=== useful make options ======================================================= # # # Use 'make -d ' to print debug details of the make process. # Use 'make -p ' to print make's database. # # #=== TODO ====================================================================== # # # - decide whether to use -static-libgcc or shared dll in MinGW # - cygwin support # - android support # - figure out how to handle '$' in filenames # - add makefile template targets dpkg-source dist libdir distclean tags? # # #=== end of documentation sections ============================================= # # ################################################################################ ################################################################################ ################################################################################ # GNU make version 3.81 (2006) or higher is required because of the following: # - function 'info' # - variable '.DEFAULT_GOAL' # force exit when make version is < 3.81 ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81) $(error GNU make version 3.81 or higher is required) endif # Relative path to externals root dir in multi-lib source tree like # pd-extended SVN. Default is parent of current working directory. May be # defined differently in including makefile. externalsdir ?= .. # variable you can use to check if Makefile.pdlibbuilder is already included Makefile.pdlibbuilder = true ################################################################################ ### variables: library name and version ######################################## ################################################################################ # strip possibles spaces from lib.name, they mess up calculated file names lib.name := $(strip $(lib.name)) # if meta file exists, check library version metafile := $(wildcard $(lib.name)-meta.pd) ifdef metafile lib.version := $(shell sed -n \ 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ $(metafile)) endif ################################################################################ ### variables: files ########################################################### ################################################################################ #=== sources =================================================================== # (re)define .class.sources using file names in class.sources define add-class-source $(notdir $(basename $v)).class.sources += $v endef $(foreach v, $(class.sources), $(eval $(add-class-source))) # derive class names from .class.sources variables sourcevariables := $(filter %.class.sources, $(.VARIABLES)) classes := $(basename $(basename $(sourcevariables))) # accumulate all source files specified in makefile classes.sources := $(sort $(foreach v, $(sourcevariables), $($v))) all.sources := $(classes.sources) $(lib.setup.sources) \ $(shared.sources) $(common.sources) #=== object files ============================================================== # construct object filenames from all C and C++ source file names classes.objects := $(addsuffix .o, $(basename $(classes.sources))) common.objects := $(addsuffix .o, $(basename $(common.sources))) shared.objects := $(addsuffix .o, $(basename $(shared.sources))) lib.setup.objects := $(addsuffix .o, $(basename $(lib.setup.sources))) all.objects = $(classes.objects) $(common.objects) $(shared.objects) \ $(lib.setup.objects) #=== executables =============================================================== # use recursive variables here because executable extension is not yet known # construct class executable names from class names classes.executables = $(addsuffix .$(extension), $(classes)) # construct shared lib executable name if shared sources are defined ifdef shared.sources shared.lib = lib$(lib.name).$(shared.extension) else shared.lib = endif ################################################################################ ### target platform detection ################################################## ################################################################################ #=== target platform =========================================================== # PLATFORM: optional user variable to define target platform for cross # compilation. Redefine build tools accordingly. PLATFORM should match # the exact target prefix of tools present in $PATH, like x86_64-w64-mingw32, # x86_64-apple-darwin12 etc. Tool definitions are exported to ensure submakes # will get the same. ifneq ($(PLATFORM),) ifneq ($(findstring darwin, $(PLATFORM)),) export CC = $(PLATFORM)-cc export CXX = $(PLATFORM)-c++ export CPP = $(PLATFORM)-cc else export CC = $(PLATFORM)-gcc export CXX = $(PLATFORM)-g++ export CPP = $(PLATFORM)-cpp endif STRIP = $(PLATFORM)-strip endif # Let (native or cross-) compiler report target triplet and isolate individual # words therein to facilitate later processing. target.triplet := $(subst -, ,$(shell $(CC) -dumpmachine)) #=== operating system ========================================================== # The following systems are defined: Linux, Darwin, Windows. GNU and # GNU/kFreeBSD are treated as Linux to get the same options. ifneq ($(filter linux gnu% kfreebsd, $(target.triplet)),) system = Linux endif ifneq ($(filter darwin%, $(target.triplet)),) system = Darwin endif ifneq ($(filter mingw% cygwin%, $(target.triplet)),) system = Windows endif # evaluate possible system-specific multiline defines from library makefile $(eval $(for$(system))) # TODO: Cygwin, Android #=== architecture ============================================================== # The following CPU names can be processed by pdlibbuilder: # i*86 Intel 32 bit # x86_64 Intel 64 bit # arm ARM 32 bit # aarch64 ARM 64 bit target.arch := $(firstword $(target.triplet)) ################################################################################ ### variables per platform ##################################################### ################################################################################ #=== flags per architecture ==================================================== # Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, # arch.c.flags are overriden below. To see gcc's default architecture flags: # $ gcc -Q --help=target # ARMv6: Raspberry Pi 1st gen, not detectable from target.arch ifeq ($(shell uname), armv6l) arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard # ARMv7: Beagle, Udoo, RPi2 etc. else ifeq ($(target.arch), arm) arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard # ARMv8 64 bit, not tested yet else ifeq ($(target.arch), aarch64) arch.c.flags = -mcpu=cortex-a53 # Intel 32 bit, build with SSE and SSE2 instructions else ifneq ($(filter i%86, $(target.arch)),) arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions else ifeq ($(target.arch), x86_64) arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 # if none of the above architectures detected else arch.c.flags = endif #=== flags and paths for Linux ================================================= ifeq ($(system), Linux) prefix = /usr/local libdir := $(prefix)/lib pkglibdir = $(libdir)/pd-externals pdincludepath := $(wildcard /usr/include/pd) extension = pd_linux cpp.flags := -DUNIX c.flags := -fPIC c.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags c.ldlibs := -lc -lm cxx.flags := -fPIC -fcheck-new cxx.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) endif #=== flags and paths for Darwin ================================================ # LLVM-clang doesn't support -fcheck-new, therefore this flag is only used when # compiling with g++. ifeq ($(system), Darwin) pkglibdir = $(HOME)/Library/Pd pdincludepath := $(firstword $(wildcard \ /Applications/Pd*.app/Contents/Resources/src)) extension = pd_darwin cpp.flags := -DUNIX -DMACOSX -I /sw/include c.flags := c.ldflags := -undefined suppress -flat_namespace -bundle c.ldlibs := -lc cxx.ldflags := -undefined suppress -flat_namespace -bundle cxx.ldlibs := -lc shared.extension = dylib shared.ldflags = -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 ifneq ($(filter %g++, $(CXX)),) cxx.flags := -fcheck-new endif ifeq ($(extension), d_fat) arch := i386 x86_64 else arch := $(target.arch) endif ifneq ($(filter -mmacosx-version-min=%, $(cflags)),) version.flag := $(filter -mmacosx-version-min=%, $(cflags)) else version.flag = -mmacosx-version-min=10.6 endif arch.c.flags := $(addprefix -arch , $(arch)) $(version.flag) arch.ld.flags := $(arch.c.flags) endif #=== flags and paths for Windows =============================================== # Standard paths on Windows contain spaces, and GNU make functions treat such # paths as lists, with unintended effects. Therefore we must use shell function # ls instead of make's wildcard when probing for a path, and use double quotes # when specifying a path in a command argument. # Default paths in Mingw / Mingw-w64 environments. 'PROGRAMFILES' is standard # location for builds with native architecture, 'ProgramFiles(x86)' for i686 # builds on x86_64 Windows (detection method by Lucas Cordiviola). Curly braces # required because of parentheses in variable name. ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd ifeq ($(target.arch), i686) programfiles := ${ProgramFiles(x86)} else programfiles := $(PROGRAMFILES) endif pdbinpath := $(programfiles)/Pd/bin pdincludepath := $(programfiles)/Pd/src endif # Store default path to pd.dll in PDBINDIR if the latter is not user-defined. # For include path this is done in the platform-independent paths section below, # but for PDBINDIR it is done here so ld flags can be evaluated as immediate # variables. ifeq ($(system), Windows) ifdef PDDIR PDBINDIR := $(PDDIR)/bin endif PDBINDIR ?= $(pdbinpath) endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) cpp.flags := -DMSW -DNT ifeq ($(target.arch), i686) arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse else ifeq ($(target.arch), x86_64) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 arch.c.flags := -march=core2 -msse -msse2 -msse3 -mfpmath=sse else arch.c.flags = endif extension = dll c.flags := c.ldflags := -static-libgcc -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new cxx.ldflags := -static-libgcc -static-libstdc++ -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" cxx.ldlibs := shared.extension = dll shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" stripflags = --strip-all endif #=== paths ===================================================================== # Platform-dependent default paths are specified above, but overridable. # Path variables in upper case can be defined as make command argument or in the # environment. Variable 'objectsdir' is supported for compatibility with # the build system that pd-l2ork has inherited from pd-extended. PDINCLUDEDIR ?= $(pdincludepath) PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) ifdef PDDIR PDINCLUDEDIR := $(wildcard $(PDDIR)/src) endif # base path where all components of the lib will be installed by default installpath := $(DESTDIR)$(PDLIBDIR)/$(lib.name) # check if include path contains spaces (as is often the case on Windows) # if so, store the path so we can later do checks with it pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR)) #=== accumulated build flags =================================================== # From GNU make docs: 'Users expect to be able to specify CFLAGS freely # themselves.' So we use CFLAGS to define options which are not strictly # required for compilation: optimizations, architecture specifications, and # warnings. CFLAGS can be safely overriden using a make command argument. # Variables cflags, ldflags and ldlibs may be defined in including makefile. optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer warn.flags = -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing # suppress -Wunused-variable & Co if you don't want to clutter a build log ifdef suppress-wunused warn.flags += $(addprefix -Wno-unused-, function parameter value variable) endif CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) # preprocessor flags cpp.flags := -DPD -I "$(PDINCLUDEDIR)" $(cpp.flags) $(CPPFLAGS) # flags for dependency checking (cflags from makefile may define -I options) depcheck.flags := $(cpp.flags) $(cflags) # architecture specifications for linker are overridable by LDFLAGS LDFLAGS := $(arch.ld.flags) # now add the same ld flags to shared dynamic lib shared.ldflags := $(shared.ldflags) $(LDFLAGS) # accumulated flags for C compiler / linker c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS) c.ldlibs := $(c.ldlibs) $(ldlibs) # accumulated flags for C++ compiler / linker cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS) cxx.ldflags := $(cxx.ldflags) $(ldflags) $(LDFLAGS) cxx.ldlibs := $(cxx.ldlibs) $(ldlibs) ################################################################################ ### variables: tools ########################################################### ################################################################################ # aliases so we can later define 'compile-$1' and set 'c' or 'cxx' as argument compile-c := $(CC) compile-cxx := $(CXX) ################################################################################ ### checks ##################################################################### ################################################################################ # At this point most variables are defined. Now do some checks and info's # before rules begin. # print Makefile.pdlibbuilder version before possible termination $(info ++++ info: using Makefile.pdlibbuilder version $(version)) # Terminate if target triplet remained empty, to avoid all sorts of confusing # scenarios and spurious bugs. ifeq ($(target.triplet),) $(error Command "$(CC) -dumpmachine" did not return a target triplet, \ needed for a build. \ Is compiler "$(CC)" installed in your PATH? ($(PATH)). \ Does compiler "$(CC)" support option "-dumpmachine"?) endif # 'forward declaration' of default target, needed to do checks all: # To avoid unpredictable results, make sure the default target is not redefined # by including makefile. ifneq ($(.DEFAULT_GOAL), all) $(error Default target must be 'all'.) endif # find out which target(s) will be made ifdef MAKECMDGOALS goals := $(MAKECMDGOALS) else goals := all endif # store path to Pd API m_pd.h if it is found ifdef PDINCLUDEDIR mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") endif # store path to pd.dll; if not found, ls will give a useful error ifeq ($(system), Windows) pddll := $(shell ls "$(PDBINDIR)/pd.dll") endif # when making target all, check if m_pd.h is found and print info about it ifeq ($(goals), all) $(if $(mpdh), \ $(info ++++ info: using Pd API $(mpdh)), \ $(warning Where is Pd API m_pd.h? Do 'make help' for info.)) endif # print target info $(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name))) # when installing, print installpath info $(if $(filter install install-lib, $(goals)), $(info ++++ info: \ installpath is '$(installpath)')) #=== define executables ======================================================== # By default we build class executables, and optionally a shared dynamic link # lib. When make-lib-executable=yes we build all classes into a single lib # executable, on the condition that variable lib.setup.sources is defined. ifeq ($(make-lib-executable),yes) $(if $(lib.setup.sources), ,\ $(error Can not build library blob because lib.setup.sources is undefined)) executables := $(lib.name).$(extension) else executables := $(classes.executables) $(shared.lib) endif ################################################################################ ### rules: special targets ##################################################### ################################################################################ # Disable built-in rules. If some target can't be built with the specified # rules, it should not be built at all. MAKEFLAGS += --no-builtin-rules .PRECIOUS: .SUFFIXES: .PHONY: all post build-lib \ $(classes) $(makefiledirs) $(makefiles) \ install install-executables install-datafiles install-datadirs \ force clean vars allvars depend help ################################################################################ ### rules: build targets ####################################################### ################################################################################ # Target all forces the build of targets [$(executables) post] in # deterministic order. Target $(executables) builds class executables plus # optional shared lib or alternatively a single lib executable when # make-lib-executable=true. Target post is optionally defined by # library makefile. all: post post: $(executables) all: $(info ++++info: target all in lib $(lib.name) completed) # build all with -g option turned on for debug symbols alldebug: c.flags += -g alldebug: cxx.flags += -g alldebug: all #=== class executable ========================================================== # recipe for linking objects in class executable # argument $1 = compiler type (c or cxx) # argument $2 = class basename define link-class $(compile-$1) \ $($1.ldflags) $($2.class.ldflags) \ -o $2.$(extension) \ $(addsuffix .o, $(basename $($2.class.sources))) \ $(addsuffix .o, $(basename $(common.sources))) \ $($1.ldlibs) $($2.class.ldlibs) $(shared.lib) endef # general rule for linking object files in class executable %.$(extension): $(shared.lib) $(info ++++ info: linking objects in $@ for lib $(lib.name)) $(if $(filter %.cc %.cpp, $($*.class.sources)), \ $(call link-class,cxx,$*), \ $(call link-class,c,$*)) #=== library blob ============================================================== # build all classes into single executable build-lib: $(lib.name).$(extension) $(info ++++ info: library blob $(lib.name).$(extension) completed) # recipe for linking objects in lib executable # argument $1 = compiler type (c or cxx) define link-lib $(compile-$1) \ $($1.ldflags) $(lib.ldflags) \ -o $(lib.name).$(extension) $(all.objects) \ $($1.ldlibs) $(lib.ldlibs) endef # rule for linking objects in lib executable # declared conditionally to avoid name clashes ifeq ($(make-lib-executable),yes) $(lib.name).$(extension): $(all.objects) $(if $(filter %.cc %.cpp, $(all.sources)), \ $(call link-lib,cxx), \ $(call link-lib,c)) endif #=== shared dynamic lib ======================================================== # recipe for linking objects in shared executable # argument $1 = compiler type (c or cxx) define link-shared $(compile-$1) \ $(shared.ldflags) \ -o lib$(lib.name).$(shared.extension) $(shared.objects) \ $($1.ldlibs) $(shared.ldlibs) endef # rule for linking objects in shared executable # build recipe is in macro 'link-shared' lib$(lib.name).$(shared.extension): $(shared.objects) $(info ++++ info: linking objects in shared lib $@) $(if $(filter %.cc %.cpp, $(shared.sources)), \ $(call link-shared,cxx), \ $(call link-shared,c)) #=== object files ============================================================== # recipe to make .o file from source # argument $1 is compiler type (c or cxx) define make-object-file $(info ++++ info: making $@ in lib $(lib.name)) $(compile-$1) \ $($1.flags) \ -o $@ -c $< endef # Three rules to create .o files. These are double colon 'terminal' rules, # meaning they are the last in a rules chain. %.o:: %.c $(call make-object-file,c) %.o:: %.cc $(call make-object-file,cxx) %.o:: %.cpp $(call make-object-file,cxx) #=== explicit prerequisites for class executables ============================== # For class executables, prerequisite rules are declared in run time. Target # 'depend' prints these rules for debugging purposes. # declare explicit prerequisites rule like 'class: class.extension' # argument $v is class basename define declare-class-target $v: $v.$(extension) endef # declare explicit prerequisites rule like 'class.extension: object1.o object2.o' # argument $v is class basename define declare-class-executable-target $v.$(extension): $(addsuffix .o, $(basename $($v.class.sources))) \ $(addsuffix .o, $(basename $(common.sources))) endef # evaluate explicit prerequisite rules for all classes $(foreach v, $(classes), $(eval $(declare-class-target))) $(foreach v, $(classes), $(eval $(declare-class-executable-target))) #=== implicit prerequisites for class executables ============================== # Evaluating implicit prerequisites (header files) with help from the # preprocessor is 'expensive' so this is done conditionally and selectively. # Note that it is also possible to trigger a build via install targets, in # which case implicit prerequisites are not checked. # When the Pd include path contains spaces it will mess up the implicit # prerequisites rules. disable-dependency-tracking := $(strip $(pdincludepathwithspaces)) ifndef disable-dependency-tracking must-build-everything := $(filter all, $(goals)) must-build-class := $(filter $(classes), $(goals)) must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) endif # declare implicit prerequisites rule like 'object.o: header1.h header2.h ...' # argument $1 is input source file(s) # dir is explicitly added because option -MM strips it by default define declare-object-target $(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(depcheck.flags) -MM $1)) $(MAKEFILE_LIST) endef # evaluate implicit prerequisite rules when rebuilding everything ifdef must-build-everything $(if $(wildcard $(all.objects)), \ $(info ++++ info: evaluating implicit prerequisites in lib $(lib.name).....) \ $(foreach v, $(all.sources), $(eval $(call declare-object-target, $v)))) endif # evaluate implicit prerequisite rules when selectively building classes ifdef must-build-class $(foreach v, $(must-build-sources), \ $(eval $(call declare-object-target, $v))) $(foreach v, $(shared.sources), \ $(eval $(call declare-object-target, $v))) endif ################################################################################ ### rules: preprocessor and assembly files ##################################### ################################################################################ # Preprocessor and assembly output files for bug tracing etc. They are not part # of the build processes for executables. By default these files are created in # the current working directory. Dependency tracking is not performed, the build # is forced instead to make sure it's up to date. force: #=== preprocessor file ========================================================= # make preprocessor output file with extension .pre # argument $1 = compiler type (c or cxx) define make-preprocessor-file $(info ++++ info: making preprocessor output file $(notdir $*.pre) \ in current working directory) $(compile-$1) -E $< $(c.flags) $($1.flags) -o $(notdir $*.pre) endef %.pre:: %.c force $(call make-preprocessor-file,c) %.pre:: %.cc force $(call make-preprocessor-file,cxx) %.pre:: %.cpp force $(call make-preprocessor-file,cxx) #=== assembly file ============================================================= # make C / assembly interleaved output file with extension .lst # argument $1 = compiler type (c or cxx) define make-assembly-file $(info ++++ info: making assembly output file $(notdir $*.lst) \ in current working directory) $(compile-$1) \ -c -Wa,-a,-ad -fverbose-asm \ $($1.flags) \ $< > $(notdir $*.lst) endef %.lst:: %.c force $(call make-assembly-file,c) %.lst:: %.cc force $(call make-assembly-file,cxx) %.lst:: %.cpp force $(call make-assembly-file,cxx) ################################################################################ ### rules: installation targets ################################################ ################################################################################ #=== strip ===================================================================== # Stripping of installed binaries will only be done when variable 'stripflags' # is defined non-empty. No default definition is provided except for Windows # where the unstripped binaries are large, especially in the case of Mingw-w64. # Note: while stripping all symbols ('-s' or '--strip-all') is possible for # Linux and Windows, in the case of OSX only non-global symbols can be stripped # (option '-x' or '--discard-all'). # Make definition of strip command overridable so it can be defined in an # environment for cross-compilation. STRIP ?= strip # Commands in 'strip-executables' will be executed conditionally in the rule for # target 'install-executables'. strip-executables = cd "$(installpath)" && \ $(foreach v, $(executables), $(STRIP) $(stripflags) '$v';) #=== install =================================================================== # Install targets depend on successful exit status of target all because nothing # must be installed in case of a build error. # -p = preserve time stamps # -m = set permission mode (as in chmod) # -d = create all components of specified directories INSTALL = install INSTALL_PROGRAM := $(INSTALL) -p -m 644 INSTALL_DATA := $(INSTALL) -p -m 644 INSTALL_DIR := $(INSTALL) -m 755 -d # strip spaces from file names executables := $(strip $(executables)) datafiles := $(strip $(datafiles)) datadirs := $(strip $(datadirs)) # Do not make any install sub-target with empty variable definition because the # install program would exit with an error. install: $(if $(executables), install-executables) install: $(if $(datafiles), install-datafiles) install: $(if $(datadirs), install-datadirs) install-executables: all $(INSTALL_DIR) -v "$(installpath)" $(foreach v, $(executables), \ $(INSTALL_PROGRAM) '$v' "$(installpath)";) $(info ++++ info: executables of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) $(if $(stripflags), $(strip-executables),) install-datafiles: all $(INSTALL_DIR) -v "$(installpath)" $(foreach v, $(datafiles), \ $(INSTALL_DATA) '$(v)' "$(installpath)";) $(info ++++ info: data files of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) install-datadirs: all $(foreach v, $(datadirs), $(INSTALL_DIR) "$(installpath)/$v";) $(foreach v, $(datadirs), \ $(INSTALL_DATA) $(wildcard $v/*) "$(installpath)/$v";) $(info ++++ info: data directories of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) ################################################################################ ### rules: distribution targets ################################################ ################################################################################ # TODO # These targets are implemented in Makefile Template, but I have to figure out # how to do it under the not-so-strict conditions of Makefile.pdlibbuilder. # make source package dist: @echo "target dist not yet implemented" # make Debian source package dpkg-source: @echo "target dpkg-source not yet implemented" $(ORIGDIR): $(DISTDIR): ################################################################################ ### rules: clean targets ####################################################### ################################################################################ # delete build products from build tree clean: rm -f $(all.objects) rm -f $(classes.executables) $(lib.name).$(extension) $(shared.lib) rm -f *.pre *.lst # remove distribution directories and tarballs from build tree distclean: clean @echo "target distclean not yet implemented" ################################################################################ ### rules: submake targets ##################################################### ################################################################################ # Iterate over sub-makefiles or makefiles in other directories. # When 'continue-make=yes' is set, sub-makes will report 'true' to the parent # process regardless of their real exit status. This prevents the parent make # from being aborted by a sub-make error. Useful when you want to quickly find # out which sub-makes from a large set will succeed. ifeq ($(continue-make),yes) continue = || true endif # These targets will trigger sub-make processes for entries in 'makefiledirs' # and 'makefiles'. all alldebug install clean distclean dist dkpg-source: \ $(makefiledirs) $(makefiles) # this expands to identical rules for each entry in 'makefiledirs' $(makefiledirs): $(MAKE) --directory=$@ $(MAKECMDGOALS) $(continue) # this expands to identical rules for each entry in 'makefiles' $(makefiles): $(MAKE) --directory=$(dir $@) --makefile=$(notdir $@) $(MAKECMDGOALS) $(continue) ################################################################################ ### rules: convenience targets ################################################# ################################################################################ #=== show variables ============================================================ # Several 'function' macro's cause errors when expanded within a rule or without # proper arguments. Variables which are set with the define directive are only # shown by name for that reason. functions = \ add-class-source \ declare-class-target \ declare-class-executable-target \ declare-object-target \ link-class \ link-lib \ link-shared \ make-object-file \ make-preprocessor-file \ make-assembly-file # show variables from makefiles vars: $(info ++++ info: showing makefile variables:) $(foreach v,\ $(sort $(filter-out $(functions) functions, $(.VARIABLES))),\ $(if $(filter file, $(origin $v)),\ $(info variable $v = $($v)))) $(foreach v, $(functions), $(info 'function' name: $v)) @echo # show all variables allvars: $(info ++++ info: showing default, automatic and makefile variables:) $(foreach v, \ $(sort $(filter-out $(functions) functions, $(.VARIABLES))), \ $(info variable ($(origin $v)) $v = $($v))) $(foreach v, $(functions), $(info 'function' name: $v)) @echo #=== show dependencies ========================================================= # show generated prerequisites rules depend: $(info ++++ info: generated prerequisite rules) $(foreach v, $(classes), $(info $(declare-class-target))) $(foreach v, $(classes), $(info $(declare-class-executable-target))) $(foreach v, $(all.sources), $(info $(call declare-object-target, $v))) @echo #=== show help text ============================================================ # brief info about targets and paths ifdef mpdh mpdhinfo := $(mpdh) else mpdhinfo := m_pd.h was not found. Is Pd installed? endif help: @echo @echo " Main targets:" @echo " all: build executables (default target)" @echo " install: install all components of the library" @echo " vars: print makefile variables for troubleshooting" @echo " allvars: print all variables for troubleshooting" @echo " help: print this help text" @echo @echo " Pd API m_pd.h:" @echo " $(mpdhinfo)" @echo " You may specify your preferred Pd include directory as argument" @echo " to the make command, like 'PDINCLUDEDIR=path/to/pd/src'." @echo @echo " Path for installation of your libdir(s):" @echo " $(PDLIBDIR)" @echo " Alternatively you may specify your path for installation as argument" @echo " to the make command, like 'PDLIBDIR=path/to/pd-externals'." @echo @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder." @echo #=== platform test ============================================================= # This target can be used to test if the compiler for specified PLATFORM is # correctly defined and available. dumpmachine: @$(CC) -dumpmachine #=== dummy target ============================================================== coffee: @echo "Makefile.pdlibbuilder: Can not make coffee. Sorry." ################################################################################ ### end of rules sections ###################################################### ################################################################################ # for syntax highlighting in vim and github # vim: set filetype=make: bsaylor-0.1.5/pd-lib-builder/README.md000066400000000000000000000102421434115665400172520ustar00rootroot00000000000000 ### Makefile.pdlibbuilder ### Helper makefile for Pure Data external libraries. Written by Katja Vetter March-June 2015 for the public domain and since then developed as a Pd community project. No warranties. Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's ShakeNMake. GNU make version >= 3.81 required. ### characteristics ### * defines build settings based on autodetected target platform * defines rules to build Pd class- or lib executables from C or C++ sources * defines rules for libdir installation * defines convenience targets for developer and user * evaluates implicit dependencies for non-clean builds ### basic usage ### In your Makefile, define your Pd lib name and class files, and include Makefile.pdlibbuilder at the end of the Makefile. Like so: # Makefile for mylib lib.name = mylib class.sources = myclass1.c myclass2.c datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt include Makefile.pdlibbuilder For files in class.sources it is assumed that class name == source file basename. The default target builds all classes as individual executables with Pd's default extension for the platform. For anything more than the most basic usage, read the documentation sections in Makefile.pdlibbuilder. ### paths ### Makefile.pdlibbuilder >= v0.4.0 supports pd path variables which can be defined not only as make command argument but also in the environment, to override platform-dependent defaults: PDDIR: Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. PDINCLUDEDIR: Directory where Pd API m_pd.h should be found, and other Pd header files. Overrides the default search path. PDBINDIR: Directory where pd.dll should be found for linking (Windows only). Overrides the default search path. PDLIBDIR: Root directory for installation of Pd library directories. Overrides the default install location. ### documentation ### This README.md provides only basic information. A large comment section inside Makefile.pdlibbuilder lists and explains the available user variables, default paths, and targets. The internal documentation reflects the exact functionality of the particular version. For suggestions about project maintenance and advanced compilation see tips-tricks.md. ### versioning ### The project is versioned in MAJOR.MINOR.BUGFIX format (see http://semver.org), and maintained at https://github.com/pure-data/pd-lib-builder. Pd lib developers are invited to regulary check for updates, and to contribute and discuss improvements here. If you really need to distribute a personalized version with your library, rename Makefile.pdlibbuilder to avoid confusion. ### examples ### The list of projects using pd-lib-builder can be helpful if you are looking for examples, from the simplest use case to more complex implementations. - helloworld: traditional illustration of simplest use case - pd-windowing: straightforward real world use case of a small library - pd-nilwind / pd-cyclone: more elaborate source tree - zexy: migrated from autotools to pd-lib-builder ### projects using pd-lib-builder ### non-exhaustive list https://github.com/pure-data/helloworld https://github.com/electrickery/pd-nilwind https://github.com/electrickery/pd-maxlib https://github.com/electrickery/pd-sigpack https://github.com/electrickery/pd-tof https://github.com/electrickery/pd-windowing https://github.com/electrickery/pd-smlib https://github.com/porres/pd-cyclone https://github.com/porres/pd-else https://github.com/porres/pd-psycho https://git.iem.at/pd/comport https://git.iem.at/pd/hexloader https://git.iem.at/pd/iemgui https://git.iem.at/pd/iemguts https://git.iem.at/pd/iemlib https://git.iem.at/pd/iemnet https://git.iem.at/pd/iem_ambi https://git.iem.at/pd/iem_tab https://git.iem.at/pd/iem_adaptfilt https://git.iem.at/pd/iem_roomsim https://git.iem.at/pd/iem_spec2 https://git.iem.at/pd/mediasettings https://git.iem.at/pd/zexy https://git.iem.at/pd-gui/punish https://github.com/residuum/PuRestJson https://github.com/libpd/abl_link https://github.com/wbrent/timbreID https://github.com/MetaluNet/moonlib bsaylor-0.1.5/pd-lib-builder/tips-tricks.md000066400000000000000000000162561434115665400206040ustar00rootroot00000000000000pd-lib-builder cheatsheet ========================= # Creating special builds ## cross-compiling on linux x86_64 for other platforms Using pd-lib-builder >=0.6.0 we can define variable `PLATFORM` to specify a target triplet for cross-compilation. Example to build W32 binaries (assuming package `mingw-w64` is installed and a W32 package for Pd is unzipped into a path `${PDWIN32}`: make PLATFORM=x86_64-w64-mingw32 PDDIR="${PDWIN32}" #### older pd-lib-builder versions Using pd-lib-builder < 0.6.0, in the absence of variable `PLATFORM`, you would instead override variables `system`, `target.arch`, `CC` and / or `CXX`, `STRIP`. Example: make system=Windows target.arch=i686 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip PDDIR="${PDWIN32}" #### toolchains Cross toolchains for relevant platforms in Debian Buster (install g++ with dependencies for a given platform to get the whole tool chain): - `arm-linux-gnueabihf` - `aarch64-linux-gnu` - `i686-linux-gnu` - `i686-w64-mingw32` and `x86_64-w64-mingw32` (install `mingw-w64`) OSX/MacOS cross tool chains are not distributed by Debian. Use project `osxcross` from Thomas Poechtraeger to create the tools. ## building double-precision externals At the time of writing (2018-02) there is no official Pd that supports double-precision numbers yet. However, if you do get hold of an experimental double-precision Pd, you can easily build your externals for 64-bit numbers: make CPPFLAGS="-DPD_FLOATSIZE=64" ## building externals for W64 (64-bit Windows) At the time of writing (2018-02) there is no official Pd that supports W64 yet. However, if you do get hold of an experimental W64 Pd, you can easily build your externals for this environment with make CPPFLAGS="-DPD_LONGINTTYPE=__int64" CC=x86_64-w64-mingw32-gcc To build a double-precision external for W64, use something like: make CPPFLAGS="-DPD_LONGINTTYPE=__int64 -DPD_FLOATSIZE=64" CC=x86_64-w64-mingw32-gcc ## TODO universal binaries on OSX # Project management In general it is advised to put the `Makefile.pdlibbuilder` into a separate subdirectory (e.g. `pd-lib-builder/`). This makes it much easier to update the `Makefile.pdlibbuilder` later You *should* also use a variable to the actual path of the Makefile.pdlibbuilder (even if you keep it in the root-directory), as this allows easy experimenting with newer (or older) (or site-specific) versions of the pd-lib-builder Makefile. ~~~make PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder ~~~ ## Keeping pd-lib-builder up-to-date ### `git subtree` With git-subtrees, you make the pd-lib-builder repository (or any other repository for that matter) part of your own repository - with full history and everything - put nicely into a distinct subdirectory. Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). The nice thing however is, that from "outside" the subtree is part of your repository like any other directory. E.g. older versions of Git can clone your repository with the full subtree (and all it's history) just fine. You can also use git-archive to make a complete snapshot of your repository (including the subtree) - nice, if you e.g. want self-contained downloads of your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) In short, `git subtree` is the better `git submodule`. So here's how to do it: #### Initial setup/check-out This will create a `pd-lib-builder/` directory containing the full history of the pd-lib-builder repository up to its release `v0.5.0` ~~~sh git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 ~~~ This will automatically merge the `pd-lib-builder/` history into your current branch, so everything is ready to go. #### Cloning your repository with the subtree Nothing special, really. Just clone your repository as always: ~~~sh git clone https://git.example.org/pd/superbonk~.git ~~~ #### Updating the subtree Time passes and sooner or later you will find, that there is a shiny new pd-lib-builder with plenty of bugfixes and new features. To update your local copy to pd-lib-builder's current `master`, simply run: ~~~sh git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master ~~~ #### Pulling the updated subtree into existing clones Again, nothing special. Just pull as always: ~~~sh git pull ~~~ #### Further reading More on the power of `git subtree` can be found online - https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 - https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree - ... ### ~~`git submodule`~~ [DISCOURAGED] #### Initial setup/check-out To add a new submodule to your repository, just run `git submodule add` and commit the changes: ~~~sh git submodule add https://github.com/pure-data/pd-lib-builder git commit .gitmodules pd-lib-builder/ -m "Added pd-lib-builder as git-submodule" ~~~ #### Cloning your repository with the submodule When doing a fresh clone of your repository, pass the `--recursive` option to automatically fetch all submodules: ~~~sh git clone --recursive https://git.example.org/pd/superbonk~.git ~~~ If you've cloned non-recursively, you can initialize and update the submodules manually: ~~~sh git submodule init git submodule update ~~~ #### Updating the submodule Submodules are usually fixed to a given commit in their repository. To update the `pd-lib-builder` submodule to the current `master` do something like: ~~~sh cd pd-lib-builder git checkout master git pull cd .. git status pd-lib-builder git commit pd-lib-builder -m "Updated pd-lib-builder to current master" ~~~ #### Pulling the updated submodule into existing clones After you have pushed the submodule updates in your repository, other clones of the repository can be updated as follows: ~~~sh git pull ~~~ The above will make your repository aware, that the submodule is out-of-sync. ~~~sh $ LANG=C git status pd-lib-builder On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: pd-lib-builder (new commits) $ ~~~ In order to sync the submodule to the correct commit, run the following: ~~~sh git submodule update ~~~ #### Drawbacks `git submodule` has a number of drawbacks: - it requires special commands to synchronize the submodules, in addition to synching your repository. - you must make sure to use an URL for the submodule that is accessible to your potential users. e.g. using `git@github.com:pure-data/pd-lib-builder` is bad, because it requires everybody who wants to checkout your sources to have a github-account - even if they could checkout *your* repository anonymously. - submodules will be excluded from `git archive`. This means, that if you use a mainstream git provider (like Github, GitLab, Bitbucket,...) and make releases by creating a `git tag`, the automatically generated zipfiles with the sources will lack the submodule - and your users will not be able to compile your source code. In general, I would suggest to **avoid** `git submodule`, and instead use the better `git subtree` (above). bsaylor-0.1.5/pvoc~-help.pd000066400000000000000000000055471434115665400156340ustar00rootroot00000000000000#N canvas 1 88 680 638 10; #X obj 265 611 dac~; #X obj 304 561 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 #fcac44 #000000 #000000 3200 1; #X obj 265 587 *~; #X obj 68 168 cnv 15 580 220 empty empty empty 20 12 0 14 #bcbcbc #404040 0; #N canvas 0 0 450 300 (subpatch) 0; #X array sample 62079 float 0; #X coords 0 1 62078 -1 560 100 1; #X restore 77 62 graph; #X msg 346 506 read -resize ../../doc/sound/voice.wav sample; #X obj 346 526 soundfiler; #X obj 346 547 s length; #X obj 346 485 loadbang; #X obj 77 182 hsl 560 15 0 1 0 0 empty empty time-position -2 -6 0 8 #e0e0e0 #000000 #000000 0 1; #X obj 214 232 vsl 15 128 0.5 2 1 0 empty empty pitch-shift 0 -8 0 8 #fce0c0 #000000 #000000 0 1; #X msg 182 213 1; #X floatatom 214 366 5 0 0 0 - - - 0; #X obj 280 232 vsl 15 128 0 1 0 0 empty empty phase-locking 0 -8 0 8 #d8fcfc #000000 #000000 0 1; #X floatatom 280 366 5 0 0 0 - - - 0; #X obj 74 532 line~; #X msg 74 510 \$1 200; #X obj 74 488 *; #X obj 89 423 r length; #X text 6 28 [pvoc~ ]; #X obj 226 551 lop~ 10; #X msg 433 486 read -resize \$1 sample; #X obj 433 466 openpanel; #X obj 548 347 bng 32 250 50 0 empty empty empty 0 -6 0 8 #fcac44 #000000 #000000; #X msg 280 457 locking \$1; #X msg 99 467 setarray sample; #X msg 380 302 transients 0 6227 35716 53368; #X msg 380 324 notransients; #X text 380 285 de-smear transients at these locations; #X text 546 329 load a sample; #X obj 226 531 sig~ 1; #X msg 125 271 0.5; #X msg 125 291 1; #X msg 125 311 2; #X msg 125 351 4; #X msg 125 510 0 \, 4.41e+06 \$1; #X obj 125 399 * 100000; #X msg 125 331 3; #X text 8 6 pvoc~ 0.2 Ben Saylor bensaylor@fastmail.fm; #X obj 99 571 pvoc~ sample 2048 4; #N canvas 379 320 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 65 INLET_0 signal locking transients notransients; #X text 12 85 INLET_1 signal; #X text 12 105 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 125 AUTHOR Benjamin R. Saylor ; #X text 12 45 DESCRIPTION needs a description; #X text 12 5 KEYWORDS signal; #X restore 586 608 pd META; #X obj 89 446 t f f; #X connect 1 0 2 1; #X connect 2 0 0 0; #X connect 2 0 0 1; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 8 0 5 0; #X connect 9 0 17 0; #X connect 10 0 12 0; #X connect 11 0 10 0; #X connect 12 0 30 0; #X connect 13 0 14 0; #X connect 14 0 24 0; #X connect 15 0 39 0; #X connect 16 0 15 0; #X connect 17 0 16 0; #X connect 18 0 41 0; #X connect 20 0 39 1; #X connect 21 0 6 0; #X connect 22 0 21 0; #X connect 23 0 22 0; #X connect 24 0 39 0; #X connect 25 0 39 0; #X connect 26 0 39 0; #X connect 27 0 39 0; #X connect 30 0 20 0; #X connect 31 0 36 0; #X connect 32 0 36 0; #X connect 33 0 36 0; #X connect 34 0 36 0; #X connect 35 0 15 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 39 0 2 0; #X connect 41 0 17 1; #X connect 41 1 25 0; bsaylor-0.1.5/pvoc~.c000066400000000000000000000303251434115665400145150ustar00rootroot00000000000000/* Copyright 2003 Benjamin R. Saylor * * 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 #include #include "m_pd.h" // FIXME: // set array when dsp is turned on // get rid of shiftbuf, just save values that will be needed next before overwriting them // cubic interp // use float fftw? // performance testing // what if there are 2 transients less than fftsize apart? second one might get smeared. // compare sound with phaselockedvoc.pd // detect transients // peaks + noise // other phase locking methods // use floats? // use in-place? // if don't have an array, call setarray(x->arrayname) // window size and fft size independent (what is gained by zero-padding?) // error if parent blocksize is larger than hopsize // slowly return window to true position after centering around a transient? // use fewer fft arrays? // DONE: // use FFTW_MEASURE static t_class *pvoc_class; typedef struct _pvoc { t_object x_obj; t_symbol *arrayname; t_garray *arrayobj; t_word *array; int arraysize; double *window; int fftsize; int overlap; int hopsize; // = fftsize / overlap int trans[256]; // sample indices of transients int ntrans; // number of transients int wastrans; // there was a transient in the left half of the window during the previous frame double phaselocking; fftw_plan fftplan; fftw_plan fft2plan; fftw_plan ifftplan; double *fftin; double *fft2in; double *ifftout; fftw_complex *fftout; fftw_complex *fft2out; fftw_complex *ifftin; fftw_complex *shiftbuf; double *outbuf; int outbufpos; } t_pvoc; // if there is a transient between samples a and b, return its position, else return -1 static inline int transient_between(t_pvoc *x, int a, int b) { // linear search for now: FIXME int i; for (i = 0; i < x->ntrans; i++) if (a <= x->trans[i] && b >= x->trans[i]) return x->trans[i]; return -1; } #if 1 static inline double interpolate(t_pvoc *x, double t) { // linear interpolation for now: FIXME if (t < 0 || t > (x->arraysize - 1)) return 0.0; else { int x_1 = t; double y_1 = x->array[x_1].w_float; double y_2 = x->array[x_1 + 1].w_float; return (y_2 - y_1) * (t - x_1) + y_1; } } #else static inline double interpolate(t_pvoc *x, double t) { // FIXME check bounds (can't think now) int truncphase = (int) x->phase; double fr = x->phase - ((double) truncphase); double inm1 = x->ifftout[truncphase - 1]; double in = x->ifftout[truncphase + 0]; double inp1 = x->ifftout[truncphase + 1]; double inp2 = x->ifftout[truncphase + 2]; // taken from swh-plugins-0.4.0/ladspa-util.h cube_interp, made to use doubles instead since doubles are what i'm using for some reason return in + 0.5 * fr * (inp1 - inm1 + fr * (4.0 * inp1 + 2.0 * inm1 - 5.0 * in - inp2 + fr * (3.0 * (in - inp1) - inm1 + inp2))); } #endif static t_int *pvoc_perform(t_int *w) { t_pvoc *x = (t_pvoc *)(w[1]); t_float *in1 = (t_float *)(w[2]); t_float *in2 = (t_float *)(w[3]); t_float *out = (t_float *)(w[4]); int n = (int)(w[5]); double t; double pitchshift; int transientpos; int desmear; double framestart; double frameend; int i; // 0 to n -type iterator int j; // start to end -type iterator int k; // bin iterator double xlook; // iterator for interpolated table lookup // if we are at the start of a new frame... if (x->outbufpos % x->hopsize == 0) { // don't desmear this frame by default desmear = 0; // sample the input signals (FIXME just sample these in the beginning..) t = in1[0]; // time position pitchshift = in2[0]; // pitch shift // set the frame boundaries with the desired time pos in the middle framestart = t - (pitchshift * x->fftsize / 2); frameend = framestart + pitchshift * x->fftsize; // prepare to de-smear transients transientpos = transient_between(x, (int) framestart, (int) frameend); if (transientpos != -1) { // there is a transient in this frame #if 0 if (transientpos > t) { // there is a transient in the right half of the window: // --> move the window left until the transient is outside it frameend = transientpos; framestart = frameend - x->fftsize; x->wastrans = 0; } else if ( ! x->wastrans) { // there is a transient in the left half of the window, // and there was no transient there during the previous frame: // --> center the window around the transient and remember to desmear this frame framestart = transientpos - (x->fftsize / 2); frameend = framestart + x->fftsize; desmear = 1; x->wastrans = 1; } else x->wastrans = 1; #else // this simpler method turns out to sound better (timing sounds more accurate, no "frozen" sound preceding transients) if ( ! x->wastrans) { // there is a transient in the window, // and there wasn't during the previous frame: // --> center the window around the transient and remember to desmear this frame framestart = transientpos - (pitchshift * x->fftsize / 2); desmear = 1; } x->wastrans = 1; #endif } else x->wastrans = 0; // interpolate-read the array from framestart to frameend into fftin, windowing it for (i = 0, xlook = framestart; i < x->fftsize; xlook += pitchshift, i++) { x->fftin[i] = interpolate(x, xlook) * x->window[i]; } // hop forward and read the second frame into fft2in // FIXME merge the two loops? framestart += pitchshift * x->hopsize; for (i = 0, xlook = framestart; i < x->fftsize; xlook += pitchshift, i++) { x->fft2in[i] = interpolate(x, xlook) * x->window[i]; } // do the ffts fftw_execute(x->fftplan); fftw_execute(x->fft2plan); if ( ! desmear) { // Miller Puckette's phase modification math (translation from 09.pvoc.pd and 10.phaselockedvoc.pd) double a, b, r, c, d; // propagate phase for (k = 0; k < (x->fftsize / 2 + 1); k++) { a = x->ifftin[k][0] * x->fftout[k][0] + x->ifftin[k][1] * x->fftout[k][1] + 0.00000000000000000001; b = x->ifftin[k][1] * x->fftout[k][0] - x->ifftin[k][0] * x->fftout[k][1]; r = 1 / sqrt(a * a + b * b); c = a * r; d = b * r; x->shiftbuf[k][0] = c * x->fft2out[k][0] - d * x->fft2out[k][1]; x->shiftbuf[k][1] = c * x->fft2out[k][1] + d * x->fft2out[k][0]; } // don't phase-lock the first bin x->ifftin[0][0] = x->shiftbuf[0][0]; x->ifftin[0][1] = x->shiftbuf[0][1]; // phase-lock for (k = 1; k < (x->fftsize / 2); k++) { x->ifftin[k][0] = x->shiftbuf[k][0] - x->phaselocking * (x->shiftbuf[k - 1][0] + x->shiftbuf[k + 1][0]); x->ifftin[k][1] = x->shiftbuf[k][1] - x->phaselocking * (x->shiftbuf[k - 1][1] + x->shiftbuf[k + 1][1]); } // don't phase-lock the last bin x->ifftin[x->fftsize / 2][0] = x->shiftbuf[x->fftsize / 2][0]; x->ifftin[x->fftsize / 2][1] = x->shiftbuf[x->fftsize / 2][1]; } else { // this frame is to be de-smeared, which means don't modify the phases, just preserve the original phases for (k = 0; k < (x->fftsize / 2 + 1); k++) { x->ifftin[k][0] = x->fftout[k][0]; x->ifftin[k][1] = x->fftout[k][1]; } } // do the ifft fftw_execute(x->ifftplan); // add into output buffer, windowing and normalizing first (divide by blocksize) for (i = 0, j = x->outbufpos; i < x->fftsize; i++, j++) { x->outbuf[j % x->fftsize] += x->ifftout[i] / x->fftsize * x->window[i]; } } // output one block of the output buffer for (i = 0, j = x->outbufpos; i < n; i++, j++) { out[i] = x->outbuf[j % x->fftsize]; x->outbuf[j % x->fftsize] = 0; // zero the part of the buffer that was just output } // move the output buffer pointer forward by one block x->outbufpos = (x->outbufpos + n) % x->fftsize; return (w+6); } static void pvoc_dsp(t_pvoc *x, t_signal **sp) { dsp_add(pvoc_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } // adapted from jsarlo's windowing library // Hanning static void makewindow(double *w, int n) { int i; double xshift = n / 2.0; double x; for (i = 0; i < n; i++) { x = (i - xshift) / xshift; w[i] = 0.5 * (1 + cos(M_PI * x)); } } static void setarray(t_pvoc *x, t_symbol *s) { x->arrayname = s; if ( ! (x->arrayobj = (t_garray *)pd_findbyclass(x->arrayname, garray_class))) { if (*x->arrayname->s_name) pd_error(x, "pvoc~: %s: no such array", x->arrayname->s_name); x->array = NULL; x->arraysize = 0; } else if ( ! garray_getfloatwords(x->arrayobj, &x->arraysize, &x->array)) { pd_error(x, "%s: bad template", x->arrayname->s_name); x->array = NULL; x->arraysize = 0; } else { garray_usedindsp(x->arrayobj); } } static void locking(t_pvoc *x, t_floatarg f) { x->phaselocking = f; } // takes a list of sample positions of transients to be de-smeared static void transients(t_pvoc *x, t_symbol *s, int argc, t_atom *argv) { int i; x->ntrans = argc; for (i = 0; i < x->ntrans; i++) x->trans[i] = atom_getfloatarg(i, argc, argv); } // for clarity (same as "transients" with no args) static void notransients(t_pvoc *x) { x->ntrans = 0; } static void *pvoc_new(t_symbol *s, int argc, t_atom *argv) { t_pvoc *x = (t_pvoc *)pd_new(pvoc_class); int i; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); // pitch-shift inlet outlet_new(&x->x_obj, gensym("signal")); if (argc != 3) { post("argc = %d", argc); pd_error(0, "pvoc~: usage: [pvoc~ ]"); return NULL; } x->fftsize = atom_getfloatarg(1, argc, argv); x->overlap = atom_getfloatarg(2, argc, argv); x->hopsize = x->fftsize / x->overlap; x->ntrans = 0; x->wastrans = 0; x->phaselocking = 0; // get the source array setarray(x, atom_getsymbol(argv)); // set up output ring buffer x->outbuf = getbytes(sizeof(double) * x->fftsize); x->outbufpos = 0; for (i = 0; i < x->fftsize; i++) x->outbuf[i] = 0; // make table for window function x->window = getbytes(sizeof(double) * x->fftsize); makewindow(x->window, x->fftsize); // set up fftw stuff x->fftin = fftw_malloc(sizeof(double) * x->fftsize); x->fft2in = fftw_malloc(sizeof(double) * x->fftsize); x->ifftout = fftw_malloc(sizeof(double) * x->fftsize); x->fftout = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->fft2out = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->ifftin = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->shiftbuf = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); for (i = 0; i < (x->fftsize / 2 + 1); i++) { x->ifftin[i][0] = 0; // need to start the phases from zero x->ifftin[i][1] = 0; } x->fftplan = fftw_plan_dft_r2c_1d(x->fftsize, x->fftin, x->fftout, FFTW_MEASURE); x->fft2plan = fftw_plan_dft_r2c_1d(x->fftsize, x->fft2in, x->fft2out, FFTW_MEASURE); x->ifftplan = fftw_plan_dft_c2r_1d(x->fftsize, x->ifftin, x->ifftout, FFTW_MEASURE | FFTW_PRESERVE_INPUT); return (x); } static void pvoc_free(t_pvoc *x) { freebytes(x->outbuf, sizeof(double) * x->fftsize); freebytes(x->window, sizeof(double) * x->fftsize); fftw_free(x->fftin); fftw_free(x->fft2in); fftw_free(x->ifftout); fftw_free(x->fftout); fftw_free(x->fft2out); fftw_free(x->ifftin); fftw_free(x->shiftbuf); fftw_destroy_plan(x->fftplan); fftw_destroy_plan(x->fft2plan); fftw_destroy_plan(x->ifftplan); } void pvoc_tilde_setup(void) { pvoc_class = class_new(gensym("pvoc~"), (t_newmethod)pvoc_new, (t_method)pvoc_free, sizeof(t_pvoc), 0, A_GIMME, 0); class_addmethod(pvoc_class, nullfn, gensym("signal"), 0); class_addmethod(pvoc_class, (t_method) pvoc_dsp, gensym("dsp"), 0); class_addmethod(pvoc_class, (t_method) setarray, gensym("setarray"), A_DEFSYMBOL, 0); class_addmethod(pvoc_class, (t_method) locking, gensym("locking"), A_DEFFLOAT, 0); class_addmethod(pvoc_class, (t_method) transients, gensym("transients"), A_GIMME, 0); class_addmethod(pvoc_class, (t_method) notransients, gensym("notransients"), 0); } bsaylor-0.1.5/sse-conv.inc.c000066400000000000000000000054321434115665400156560ustar00rootroot00000000000000// Ben Saylor 2005-08-10 // attempt at an SSE version of the convolution loop. // Results sound weird, and CPU usage is about the same. :( cursumbuf_fd = (v4sf *) x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; input_fd = (v4sf *) x->input_fd; irpart_fd = (v4sf *) x->irpart_fd[p]; nvecs = x->paddedsize/4; for (v1=0, v2=1; v2 < nvecs; v1+=2, v2+=2) { // v1 is the index of the first 4-float vector (v4sf) to process (v2 is the second) // input_fd, etc. are v4sf pointers. // pull in 4 bins (8 floats) (2 v4sfs) at a time. // (a + bi) * (c + di) = (ac - bd) + (ad + bc)i asm volatile ( // load inputs "movaps %[in1], %%xmm0\n\t" "movaps %[in2], %%xmm6\n\t" "movaps %[ir1], %%xmm2\n\t" "movaps %[ir2], %%xmm7\n\t" "movaps %%xmm0, %%xmm1\n\t" "movaps %%xmm2, %%xmm3\n\t" // xmm0 = xmm1 = [a1 b1 a2 b2] // xmm6 = [a3 b3 a4 b4] // xmm2 = xmm3 = [c1 d1 c2 d2] // xmm7 = [c3 d3 c4 d4] // de-interleave real and imaginary parts "shufps $0x88, %%xmm6, %%xmm0\n\t" // xmm0 = [a1 a2 a3 a4] "shufps $0xDD, %%xmm6, %%xmm1\n\t" // xmm1 = [b1 b2 b3 b4] "shufps $0x88, %%xmm7, %%xmm2\n\t" // xmm2 = [c1 c2 c3 c4] "shufps $0xDD, %%xmm7, %%xmm3\n\t" // xmm3 = [d1 d2 d3 d4] // load output (early, maybe it will help) "movaps %[out1], %%xmm6\n\t" "movaps %[out2], %%xmm7\n\t" // compute the real part of the complex product // (work on copies of xmm0 and xmm1, because we need to keep them) "movaps %%xmm0, %%xmm4\n\t" // xmm4 = [a1 a2 a3 a4] "mulps %%xmm2, %%xmm4\n\t" // xmm4 = [a1c1 a2c2 a3c3 a4c4] "movaps %%xmm1, %%xmm5\n\t" // xmm5 = [b1 b2 b3 b4] "mulps %%xmm3, %%xmm5\n\t" // xmm5 = [b1d1 b2d2 b3d3 b4d4] "subps %%xmm5, %%xmm4\n\t" // xmm4 = (ac - bd) [r1 r2 r3 r4] // compute the imaginary part of the complex product "mulps %%xmm3, %%xmm0\n\t" // xmm0 = [a1d1 a2d2 a3d3 a4d4] "mulps %%xmm2, %%xmm1\n\t" // xmm1 = [b1c1 b2c2 b3c3 b4c4] "addps %%xmm1, %%xmm0\n\t" // xmm0 = (ad + bc) [i1 i2 i3 i4] // re-interleave "movaps %%xmm4, %%xmm5\n\t" // xmm5 = [r1 r2 r3 r4] "unpcklps %%xmm0, %%xmm4\n\t" // xmm4 = [r1 i1 r2 i2] "unpckhps %%xmm5, %%xmm0\n\t" // xmm0 = [r3 i3 r4 i4] // add into sumbuf "addps %%xmm4, %%xmm6\n\t" "addps %%xmm0, %%xmm7\n\t" "movaps %%xmm6, %[out1]\n\t" "movaps %%xmm7, %[out2]" // output/input operands : [out1] "+m" (cursumbuf_fd[v1]), [out2] "+m" (cursumbuf_fd[v2]) // input operands : [in1] "m" (input_fd[v1]), [in2] "m" (input_fd[v2]), [ir1] "m" (irpart_fd[v1]), [ir2] "m" (irpart_fd[v2]) // clobbered registers : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7" ); } bsaylor-0.1.5/susloop~-help.pd000066400000000000000000000067701434115665400163700ustar00rootroot00000000000000#N canvas 1 53 735 689 10; #N canvas 0 0 450 300 (subpatch) 0; #X array sample 86754 float 0; #X coords 0 1 86753 -1 200 64 1; #X restore 441 412 graph; #X obj 480 341 soundfiler; #X msg 480 315 read -resize \$1 sample; #X obj 480 289 openpanel; #X obj 480 267 bng 15 250 50 0 empty empty empty 20 8 0 8 #fcfcfc #000000 #000000; #X obj 8 513 dac~; #X floatatom 69 489 5 0 0 0 - - - 0; #X obj 69 513 / 100; #X obj 8 450 tabread4~ sample; #X obj 8 481 *~; #X floatatom 127 272 5 0 0 0 - - - 0; #X obj 127 310 mtosr 44100; #X msg 17 271 type 0; #X msg 17 299 type 1; #X msg 176 272 44100; #X floatatom 322 380 5 0 0 0 - - - 0; #X floatatom 179 380 6 0 0 0 - - - 0; #X floatatom 245 380 6 0 0 0 - - - 0; #X obj 88 271 bng 15 250 50 0 empty empty empty 20 8 0 8 #fcfcfc #000000 #000000; #X text 514 265 <- load a sample; #X text 421 230 Ben Saylor - bsaylor@macalester.edu; #X msg 124 489 70; #X obj 156 489 loadbang; #X text 54 45 optional creation args:; #X text 239 45 [loopstart loopend [looptype [startpos]]]; #X text 172 336 loopstart; #X text 242 337 loopend; #X text 319 338 startpos; #X text 38 154 is 0 for a forward loop (default) and 1 for a pingpong loop.; #X text 40 193 Playback speed is in samples/sec - send a float or signal to the left inlet.; #X text 10 7 susloop~ - another phase generator for sample looping; #X obj 127 414 susloop~ 4000 12000; #X text 37 94 When the left inlet gets a bang \, the phase output will start at (defaults to 0) \, continue until it reaches \, and then start looping between and .; #X floatatom 480 366 5 0 0 0 - - filesize 0; #X obj 442 480 hsl 200 15 0 1 0 0 empty empty loop_start 10 8 0 8 #bcbcbc #202020 #202020 0 0; #X obj 442 499 hsl 200 15 0 1 0 0 empty empty loop_end 10 8 0 8 #e0e0e0 #000000 #000000 0 0; #X obj 250 565 *; #X obj 317 565 *; #X obj 317 589 int; #X obj 250 589 int; #X obj 265 501 r filesize; #X obj 250 615 s lstart; #X obj 317 615 s lend; #X obj 245 356 r lend; #X obj 179 358 r lstart; #X obj 442 516 hsl 200 15 0 1 0 0 empty empty start 10 8 0 8 #fcfcfc #000000 #000000 0 0; #X obj 385 565 *; #X obj 385 589 int; #X obj 385 615 s start; #X obj 322 356 r start; #N canvas 266 207 494 384 META 0; #X text 12 205 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 165 LIBRARY external bsaylor; #X text 12 5 KEYWORDS signal; #X text 12 45 DESCRIPTION another phase generator for sample looping; #X text 12 125 INLET_3 float; #X text 12 105 INLET_2 float; #X text 12 85 INLET_1 float; #X text 12 65 INLET_0 float bang type; #X text 12 145 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 185 AUTHOR Benjamin R. Saylor ; #X restore 673 602 pd META; #X obj 265 524 t f f f, f 23; #X connect 1 0 33 0; #X connect 2 0 1 0; #X connect 3 0 2 0; #X connect 4 0 3 0; #X connect 6 0 7 0; #X connect 7 0 9 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 5 1; #X connect 10 0 11 0; #X connect 11 0 31 0; #X connect 12 0 31 0; #X connect 13 0 31 0; #X connect 14 0 31 0; #X connect 15 0 31 3; #X connect 16 0 31 1; #X connect 17 0 31 2; #X connect 18 0 31 0; #X connect 21 0 7 0; #X connect 22 0 21 0; #X connect 31 0 8 0; #X connect 34 0 36 0; #X connect 35 0 37 0; #X connect 36 0 39 0; #X connect 37 0 38 0; #X connect 38 0 42 0; #X connect 39 0 41 0; #X connect 40 0 51 0; #X connect 43 0 17 0; #X connect 44 0 16 0; #X connect 45 0 46 0; #X connect 46 0 47 0; #X connect 47 0 48 0; #X connect 49 0 15 0; #X connect 51 0 36 1; #X connect 51 1 37 1; #X connect 51 2 46 1; bsaylor-0.1.5/susloop~.c000066400000000000000000000077251434115665400152620ustar00rootroot00000000000000/* Copyright 2002 Benjamin R. Saylor * * 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 "m_pd.h" static t_class *susloop_class; static t_float pdsr; /* pd's sample rate */ typedef struct _susloop { t_object x_obj; t_float a; /* beginning of loop */ t_float b; /* end of loop */ t_float startpos; /* start offset */ t_float pos; /* position in sample */ t_float direction; /* for pingpong loops */ t_float f; /* dummy for when input is float instead of signal */ void (*susloop_func)(t_int *x, t_float *in, t_float *out, int n); /* can be forward or pingpong */ } t_susloop; static void susloop_forward(t_int *x, t_float *in, t_float *out, int n) { t_float sr; t_float p = ((t_susloop *)x)->pos; t_float a = ((t_susloop *)x)->a; t_float b = ((t_susloop *)x)->b; while (n--) { sr = *in; if (p > b) { p = a + (p - b); } *out = p; p += sr/pdsr; in++; out++; } ((t_susloop *)x)->pos = p; } static void susloop_pingpong(t_int *x, t_float *in, t_float *out, int n) { t_float sr; t_float p = ((t_susloop *)x)->pos; t_float a = ((t_susloop *)x)->a; t_float b = ((t_susloop *)x)->b; t_float d = ((t_susloop *)x)->direction; while (n--) { sr = *in; if (p > b) { p = b - (p - b); d = -1; } else if (p < a && d < 0) { p = a + (a - p); d = 1; } *out = p; p += d*(sr/pdsr); in++; out++; } ((t_susloop *)x)->pos = p; ((t_susloop *)x)->direction = d; } static t_int *susloop_perform(t_int *w) { ((t_susloop *)w[1])->susloop_func((t_int *)w[1], (t_float *)(w[2]), (t_float *)(w[3]), (int)(w[4])); return (w+5); } static void susloop_dsp(t_susloop *x, t_signal **sp) { dsp_add(susloop_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *susloop_new(t_symbol *s, int argc, t_atom *argv) { t_susloop *x = (t_susloop *)pd_new(susloop_class); int looptype = 0; x->a = x->b = x->startpos = 0; x->direction = 1; x->susloop_func = susloop_forward; switch (argc) { case 4: x->startpos = atom_getfloat(argv+3); /* falls through */ case 3: looptype = atom_getint(argv+2); if (looptype == 0) x->susloop_func = susloop_forward; else x->susloop_func = susloop_pingpong; /* falls through */ case 2: x->a = atom_getfloat(argv); x->b = atom_getfloat(argv+1); } floatinlet_new(&x->x_obj, &x->a); floatinlet_new(&x->x_obj, &x->b); floatinlet_new(&x->x_obj, &x->startpos); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void susloop_bang(t_susloop *x) { x->pos = x->startpos; x->direction = 1; } static void susloop_setfunc(t_susloop *x, t_floatarg type) { if (type == 1) { x->direction = 1; x->susloop_func = susloop_pingpong; } else x->susloop_func = susloop_forward; } void susloop_tilde_setup(void) { pdsr = sys_getsr(); susloop_class = class_new(gensym("susloop~"), (t_newmethod)susloop_new, 0, sizeof(t_susloop), 0, A_GIMME, 0); class_addbang(susloop_class, susloop_bang); /* class_addmethod(susloop_class, nullfn, gensym("signal"), 0); */ CLASS_MAINSIGNALIN(susloop_class, t_susloop, f); class_addmethod(susloop_class, (t_method)susloop_dsp, gensym("dsp"), 0); class_addmethod(susloop_class, (t_method)susloop_setfunc, gensym("type"), A_DEFFLOAT, 0); } bsaylor-0.1.5/svf~-help.pd000066400000000000000000000103121434115665400154450ustar00rootroot00000000000000#N canvas 1 53 762 520 10; #X obj 200 455 dac~; #X obj 7 369 phasor~; #X floatatom 7 347 5 0 0 0 - - - 0; #X obj 145 329 sig~; #X obj 190 329 sig~; #X obj 97 257 mtof; #X obj 97 120 vsl 15 128 16 135 0 0 empty empty empty 0 -8 0 8 #fcfcfc #000000 #000000 0 1; #X obj 145 120 vsl 15 128 0 1 0 0 empty empty empty 0 -8 0 8 #fcfcfc #000000 #000000 0 1; #X obj 190 119 vsl 15 128 0 1 0 0 empty empty empty 0 -8 0 8 #fcfcfc #000000 #000000 0 1; #X obj 97 329 line~; #X msg 97 306 \$1 100; #X floatatom 190 281 5 0 0 0 - - - 0; #X floatatom 145 281 5 0 0 0 - - - 0; #X floatatom 97 281 7 0 0 0 - - - 0; #X msg 361 123 low; #X msg 361 147 high; #X msg 361 171 band; #X msg 361 195 notch; #X msg 361 219 peak; #X obj 7 303 loadbang; #N canvas 4 20 608 388 hanning-table 0; #X obj 113 196 phasor~; #X obj 113 224 cos~; #X obj 23 328 tabwrite~ hanning; #X obj 49 242 -~; #X obj 49 208 sig~ 1; #X msg 152 170 0; #X text 141 11 CALCULATE HANNING; #X text 141 27 WINDOW TABLE; #N canvas 0 0 450 300 (subpatch) 0; #X array hanning 512 float 0; #X coords 0 1 511 0 256 128 1; #X restore 305 93 graph; #X obj 113 161 sig~; #X text 24 354 sample rate / window size; #X msg 23 124 bang; #X obj 65 269 sig~ 0.5; #X obj 49 300 *~; #X obj 113 86 samplerate~; #X obj 23 8 loadbang; #X msg 23 31 512; #X obj 113 121 / 512; #X obj 23 53 t b b f; #X obj 23 147 t b b; #X connect 0 0 1 0; #X connect 1 0 3 1; #X connect 3 0 13 0; #X connect 4 0 3 0; #X connect 5 0 0 1; #X connect 9 0 0 0; #X connect 11 0 19 0; #X connect 12 0 13 1; #X connect 13 0 2 0; #X connect 14 0 17 0; #X connect 15 0 16 0; #X connect 16 0 18 0; #X connect 17 0 9 0; #X connect 18 0 11 0; #X connect 18 1 14 0; #X connect 18 2 17 1; #X connect 19 0 2 0; #X connect 19 1 5 0; #X restore 13 430 pd hanning-table; #N canvas 10 112 328 354 fft-analysis 0; #X obj 43 15 inlet~; #X obj 43 134 rfft~, f 7; #X obj 43 163 *~; #X obj 81 164 *~; #X obj 43 187 +~; #X obj 43 216 sqrt~; #X obj 43 297 tabsend~ response; #X obj 171 209 block~ 512 2; #X obj 57 71 tabreceive~ hanning; #X obj 43 99 *~; #X obj 43 36 /~ 8; #X obj 43 249 clip~ 0 1; #X connect 0 0 10 0; #X connect 1 0 2 0; #X connect 1 0 2 1; #X connect 1 1 3 0; #X connect 1 1 3 1; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 5 0; #X connect 5 0 11 0; #X connect 8 0 9 1; #X connect 9 0 1 0; #X connect 10 0 9 0; #X connect 11 0 6 0; #X restore 216 421 pd fft-analysis; #N canvas 0 0 450 300 (subpatch) 0; #X array response 256 float 0; #X coords 0 1 255 0 256 140 1; #X restore 478 20 graph; #X msg 7 325 110; #X text 5 1 svf~ - state-variable filter; #X text 146 99 q; #X text 171 100 resonance; #X text 67 100 frequency; #X text 331 100 filter type; #X obj 200 387 svf~ low; #X text 8 28 A port of Steve Harris' LADSPA plugin; #X text 6 45 (http://plugin.org.uk); #X text 325 313 Notes:; #X text 338 334 'q' controls the filter resonance. The resonance input is for 'extra' resonance.. :); #X text 400 171 <- keep q below 0.1; #X text 339 370 The filters don't use the same scale for frequency. Bandpass frequency seems to be in Hz. If the frequency is set too high \, LOUD aliasing is produced.; #X text 339 418 The bandpass filter is very sensitive to q - normal range is 0 to 0.1.; #N canvas 338 198 494 403 META 0; #X text 12 245 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 205 LIBRARY external bsaylor; #X text 12 5 KEYWORDS signal filter; #X text 12 45 DESCRIPTION state-variable filter; #X text 12 65 INLET_0 signal low high band notch peak; #X text 12 105 INLET_2 signal; #X text 12 85 INLET_1 signal; #X text 12 125 OUTLET_0 signal; #X text 12 145 OUTLET_1 signal; #X text 12 165 OUTLET_2 signal; #X text 12 185 OUTLET_3 signal; #X text 12 25 LICENSE GPL v2; #X text 12 225 AUTHOR Benjamin R. Saylor ; #X restore 690 468 pd META; #X connect 1 0 29 0; #X connect 2 0 1 0; #X connect 3 0 29 2; #X connect 5 0 13 0; #X connect 6 0 5 0; #X connect 7 0 12 0; #X connect 8 0 11 0; #X connect 9 0 29 1; #X connect 10 0 9 0; #X connect 11 0 4 0; #X connect 12 0 3 0; #X connect 13 0 10 0; #X connect 14 0 29 0; #X connect 15 0 29 0; #X connect 16 0 29 0; #X connect 17 0 29 0; #X connect 18 0 29 0; #X connect 19 0 23 0; #X connect 23 0 2 0; #X connect 29 0 0 0; #X connect 29 0 0 1; #X connect 29 0 21 0; bsaylor-0.1.5/svf~.c000066400000000000000000000116151434115665400143450ustar00rootroot00000000000000/* * copyright Steve Harris, Ben Saylor * see GPL.txt */ #include #include #include "m_pd.h" #ifdef _MSC_VER #define inline __inline #define M_PI 3.14159265358979323846 #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif // Number of filter oversamples #define F_R 3 // Denormalise floats, only actually needed for PIII and very recent PowerPC #define FLUSH_TO_ZERO(fv) (((*(unsigned int*)&(fv))&0x7f800000)==0)?0.0f:(fv) /* pd's samplerate */ float fs; static t_class *svf_class; typedef struct _svf { t_object x_obj; float f; // 2.0*sin(PI*fs/(fc*r)); float q; // 2.0*cos(pow(q, 0.1)*PI*0.5); float qnrm; // sqrt(m/2.0f+0.01f); float h; // high pass output float b; // band pass output float l; // low pass output float p; // peaking output (allpass with resonance) float n; // notch output float *op; // pointer to output value } t_svf; /* Store data in SVF struct, takes the sampling frequency, cutoff frequency and Q, and fills in the structure passed */ //static inline void setup_svf(sv_filter *sv, float fs, float fc, float q, int t) { static inline void setup_svf(t_svf *sv, float fc, float q) { sv->f = 2.0f * sin(M_PI * fc / (float)(fs * F_R)); sv->q = 2.0f * cos(pow(q, 0.1f) * M_PI * 0.5f); sv->qnrm = sqrt(sv->q/2.0+0.01); } /* Run one sample through the SV filter. Filter is by andy@vellocet */ static inline float run_svf(t_svf *sv, float in) { float out; int i; in = sv->qnrm * in ; for (i=0; i < F_R; i++) { // only needed for pentium chips if(PD_BIGORSMALL(in)) in = 0.; if(PD_BIGORSMALL(sv->l)) sv->l = 0.; // OLD VERSION //in = FLUSH_TO_ZERO(in); //sv->l = FLUSH_TO_ZERO(sv->l); // new versions, thanks to Damon Chaplin, inserted by Ed Kelly, not yet working!!! //in = ((int)in & 0x7f800000)==0?0.0f:in; //sv->l = ((int)sv->l & 0x7f800000)==0?0.0f:sv->l; // very slight waveshape for extra stability sv->b = sv->b - sv->b * sv->b * sv->b * 0.001f; // regular state variable code here // the notch and peaking outputs are optional sv->h = in - sv->l - sv->q * sv->b; sv->b = sv->b + sv->f * sv->h; sv->l = sv->l + sv->f * sv->b; sv->n = sv->l + sv->h; sv->p = sv->l - sv->h; out = *(sv->op); in = out; } return out; } static void svf_setstate_LP(t_svf *sv) { sv->op = &(sv->l); } static void svf_setstate_HP(t_svf *sv) { sv->op = &(sv->h); } static void svf_setstate_BP(t_svf *sv) { sv->op = &(sv->b); } static void svf_setstate_BR(t_svf *sv) { sv->op = &(sv->n); } static void svf_setstate_AP(t_svf *sv) { sv->op = &(sv->p); } static t_int *svf_perform(t_int *w) { t_svf *obj = (t_svf *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *freq = (t_float *)(w[3]); t_float *q = (t_float *)(w[4]); t_float *res = (t_float *)(w[5]); t_float *out = (t_float *)(w[6]); int n = (int)(w[7]); while (n--) { float f = *(in++); setup_svf(obj, *(freq++), *(q++)); *(out++) = run_svf(obj, f + ((obj->b) * (*(res++)))); } return (w+8); } static void svf_dsp(t_svf *x, t_signal **sp) { dsp_add(svf_perform, 7, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[0]->s_n); } static void *svf_new(t_symbol *s, int argc, t_atom *argv) { char string[11]; t_svf *x = (t_svf *)pd_new(svf_class); svf_setstate_LP(x); if (argc > 0) { atom_string(argv, string, 10); if (!strcmp(string, "high")) svf_setstate_HP(x); if (!strcmp(string, "band")) svf_setstate_BP(x); if (!strcmp(string, "notch")) svf_setstate_BR(x); if (!strcmp(string, "peak")) svf_setstate_AP(x); } 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_signal, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, gensym("signal")); return (x); } void svf_tilde_setup(void) { fs = sys_getsr(); svf_class = class_new(gensym("svf~"), (t_newmethod)svf_new, 0, sizeof(t_svf), 0, A_GIMME, 0); class_addmethod(svf_class, nullfn, gensym("signal"), 0); class_addmethod(svf_class, (t_method)svf_dsp, gensym("dsp"), 0); class_addmethod(svf_class, (t_method)svf_setstate_LP, gensym("low"), 0); class_addmethod(svf_class, (t_method)svf_setstate_HP, gensym("high"), 0); class_addmethod(svf_class, (t_method)svf_setstate_BP, gensym("band"), 0); class_addmethod(svf_class, (t_method)svf_setstate_BR, gensym("notch"), 0); class_addmethod(svf_class, (t_method)svf_setstate_AP, gensym("peak"), 0); } bsaylor-0.1.5/zhzxh~-help.pd000066400000000000000000000030361434115665400160270ustar00rootroot00000000000000#N canvas 67 53 418 347 10; #X floatatom 111 197 5 0 0 0 - - - 0; #X obj 78 307 dac~; #X obj 78 277 *~; #X obj 13 123 readsf~; #X msg 36 94 1; #X floatatom 105 46 5 0 0 0 - - - 0; #X obj 114 183 hsl 128 8 0 2500 0 1 empty empty tone -2 -6 0 8 #fcfcfc #000000 #000000 8200 1; #X obj 78 220 zhzxh~; #X msg 13 56 open \$1; #X obj 136 244 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 #fcfcfc #000000 #000000 4200 1; #X text 163 25 http://www.macalester.edu/~bsaylor; #X text 160 9 Ben Saylor ; #X obj 13 31 openpanel; #X obj 13 8 bng 15 250 50 0 empty empty empty 0 -6 0 8 #fcfcfc #000000 #000000; #X obj 105 120 *~; #X obj 161 94 tgl 15 1 empty empty empty 0 -6 0 8 #fcfcfc #000000 #000000 1 1; #X obj 105 67 mtof; #X obj 105 93 osc~ 50; #N canvas 83 184 494 344 META 0; #X text 12 65 PLATFORM windows macosx gnulinux; #X text 12 165 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.; #X text 12 85 INLET_0 signal; #X text 12 105 INLET_1 float; #X text 12 125 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR Benjamin R. Saylor ; #X text 12 45 DESCRIPTION needs a description; #X text 12 5 KEYWORDS signal; #X restore 356 305 pd META; #X connect 0 0 7 1; #X connect 2 0 1 0; #X connect 2 0 1 1; #X connect 3 0 7 0; #X connect 4 0 3 0; #X connect 5 0 16 0; #X connect 6 0 0 0; #X connect 7 0 2 0; #X connect 8 0 3 0; #X connect 9 0 2 1; #X connect 12 0 8 0; #X connect 13 0 12 0; #X connect 14 0 7 0; #X connect 15 0 14 1; #X connect 16 0 17 0; #X connect 17 0 14 0; bsaylor-0.1.5/zhzxh~.c000066400000000000000000000041621434115665400147210ustar00rootroot00000000000000/* Copyright 2002 Benjamin R. Saylor * * 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 "m_pd.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif static t_class *zhzxh_class; typedef struct _zhzxh { t_object x_obj; t_float slope; t_float lastval; t_float srate; t_float f; } t_zhzxh; static t_int *zhzxh_perform(t_int *w) { t_zhzxh *x = (t_zhzxh *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); t_float f; t_float lastval = x->lastval; t_float delta = x->slope / x->srate; while (n--) { f = *(in++); if (lastval < f) *out = lastval + delta; else *out = lastval - delta; lastval = *(out++); } x->lastval = lastval; return (w+5); } static void zhzxh_dsp(t_zhzxh *x, t_signal **sp) { dsp_add(zhzxh_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *zhzxh_new(t_symbol *s, int argc, t_atom *argv) { t_zhzxh *x = (t_zhzxh *)pd_new(zhzxh_class); x->slope = 1; x->lastval = 0; x->srate = sys_getsr(); floatinlet_new(&x->x_obj, &x->slope); outlet_new(&x->x_obj, gensym("signal")); return (x); } void zhzxh_tilde_setup(void) { zhzxh_class = class_new(gensym("zhzxh~"), (t_newmethod)zhzxh_new, 0, sizeof(t_zhzxh), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(zhzxh_class, t_zhzxh, f); class_addmethod(zhzxh_class, (t_method)zhzxh_dsp, gensym("dsp"), 0); }