From a1e92bd8ad513384243b67af4a44dab8744515d9 Mon Sep 17 00:00:00 2001 From: musil Date: Wed, 29 Nov 2006 19:20:43 +0000 Subject: initial commit changed float to t_float -fno-strict-aliasing #pragma obsolete svn path=/trunk/externals/iem/iem_delay/; revision=6515 --- GnuGPL.txt | 340 +++++++++++++++++++++++++++++++ LICENSE.txt | 27 +++ READ_ME.txt | 16 ++ help/block_delay~-help.pd | 42 ++++ help/n_delay1p_line~-help.pd | 52 +++++ help/n_delay2p_line~-help.pd | 52 +++++ pd_start.bat | 13 ++ src/block_delay~.c | 124 ++++++++++++ src/iem_delay.c | 34 ++++ src/iem_delay.dsp | 85 ++++++++ src/iem_delay.dsw | 29 +++ src/iem_delay.h | 11 ++ src/iemlib.h | 108 ++++++++++ src/makefile | 49 +++++ src/makefile_linux | 49 +++++ src/makefile_win | 41 ++++ src/n_delay1p_line~.c | 428 +++++++++++++++++++++++++++++++++++++++ src/n_delay2p_line~.c | 462 +++++++++++++++++++++++++++++++++++++++++++ src/nz~.c | 250 +++++++++++++++++++++++ 19 files changed, 2212 insertions(+) create mode 100644 GnuGPL.txt create mode 100644 LICENSE.txt create mode 100644 READ_ME.txt create mode 100644 help/block_delay~-help.pd create mode 100644 help/n_delay1p_line~-help.pd create mode 100644 help/n_delay2p_line~-help.pd create mode 100644 pd_start.bat create mode 100644 src/block_delay~.c create mode 100644 src/iem_delay.c create mode 100644 src/iem_delay.dsp create mode 100644 src/iem_delay.dsw create mode 100644 src/iem_delay.h create mode 100644 src/iemlib.h create mode 100644 src/makefile create mode 100644 src/makefile_linux create mode 100644 src/makefile_win create mode 100644 src/n_delay1p_line~.c create mode 100644 src/n_delay2p_line~.c create mode 100644 src/nz~.c diff --git a/GnuGPL.txt b/GnuGPL.txt new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/GnuGPL.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library General +Public License instead of this License. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..09ae4d7 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +iem_delay - dynamic library for pd; some delay objects + +Copyright (C) 2000-2006 Thomas MUSIL [musil_at_iem.at] + +IEM - Institute of Electronic Music and Acoustics, Graz +Inffeldgasse 10/3, 8010 Graz, Austria +http://iem.at + + + + 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 ( GnuGPL.txt ). + (e.g. http://www.gnu.org/copyleft/gpl.html) + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Graz, 15 Nov. 2006 + Thomas Musil \ No newline at end of file diff --git a/READ_ME.txt b/READ_ME.txt new file mode 100644 index 0000000..d3d04dd --- /dev/null +++ b/READ_ME.txt @@ -0,0 +1,16 @@ +This library extends the performance of miller puckette's pure data (pd). + +iem_delay is written by Thomas Musil from IEM Graz Austria + and it is compatible to miller puckette's pd-0.37-3 to pd-0.39-2. +see also LICENCE.txt, GnuGPL.txt. + +iem_delay contains 4 objects: +"block_delay~", "n_delay1p_line~", "n_delay2p_line~" and "nz~" +block_delay~ delays signals to one blocksize. +n_delay1p_line~ is a delay with one signal inlet and n signal outlets + which change its delay taps during a time period, without interpolation. +n_delay2p_line~ is a delay with one signal inlet and n signal outlets + which change its delay taps during a time period, with a 2-point interpolation + between the samples. +nz~ is static delay with one signal inlet and n signal outlets + the control parameters are in samples. \ No newline at end of file diff --git a/help/block_delay~-help.pd b/help/block_delay~-help.pd new file mode 100644 index 0000000..67fe4f2 --- /dev/null +++ b/help/block_delay~-help.pd @@ -0,0 +1,42 @@ +#N canvas 22 12 564 467 10; +#X text 117 399 IEM KUG; +#X text 101 387 musil; +#X text 131 387 @; +#X text 137 387 iem.at; +#X text 100 409 Graz \, Austria; +#X text 52 376 (c) Thomas Musil 2000 - 2006; +#X obj 21 66 dsp; +#X obj 21 43 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X floatatom 21 107 5 0 0 0 - - -; +#X floatatom 34 90 5 0 0 0 - - -; +#X text 130 11 2 point interpolation between 2 samples; +#X obj 161 139 dirac~; +#N canvas 0 0 450 300 graph1 0; +#X array array101 100 float 0; +#X coords 0 1.1 99 -0.1 100 50 1; +#X restore 404 223 graph; +#X obj 187 258 tabwrite~ array101; +#N canvas 0 0 450 300 graph1 0; +#X array array100 100 float 0; +#X coords 0 1.1 99 -0.1 100 50 1; +#X restore 404 153 graph; +#X obj 226 192 tabwrite~ array100; +#X text 250 220 no initial arguments; +#X obj 162 220 block_delay~; +#X obj 160 97 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 405 274 hsl 100 15 0 99 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 6400 1; +#X floatatom 402 295 5 0 0 0 - - -; +#X text 21 11 block_delay~; +#X connect 6 0 8 0; +#X connect 6 1 9 0; +#X connect 7 0 6 0; +#X connect 11 0 15 0; +#X connect 11 0 17 0; +#X connect 17 0 13 0; +#X connect 18 0 11 0; +#X connect 18 0 15 0; +#X connect 18 0 13 0; +#X connect 19 0 20 0; diff --git a/help/n_delay1p_line~-help.pd b/help/n_delay1p_line~-help.pd new file mode 100644 index 0000000..8402354 --- /dev/null +++ b/help/n_delay1p_line~-help.pd @@ -0,0 +1,52 @@ +#N canvas 22 12 782 522 10; +#X text 117 399 IEM KUG; +#X text 101 387 musil; +#X text 131 387 @; +#X text 137 387 iem.at; +#X text 100 409 Graz \, Austria; +#X text 52 376 (c) Thomas Musil 2000 - 2006; +#X obj 21 66 dsp; +#X obj 21 43 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X floatatom 21 107 5 0 0 0 - - -; +#X floatatom 34 90 5 0 0 0 - - -; +#X obj 220 227 n_delay1p_line~ 2 100; +#X obj 252 178 pack 0 0; +#X obj 308 145 t b f; +#X floatatom 233 93 5 0 0 0 - - -; +#X floatatom 313 94 5 0 0 0 - - -; +#X obj 133 109 osc~ 700; +#X obj 152 180 dbtorms; +#X floatatom 152 161 5 0 100 0 - - -; +#X obj 133 204 *~ 0; +#X obj 221 262 dac~; +#X msg 399 176 time \$1; +#X floatatom 399 150 5 0 0 0 - - -; +#X msg 425 118 100; +#X msg 460 121 1000; +#X msg 391 119 0; +#X msg 503 121 3000; +#X text 21 11 n_delay1p_line~; +#X text 357 233 1.arg: number of outlets; +#X text 357 243 2.arg: interpolation time in ms; +#X text 196 11 one point interpolation of one sample; +#X connect 6 0 8 0; +#X connect 6 1 9 0; +#X connect 7 0 6 0; +#X connect 10 0 19 0; +#X connect 10 1 19 1; +#X connect 11 0 10 0; +#X connect 12 0 11 0; +#X connect 12 1 11 1; +#X connect 13 0 11 0; +#X connect 14 0 12 0; +#X connect 15 0 18 0; +#X connect 16 0 18 1; +#X connect 17 0 16 0; +#X connect 18 0 10 0; +#X connect 20 0 10 0; +#X connect 21 0 20 0; +#X connect 22 0 21 0; +#X connect 23 0 21 0; +#X connect 24 0 21 0; +#X connect 25 0 21 0; diff --git a/help/n_delay2p_line~-help.pd b/help/n_delay2p_line~-help.pd new file mode 100644 index 0000000..72e5da2 --- /dev/null +++ b/help/n_delay2p_line~-help.pd @@ -0,0 +1,52 @@ +#N canvas 22 12 782 522 10; +#X text 117 399 IEM KUG; +#X text 101 387 musil; +#X text 131 387 @; +#X text 137 387 iem.at; +#X text 100 409 Graz \, Austria; +#X text 52 376 (c) Thomas Musil 2000 - 2006; +#X obj 21 66 dsp; +#X obj 21 43 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X floatatom 21 107 5 0 0 0 - - -; +#X floatatom 34 90 5 0 0 0 - - -; +#X obj 252 178 pack 0 0; +#X obj 308 145 t b f; +#X floatatom 233 93 5 0 0 0 - - -; +#X floatatom 313 94 5 0 0 0 - - -; +#X obj 133 109 osc~ 700; +#X obj 152 180 dbtorms; +#X floatatom 152 161 5 0 100 0 - - -; +#X obj 133 204 *~ 0; +#X obj 221 262 dac~; +#X msg 399 176 time \$1; +#X floatatom 399 150 5 0 0 0 - - -; +#X msg 425 118 100; +#X msg 460 121 1000; +#X msg 391 119 0; +#X msg 503 121 3000; +#X text 357 233 1.arg: number of outlets; +#X text 357 243 2.arg: interpolation time in ms; +#X text 21 11 n_delay2p_line~; +#X text 196 11 2 point interpolation between 2 samples; +#X obj 220 227 n_delay2p_line~ 2 100; +#X connect 6 0 8 0; +#X connect 6 1 9 0; +#X connect 7 0 6 0; +#X connect 10 0 29 0; +#X connect 11 0 10 0; +#X connect 11 1 10 1; +#X connect 12 0 10 0; +#X connect 13 0 11 0; +#X connect 14 0 17 0; +#X connect 15 0 17 1; +#X connect 16 0 15 0; +#X connect 17 0 29 0; +#X connect 19 0 29 0; +#X connect 20 0 19 0; +#X connect 21 0 20 0; +#X connect 22 0 20 0; +#X connect 23 0 20 0; +#X connect 24 0 20 0; +#X connect 29 0 18 0; +#X connect 29 1 18 1; diff --git a/pd_start.bat b/pd_start.bat new file mode 100644 index 0000000..19a794f --- /dev/null +++ b/pd_start.bat @@ -0,0 +1,13 @@ +@echo off + +set PD_PATCH=%1 +set PD_INSTALL=C:\Programme\pd\bin +set PD_AUDIO=-r 44100 -audiobuf 80 -channels 2 +set PD_MIDI=-nomidi +set PD_OPTIONS=-font 10 +set PD_PATH=-path C:/Programme/pd/externs/iemlib_R1.16/iemabs -path C:/Programme/pd/externs/iemlib_R1.16/lib -path C:/Programme/pd/externs/zexy +set PD_LIB=-lib iemlib1 -lib iemlib2 -lib iem_delay -lib zexy + + +@echo starting pd ... +%PD_INSTALL%\pd %PD_AUDIO% %PD_MIDI% %PD_OPTIONS% %PD_PATH% %PD_LIB% %PD_PATCH% diff --git a/src/block_delay~.c b/src/block_delay~.c new file mode 100644 index 0000000..d80f96b --- /dev/null +++ b/src/block_delay~.c @@ -0,0 +1,124 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include "iem_delay.h" + +/* -------------------------- block_delay~ ------------------------------ */ +static t_class *block_delay_tilde_class; + +typedef struct _block_delay_tilde +{ + t_object x_obj; + t_float *x_begmem; + int x_blocksize; + t_float x_msi; +} t_block_delay_tilde; + +static t_int *block_delay_tilde_perform(t_int *w) +{ + t_float *in = (float *)(w[1]); + t_float *out = (float *)(w[2]); + t_block_delay_tilde *x = (t_block_delay_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float *rw_vec, f; + + rw_vec = x->x_begmem; + for(i=0; ix_begmem; + while(n) + { + f[0] = in[0]; + f[1] = in[1]; + f[2] = in[2]; + f[3] = in[3]; + f[4] = in[4]; + f[5] = in[5]; + f[6] = in[6]; + f[7] = in[7]; + + out[0] = rw_vec[0]; + out[1] = rw_vec[1]; + out[2] = rw_vec[2]; + out[3] = rw_vec[3]; + out[4] = rw_vec[4]; + out[5] = rw_vec[5]; + out[6] = rw_vec[6]; + out[7] = rw_vec[7]; + + rw_vec[0] = f[0]; + rw_vec[1] = f[1]; + rw_vec[2] = f[2]; + rw_vec[3] = f[3]; + rw_vec[4] = f[4]; + rw_vec[5] = f[5]; + rw_vec[6] = f[6]; + rw_vec[7] = f[7]; + + rw_vec += 8; + in += 8; + out += 8; + n -= 8; + } + return(w+5); +} + +static void block_delay_tilde_dsp(t_block_delay_tilde *x, t_signal **sp) +{ + int n = sp[0]->s_n; + + if(!x->x_blocksize)/*first time*/ + x->x_begmem = (t_float *)getbytes(n * sizeof(t_float)); + else if(x->x_blocksize != n) + x->x_begmem = (t_float *)resizebytes(x->x_begmem, x->x_blocksize*sizeof(t_float), n*sizeof(t_float)); + x->x_blocksize = n; + if(n&7) + dsp_add(block_delay_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); + else + dsp_add(block_delay_tilde_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void *block_delay_tilde_new(void) +{ + t_block_delay_tilde *x = (t_block_delay_tilde *)pd_new(block_delay_tilde_class); + + x->x_blocksize = 0; + x->x_begmem = (t_float *)0; + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0.0f; + return (x); +} + +static void block_delay_tilde_free(t_block_delay_tilde *x) +{ + if(x->x_begmem) + freebytes(x->x_begmem, x->x_blocksize * sizeof(t_float)); +} + +void block_delay_tilde_setup(void) +{ + block_delay_tilde_class = class_new(gensym("block_delay~"), (t_newmethod)block_delay_tilde_new, (t_method)block_delay_tilde_free, + sizeof(t_block_delay_tilde), 0, 0); + CLASS_MAINSIGNALIN(block_delay_tilde_class, t_block_delay_tilde, x_msi); + class_addmethod(block_delay_tilde_class, (t_method)block_delay_tilde_dsp, gensym("dsp"), 0); + class_sethelpsymbol(block_delay_tilde_class, gensym("iemhelp2/help-block_delay~")); +} diff --git a/src/iem_delay.c b/src/iem_delay.c new file mode 100644 index 0000000..1ba3607 --- /dev/null +++ b/src/iem_delay.c @@ -0,0 +1,34 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" + +static t_class *iem_delay_class; + +static void *iem_delay_new(void) +{ + t_object *x = (t_object *)pd_new(iem_delay_class); + + return (x); +} + +void n_delay1p_line_tilde_setup(void); +void n_delay2p_line_tilde_setup(void); +void nz_tilde_setup(void); +void block_delay_tilde_setup(void); + +/* ------------------------ setup routine ------------------------- */ + +void iem_delay_setup(void) +{ + n_delay1p_line_tilde_setup(); + n_delay2p_line_tilde_setup(); + nz_tilde_setup(); + block_delay_tilde_setup(); + + post("iem_delay (R-1.16) library loaded! (c) Thomas Musil 05.2005"); + post(" musil%ciem.at iem KUG Graz Austria", '@'); +} diff --git a/src/iem_delay.dsp b/src/iem_delay.dsp new file mode 100644 index 0000000..df7588d --- /dev/null +++ b/src/iem_delay.dsp @@ -0,0 +1,85 @@ +# Microsoft Developer Studio Project File - Name="iem_delay" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=iem_delay - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "iem_delay.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "iem_delay.mak" CFG="iem_delay - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "iem_delay - Win32 Release" (basierend auf "Win32 (x86) External Target") +!MESSAGE "iem_delay - Win32 Debug" (basierend auf "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "iem_delay - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_delay.exe" +# PROP Bsc_Name "iem_delay.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "iem_delay - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_delay.exe" +# PROP Bsc_Name "iem_delay.bsc" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "iem_delay - Win32 Release" +# Name "iem_delay - Win32 Debug" + +!IF "$(CFG)" == "iem_delay - Win32 Release" + +!ELSEIF "$(CFG)" == "iem_delay - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=.\makefile_win +# End Source File +# End Target +# End Project diff --git a/src/iem_delay.dsw b/src/iem_delay.dsw new file mode 100644 index 0000000..e8060b1 --- /dev/null +++ b/src/iem_delay.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "iem_delay"=.\iem_delay.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/iem_delay.h b/src/iem_delay.h new file mode 100644 index 0000000..dea664b --- /dev/null +++ b/src/iem_delay.h @@ -0,0 +1,11 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + +#ifndef __IEMDELAY_H__ +#define __IEMDELAY_H__ + +#define DELLINE_DEF_VEC_SIZE 64 + +#endif diff --git a/src/iemlib.h b/src/iemlib.h new file mode 100644 index 0000000..6be2de0 --- /dev/null +++ b/src/iemlib.h @@ -0,0 +1,108 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifndef __IEMLIB_H__ +#define __IEMLIB_H__ + + +#define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER) +#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT) +#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL) +#define IS_A_DOLLAR(atom,index) ((atom+index)->a_type == A_DOLLAR) +#define IS_A_DOLLSYM(atom,index) ((atom+index)->a_type == A_DOLLSYM) +#define IS_A_SEMI(atom,index) ((atom+index)->a_type == A_SEMI) +#define IS_A_COMMA(atom,index) ((atom+index)->a_type == A_COMMA) + + +#ifdef NT +int sys_noloadbang; +//t_symbol *iemgui_key_sym=0; +#include +#else +extern int sys_noloadbang; +//extern t_symbol *iemgui_key_sym; +#include +#endif + +#define DEFDELVS 64 +#define XTRASAMPS 4 +#define SAMPBLK 4 + + +#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */ + +/* machine-dependent definitions. These ifdefs really +should have been by CPU type and not by operating system! */ +#ifdef IRIX +/* big-endian. Most significant byte is at low address in memory */ +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#define int32 long /* a data type that has 32 bits */ +#else +#ifdef MSW +/* little-endian; most significant byte is at highest address */ +#define HIOFFSET 1 +#define LOWOFFSET 0 +#define int32 long +#else +#ifdef __FreeBSD__ +#include +#if BYTE_ORDER == LITTLE_ENDIAN +#define HIOFFSET 1 +#define LOWOFFSET 0 +#else +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#endif /* BYTE_ORDER */ +#include +#define int32 int32_t +#endif +#ifdef __linux__ + +#include + +#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) +#error No byte order defined +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define HIOFFSET 1 +#define LOWOFFSET 0 +#else +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#endif /* __BYTE_ORDER */ + +#include +#define int32 int32_t + +#else +#ifdef __APPLE__ +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#define int32 int /* a data type that has 32 bits */ + +#endif /* __APPLE__ */ +#endif /* __linux__ */ +#endif /* MSW */ +#endif /* SGI */ + +union tabfudge +{ + double tf_d; + int32 tf_i[2]; +}; + +#ifdef __i386__ +#define IEM_DENORMAL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \ +(((*(unsigned int*)&(f))&0x60000000)==0x60000000)) +/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */ +#else + +#define IEM_DENORMAL(f) 0 + +#endif + +#endif diff --git a/src/makefile b/src/makefile new file mode 100644 index 0000000..d551c0c --- /dev/null +++ b/src/makefile @@ -0,0 +1,49 @@ +current: all + +.SUFFIXES: .pd_linux + +INCLUDE = -I. -I/usr/local/src/pd/src + +LDFLAGS = -export-dynamic -shared +LIB = -ldl -lm + +#select either the DBG and OPT compiler flags below: + +CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \ + -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \ + -DDL_OPEN -fPIC + +SYSTEM = $(shell uname -m) + +# the sources + +SRC = n_delay1p_line~.c \ + n_delay2p_line~.c \ + nz~.c \ + block_delay~.c \ + iem_delay.c + +TARGET = iem_delay.pd_linux + + +OBJ = $(SRC:.c=.o) + +# +# ------------------ targets ------------------------------------ +# + +clean: + rm $(TARGET) + rm *.o + +all: $(OBJ) + @echo :: $(OBJ) + $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB) + strip --strip-unneeded $(TARGET) + +$(OBJ) : %.o : %.c + $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c + + + + diff --git a/src/makefile_linux b/src/makefile_linux new file mode 100644 index 0000000..d551c0c --- /dev/null +++ b/src/makefile_linux @@ -0,0 +1,49 @@ +current: all + +.SUFFIXES: .pd_linux + +INCLUDE = -I. -I/usr/local/src/pd/src + +LDFLAGS = -export-dynamic -shared +LIB = -ldl -lm + +#select either the DBG and OPT compiler flags below: + +CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \ + -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \ + -DDL_OPEN -fPIC + +SYSTEM = $(shell uname -m) + +# the sources + +SRC = n_delay1p_line~.c \ + n_delay2p_line~.c \ + nz~.c \ + block_delay~.c \ + iem_delay.c + +TARGET = iem_delay.pd_linux + + +OBJ = $(SRC:.c=.o) + +# +# ------------------ targets ------------------------------------ +# + +clean: + rm $(TARGET) + rm *.o + +all: $(OBJ) + @echo :: $(OBJ) + $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB) + strip --strip-unneeded $(TARGET) + +$(OBJ) : %.o : %.c + $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c + + + + diff --git a/src/makefile_win b/src/makefile_win new file mode 100644 index 0000000..2d84b91 --- /dev/null +++ b/src/makefile_win @@ -0,0 +1,41 @@ + +all: iem_delay.dll + +VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98" + +PD_INST_PATH = "C:\Programme\pd-0.39-2" + +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include + +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN + +PD_WIN_L_FLAGS = /nologo + +PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ + $(VIS_CPP_PATH)\lib\libc.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + $(VIS_CPP_PATH)\lib\kernel32.lib \ + $(VIS_CPP_PATH)\lib\wsock32.lib \ + $(VIS_CPP_PATH)\lib\winmm.lib \ + $(PD_INST_PATH)\bin\pthreadVC.lib \ + $(PD_INST_PATH)\bin\pd.lib + + +SRC = n_delay1p_line~.c \ + n_delay2p_line~.c \ + nz~.c \ + block_delay~.c \ + iem_delay.c + + +OBJ = $(SRC:.c=.obj) + +.c.obj: + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + +iem_delay.dll: $(OBJ) + link $(PD_WIN_L_FLAGS) /dll /export:iem_delay_setup \ + /out:iem_delay.dll $(OBJ) $(PD_WIN_LIB) + +clean: + del *.obj diff --git a/src/n_delay1p_line~.c b/src/n_delay1p_line~.c new file mode 100644 index 0000000..f65d149 --- /dev/null +++ b/src/n_delay1p_line~.c @@ -0,0 +1,428 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include "iem_delay.h" + +/* -------------------------- n_delay1p_line_tilde~ ------------------------------ */ +static t_class *n_delay1p_line_tilde_class; + +typedef struct _n_delay1p_line_tilde +{ + t_object x_obj; + int x_mallocsize; + t_float x_max_delay_ms; + t_float *x_begmem0; + t_float *x_begmem1; + int x_writeindex; + int x_n_delays; + int *x_del_samp256_end; + int *x_del_samp256_cur; + int *x_inc256; + int *x_biginc256; + int x_blocksize; + t_float x_sr; + t_float x_ms2tick; + t_float x_ms2samples256; + t_float x_interpol_ms; + int x_interpol_ticks; + int x_ticksleft; + int x_old; + int x_retarget; + t_float **x_io; + t_float x_msi; +} t_n_delay1p_line_tilde; + +static void n_delay1p_line_tilde_list(t_n_delay1p_line_tilde *x, t_symbol *s, int argc, t_atom *argv) +{ + if(argc == x->x_n_delays) + { + int i; + t_float delay, max=x->x_max_delay_ms; + + if(x->x_interpol_ms <= 0.0f) + x->x_ticksleft = x->x_retarget = 0; + else + x->x_retarget = 1; + for(i=0; i max) + delay = max; + if(x->x_interpol_ms <= 0.0f) + x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127; + else + x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127; + } + } +} + +static void n_delay1p_line_tilde_time(t_n_delay1p_line_tilde *x, t_floatarg interpol_ms) +{ + if(interpol_ms < 0.0f) + interpol_ms = 0.0f; + x->x_interpol_ms = interpol_ms; + x->x_interpol_ticks = (int)(x->x_ms2tick * interpol_ms); +} + +static void n_delay1p_line_tilde_stop(t_n_delay1p_line_tilde *x) +{ + int i, n=x->x_n_delays; + + for(i=0; ix_del_samp256_end[i] = x->x_del_samp256_cur[i]; + x->x_ticksleft = x->x_retarget = 0; +} + +static t_int *n_delay1p_line_tilde_perform(t_int *w) +{ + t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)(w[1]); + int hn=(int)(w[2]); + int nout=x->x_n_delays; + t_float *in; + t_float *out; + int writeindex = x->x_writeindex; + int i, j, n; + int malloc_samples = x->x_mallocsize; + t_float *begvec0 = x->x_begmem0; + t_float *begvec1 = x->x_begmem1; + t_float *writevec; + t_float *readvec; + int del256, inc256; + + writevec = begvec0 + writeindex; + in=x->x_io[0]; + n = hn; + while(n--) + { + *writevec++ = *in++; + } + writevec = begvec1 + writeindex; + in=x->x_io[0]; + n = hn; + while(n--) + { + *writevec++ = *in++; + } + + if(x->x_retarget) + { + int nticks = x->x_interpol_ticks; + + if(!nticks) + nticks = 1; + x->x_ticksleft = nticks; + for(j=0; jx_biginc256[j] = (x->x_del_samp256_end[j] - x->x_del_samp256_cur[j]) / nticks; + x->x_inc256[j] = x->x_biginc256[j] / x->x_blocksize; + } + x->x_retarget = 0; + } + + if(x->x_ticksleft) + { + for(j=0; jx_inc256[j]; + del256 = x->x_del_samp256_cur[j]; + out = x->x_io[j+1]; + for(i=0; i> 8) + i; + *out++ = *readvec; + del256 += inc256; + } + x->x_del_samp256_cur[j] += x->x_biginc256[j]; + } + x->x_ticksleft--; + } + else + { + for(j=0; jx_del_samp256_cur[j] = x->x_del_samp256_end[j]; + readvec = begvec1 + writeindex - (del256 >> 8); + out = x->x_io[j+1]; + n = hn; + while(n--) + { + *out++ = *readvec++; + } + } + } + writeindex += hn; + if(writeindex >= malloc_samples) + { + writeindex -= malloc_samples; + } + x->x_writeindex = writeindex; + return(w+3); +} + +static t_int *n_delay1p_line_tilde_perf8(t_int *w) +{ + t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)(w[1]); + int hn=(int)(w[2]); + int nout=x->x_n_delays; + t_float *in; + t_float *out; + int writeindex = x->x_writeindex; + int i, j, k, n; + int malloc_samples = x->x_mallocsize; + t_float *begvec0 = x->x_begmem0; + t_float *begvec1 = x->x_begmem1; + t_float *writevec; + t_float *readvec; + int del256, inc256; + +// post("writevec = %d",writeindex); + writevec = begvec0 + writeindex; + in=x->x_io[0]; + n = hn; + while(n) + { + writevec[0] = in[0]; + writevec[1] = in[1]; + writevec[2] = in[2]; + writevec[3] = in[3]; + writevec[4] = in[4]; + writevec[5] = in[5]; + writevec[6] = in[6]; + writevec[7] = in[7]; + + writevec += 8; + n -= 8; + in += 8; + } + writevec = begvec1 + writeindex; + in=x->x_io[0]; + n = hn; + while(n) + { + writevec[0] = in[0]; + writevec[1] = in[1]; + writevec[2] = in[2]; + writevec[3] = in[3]; + writevec[4] = in[4]; + writevec[5] = in[5]; + writevec[6] = in[6]; + writevec[7] = in[7]; + + writevec += 8; + n -= 8; + in += 8; + } + + if(x->x_retarget) + { + int nticks = x->x_interpol_ticks; + + if(!nticks) + nticks = 1; + x->x_ticksleft = nticks; + for(j=0; jx_biginc256[j] = (x->x_del_samp256_end[j] - x->x_del_samp256_cur[j]) / nticks; + x->x_inc256[j] = x->x_biginc256[j] / x->x_blocksize; + } + x->x_retarget = 0; + } + + if(x->x_ticksleft) + { + for(j=0; jx_inc256[j]; + del256 = x->x_del_samp256_cur[j]; + out = x->x_io[j+1]; + readvec = begvec1 + writeindex; + for(i=0; i> 8; + out[0] = readvec[0-k]; + del256 += inc256; + + k = del256 >> 8; + out[1] = readvec[1-k]; + del256 += inc256; + + k = del256 >> 8; + out[2] = readvec[2-k]; + del256 += inc256; + + k = del256 >> 8; + out[3] = readvec[3-k]; + del256 += inc256; + + k = del256 >> 8; + out[4] = readvec[4-k]; + del256 += inc256; + + k = del256 >> 8; + out[5] = readvec[5-k]; + del256 += inc256; + + k = del256 >> 8; + out[6] = readvec[6-k]; + del256 += inc256; + + k = del256 >> 8; + out[7] = readvec[7-k]; + del256 += inc256; + + out += 8; + readvec += 8; + } + x->x_del_samp256_cur[j] += x->x_biginc256[j]; + } + x->x_ticksleft--; + } + else + { + for(j=0; jx_del_samp256_cur[j] = x->x_del_samp256_end[j]; + readvec = begvec1 + writeindex - (del256 >> 8); + out = x->x_io[j+1]; + n = hn; + while(n) + { + out[0] = readvec[0]; + out[1] = readvec[1]; + out[2] = readvec[2]; + out[3] = readvec[3]; + out[4] = readvec[4]; + out[5] = readvec[5]; + out[6] = readvec[6]; + out[7] = readvec[7]; + out += 8; + readvec += 8; + n -= 8; + } + } + } + + writeindex += hn; + if(writeindex >= malloc_samples) + { + writeindex -= malloc_samples; + } + x->x_writeindex = writeindex; + + return(w+3); +} + +static void n_delay1p_line_tilde_dsp(t_n_delay1p_line_tilde *x, t_signal **sp) +{ + int n = sp[0]->s_n; + int i, nd = x->x_n_delays + 1; + + if(!x->x_blocksize)/*first time*/ + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (n - 1)); + nsamps += n; + x->x_mallocsize = nsamps; + x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + x->x_writeindex = n; + } + else if((x->x_blocksize != n) || ((t_float)sp[0]->s_sr != x->x_sr)) + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (n - 1)); + nsamps += n; + + x->x_begmem0 = (t_float *)resizebytes(x->x_begmem0, 2*x->x_mallocsize*sizeof(t_float), 2*nsamps*sizeof(t_float)); + x->x_mallocsize = nsamps; + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + if(x->x_writeindex >= nsamps) + x->x_writeindex -= nsamps; + } + x->x_blocksize = n; + x->x_ms2tick = 0.001f * (t_float)sp[0]->s_sr / (t_float)n; + x->x_ms2samples256 = 0.256f * (t_float)sp[0]->s_sr; + x->x_interpol_ticks = (int)(x->x_ms2tick * x->x_interpol_ms); + for(i=0; ix_io[i] = sp[i]->s_vec; + if(n&7) + dsp_add(n_delay1p_line_tilde_perform, 2, x, n); + else + dsp_add(n_delay1p_line_tilde_perf8, 2, x, n); +} + +static void *n_delay1p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_floatarg interpol_ms) +{ + t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)pd_new(n_delay1p_line_tilde_class); + int i, n_out = (int)fout; + int nsamps = delay_ms * sys_getsr() * 0.001f; + + if(n_out < 1) + n_out = 1; + x->x_n_delays = n_out; + x->x_max_delay_ms = delay_ms; + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (DELLINE_DEF_VEC_SIZE - 1)); + nsamps += DELLINE_DEF_VEC_SIZE; + x->x_mallocsize = nsamps; + x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + x->x_writeindex = DELLINE_DEF_VEC_SIZE; + x->x_blocksize = 0; + x->x_sr = 0.0f; + if(interpol_ms < 0.0f) + interpol_ms = 0.0f; + x->x_interpol_ms = interpol_ms; + x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *)); + for(i=0; ix_obj, &s_signal); + x->x_del_samp256_end = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_del_samp256_cur = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_inc256 = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_biginc256 = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_ticksleft = x->x_retarget = 0; + for(i=0; ix_del_samp256_cur[i] = x->x_del_samp256_end[i] = 0; + x->x_inc256[i] = x->x_biginc256[i] = 0; + } + x->x_interpol_ticks = 0; + x->x_msi = 0.0f; + return (x); +} + +static void n_delay1p_line_tilde_free(t_n_delay1p_line_tilde *x) +{ + freebytes(x->x_del_samp256_end, x->x_n_delays * sizeof(int)); + freebytes(x->x_del_samp256_cur, x->x_n_delays * sizeof(int)); + freebytes(x->x_inc256, x->x_n_delays * sizeof(int)); + freebytes(x->x_biginc256, x->x_n_delays * sizeof(int)); + freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *)); + freebytes(x->x_begmem0, 2 * x->x_mallocsize * sizeof(t_float)); +} + +void n_delay1p_line_tilde_setup(void) +{ + n_delay1p_line_tilde_class = class_new(gensym("n_delay1p_line~"), (t_newmethod)n_delay1p_line_tilde_new, (t_method)n_delay1p_line_tilde_free, + sizeof(t_n_delay1p_line_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(n_delay1p_line_tilde_class, t_n_delay1p_line_tilde, x_msi); + class_addlist(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_list); + class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_dsp, gensym("dsp"), 0); + class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_stop, gensym("stop"), 0); + class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_time, gensym("time"), A_FLOAT, 0); + class_sethelpsymbol(n_delay1p_line_tilde_class, gensym("iemhelp2/help-n_delay1p_line~")); +} diff --git a/src/n_delay2p_line~.c b/src/n_delay2p_line~.c new file mode 100644 index 0000000..f747b65 --- /dev/null +++ b/src/n_delay2p_line~.c @@ -0,0 +1,462 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include "iem_delay.h" + +/* -------------------------- n_delay2p_line_tilde~ ------------------------------ */ +static t_class *n_delay2p_line_tilde_class; + +t_float n_delay2p_line_tilde_256f[258]; + +typedef struct _n_delay2p_line_tilde +{ + t_object x_obj; + int x_mallocsize; + t_float x_max_delay_ms; + t_float *x_begmem0; + t_float *x_begmem1; + int x_writeindex; + int x_n_delays; + int *x_del_samp256_end; + int *x_del_samp256_cur; + int *x_inc256; + int *x_biginc256; + int x_blocksize; + t_float x_sr; + t_float x_ms2tick; + t_float x_ms2samples256; + t_float x_interpol_ms; + int x_interpol_ticks; + int x_ticksleft; + int x_old; + int x_retarget; + t_float **x_io; + t_float x_msi; +} t_n_delay2p_line_tilde; + +static void n_delay2p_line_tilde_init_f(t_n_delay2p_line_tilde *x) +{ + if(n_delay2p_line_tilde_256f[257] == 0.0f) + { + int i; + + for(i=0; i<257; i++) + { + n_delay2p_line_tilde_256f[i] = (t_float)i / 256.0f; + } + n_delay2p_line_tilde_256f[257] = 1.0f; + } +} + +static void n_delay2p_line_tilde_list(t_n_delay2p_line_tilde *x, t_symbol *s, int argc, t_atom *argv) +{ + if(argc == x->x_n_delays) + { + int i; + t_float delay, max=x->x_max_delay_ms; + + if(x->x_interpol_ms <= 0.0f) + x->x_ticksleft = x->x_retarget = 0; + else + x->x_retarget = 1; + for(i=0; i max) + delay = max; + if(x->x_interpol_ms <= 0.0f) + x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127; + else + x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127; + } + } +} + +static void n_delay2p_line_tilde_time(t_n_delay2p_line_tilde *x, t_floatarg interpol_ms) +{ + if(interpol_ms < 0.0f) + interpol_ms = 0.0f; + x->x_interpol_ms = interpol_ms; + x->x_interpol_ticks = (int)(x->x_ms2tick * interpol_ms); +} + +static void n_delay2p_line_tilde_stop(t_n_delay2p_line_tilde *x) +{ + int i, n=x->x_n_delays; + + for(i=0; ix_del_samp256_end[i] = x->x_del_samp256_cur[i]; + x->x_ticksleft = x->x_retarget = 0; +} + +static t_int *n_delay2p_line_tilde_perform(t_int *w) +{ + t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)(w[1]); + int hn=(int)(w[2]); + int nout=x->x_n_delays; + t_float *in; + t_float *out; + int writeindex = x->x_writeindex; + int i, j, n, fractindex; + int malloc_samples = x->x_mallocsize; + t_float *begvec0 = x->x_begmem0; + t_float *begvec1 = x->x_begmem1; + t_float *writevec; + t_float *readvec; + t_float fract; + int del256, inc256; + + writevec = begvec0 + writeindex; + in=x->x_io[0]; + n = hn; + while(n--) + { + *writevec++ = *in++; + } + writevec = begvec1 + writeindex; + in=x->x_io[0]; + n = hn; + while(n--) + { + *writevec++ = *in++; + } + + if(x->x_retarget) + { + int nticks = x->x_interpol_ticks; + + if(!nticks) + nticks = 1; + x->x_ticksleft = nticks; + for(j=0; jx_biginc256[j] = (x->x_del_samp256_end[j] - x->x_del_samp256_cur[j]) / nticks; + x->x_inc256[j] = x->x_biginc256[j] / x->x_blocksize; + } + x->x_retarget = 0; + } + + if(x->x_ticksleft) + { + for(j=0; jx_inc256[j]; + del256 = x->x_del_samp256_cur[j]; + out = x->x_io[j+1]; + for(i=0; i> 8) + i; + *out++ = readvec[0] - (readvec[0] - readvec[-1])*fract; + del256 += inc256; + } + x->x_del_samp256_cur[j] += x->x_biginc256[j]; + } + x->x_ticksleft--; + } + else + { + for(j=0; jx_del_samp256_cur[j] = x->x_del_samp256_end[j]; + readvec = begvec1 + writeindex - (del256 >> 8); + out = x->x_io[j+1]; + n = hn; + while(n--) + { + *out++ = *readvec++; + } + } + } + writeindex += hn; + if(writeindex >= malloc_samples) + { + writeindex -= malloc_samples; + } + x->x_writeindex = writeindex; + return(w+3); +} + +static t_int *n_delay2p_line_tilde_perf8(t_int *w) +{ + t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)(w[1]); + int hn=(int)(w[2]); + int nout=x->x_n_delays; + t_float *in; + t_float *out; + int writeindex = x->x_writeindex; + int i, j, k, n, fractindex; + int malloc_samples = x->x_mallocsize; + t_float *begvec0 = x->x_begmem0; + t_float *begvec1 = x->x_begmem1; + t_float *writevec; + t_float *readvec; + t_float fract; + int del256, inc256; + +// post("writevec = %d",writeindex); + writevec = begvec0 + writeindex; + in=x->x_io[0]; + n = hn; + while(n) + { + writevec[0] = in[0]; + writevec[1] = in[1]; + writevec[2] = in[2]; + writevec[3] = in[3]; + writevec[4] = in[4]; + writevec[5] = in[5]; + writevec[6] = in[6]; + writevec[7] = in[7]; + + writevec += 8; + n -= 8; + in += 8; + } + writevec = begvec1 + writeindex; + in=x->x_io[0]; + n = hn; + while(n) + { + writevec[0] = in[0]; + writevec[1] = in[1]; + writevec[2] = in[2]; + writevec[3] = in[3]; + writevec[4] = in[4]; + writevec[5] = in[5]; + writevec[6] = in[6]; + writevec[7] = in[7]; + + writevec += 8; + n -= 8; + in += 8; + } + + if(x->x_retarget) + { + int nticks = x->x_interpol_ticks; + + if(!nticks) + nticks = 1; + x->x_ticksleft = nticks; + for(j=0; jx_biginc256[j] = (x->x_del_samp256_end[j] - x->x_del_samp256_cur[j]) / nticks; + x->x_inc256[j] = x->x_biginc256[j] / x->x_blocksize; + } + x->x_retarget = 0; + } + + if(x->x_ticksleft) + { + for(j=0; jx_inc256[j]; + del256 = x->x_del_samp256_cur[j]; + out = x->x_io[j+1]; + readvec = begvec1 + writeindex; + for(i=0; i> 8; + out[0] = readvec[0-k] - (readvec[0-k] - readvec[-1-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[1] = readvec[1-k] - (readvec[1-k] - readvec[0-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[2] = readvec[2-k] - (readvec[2-k] - readvec[1-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[3] = readvec[3-k] - (readvec[3-k] - readvec[2-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[4] = readvec[4-k] - (readvec[4-k] - readvec[3-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[5] = readvec[5-k] - (readvec[5-k] - readvec[4-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[6] = readvec[6-k] - (readvec[6-k] - readvec[5-k])*fract; + del256 += inc256; + + fractindex = del256 & 0xff; + fract = n_delay2p_line_tilde_256f[fractindex]; + k = del256 >> 8; + out[7] = readvec[7-k] - (readvec[7-k] - readvec[6-k])*fract; + del256 += inc256; + + out += 8; + readvec += 8; + } + x->x_del_samp256_cur[j] += x->x_biginc256[j]; + } + x->x_ticksleft--; + } + else + { + for(j=0; jx_del_samp256_cur[j] = x->x_del_samp256_end[j]; + readvec = begvec1 + writeindex - (del256 >> 8); + out = x->x_io[j+1]; + n = hn; + while(n) + { + out[0] = readvec[0]; + out[1] = readvec[1]; + out[2] = readvec[2]; + out[3] = readvec[3]; + out[4] = readvec[4]; + out[5] = readvec[5]; + out[6] = readvec[6]; + out[7] = readvec[7]; + out += 8; + readvec += 8; + n -= 8; + } + } + } + writeindex += hn; + if(writeindex >= malloc_samples) + { + writeindex -= malloc_samples; + } + x->x_writeindex = writeindex; + return(w+3); +} + +static void n_delay2p_line_tilde_dsp(t_n_delay2p_line_tilde *x, t_signal **sp) +{ + int n = sp[0]->s_n; + int i, nd = x->x_n_delays + 1; + + if(!x->x_blocksize)/*first time*/ + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (n - 1)); + nsamps += n; + x->x_mallocsize = nsamps; + x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + x->x_writeindex = n; + } + else if((x->x_blocksize != n) || ((t_float)sp[0]->s_sr != x->x_sr)) + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (n - 1)); + nsamps += n; + x->x_begmem0 = (t_float *)resizebytes(x->x_begmem0, 2*x->x_mallocsize*sizeof(t_float), 2*nsamps*sizeof(t_float)); + x->x_mallocsize = nsamps; + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + if(x->x_writeindex >= nsamps) + x->x_writeindex -= nsamps; + } + x->x_blocksize = n; + x->x_ms2tick = 0.001f * (t_float)sp[0]->s_sr / (t_float)n; + x->x_ms2samples256 = 0.256f * (t_float)sp[0]->s_sr; + x->x_interpol_ticks = (int)(x->x_ms2tick * x->x_interpol_ms); + for(i=0; ix_io[i] = sp[i]->s_vec; + if(n&7) + dsp_add(n_delay2p_line_tilde_perform, 2, x, n); + else + dsp_add(n_delay2p_line_tilde_perf8, 2, x, n); +} + +static void *n_delay2p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_floatarg interpol_ms) +{ + t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)pd_new(n_delay2p_line_tilde_class); + int i, n_out = (int)fout; + int nsamps = delay_ms * sys_getsr() * 0.001f; + + if(n_out < 1) + n_out = 1; + x->x_n_delays = n_out; + x->x_max_delay_ms = delay_ms; + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (DELLINE_DEF_VEC_SIZE - 1)); + nsamps += DELLINE_DEF_VEC_SIZE; + x->x_mallocsize = nsamps; + x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem1 = x->x_begmem0 + x->x_mallocsize; + x->x_writeindex = DELLINE_DEF_VEC_SIZE; + x->x_blocksize = 0; + x->x_sr = 0.0f; + if(interpol_ms < 0.0f) + interpol_ms = 0.0f; + x->x_interpol_ms = interpol_ms; + x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *)); + for(i=0; ix_obj, &s_signal); + x->x_del_samp256_end = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_del_samp256_cur = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_inc256 = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_biginc256 = (int *)getbytes(x->x_n_delays * sizeof(int)); + x->x_ticksleft = x->x_retarget = 0; + for(i=0; ix_del_samp256_cur[i] = x->x_del_samp256_end[i] = 0; + x->x_inc256[i] = x->x_biginc256[i] = 0; + } + x->x_interpol_ticks = 0; + x->x_msi = 0.0f; + n_delay2p_line_tilde_init_f(x); + return (x); +} + +static void n_delay2p_line_tilde_free(t_n_delay2p_line_tilde *x) +{ + freebytes(x->x_del_samp256_end, x->x_n_delays * sizeof(int)); + freebytes(x->x_del_samp256_cur, x->x_n_delays * sizeof(int)); + freebytes(x->x_inc256, x->x_n_delays * sizeof(int)); + freebytes(x->x_biginc256, x->x_n_delays * sizeof(int)); + freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *)); + freebytes(x->x_begmem0, 2 * x->x_mallocsize * sizeof(t_float)); +} + +void n_delay2p_line_tilde_setup(void) +{ + n_delay2p_line_tilde_class = class_new(gensym("n_delay2p_line~"), (t_newmethod)n_delay2p_line_tilde_new, (t_method)n_delay2p_line_tilde_free, + sizeof(t_n_delay2p_line_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(n_delay2p_line_tilde_class, t_n_delay2p_line_tilde, x_msi); + class_addlist(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_list); + class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_dsp, gensym("dsp"), 0); + class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_stop, gensym("stop"), 0); + class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_time, gensym("time"), A_FLOAT, 0); + class_sethelpsymbol(n_delay2p_line_tilde_class, gensym("iemhelp2/help-n_delay2p_line~")); +} diff --git a/src/nz~.c b/src/nz~.c new file mode 100644 index 0000000..110e3d9 --- /dev/null +++ b/src/nz~.c @@ -0,0 +1,250 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include "iem_delay.h" + +/* -------------------------- nz_tilde~ ------------------------------ */ +static t_class *nz_tilde_class; + +typedef struct _nz_tilde +{ + t_object x_obj; + t_float *x_begmem1; + t_float *x_begmem2; + int x_mallocsize; + int x_max_delay_samples; + int x_n_delays; + int x_writeindex; + int *x_del_samples; + int x_blocksize; + t_float **x_io; + t_float x_msi; +} t_nz_tilde; + +static void nz_tilde_list(t_nz_tilde *x, t_symbol *s, int argc, t_atom *argv) +{ + if(argc == x->x_n_delays) + { + int i, delay, max=x->x_max_delay_samples; + + for(i=0; i max) + delay = max; + x->x_del_samples[i] = delay; + } + } + else + post("nz~-ERROR: list need %d delay-values between 0 and %d samples !!!!", x->x_n_delays, x->x_max_delay_samples); +} + +static t_int *nz_tilde_perform(t_int *w) +{ + t_nz_tilde *x = (t_nz_tilde *)(w[1]); + int n=(int)(w[2]); + int num_dels=x->x_n_delays; + t_float *in; + t_float *out; + int i, j; + t_float *writevec1; + t_float *writevec2; + t_float *readvec; + + writevec2 = x->x_begmem2 + x->x_writeindex; + in = x->x_io[0]; + for(i=0; ix_io[j+1]; + readvec = writevec2 - x->x_del_samples[j]; + for(i=0; ix_begmem1 + x->x_writeindex; + for(i=0; ix_writeindex += n; + if(x->x_writeindex >= x->x_mallocsize) + x->x_writeindex -= x->x_mallocsize; + + return(w+3); +} + +static t_int *nz_tilde_perf8(t_int *w) +{ + t_nz_tilde *x = (t_nz_tilde *)(w[1]); + int n=(int)(w[2]); + int num_dels=x->x_n_delays; + t_float *in; + t_float *out; + int i, j; + t_float *writevec1; + t_float *writevec2; + t_float *readvec; + + writevec2 = x->x_begmem2 + x->x_writeindex; + in = x->x_io[0]; + i = n; + while(i) + { + writevec2[0] = in[0]; + writevec2[1] = in[1]; + writevec2[2] = in[2]; + writevec2[3] = in[3]; + writevec2[4] = in[4]; + writevec2[5] = in[5]; + writevec2[6] = in[6]; + writevec2[7] = in[7]; + + writevec2 += 8; + in += 8; + i -= 8; + } + + for(j=0; jx_io[j+1]; + readvec = writevec2 - x->x_del_samples[j]; + i = n; + while(i) + { + out[0] = readvec[0]; + out[1] = readvec[1]; + out[2] = readvec[2]; + out[3] = readvec[3]; + out[4] = readvec[4]; + out[5] = readvec[5]; + out[6] = readvec[6]; + out[7] = readvec[7]; + out += 8; + readvec += 8; + i -= 8; + } + } + + writevec1 = x->x_begmem1 + x->x_writeindex; + writevec2 = x->x_begmem2 + x->x_writeindex; + i = n; + while(i) + { + writevec1[0] = writevec2[0]; + writevec1[1] = writevec2[1]; + writevec1[2] = writevec2[2]; + writevec1[3] = writevec2[3]; + writevec1[4] = writevec2[4]; + writevec1[5] = writevec2[5]; + writevec1[6] = writevec2[6]; + writevec1[7] = writevec2[7]; + + writevec1 += 8; + writevec2 += 8; + i -= 8; + } + + x->x_writeindex += n; + if(x->x_writeindex >= x->x_mallocsize) + x->x_writeindex -= x->x_mallocsize; + + return(w+3); +} + +static void nz_tilde_dsp(t_nz_tilde *x, t_signal **sp) +{ + int n = sp[0]->s_n; + int i, j, max_samps, num_dels = x->x_n_delays + 1; + + if(!x->x_blocksize)/*first time*/ + { + max_samps = x->x_max_delay_samples; + i = max_samps / n; + j = max_samps - i * n; + if(j) + max_samps = (i+1) * n; + else + max_samps = i * n; +// post("malloc = %d, maxdel = %d", max_samps, x->x_max_delay_samples); + x->x_mallocsize = max_samps; + x->x_begmem1 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem2 = x->x_begmem1 + x->x_mallocsize; + x->x_writeindex = 0; + } + else if(x->x_blocksize != n) + { + max_samps = x->x_max_delay_samples; + i = max_samps / n; + j = max_samps - i * n; + if(j) + max_samps = (i+1) * n; + else + max_samps = i * n; + x->x_begmem1 = (t_float *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_float), 2*max_samps*sizeof(t_float)); + x->x_mallocsize = max_samps; + x->x_begmem2 = x->x_begmem1 + x->x_mallocsize; + x->x_writeindex = 0; + } + x->x_blocksize = n; + for(i=0; ix_io[i] = sp[i]->s_vec; + if(n&7) + dsp_add(nz_tilde_perform, 2, x, n); + else + dsp_add(nz_tilde_perf8, 2, x, n); +} + +static void *nz_tilde_new(t_floatarg n_delays, t_floatarg max_delay_samples) +{ + t_nz_tilde *x = (t_nz_tilde *)pd_new(nz_tilde_class); + int i, n_out = (int)n_delays; + int max_samps = (int)max_delay_samples; + + if(n_out < 1) + n_out = 1; + x->x_n_delays = n_out; + if(max_samps < 1) + max_samps = 1; + x->x_max_delay_samples = max_samps; + x->x_mallocsize = 0; + x->x_begmem1 = (t_float *)0; + x->x_begmem2 = (t_float *)0; + x->x_writeindex = 0; + x->x_blocksize = 0; + x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *)); + x->x_del_samples = (int *)getbytes(x->x_n_delays * sizeof(int)); + for(i=0; ix_obj, &s_signal); + x->x_del_samples[i] = 0; + } + x->x_msi = 0.0f; + return (x); +} + +static void nz_tilde_free(t_nz_tilde *x) +{ + freebytes(x->x_del_samples, x->x_n_delays * sizeof(int)); + freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *)); + if(x->x_begmem1) + freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_float)); +} + +void nz_tilde_setup(void) +{ + nz_tilde_class = class_new(gensym("nz~"), (t_newmethod)nz_tilde_new, (t_method)nz_tilde_free, + sizeof(t_nz_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(nz_tilde_class, t_nz_tilde, x_msi); + class_addlist(nz_tilde_class, (t_method)nz_tilde_list); + class_addmethod(nz_tilde_class, (t_method)nz_tilde_dsp, gensym("dsp"), 0); + class_sethelpsymbol(nz_tilde_class, gensym("iemhelp2/help-nz~")); +} -- cgit v1.2.1