From 0ec3b348a5c2c5ea80d95bae37b34417ab8685e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 5 Sep 2007 09:38:17 +0000 Subject: a new library for innards svn path=/trunk/externals/iem/iemguts/; revision=8704 --- GnuGPL.txt | 340 +++++++++++++++++++++++++++++++++++ README.txt | 36 ++++ examples/01.persistent_properties.pd | 10 ++ examples/gopcanvas.pd | 225 +++++++++++++++++++++++ help/propertybang-help.pd | 25 +++ help/saveargs-help.pd | 25 +++ src/Makefile | 154 ++++++++++++++++ src/propertybang.c | 86 +++++++++ src/saveargs.c | 92 ++++++++++ 9 files changed, 993 insertions(+) create mode 100644 GnuGPL.txt create mode 100644 README.txt create mode 100644 examples/01.persistent_properties.pd create mode 100644 examples/gopcanvas.pd create mode 100644 help/propertybang-help.pd create mode 100644 help/saveargs-help.pd create mode 100644 src/Makefile create mode 100644 src/propertybang.c create mode 100644 src/saveargs.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/README.txt b/README.txt new file mode 100644 index 0000000..ab6acd7 --- /dev/null +++ b/README.txt @@ -0,0 +1,36 @@ +============================================================================== + IEMguts +============================================================================== + +whatsit:: +--------- +IEMguts is an extension-library (aka: external, plugin) for +miller.s.puckette's realtime computer-music environment "Pure data"; +it is of no use without Pure data + +IEMguts is a collection of objects that deal with the infrastructure to build +better abstractions. +they might be of no use on their own... + +installation:: +-------------- +#1> cd src/ +#2> make +#3> make install + + +license:: +--------- +this software is released under the GNU General Public License v2 or later +you can find the full text of this license in the GnuGPL.txt file that must +be shipped with this software + +authors:: +--------- +this software is +copyleft 2007- by + IOhannes m zmoelnig , + Institute of Electronic Music and Acoustics, + University of Music and Dramatic Arts, Graz, Austria + + diff --git a/examples/01.persistent_properties.pd b/examples/01.persistent_properties.pd new file mode 100644 index 0000000..3b84ee3 --- /dev/null +++ b/examples/01.persistent_properties.pd @@ -0,0 +1,10 @@ +#N canvas 416 189 491 300 10; +#X text 98 82 right-click on the objects and select "properties".; +#X text 99 103 then modify the properties and click on "OK"; +#X text 100 125 finally save this patch and re-open it!; +#X obj 73 195 gopcanvas 150 212 0; +#X text 77 175 [gopcanvas]; +#X text 263 179 [gopcanvas]; +#X text 266 164 another; +#X text 46 43 persistent properties for abstractions!; +#X obj 259 199 gopcanvas 255 120 28; diff --git a/examples/gopcanvas.pd b/examples/gopcanvas.pd new file mode 100644 index 0000000..c97814c --- /dev/null +++ b/examples/gopcanvas.pd @@ -0,0 +1,225 @@ +#N canvas 452 272 631 456 10; +#X obj 138 250 propertybang; +#N canvas 203 89 362 187 \$0-properties 0; +#X obj 58 137 cnv 15 200 35 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 67 145 bng 15 250 50 0 \$0-done empty OK 17 7 0 10 -24198 -1 +-1; +#X obj 188 145 bng 15 250 50 0 \$0-cancel empty cancel 17 7 0 10 -258699 +-1 -1; +#X obj 61 76 hsl 128 15 0 255 0 0 \$0-R \$0-R empty -2 -8 0 10 -258699 +-1 -1 0 1; +#X obj 61 93 hsl 128 15 0 255 0 0 \$0-G \$0-G empty -2 -8 0 10 -24198 +-1 -1 0 1; +#X obj 61 110 hsl 128 15 0 255 0 0 \$0-B \$0-B empty -2 -8 0 10 -62784 +-1 -1 0 1; +#X obj 206 76 cnv 15 50 50 empty \$0-color empty 20 12 0 14 -154945 +-262144 0; +#X obj 120 145 bng 15 250 50 0 \$0-apply empty apply 17 7 0 10 -241291 +-1 -1; +#X text 90 37 select your color!; +#X restore 138 419 pd \$0-properties; +#X obj 138 282 t b b; +#X obj 101 101 cnv 15 83 58 empty \$0-label empty 20 12 0 14 -154945 +-262144 0; +#X obj 138 398 s pd-\$0-properties; +#X msg 138 381 vis \$1; +#X msg 163 361 1; +#X msg 138 361 0; +#N canvas 42 382 857 456 propertyguts 0; +#X obj 118 105 r \$0-R; +#X obj 160 105 r \$0-G; +#X obj 201 105 r \$0-B; +#N canvas 15 207 606 448 RGB_____________ 0; +#X obj 97 56 inlet; +#X obj 262 43 inlet; +#X obj 339 45 inlet; +#X obj 405 44 inlet; +#X obj 97 230 bang; +#X msg 97 255 0; +#X msg 123 254 1; +#X obj 146 228 bang; +#X msg 152 255 0; +#X msg 180 255 1; +#X obj 312 313 spigot; +#X obj 249 385 outlet; +#X text 93 33 select; +#X text 267 28 red; +#X text 337 30 green; +#X text 409 30 blue; +#X obj 405 132 t b f; +#X obj 339 160 +; +#X obj 339 185 t b f; +#X obj 339 216 +; +#X obj 296 385 outlet; +#X obj 296 361 f; +#X obj 249 361 f; +#X obj 262 109 * -65536; +#X obj 339 110 * -256; +#X obj 405 110 * -1; +#X obj 339 247 - 1; +#X obj 97 135 route back label bang; +#X obj 235 168 t b b b; +#X obj 265 313 spigot 1; +#X obj 262 77 max 0; +#X obj 262 93 min 255; +#X obj 339 77 max 0; +#X obj 339 93 min 255; +#X obj 405 77 max 0; +#X obj 405 93 min 255; +#X obj 262 61 i; +#X obj 339 61 i; +#X obj 405 61 i; +#X connect 0 0 27 0; +#X connect 1 0 36 0; +#X connect 2 0 37 0; +#X connect 3 0 38 0; +#X connect 4 0 5 0; +#X connect 4 0 6 0; +#X connect 5 0 10 1; +#X connect 6 0 29 1; +#X connect 7 0 8 0; +#X connect 7 0 9 0; +#X connect 8 0 29 1; +#X connect 9 0 10 1; +#X connect 10 0 21 1; +#X connect 16 0 17 0; +#X connect 16 1 17 1; +#X connect 17 0 18 0; +#X connect 18 0 19 0; +#X connect 18 1 19 1; +#X connect 19 0 26 0; +#X connect 21 0 20 0; +#X connect 22 0 11 0; +#X connect 23 0 19 0; +#X connect 24 0 17 0; +#X connect 25 0 16 0; +#X connect 26 0 10 0; +#X connect 26 0 29 0; +#X connect 27 0 4 0; +#X connect 27 1 7 0; +#X connect 27 2 28 0; +#X connect 28 0 22 0; +#X connect 28 1 21 0; +#X connect 28 2 26 0; +#X connect 29 0 22 1; +#X connect 30 0 31 0; +#X connect 31 0 23 0; +#X connect 32 0 33 0; +#X connect 33 0 24 0; +#X connect 34 0 35 0; +#X connect 35 0 25 0; +#X connect 36 0 30 0; +#X connect 37 0 32 0; +#X connect 38 0 34 0; +#X restore 118 244 pd RGB_____________; +#X obj 118 165 b; +#X obj 118 130 t b f; +#X obj 160 130 t b f; +#X obj 201 130 t b f; +#X obj 118 304 s \$0-color; +#X obj 202 63 r \$0-done; +#X obj 202 81 t b b; +#X obj 29 100 b; +#X obj 29 47 r \$0-cancel; +#X obj 432 28 inlet properties opened; +#X obj 29 415 outlet close properties; +#X msg 118 285 color \$1 0; +#X obj 257 355 route 0; +#X obj 257 303 t b b; +#X obj 310 357 f; +#X obj 118 262 t f f; +#X obj 310 392 s \$0-label; +#X msg 310 374 color \$1 0; +#X obj 257 83 r \$0-apply; +#X obj 257 101 t b b; +#X obj 335 106 pack \$1 \$2 \$3; +#X obj 335 126 unpack 0 0 0; +#X obj 310 44 loadbang; +#X obj 310 63 t b b; +#X obj 257 414 outlet arguments; +#X obj 257 324 pack 0 \$1 \$2 \$3; +#X obj 154 213 i; +#X obj 190 213 i; +#X obj 228 213 i; +#X obj 432 100 b; +#X obj 432 308 route 0; +#X obj 432 287 pack 0 \$1 \$2 \$3; +#X obj 432 345 s \$0-R; +#X obj 474 345 s \$0-G; +#X obj 515 345 s \$0-B; +#X obj 432 327 unpack 0 0 0; +#X connect 0 0 5 0; +#X connect 1 0 6 0; +#X connect 2 0 7 0; +#X connect 3 0 19 0; +#X connect 4 0 3 0; +#X connect 5 0 4 0; +#X connect 5 1 30 0; +#X connect 6 0 4 0; +#X connect 6 1 31 0; +#X connect 7 0 4 0; +#X connect 7 1 32 0; +#X connect 9 0 10 0; +#X connect 10 0 11 0; +#X connect 10 1 23 0; +#X connect 11 0 14 0; +#X connect 12 0 11 0; +#X connect 13 0 33 0; +#X connect 15 0 8 0; +#X connect 16 0 28 0; +#X connect 17 0 29 0; +#X connect 17 1 18 0; +#X connect 18 0 21 0; +#X connect 19 0 15 0; +#X connect 19 1 18 1; +#X connect 21 0 20 0; +#X connect 22 0 23 0; +#X connect 23 0 17 0; +#X connect 24 0 25 0; +#X connect 25 0 5 0; +#X connect 25 1 3 2; +#X connect 25 2 3 3; +#X connect 26 0 27 0; +#X connect 27 0 18 0; +#X connect 27 1 24 0; +#X connect 29 0 16 0; +#X connect 30 0 3 1; +#X connect 30 0 29 1; +#X connect 30 0 35 1; +#X connect 31 0 3 2; +#X connect 31 0 29 2; +#X connect 31 0 35 2; +#X connect 32 0 3 3; +#X connect 32 0 29 3; +#X connect 32 0 35 3; +#X connect 33 0 35 0; +#X connect 34 0 39 0; +#X connect 35 0 34 0; +#X connect 39 0 36 0; +#X connect 39 1 37 0; +#X connect 39 2 38 0; +#X restore 138 304 pd propertyguts; +#X obj 223 331 saveargs; +#X text 43 37 this is a simple abstraction that displays a canvas via +gop.; +#X text 38 168 the canvas-color can be changed via a properties-panel +(which is really the subpatch [\$0-properties]); +#X text 38 196 saving the parent-patch (wherein this abstraction is +embedded will also save the properties); +#X text 228 248 <- enables the "property" menu and emits a bang when +it is selected; +#X text 237 306 <- all the property handling logic; +#X text 277 333 <- handles the overriding of arguments in the parent +patch; +#X text 255 420 <-- the property-panel subpatch; +#X text 42 53 it is used in the "persistent_properties" example.; +#X connect 0 0 2 0; +#X connect 2 0 8 0; +#X connect 2 1 6 0; +#X connect 5 0 4 0; +#X connect 6 0 5 0; +#X connect 7 0 5 0; +#X connect 8 0 7 0; +#X connect 8 1 9 0; +#X coords 0 -1 1 1 85 60 2 100 100; diff --git a/help/propertybang-help.pd b/help/propertybang-help.pd new file mode 100644 index 0000000..30b33ba --- /dev/null +++ b/help/propertybang-help.pd @@ -0,0 +1,25 @@ +#N canvas 469 268 645 300 10; +#X obj 90 43 propertybang; +#N canvas 0 0 450 300 with 0; +#X obj 110 126 propertybang; +#X obj 110 146 t b b; +#X obj 135 166 print property; +#X obj 110 200 outlet; +#X connect 0 0 1 0; +#X connect 1 0 3 0; +#X connect 1 1 2 0; +#X restore 86 152 pd with propertybang; +#X obj 86 176 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X text 174 44 enables the "property" menu for abstractions; +#X text 90 77 usage:; +#X text 140 77 put a [propertybang] object into your abstraction; +#X text 139 94 put your abstraction into your patch; +#X text 127 114 --> the [propertybang] will send out a bang \, everytime +you right-clock on your abstraction and select "Properties"; +#X text 367 276 (c) IOhannes m zmoelnig @ iem \, 2007; +#X text 61 224 note: the [propertybang] is PER ABSTRACTION! having +multiple [propertybang]s within one abstraction \, will trigger them +all at the same time. you cannot have [propertybang]s per subpatch +(yet); +#X connect 1 0 2 0; diff --git a/help/saveargs-help.pd b/help/saveargs-help.pd new file mode 100644 index 0000000..efcc739 --- /dev/null +++ b/help/saveargs-help.pd @@ -0,0 +1,25 @@ +#N canvas 315 241 645 450 10; +#X text 39 77 usage:; +#X text 367 336 (c) IOhannes m zmoelnig @ iem \, 2007; +#X obj 90 43 saveargs; +#X text 174 44 manipulate the abstractions arguments (and name) on +saving; +#X obj 71 384 saveargs; +#X msg 71 281 list 10 20; +#X msg 91 303 list quite a lot of arguments; +#X msg 102 340 abstraction1; +#X msg 118 357 abstraction2 argument1; +#X text 83 78 put the [saveargs] in your abstraction; +#X text 81 114 send a _list_ of new arguments to the [saveargs]; +#X text 82 130 save the parent patch; +#X text 83 94 put the abstraction in your parent patch; +#X text 74 150 --> the parent patch will save your abstraction with +the arguments you sent to [saveargs] instead of the original ones; +#X text 77 203 you can also change the (saved) name of the abstraction +\, by using a selector other than "list" (and the like).; +#X text 77 226 take care \, as this can totally change the behaviour +of your patch (or break it); +#X connect 5 0 4 0; +#X connect 6 0 4 0; +#X connect 7 0 4 0; +#X connect 8 0 4 0; diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..767d012 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,154 @@ +# Makefile +# (c) 2006 IOhannes m zmölnig + +# path to pd +## change this according to your setup! +PDROOT?=../../pd +#PDROOT=/home/zmoelnig/src/pd/ + +# here we find the sources of pd (and evtl. the pd.lib) +PDSRCDIR?=$(PDROOT)/src +PDLIBDIR?=$(PDROOT)/bin + +# this is the filename-extension +# people have to specify it at the cmdline: eg "make pd_linux" +EXTENSION=$(MAKECMDGOALS) + +# if no filename-extension is supplied by the user +# try to guess one, based on what "uname" tells us +UNAME := $(shell uname -s) +ifeq ($(UNAME),Linux) + DEFAULTEXTENSION= pd_linux +else + ifeq ($(UNAME),Darwin) + DEFAULTEXTENSION= pd_darwin + else + ifeq (MINGW,$(findstring MINGW,$(UNAME))) + DEFAULTEXTENSION= pd_nt + else + ifeq ($(UNAME),IRIX) + UNAMEV := $(shell uname -R) + ifeq (6.,$(findstring 6.,$(UNAMEV))) + DEFAULTEXTENSION= pd_irix6 + else + DEFAULTEXTENSION= pd_irix5 + endif + else + DEFAULTEXTENSION=help + endif + endif + endif +endif + +# if no extension is given, call "make" again with a guessed extension +auto: + make $(DEFAULTEXTENSION) + +# just a stupid fallback +help: + @echo "choose one command: make pd_linux (linux), make pd_darwin (osX), make pd_irix5 (IRIX5), make pd_irix6 (IRIX6), make dll (MSVC), make pd_nt (MinWG)" + +# delete old build files +clean: + -rm -f *.dll *.pd_* *.o *.obj *~ + +# we want to compile all C-files we find in the current directory +SOURCES=$(sort $(filter %.c, $(wildcard *.c))) +# each C-files maps will become an external with the given filename-extension +TARGETS=$(SOURCES:.c=.$(EXTENSION)) + + +# ----------------------- Linux ----------------------- + +pd_linux: $(TARGETS) + +LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch + +LINUXLDFLAGS = -export_dynamic -shared -lc -lm + +LINUXINCLUDE = -I$(PDSRCDIR) + +%.pd_linux: %.c + $(CC) $(LINUXLDFLAGS) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.pd_linux $*.c + strip --strip-unneeded $*.pd_linux + + + +# ----------------------- Mac OSX ----------------------- + +pd_darwin: $(TARGETS) + +DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ + -Wno-unused -Wno-parentheses -Wno-switch + +DARWININCLUDE = -I$(PDSRCDIR) + +DARWINLDFLAGS = -bundle -undefined suppress -flat_namespace + +%.pd_darwin: %.c + $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) $(DARWINLDFLAGS) -o $*.pd_darwin $*.c + + +# ----------------------- IRIX 5.x ----------------------- +pd_irix5: $(TARGETS) + +SGICFLAGS5 = -o32 -DPD -DSGI -O2 + +SGIINCLUDE = -I$(PDSRCDIR) + +SGILDFLAGS = -elf -shared -rdata_shared + +%.pd_irix5: %.c + $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c + $(LD) $(SGILDFLAGS) -o $*.pd_irix5 $*.o + rm $*.o + + +# ----------------------- IRIX 6.x ----------------------- +pd_irix6: $(TARGETS) + +SGICFLAGS6 = -DPD -DSGI -n32 \ + -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ + -Ofast=ip32 + +%.pd_irix6: %.c + $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c + $(LD) $(SGILDFLAGS) -o $*.pd_irix6 $*.o + rm $*.o + + +# ----------------------- NT ----------------------- +dll: $(TARGETS) + +PDNTCFLAGS = /W3 /WX /DPD /DNT /D__WIN32__ /DMSW /nologo + +VC="C:\Programme\Microsoft Visual Studio\Vc98" + +PDNTINCLUDE = /I. /I$(PDROOT)\tcl\include /I$(PDSRCDIR)\src /I$(VC)\include + +PDNTLDIR = $(VC)\lib + +PDNTLIB = $(PDNTLDIR)\libc.lib \ + $(PDNTLDIR)\oldnames.lib \ + $(PDNTLDIR)\kernel32.lib \ + $(PDLIBDIR)\pd.lib + +%.dll: %.c + cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c + link /dll /export:$*_setup $*.obj $(PDNTLIB) + + +pd_nt: $(TARGETS) + +MINGWCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch -mms-bitfields + +MINGWLDFLAGS = -export_dynamic -shared -lm -lkernel32 -lcoldname -lcrtdll -lpd -L$(PDLIBDIR) + +MINGWINCLUDE = -I$(PDSRCDIR) + +%.pd_nt: %.c + $(CC) $(MINGWLDFLAGS) $(MINGWCFLAGS) $(MINGWINCLUDE) -o $*.dll $*.c diff --git a/src/propertybang.c b/src/propertybang.c new file mode 100644 index 0000000..d994582 --- /dev/null +++ b/src/propertybang.c @@ -0,0 +1,86 @@ + +/****************************************************** + * + * propertybang - implementation file + * + * copyleft (c) IOhannes m zm-bölnig-A + * + * 2007:forum::f-bür::umläute:2007-A + * + * institute of electronic music and acoustics (iem) + * + ****************************************************** + * + * license: GNU General Public License v.2 + * + ******************************************************/ + + +/* + * this object provides a way to make an abstraction "property" aware + * usage: + * + put this object into an abstraction + * + put the abstraction in a patch + * + you can now right-click on the abstraction and select the "properties" menu + * + selecting the "properties" menu, will send a bang to the outlet of this object + * + * nice, eh? + */ + + +#include "m_pd.h" +#include "g_canvas.h" + + +/* ------------------------- propertybang ---------------------------- */ + +static t_class *propertybang_class; + +typedef struct _propertybang +{ + t_object x_obj; + t_symbol *x_d0name; +} t_propertybang; + + +static void propertybang_free(t_propertybang *x) +{ + pd_unbind(&x->x_obj.ob_pd, x->x_d0name); +} + +static void propertybang_anything(t_propertybang *x, t_symbol*s, int argc, t_atom*argv) { + if(s==&s_bang && argc==0) { + outlet_bang(x->x_obj.ob_outlet); + } +} + +static void propertybang_properties(t_gobj*z, t_glist*owner) { + // argh: z is the abstraction! but we need to access ourselfs! + // we handle this by binding to a special symbol. e.g. "$0-propertybang" + + t_symbol*s_d0name=canvas_realizedollar((t_canvas*)z, gensym("$0 propertybang")); + pd_bang(s_d0name->s_thing); +} + +static void *propertybang_new(void) +{ + t_propertybang *x = (t_propertybang *)pd_new(propertybang_class); + t_glist *glist=(t_glist *)canvas_getcurrent(); + t_canvas *canvas=(t_canvas*)glist_getcanvas(glist); + t_class *class = ((t_gobj*)canvas)->g_pd; + + outlet_new(&x->x_obj, &s_bang); + + x->x_d0name=canvas_realizedollar(canvas, gensym("$0 propertybang")); + pd_bind(&x->x_obj.ob_pd, x->x_d0name); + + class_setpropertiesfn(class, propertybang_properties); + return (x); +} + +void propertybang_setup(void) +{ + propertybang_class = class_new(gensym("propertybang"), (t_newmethod)propertybang_new, + (t_method)propertybang_free, sizeof(t_propertybang), CLASS_NOINLET, 0); + class_addanything(propertybang_class, propertybang_anything); +} diff --git a/src/saveargs.c b/src/saveargs.c new file mode 100644 index 0000000..35b4d12 --- /dev/null +++ b/src/saveargs.c @@ -0,0 +1,92 @@ + +/****************************************************** + * + * saveargs - implementation file + * + * copyleft (c) IOhannes m zm-bölnig-A + * + * 2007:forum::f-bür::umläute:2007-A + * + * institute of electronic music and acoustics (iem) + * + ****************************************************** + * + * license: GNU General Public License v.2 + * + ******************************************************/ + + +/* + * this object provides a way to manipulate the parent-patches arguments (and name!) + * usage: + * + put this object into an abstraction + * + put the abstraction in a patch + * + send the object a _list_ of arguments + * + the next time the patch (wherein the abstraction that holds this object lives) + * is saved, it will be saved with the new arguments instead of the old ones! + * - example: "list 2 3 4" will save the object as [ 2 3 4] + * + you can also change the abstraction name itself by using a selector other than "list" + * - example: "bonkers 8 9" will save the object as [bonkers 8 9] regardless of it's original name + * - use with care! + * + * nice, eh? + */ + +#include "m_pd.h" +#include "g_canvas.h" + + +/* ------------------------- saveargs ---------------------------- */ + +static t_class *saveargs_class; + +typedef struct _saveargs +{ + t_object x_obj; + + t_canvas *x_canvas; +} t_saveargs; + + +static void saveargs_list(t_saveargs *x, t_symbol*s, int argc, t_atom*argv) +{ + t_canvas*c=x->x_canvas; + t_binbuf*b=0; + t_atom name[1]; + + if(!x->x_canvas) return; + b=x->x_canvas->gl_obj.te_binbuf; + + if(!b)return; + + if(s==0 || s==gensym("") || s==&s_list || s==&s_bang || s==&s_float || s==&s_symbol || s==&s_) { + t_atom*ap=binbuf_getvec(b); + s=atom_getsymbol(ap); + } + SETSYMBOL(name, s); + + binbuf_clear(b); + binbuf_add(b, 1, name); + binbuf_add(b, argc, argv); +} + +static void saveargs_free(t_saveargs *x) +{ +} + +static void *saveargs_new(void) +{ + t_saveargs *x = (t_saveargs *)pd_new(saveargs_class); + t_glist *glist=(t_glist *)canvas_getcurrent(); + t_canvas *canvas=(t_canvas*)glist_getcanvas(glist); + + x->x_canvas = canvas; + return (x); +} + +void saveargs_setup(void) +{ + saveargs_class = class_new(gensym("saveargs"), (t_newmethod)saveargs_new, + (t_method)saveargs_free, sizeof(t_saveargs), 0, 0); + class_addanything(saveargs_class, (t_method)saveargs_list); +} -- cgit v1.2.1