aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2006-12-14 19:41:04 +0000
committermusil <tmusil@users.sourceforge.net>2006-12-14 19:41:04 +0000
commit68bc10e23ddfbd805095a1c03ba06c5c63f57f52 (patch)
tree79938626dfb94265481b84e18568598b90aca971
initial check insvn2git-root
svn path=/trunk/externals/iem/iemgui/; revision=6897
-rw-r--r--GnuGPL.txt340
-rw-r--r--LICENSE.txt27
-rw-r--r--READ_ME.txt7
-rw-r--r--help/cube_sphere-help.pd615
-rw-r--r--help/go_stop.gifbin0 -> 19099 bytes
-rw-r--r--help/hfadl_scale-help.pd28
-rw-r--r--help/hfadr_scale-help.pd28
-rw-r--r--help/iem_event-help.pd50
-rw-r--r--help/iem_image-help.pd57
-rw-r--r--help/iem_vu-help.pd42
-rw-r--r--help/mp3_play.gifbin0 -> 126202 bytes
-rw-r--r--help/numberbox_matrix-help.pd502
-rw-r--r--help/pair.gifbin0 -> 93498 bytes
-rw-r--r--help/pd.gifbin0 -> 1673 bytes
-rw-r--r--help/room_sim_2d-help.pd764
-rw-r--r--help/room_sim_3d-help.pd801
-rw-r--r--help/vfad_scale-help.pd27
-rw-r--r--pd_start.bat13
-rw-r--r--src/cube_sphere.c791
-rw-r--r--src/hfadl_scale.c203
-rw-r--r--src/hfadr_scale.c202
-rw-r--r--src/iem_event.c473
-rw-r--r--src/iem_image.c427
-rw-r--r--src/iem_vu.c837
-rw-r--r--src/iemgui.c113
-rw-r--r--src/iemgui.dsp85
-rw-r--r--src/iemgui.dsw29
-rw-r--r--src/iemgui.h43
-rw-r--r--src/iemlib.h102
-rw-r--r--src/makefile58
-rw-r--r--src/makefile_linux58
-rw-r--r--src/makefile_win48
-rw-r--r--src/numberbox_matrix.c1382
-rw-r--r--src/room_sim_2d.c827
-rw-r--r--src/room_sim_3d.c966
-rw-r--r--src/sym_dial.c931
-rw-r--r--src/vfad_scale.c202
37 files changed, 11078 insertions, 0 deletions
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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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.
+
+ <signature of Ty Coon>, 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..8105c1a
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,27 @@
+iemgui - dynamic library for pd; some graphic objects in tcl/tk
+
+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..115d8b8
--- /dev/null
+++ b/READ_ME.txt
@@ -0,0 +1,7 @@
+This library extends the performance of miller puckette's pure data (pd).
+
+iemgui 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.
+
+iemgui contains some graphical objects. \ No newline at end of file
diff --git a/help/cube_sphere-help.pd b/help/cube_sphere-help.pd
new file mode 100644
index 0000000..95b1cf3
--- /dev/null
+++ b/help/cube_sphere-help.pd
@@ -0,0 +1,615 @@
+#N canvas 33 0 924 718 10;
+#X obj 42 118 r to_GUI;
+#X floatatom 493 53 5 20 500 0 - - -;
+#X floatatom 493 152 5 5 150 0 - - -;
+#X msg 493 170 \; to_GUI src_font \$1;
+#X text 529 149 pix;
+#X obj 42 617 s from_GUI;
+#X obj 735 14 r from_GUI;
+#X floatatom 655 107 5 0 0 0 - - -;
+#X floatatom 695 107 5 0 0 0 - - -;
+#X obj 655 85 unpack;
+#X obj 493 280 pack;
+#X obj 527 280 t b f;
+#X floatatom 486 263 5 0 90 0 - - -;
+#X floatatom 529 263 5 -720 720 0 - - -;
+#X text 696 84 source 1;
+#X text 730 109 degree;
+#N canvas 230 75 343 545 colors 0;
+#N canvas 16 80 189 98 sphere_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 47 17 pd sphere_color;
+#X msg 47 125 \; to_GUI sphere_col \$1;
+#N canvas 16 80 189 98 frame_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 46 161 pd frame_color;
+#X msg 46 263 \; to_GUI frame_col \$1;
+#X msg 57 476 \; to_GUI src_col \$1 \$2;
+#X obj 57 453 pack 1 15;
+#X obj 81 410 t b f;
+#X obj 57 433 f 1;
+#N canvas 16 80 189 98 source_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 81 306 pd source_color;
+#X floatatom 39 364 5 1 100 0 - - -;
+#X text 42 337 src;
+#X text 35 348 number;
+#X connect 0 0 1 0;
+#X connect 2 0 3 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 6 1 5 1;
+#X connect 7 0 5 0;
+#X connect 8 0 6 0;
+#X connect 9 0 7 1;
+#X restore 715 525 pd colors;
+#X text 9 11 cube_sphere;
+#X obj 42 139 cube_sphere 5 222 50 354 0 250684 347 194 195567 229
+98 225270 84 205 241290 191 332 24197 314 314;
+#X msg 494 16 \; to_GUI size 400;
+#X msg 493 73 \; to_GUI size \$1;
+#X msg 493 114 \; to_GUI src_font 40;
+#X msg 494 210 \; to_GUI bang;
+#X msg 493 301 \; to_GUI src_dp 1 \$1 \$2;
+#X obj 492 359 pack;
+#X obj 526 359 t b f;
+#X floatatom 485 342 5 0 90 0 - - -;
+#X floatatom 528 342 5 -720 720 0 - - -;
+#X obj 493 439 pack;
+#X obj 527 439 t b f;
+#X floatatom 486 422 5 0 90 0 - - -;
+#X floatatom 529 422 5 -720 720 0 - - -;
+#X obj 494 521 pack;
+#X obj 528 521 t b f;
+#X floatatom 487 504 5 0 90 0 - - -;
+#X floatatom 530 504 5 -720 720 0 - - -;
+#X obj 496 603 pack;
+#X obj 530 603 t b f;
+#X floatatom 489 586 5 0 90 0 - - -;
+#X floatatom 532 586 5 -720 720 0 - - -;
+#X msg 492 380 \; to_GUI src_dp 2 \$1 \$2;
+#X msg 493 460 \; to_GUI src_dp 3 \$1 \$2;
+#X msg 496 624 \; to_GUI src_dp 5 \$1 \$2;
+#X msg 494 542 \; to_GUI src_dp 4 \$1 \$2;
+#X obj 735 43 route 1 2 3 4 5;
+#X floatatom 665 162 5 0 0 0 - - -;
+#X floatatom 705 162 5 0 0 0 - - -;
+#X obj 665 140 unpack;
+#X text 740 164 degree;
+#X floatatom 686 211 5 0 0 0 - - -;
+#X floatatom 726 211 5 0 0 0 - - -;
+#X obj 686 189 unpack;
+#X text 761 213 degree;
+#X floatatom 706 261 5 0 0 0 - - -;
+#X floatatom 746 261 5 0 0 0 - - -;
+#X obj 706 239 unpack;
+#X text 781 263 degree;
+#X floatatom 722 312 5 0 0 0 - - -;
+#X floatatom 762 312 5 0 0 0 - - -;
+#X obj 722 290 unpack;
+#X text 797 314 degree;
+#X text 706 139 source 2;
+#X text 727 188 source 3;
+#X text 747 238 source 4;
+#X text 763 289 source 5;
+#X text 760 336 azimuth;
+#X text 696 329 elevation;
+#X floatatom 372 58 5 0 100 0 - - -;
+#X msg 372 78 \; to_GUI nr_src \$1;
+#X text 530 50 pix;
+#X text 150 99 |;
+#X text 150 110 |;
+#X text 150 105 |cube_sphere 5|;
+#X text 153 91 ______________;
+#X text 153 108 ______________;
+#X text 234 99 |;
+#X text 234 110 |;
+#X text 97 669 IEM KUG;
+#X text 81 657 musil;
+#X text 111 657 @;
+#X text 117 657 iem.at;
+#X text 80 679 Graz \, Austria;
+#X text 32 646 (c) Thomas Musil 2000 - 2006;
+#X text 102 12 is a graphical object for a 2D projection of a hemisphere
+;
+#X text 100 24 the azimuth angle is mathematical positiv orientated
+;
+#X text 100 36 the elevation is geodatical: northpole is +90 degree
+;
+#X text 120 47 equator is 0 degree;
+#X connect 0 0 18 0;
+#X connect 1 0 20 0;
+#X connect 2 0 3 0;
+#X connect 6 0 44 0;
+#X connect 9 0 7 0;
+#X connect 9 1 8 0;
+#X connect 10 0 23 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 18 0 5 0;
+#X connect 24 0 40 0;
+#X connect 25 0 24 0;
+#X connect 25 1 24 1;
+#X connect 26 0 24 0;
+#X connect 27 0 25 0;
+#X connect 28 0 41 0;
+#X connect 29 0 28 0;
+#X connect 29 1 28 1;
+#X connect 30 0 28 0;
+#X connect 31 0 29 0;
+#X connect 32 0 43 0;
+#X connect 33 0 32 0;
+#X connect 33 1 32 1;
+#X connect 34 0 32 0;
+#X connect 35 0 33 0;
+#X connect 36 0 42 0;
+#X connect 37 0 36 0;
+#X connect 37 1 36 1;
+#X connect 38 0 36 0;
+#X connect 39 0 37 0;
+#X connect 44 0 9 0;
+#X connect 44 1 47 0;
+#X connect 44 2 51 0;
+#X connect 44 3 55 0;
+#X connect 44 4 59 0;
+#X connect 47 0 45 0;
+#X connect 47 1 46 0;
+#X connect 51 0 49 0;
+#X connect 51 1 50 0;
+#X connect 55 0 53 0;
+#X connect 55 1 54 0;
+#X connect 59 0 57 0;
+#X connect 59 1 58 0;
+#X connect 67 0 68 0;
diff --git a/help/go_stop.gif b/help/go_stop.gif
new file mode 100644
index 0000000..0a8c9df
--- /dev/null
+++ b/help/go_stop.gif
Binary files differ
diff --git a/help/hfadl_scale-help.pd b/help/hfadl_scale-help.pd
new file mode 100644
index 0000000..d349678
--- /dev/null
+++ b/help/hfadl_scale-help.pd
@@ -0,0 +1,28 @@
+#N canvas 4 20 454 304 10;
+#X obj 90 135 fadtodb;
+#X obj 90 157 - 100;
+#X floatatom 90 178 5 0 0 0 - - -;
+#X text 130 180 dB;
+#X obj 94 94 hfadl_scale -1;
+#X text 10 10 hfadl_scale;
+#X text 121 9 horizontal fader scale with left max;
+#X text 101 32 for horizontal slider with width of 121 pixels;
+#X obj 93 115 hsl 121 15 120 0 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X text 127 49 and a value-range from 120 to 0;
+#X text 96 242 IEM KUG;
+#X text 80 230 musil;
+#X text 110 230 @;
+#X text 116 230 iem.at;
+#X text 79 252 Graz \, Austria;
+#X text 31 219 (c) Thomas Musil 2000 - 2006;
+#X text 253 107 |;
+#X text 253 118 |;
+#X text 325 107 |;
+#X text 325 118 |;
+#X text 253 113 |hfadl_scale|;
+#X text 256 99 ____________;
+#X text 256 116 ____________;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 8 0 0 0;
diff --git a/help/hfadr_scale-help.pd b/help/hfadr_scale-help.pd
new file mode 100644
index 0000000..4bd21b1
--- /dev/null
+++ b/help/hfadr_scale-help.pd
@@ -0,0 +1,28 @@
+#N canvas 4 20 454 304 10;
+#X obj 90 134 fadtodb;
+#X obj 90 156 - 100;
+#X floatatom 90 177 5 0 0 0 - - -;
+#X text 130 179 dB;
+#X text 101 31 for horizontal slider with width of 121 pixels;
+#X obj 93 114 hsl 121 15 0 120 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X text 10 9 hfadr_scale;
+#X text 121 8 horizontal fader scale with right max;
+#X text 127 48 and a value-range from 0 to 120;
+#X obj 89 93 hfadr_scale -1;
+#X text 96 242 IEM KUG;
+#X text 80 230 musil;
+#X text 110 230 @;
+#X text 116 230 iem.at;
+#X text 79 252 Graz \, Austria;
+#X text 31 219 (c) Thomas Musil 2000 - 2006;
+#X text 253 107 |;
+#X text 253 118 |;
+#X text 325 107 |;
+#X text 325 118 |;
+#X text 256 99 ____________;
+#X text 256 116 ____________;
+#X text 253 113 |hfadr_scale|;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 5 0 0 0;
diff --git a/help/iem_event-help.pd b/help/iem_event-help.pd
new file mode 100644
index 0000000..48b98db
--- /dev/null
+++ b/help/iem_event-help.pd
@@ -0,0 +1,50 @@
+#N canvas 387 61 565 382 10;
+#X obj 67 112 ivnt 100 100 0 0 empty empty;
+#X obj 67 112 cnv 15 100 100 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 67 248 unpack;
+#X floatatom 67 271 5 0 0 0 - - -;
+#X floatatom 104 273 5 0 0 0 - - -;
+#X obj 75 320 print;
+#X obj 149 250 unpack;
+#X floatatom 149 273 5 0 0 0 - - -;
+#X floatatom 186 275 5 0 0 0 - - -;
+#X obj 230 249 unpack 0 0 0;
+#X obj 230 276 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 263 276 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 297 277 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 67 218 route move_x_y dragg_x_y mouse_shft_alt key;
+#X obj 370 249 sel 0 127;
+#X obj 336 352 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 375 329 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 419 274 makefilename %c;
+#X symbolatom 419 297 2 0 0 0 - - -;
+#X text 356 352 return and end;
+#X text 395 327 backspace = correct;
+#X msg 67 46 size 100 100;
+#X msg 80 67 send from_ivnt;
+#X msg 93 88 receive to_ivnt;
+#X connect 0 0 13 0;
+#X connect 2 0 3 0;
+#X connect 2 1 4 0;
+#X connect 6 0 7 0;
+#X connect 6 1 8 0;
+#X connect 9 0 10 0;
+#X connect 9 1 11 0;
+#X connect 9 2 12 0;
+#X connect 13 0 2 0;
+#X connect 13 1 6 0;
+#X connect 13 2 9 0;
+#X connect 13 3 14 0;
+#X connect 14 0 15 0;
+#X connect 14 1 16 0;
+#X connect 14 2 17 0;
+#X connect 17 0 18 0;
+#X connect 21 0 0 0;
+#X connect 22 0 0 0;
+#X connect 23 0 0 0;
diff --git a/help/iem_image-help.pd b/help/iem_image-help.pd
new file mode 100644
index 0000000..b64b114
--- /dev/null
+++ b/help/iem_image-help.pd
@@ -0,0 +1,57 @@
+#N canvas 40 2 852 657 10;
+#X obj 200 261 iem_image pd.gif 0 0 empty empty;
+#X msg 280 54 open \$1;
+#X obj 280 31 openpanel;
+#X obj 261 32 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 289 73 open gates.gif;
+#X msg 337 130 open go_stop.gif;
+#X msg 304 92 open pair.gif;
+#X msg 319 111 open super_gau.gif;
+#X msg 353 149 open pd.gif;
+#X msg 372 168 open xxx.gif;
+#X obj 200 580 unpack;
+#X floatatom 200 606 5 0 0 0 - - -;
+#X floatatom 239 605 5 0 0 0 - - -;
+#X msg 87 61 pos 200 260;
+#X msg 168 61 pos 180 280;
+#X msg 89 92 delta 1 1;
+#X msg 168 95 delta -1 -1;
+#X msg 76 162 receive to_image;
+#X text 82 598 IEM KUG;
+#X text 66 586 musil;
+#X text 96 586 @;
+#X text 102 586 iem.at;
+#X text 65 608 Graz \, Austria;
+#X text 17 575 (c) Thomas Musil 2000 - 2006;
+#X text 326 233 |;
+#X text 326 244 |;
+#X text 386 233 |;
+#X text 386 244 |;
+#X text 326 239 |iem_image|;
+#X text 329 242 __________;
+#X text 329 225 __________;
+#X text 18 12 iem_image;
+#X text 112 15 gif only \, sorry;
+#X msg 77 139 send from_image;
+#X msg 224 160 clear;
+#X text 282 603 size in pixel after opening a gif;
+#X connect 0 0 10 0;
+#X connect 1 0 0 0;
+#X connect 2 0 1 0;
+#X connect 3 0 2 0;
+#X connect 4 0 0 0;
+#X connect 5 0 0 0;
+#X connect 6 0 0 0;
+#X connect 7 0 0 0;
+#X connect 8 0 0 0;
+#X connect 9 0 0 0;
+#X connect 10 0 11 0;
+#X connect 10 1 12 0;
+#X connect 13 0 0 0;
+#X connect 14 0 0 0;
+#X connect 15 0 0 0;
+#X connect 16 0 0 0;
+#X connect 17 0 0 0;
+#X connect 33 0 0 0;
+#X connect 34 0 0 0;
diff --git a/help/iem_vu-help.pd b/help/iem_vu-help.pd
new file mode 100644
index 0000000..4ac1b3e
--- /dev/null
+++ b/help/iem_vu-help.pd
@@ -0,0 +1,42 @@
+#N canvas 255 247 485 455 10;
+#X obj 78 162 iem_vu 16 120 empty empty -1 -8 0 8 -66577 -1 1 0;
+#X text 13 17 iem_vu;
+#X text 86 17 a new vu-GUI \, with same inputs and outputs as "vu"
+;
+#X floatatom 54 85 5 -100 12 0 - - -;
+#X floatatom 102 85 5 -100 12 0 - - -;
+#X text 43 68 rms_db;
+#X text 103 68 peak_db;
+#X floatatom 181 82 5 -100 12 0 - - -;
+#X floatatom 229 82 5 -100 12 0 - - -;
+#X text 170 65 rms_db;
+#X text 230 65 peak_db;
+#X obj 229 100 t b f;
+#X obj 227 124 pack;
+#X floatatom 45 303 5 -100 12 0 - - -;
+#X floatatom 109 303 5 -100 12 0 - - -;
+#X text 34 286 rms_db;
+#X text 110 286 peak_db;
+#X text 93 37 (you cannot change height via properties);
+#X text 83 366 IEM KUG;
+#X text 67 354 musil;
+#X text 97 354 @;
+#X text 103 354 iem.at;
+#X text 66 376 Graz \, Austria;
+#X text 18 343 (c) Thomas Musil 2000 - 2006;
+#X text 217 157 |;
+#X text 217 168 |;
+#X text 259 157 |;
+#X text 259 168 |;
+#X text 217 163 |iem_vu|;
+#X text 220 149 _______;
+#X text 220 166 _______;
+#X connect 0 0 13 0;
+#X connect 0 1 14 0;
+#X connect 3 0 0 0;
+#X connect 4 0 0 1;
+#X connect 7 0 12 0;
+#X connect 8 0 11 0;
+#X connect 11 0 12 0;
+#X connect 11 1 12 1;
+#X connect 12 0 0 0;
diff --git a/help/mp3_play.gif b/help/mp3_play.gif
new file mode 100644
index 0000000..870bfc7
--- /dev/null
+++ b/help/mp3_play.gif
Binary files differ
diff --git a/help/numberbox_matrix-help.pd b/help/numberbox_matrix-help.pd
new file mode 100644
index 0000000..e5ef418
--- /dev/null
+++ b/help/numberbox_matrix-help.pd
@@ -0,0 +1,502 @@
+#N canvas 7 5 966 718 10;
+#X obj 54 257 cnv 15 382 570 empty empty empty 20 12 0 14 -195568 -66577
+0;
+#X msg 48 45 matrix 5 3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15;
+#X msg 71 67 row 2 -2 -3 -4;
+#X msg 86 89 col 2 -2 -3 -4 -5 -6;
+#X msg 99 109 element 2 2 99;
+#X obj 103 137 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 450 15 dim 6 4;
+#X msg 503 12 dim 5 3;
+#X msg 450 38 size 5 18;
+#X msg 520 37 size 3 12;
+#X msg 541 62 color #000000;
+#X msg 452 62 color #00bb00;
+#X msg 524 95 font 0 10;
+#X msg 451 96 font 0 14;
+#X msg 453 134 font 1 10;
+#X msg 524 134 font 2 10;
+#X msg 591 134 font 0 10;
+#X msg 575 160 range -100 27;
+#X msg 395 160 range -10 2;
+#X msg 459 194 send from_matrix;
+#X msg 570 194 send empty;
+#X obj 808 511 r from_matrix;
+#X msg 460 216 receive to_matrix;
+#X msg 571 216 receive empty;
+#X obj 809 537 print cc;
+#X obj 53 888 print aa;
+#X msg 469 160 range -1000 1000;
+#N canvas 55 60 289 208 PROPERTIES 0;
+#X obj 443 17 inlet;
+#X obj 57 494 outlet;
+#X obj 98 584 pp dim;
+#X obj 120 528 t b f;
+#X obj 69 36 nbx 3 14 1 999 0 0 empty empty n_columns 0 -6 0 10 -262144
+-1 -1 1 256;
+#X obj 10 36 nbx 3 14 1 999 0 0 empty empty n_rows 0 -6 0 10 -262144
+-1 -1 1 256;
+#X obj 78 575 t b f;
+#X obj 70 74 nbx 3 14 1 999 0 0 empty empty heigth 0 -6 0 10 -262144
+-1 -1 1 256;
+#X obj 10 74 nbx 3 14 1 999 0 0 empty empty width 0 -6 0 10 -262144
+-1 -1 1 256;
+#X obj 56 631 pp size;
+#X obj 97 556 pack 5 3;
+#X obj 55 603 pack 3 12;
+#X symbolatom 37 104 6 0 0 0 - - -;
+#X obj 180 513 pp #;
+#X obj 180 533 mergefilename;
+#X obj 178 467 init 0 0 0 0 0 0;
+#X obj 178 488 mergefilename;
+#X obj 180 554 pp color;
+#X obj 38 98 cnv 1 1 1 empty empty color 0 0 0 10 -262144 -1 0;
+#X obj 298 472 t b f;
+#X obj 160 74 nbx 3 14 1 999 0 0 empty empty fontsize 0 -6 0 10 -262144
+-1 -1 1 256;
+#X obj 273 525 pack 3 12;
+#X obj 274 553 pp font;
+#X obj 160 25 vradio 10 1 0 3 empty empty empty 0 -6 0 8 -262144 -1
+-1 0;
+#X obj 173 29 cnv 1 1 1 empty empty courier 0 0 0 10 -262144 -1 0;
+#X obj 173 40 cnv 1 1 1 empty empty helvetica 0 0 0 10 -262144 -1 0
+;
+#X obj 173 51 cnv 1 1 1 empty empty times 0 0 0 10 -262144 -1 0;
+#X obj 38 124 cnv 1 1 1 empty empty R_G_B 0 0 0 8 -262144 -1 0;
+#X obj 390 530 t b f;
+#X obj 17 145 nbx 4 14 -1e+037 1e+037 0 0 empty empty min 0 -6 0 10
+-262144 -1 -1 -100 256;
+#X obj 367 558 pack 3 12;
+#X obj 72 145 nbx 3 14 -1e+037 1e+037 0 0 empty empty max 0 -6 0 10
+-262144 -1 -1 27 256;
+#X obj 368 586 pp range;
+#X symbolatom 158 108 10 0 0 0 - - -;
+#X obj 159 102 cnv 1 1 1 empty empty send_name 0 0 0 10 -262144 -1
+0;
+#X obj 423 448 pp send;
+#X obj 425 426 init symbol empty;
+#X symbolatom 158 145 10 0 0 0 - - -;
+#X obj 159 139 cnv 1 1 1 empty empty receive_name 0 0 0 10 -262144
+-1 0;
+#X obj 553 452 init symbol empty;
+#X obj 519 506 pp receive;
+#X obj 109 202 init -100 27;
+#X obj 111 226 unpack;
+#X connect 2 0 1 0;
+#X connect 3 0 10 0;
+#X connect 3 1 10 1;
+#X connect 4 0 3 0;
+#X connect 5 0 10 0;
+#X connect 6 0 11 0;
+#X connect 6 1 11 1;
+#X connect 7 0 6 0;
+#X connect 8 0 11 0;
+#X connect 9 0 1 0;
+#X connect 10 0 2 0;
+#X connect 11 0 9 0;
+#X connect 12 0 13 0;
+#X connect 13 0 14 0;
+#X connect 14 0 17 0;
+#X connect 15 0 16 0;
+#X connect 16 0 12 0;
+#X connect 17 0 1 0;
+#X connect 19 0 21 0;
+#X connect 19 1 21 1;
+#X connect 20 0 19 0;
+#X connect 21 0 22 0;
+#X connect 22 0 1 0;
+#X connect 23 0 21 0;
+#X connect 28 0 30 0;
+#X connect 28 1 30 1;
+#X connect 29 0 30 0;
+#X connect 30 0 32 0;
+#X connect 31 0 28 0;
+#X connect 32 0 1 0;
+#X connect 33 0 35 0;
+#X connect 35 0 1 0;
+#X connect 36 0 33 0;
+#X connect 37 0 40 0;
+#X connect 39 0 37 0;
+#X connect 40 0 1 0;
+#X connect 41 0 42 0;
+#X connect 42 0 29 0;
+#X connect 42 1 31 0;
+#X coords 0 0 1 1 250 180 1;
+#X restore 668 76 pd PROPERTIES of numberbox_matrix;
+#X obj 829 590 nbxm 1 3 3 11 -100 27 0 empty empty #000000 0 8;
+#X obj 922 610 nbxm 3 1 3 11 -100 27 0 empty empty #000000 0 8;
+#X obj 787 610 nbxm 1 1 3 11 -100 27 0 empty empty #000000 0 8;
+#X obj 796 654 print;
+#X obj 825 425 for++ 1 16;
+#X obj 823 402 t b;
+#X obj 816 353 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 826 452 add2 -30;
+#X obj 817 377 for++ 1 52 10;
+#X msg 14 109 -100;
+#X obj 16 261 cnv 3 1 1 empty empty DAC01 0 0 0 8 -262144 -1 0;
+#X obj 16 272 cnv 3 1 1 empty empty DAC02 0 0 0 8 -262144 -1 0;
+#X obj 16 283 cnv 3 1 1 empty empty DAC03 0 0 0 8 -262144 -1 0;
+#X obj 16 294 cnv 3 1 1 empty empty DAC04 0 0 0 8 -262144 -1 0;
+#X obj 16 305 cnv 3 1 1 empty empty DAC05 0 0 0 8 -262144 -1 0;
+#X obj 16 316 cnv 3 1 1 empty empty DAC06 0 0 0 8 -262144 -1 0;
+#X obj 16 327 cnv 3 1 1 empty empty DAC07 0 0 0 8 -262144 -1 0;
+#X obj 16 338 cnv 3 1 1 empty empty DAC08 0 0 0 8 -262144 -1 0;
+#X obj 16 349 cnv 3 1 1 empty empty DAC09 0 0 0 8 -262144 -1 0;
+#X obj 16 360 cnv 3 1 1 empty empty DAC10 0 0 0 8 -262144 -1 0;
+#X obj 16 371 cnv 3 1 1 empty empty DAC11 0 0 0 8 -262144 -1 0;
+#X obj 16 382 cnv 3 1 1 empty empty DAC12 0 0 0 8 -262144 -1 0;
+#X obj 16 393 cnv 3 1 1 empty empty DAC13 0 0 0 8 -262144 -1 0;
+#X obj 16 404 cnv 3 1 1 empty empty DAC14 0 0 0 8 -262144 -1 0;
+#X obj 16 415 cnv 3 1 1 empty empty DAC15 0 0 0 8 -262144 -1 0;
+#X obj 16 426 cnv 3 1 1 empty empty DAC16 0 0 0 8 -262144 -1 0;
+#X obj 16 437 cnv 3 1 1 empty empty DAC17 0 0 0 8 -262144 -1 0;
+#X obj 16 448 cnv 3 1 1 empty empty DAC18 0 0 0 8 -262144 -1 0;
+#X obj 16 459 cnv 3 1 1 empty empty DAC19 0 0 0 8 -262144 -1 0;
+#X obj 16 470 cnv 3 1 1 empty empty DAC20 0 0 0 8 -262144 -1 0;
+#X obj 16 481 cnv 3 1 1 empty empty DAC21 0 0 0 8 -262144 -1 0;
+#X obj 16 492 cnv 3 1 1 empty empty DAC22 0 0 0 8 -262144 -1 0;
+#X obj 16 503 cnv 3 1 1 empty empty DAC23 0 0 0 8 -262144 -1 0;
+#X obj 16 514 cnv 3 1 1 empty empty DAC24 0 0 0 8 -262144 -1 0;
+#X obj 16 525 cnv 3 1 1 empty empty DAC25 0 0 0 8 -262144 -1 0;
+#X obj 16 536 cnv 3 1 1 empty empty DAC26 0 0 0 8 -262144 -1 0;
+#X obj 16 547 cnv 3 1 1 empty empty DAC27 0 0 0 8 -262144 -1 0;
+#X obj 16 558 cnv 3 1 1 empty empty DAC28 0 0 0 8 -262144 -1 0;
+#X obj 16 569 cnv 3 1 1 empty empty DAC29 0 0 0 8 -262144 -1 0;
+#X obj 16 580 cnv 3 1 1 empty empty DAC30 0 0 0 8 -262144 -1 0;
+#X obj 16 591 cnv 3 1 1 empty empty DAC31 0 0 0 8 -262144 -1 0;
+#X obj 16 602 cnv 3 1 1 empty empty DAC32 0 0 0 8 -262144 -1 0;
+#X obj 16 613 cnv 3 1 1 empty empty DAC33 0 0 0 8 -262144 -1 0;
+#X obj 16 624 cnv 3 1 1 empty empty DAC34 0 0 0 8 -262144 -1 0;
+#X obj 16 635 cnv 3 1 1 empty empty DAC35 0 0 0 8 -262144 -1 0;
+#X obj 16 646 cnv 3 1 1 empty empty DAC36 0 0 0 8 -262144 -1 0;
+#X obj 16 657 cnv 3 1 1 empty empty DAC37 0 0 0 8 -262144 -1 0;
+#X obj 16 668 cnv 3 1 1 empty empty DAC38 0 0 0 8 -262144 -1 0;
+#X obj 16 679 cnv 3 1 1 empty empty DAC39 0 0 0 8 -262144 -1 0;
+#X obj 16 690 cnv 3 1 1 empty empty DAC40 0 0 0 8 -262144 -1 0;
+#X obj 16 701 cnv 3 1 1 empty empty DAC41 0 0 0 8 -262144 -1 0;
+#X obj 16 712 cnv 3 1 1 empty empty DAC42 0 0 0 8 -262144 -1 0;
+#X obj 16 723 cnv 3 1 1 empty empty DAC43 0 0 0 8 -262144 -1 0;
+#X obj 16 734 cnv 3 1 1 empty empty DAC44 0 0 0 8 -262144 -1 0;
+#X obj 16 745 cnv 3 1 1 empty empty DAC45 0 0 0 8 -262144 -1 0;
+#X obj 16 756 cnv 3 1 1 empty empty DAC46 0 0 0 8 -262144 -1 0;
+#X obj 16 767 cnv 3 1 1 empty empty DAC47 0 0 0 8 -262144 -1 0;
+#X obj 16 778 cnv 3 1 1 empty empty DAC48 0 0 0 8 -262144 -1 0;
+#X obj 16 789 cnv 3 1 1 empty empty DAC49 0 0 0 8 -262144 -1 0;
+#X obj 16 800 cnv 3 1 1 empty empty DAC50 0 0 0 8 -262144 -1 0;
+#X obj 16 811 cnv 3 1 1 empty empty DAC51 0 0 0 8 -262144 -1 0;
+#X obj 16 822 cnv 3 1 1 empty empty DAC52 0 0 0 8 -262144 -1 0;
+#X obj 62 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 62 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 62 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 62 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 62 866 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 86 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 86 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 86 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 86 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 86 866 cnv 3 1 1 empty empty 2 0 0 0 8 -262144 -1 0;
+#X obj 110 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 110 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 110 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 110 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 110 866 cnv 3 1 1 empty empty 3 0 0 0 8 -262144 -1 0;
+#X obj 134 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 134 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 134 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 134 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 134 866 cnv 3 1 1 empty empty 4 0 0 0 8 -262144 -1 0;
+#X obj 158 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 158 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 158 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 158 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 158 866 cnv 3 1 1 empty empty 5 0 0 0 8 -262144 -1 0;
+#X obj 182 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 182 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 182 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 182 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 182 866 cnv 3 1 1 empty empty 6 0 0 0 8 -262144 -1 0;
+#X obj 206 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 206 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 206 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 206 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 206 866 cnv 3 1 1 empty empty 7 0 0 0 8 -262144 -1 0;
+#X obj 230 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 230 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 230 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 230 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 230 866 cnv 3 1 1 empty empty 8 0 0 0 8 -262144 -1 0;
+#X obj 255 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 255 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 255 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 255 858 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 255 866 cnv 3 1 1 empty empty 9 0 0 0 8 -262144 -1 0;
+#X obj 279 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 279 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 279 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 279 866 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 279 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 303 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 303 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 303 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 303 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 327 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 327 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 327 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 327 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 351 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 351 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 351 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 351 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 375 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 375 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 375 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 375 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 399 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 399 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 399 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 399 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 423 834 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 423 842 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 423 850 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 423 858 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 303 866 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 327 866 cnv 3 1 1 empty empty 2 0 0 0 8 -262144 -1 0;
+#X obj 351 866 cnv 3 1 1 empty empty 3 0 0 0 8 -262144 -1 0;
+#X obj 375 866 cnv 3 1 1 empty empty 4 0 0 0 8 -262144 -1 0;
+#X obj 399 866 cnv 3 1 1 empty empty 5 0 0 0 8 -262144 -1 0;
+#X obj 423 866 cnv 3 1 1 empty empty 6 0 0 0 8 -262144 -1 0;
+#X msg 129 129 2 2 99;
+#N canvas 0 0 454 304 /SUBPATCH/ 0;
+#X obj 95 42 inlet;
+#X obj 95 155 outlet;
+#X connect 0 0 1 0;
+#X restore 53 160 pd;
+#N canvas 0 0 454 304 /SUBPATCH/ 0;
+#X obj 95 42 inlet;
+#X obj 95 155 outlet;
+#X connect 0 0 1 0;
+#X restore 171 150 pd;
+#X obj 62 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 62 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 62 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 62 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 62 250 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 86 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 86 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 86 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 86 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 86 250 cnv 3 1 1 empty empty 2 0 0 0 8 -262144 -1 0;
+#X obj 110 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 110 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 110 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 110 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 110 250 cnv 3 1 1 empty empty 3 0 0 0 8 -262144 -1 0;
+#X obj 134 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 134 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 134 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 134 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 134 250 cnv 3 1 1 empty empty 4 0 0 0 8 -262144 -1 0;
+#X obj 158 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 158 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 158 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 158 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 158 250 cnv 3 1 1 empty empty 5 0 0 0 8 -262144 -1 0;
+#X obj 182 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 182 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 182 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 182 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 182 250 cnv 3 1 1 empty empty 6 0 0 0 8 -262144 -1 0;
+#X obj 206 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 206 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 206 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 206 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 206 250 cnv 3 1 1 empty empty 7 0 0 0 8 -262144 -1 0;
+#X obj 230 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 230 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 230 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 230 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 230 250 cnv 3 1 1 empty empty 8 0 0 0 8 -262144 -1 0;
+#X obj 255 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 255 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 255 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 255 242 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 255 250 cnv 3 1 1 empty empty 9 0 0 0 8 -262144 -1 0;
+#X obj 279 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 279 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 279 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 279 250 cnv 3 1 1 empty empty 0 0 0 0 8 -262144 -1 0;
+#X obj 279 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 303 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 303 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 303 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 303 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 327 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 327 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 327 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 327 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 351 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 351 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 351 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 351 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 375 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 375 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 375 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 375 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 399 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 399 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 399 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 399 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 423 218 cnv 3 1 1 empty empty B 0 0 0 8 -262144 -1 0;
+#X obj 423 226 cnv 3 1 1 empty empty U 0 0 0 8 -262144 -1 0;
+#X obj 423 234 cnv 3 1 1 empty empty S 0 0 0 8 -262144 -1 0;
+#X obj 423 242 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 303 250 cnv 3 1 1 empty empty 1 0 0 0 8 -262144 -1 0;
+#X obj 327 250 cnv 3 1 1 empty empty 2 0 0 0 8 -262144 -1 0;
+#X obj 351 250 cnv 3 1 1 empty empty 3 0 0 0 8 -262144 -1 0;
+#X obj 375 250 cnv 3 1 1 empty empty 4 0 0 0 8 -262144 -1 0;
+#X obj 399 250 cnv 3 1 1 empty empty 5 0 0 0 8 -262144 -1 0;
+#X obj 423 250 cnv 3 1 1 empty empty 6 0 0 0 8 -262144 -1 0;
+#X obj 440 261 cnv 3 1 1 empty empty DAC01 0 0 0 8 -262144 -1 0;
+#X obj 440 272 cnv 3 1 1 empty empty DAC02 0 0 0 8 -262144 -1 0;
+#X obj 440 283 cnv 3 1 1 empty empty DAC03 0 0 0 8 -262144 -1 0;
+#X obj 440 294 cnv 3 1 1 empty empty DAC04 0 0 0 8 -262144 -1 0;
+#X obj 440 305 cnv 3 1 1 empty empty DAC05 0 0 0 8 -262144 -1 0;
+#X obj 440 316 cnv 3 1 1 empty empty DAC06 0 0 0 8 -262144 -1 0;
+#X obj 440 327 cnv 3 1 1 empty empty DAC07 0 0 0 8 -262144 -1 0;
+#X obj 440 338 cnv 3 1 1 empty empty DAC08 0 0 0 8 -262144 -1 0;
+#X obj 440 349 cnv 3 1 1 empty empty DAC09 0 0 0 8 -262144 -1 0;
+#X obj 440 360 cnv 3 1 1 empty empty DAC10 0 0 0 8 -262144 -1 0;
+#X obj 440 371 cnv 3 1 1 empty empty DAC11 0 0 0 8 -262144 -1 0;
+#X obj 440 382 cnv 3 1 1 empty empty DAC12 0 0 0 8 -262144 -1 0;
+#X obj 440 393 cnv 3 1 1 empty empty DAC13 0 0 0 8 -262144 -1 0;
+#X obj 440 404 cnv 3 1 1 empty empty DAC14 0 0 0 8 -262144 -1 0;
+#X obj 440 415 cnv 3 1 1 empty empty DAC15 0 0 0 8 -262144 -1 0;
+#X obj 440 426 cnv 3 1 1 empty empty DAC16 0 0 0 8 -262144 -1 0;
+#X obj 440 437 cnv 3 1 1 empty empty DAC17 0 0 0 8 -262144 -1 0;
+#X obj 440 448 cnv 3 1 1 empty empty DAC18 0 0 0 8 -262144 -1 0;
+#X obj 440 459 cnv 3 1 1 empty empty DAC19 0 0 0 8 -262144 -1 0;
+#X obj 440 470 cnv 3 1 1 empty empty DAC20 0 0 0 8 -262144 -1 0;
+#X obj 440 481 cnv 3 1 1 empty empty DAC21 0 0 0 8 -262144 -1 0;
+#X obj 440 492 cnv 3 1 1 empty empty DAC22 0 0 0 8 -262144 -1 0;
+#X obj 440 503 cnv 3 1 1 empty empty DAC23 0 0 0 8 -262144 -1 0;
+#X obj 440 514 cnv 3 1 1 empty empty DAC24 0 0 0 8 -262144 -1 0;
+#X obj 440 525 cnv 3 1 1 empty empty DAC25 0 0 0 8 -262144 -1 0;
+#X obj 440 536 cnv 3 1 1 empty empty DAC26 0 0 0 8 -262144 -1 0;
+#X obj 440 547 cnv 3 1 1 empty empty DAC27 0 0 0 8 -262144 -1 0;
+#X obj 440 558 cnv 3 1 1 empty empty DAC28 0 0 0 8 -262144 -1 0;
+#X obj 440 569 cnv 3 1 1 empty empty DAC29 0 0 0 8 -262144 -1 0;
+#X obj 440 580 cnv 3 1 1 empty empty DAC30 0 0 0 8 -262144 -1 0;
+#X obj 440 591 cnv 3 1 1 empty empty DAC31 0 0 0 8 -262144 -1 0;
+#X obj 440 602 cnv 3 1 1 empty empty DAC32 0 0 0 8 -262144 -1 0;
+#X obj 440 613 cnv 3 1 1 empty empty DAC33 0 0 0 8 -262144 -1 0;
+#X obj 440 624 cnv 3 1 1 empty empty DAC34 0 0 0 8 -262144 -1 0;
+#X obj 440 635 cnv 3 1 1 empty empty DAC35 0 0 0 8 -262144 -1 0;
+#X obj 440 646 cnv 3 1 1 empty empty DAC36 0 0 0 8 -262144 -1 0;
+#X obj 440 657 cnv 3 1 1 empty empty DAC37 0 0 0 8 -262144 -1 0;
+#X obj 440 668 cnv 3 1 1 empty empty DAC38 0 0 0 8 -262144 -1 0;
+#X obj 440 679 cnv 3 1 1 empty empty DAC39 0 0 0 8 -262144 -1 0;
+#X obj 440 690 cnv 3 1 1 empty empty DAC40 0 0 0 8 -262144 -1 0;
+#X obj 440 701 cnv 3 1 1 empty empty DAC41 0 0 0 8 -262144 -1 0;
+#X obj 440 712 cnv 3 1 1 empty empty DAC42 0 0 0 8 -262144 -1 0;
+#X obj 440 723 cnv 3 1 1 empty empty DAC43 0 0 0 8 -262144 -1 0;
+#X obj 440 734 cnv 3 1 1 empty empty DAC44 0 0 0 8 -262144 -1 0;
+#X obj 440 745 cnv 3 1 1 empty empty DAC45 0 0 0 8 -262144 -1 0;
+#X obj 440 756 cnv 3 1 1 empty empty DAC46 0 0 0 8 -262144 -1 0;
+#X obj 440 767 cnv 3 1 1 empty empty DAC47 0 0 0 8 -262144 -1 0;
+#X obj 440 778 cnv 3 1 1 empty empty DAC48 0 0 0 8 -262144 -1 0;
+#X obj 440 789 cnv 3 1 1 empty empty DAC49 0 0 0 8 -262144 -1 0;
+#X obj 440 800 cnv 3 1 1 empty empty DAC50 0 0 0 8 -262144 -1 0;
+#X obj 440 811 cnv 3 1 1 empty empty DAC51 0 0 0 8 -262144 -1 0;
+#X obj 440 822 cnv 3 1 1 empty empty DAC52 0 0 0 8 -262144 -1 0;
+#X obj 147 257 cnv 4 4 570 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 243 257 cnv 4 4 570 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 339 257 cnv 4 4 570 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 342 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 430 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 518 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 606 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 694 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 782 cnv 4 382 4 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X obj 54 738 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 54 650 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 54 562 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 54 474 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 54 386 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 54 298 cnv 4 382 4 empty empty empty 20 12 0 14 -166441 -66577
+0;
+#X obj 53 256 nbxm 52 16 3 11 -100 27 0 empty empty #000000 0 8;
+#X msg 835 322 -100;
+#X text 560 384 IEM KUG;
+#X text 544 372 musil;
+#X text 574 372 @;
+#X text 580 372 iem.at;
+#X text 543 394 Graz \, Austria;
+#X text 495 361 (c) Thomas Musil 2000 - 2006;
+#X text 492 267 |;
+#X text 492 278 |;
+#X text 594 267 |;
+#X text 594 278 |;
+#X text 492 293 |;
+#X text 492 304 |;
+#X text 522 293 |;
+#X text 522 304 |;
+#X text 492 273 |numberbox_matrix|;
+#X text 495 259 _________________;
+#X text 495 276 _________________;
+#X text 492 299 |nbxm|;
+#X text 495 302 _____;
+#X text 495 284 _____;
+#X text 9 6 numberbox_matrix;
+#X connect 1 0 171 0;
+#X connect 2 0 171 0;
+#X connect 3 0 171 0;
+#X connect 4 0 171 0;
+#X connect 5 0 171 0;
+#X connect 6 0 172 0;
+#X connect 7 0 172 0;
+#X connect 8 0 172 0;
+#X connect 9 0 172 0;
+#X connect 10 0 172 0;
+#X connect 11 0 172 0;
+#X connect 12 0 172 0;
+#X connect 13 0 172 0;
+#X connect 14 0 172 0;
+#X connect 15 0 172 0;
+#X connect 16 0 172 0;
+#X connect 17 0 172 0;
+#X connect 18 0 172 0;
+#X connect 19 0 172 0;
+#X connect 20 0 172 0;
+#X connect 21 0 24 0;
+#X connect 22 0 172 0;
+#X connect 23 0 172 0;
+#X connect 26 0 172 0;
+#X connect 27 0 320 0;
+#X connect 28 0 31 0;
+#X connect 29 0 31 0;
+#X connect 30 0 31 0;
+#X connect 32 0 35 0;
+#X connect 33 0 32 0;
+#X connect 34 0 36 0;
+#X connect 36 0 33 0;
+#X connect 37 0 171 0;
+#X connect 170 0 171 0;
+#X connect 171 0 320 0;
+#X connect 172 0 320 0;
+#X connect 320 0 25 0;
diff --git a/help/pair.gif b/help/pair.gif
new file mode 100644
index 0000000..f65400d
--- /dev/null
+++ b/help/pair.gif
Binary files differ
diff --git a/help/pd.gif b/help/pd.gif
new file mode 100644
index 0000000..9415bcb
--- /dev/null
+++ b/help/pd.gif
Binary files differ
diff --git a/help/room_sim_2d-help.pd b/help/room_sim_2d-help.pd
new file mode 100644
index 0000000..4589b8d
--- /dev/null
+++ b/help/room_sim_2d-help.pd
@@ -0,0 +1,764 @@
+#N canvas 0 0 1012 718 10;
+#X obj 42 172 room_sim_2d 4 30 0 1.4 30 24197 12 10 123525 150 180
+250684 61 90 62783 240 90 250684 233 100 250684 21 100;
+#X text 9 11 room_sim_2d;
+#X obj 42 148 r to_GUI;
+#X msg 494 16 \; to_GUI room_dim 12 10;
+#X msg 498 149 \; to_GUI r_ambi 1.4;
+#X msg 494 91 \; to_GUI room_dim \$1 \$2;
+#X obj 494 70 pack;
+#X obj 528 70 t b f;
+#X floatatom 487 53 5 2 30 0 - - -;
+#X floatatom 530 53 5 2 30 0 - - -;
+#X text 572 52 m x m;
+#X msg 498 202 \; to_GUI r_ambi \$1;
+#X floatatom 498 184 5 0.1 10 0 - - -;
+#X text 539 183 m;
+#X msg 496 306 \; to_GUI pix_per_m_ratio \$1;
+#X floatatom 496 288 5 5 50 0 - - -;
+#X text 539 286 pix/m;
+#X floatatom 501 412 5 5 150 0 - - -;
+#X msg 501 430 \; to_GUI src_font \$1;
+#X text 544 410 pix;
+#X msg 501 374 \; to_GUI src_font 30;
+#X obj 42 607 s from_GUI;
+#X obj 735 14 r from_GUI;
+#X obj 735 43 route 0 1 2;
+#X floatatom 735 260 5 0 0 0 - - -;
+#X floatatom 775 260 5 0 0 0 - - -;
+#X obj 735 238 unpack;
+#X floatatom 759 189 5 0 0 0 - - -;
+#X floatatom 799 189 5 0 0 0 - - -;
+#X obj 759 167 unpack;
+#X obj 759 144 route src_xy;
+#X floatatom 783 115 5 0 0 0 - - -;
+#X floatatom 823 115 5 0 0 0 - - -;
+#X obj 783 93 unpack;
+#X obj 783 70 route src_xy;
+#X obj 495 560 pack;
+#X obj 529 560 t b f;
+#X floatatom 488 543 5 -20 20 0 - - -;
+#X floatatom 531 543 5 -20 20 0 - - -;
+#X text 573 542 m x m;
+#X msg 495 506 \; to_GUI set_head_xy 0 0;
+#X msg 495 581 \; to_GUI set_head_xy \$1 \$2;
+#X text 865 114 m x m;
+#X text 841 187 m x m;
+#X text 817 260 m x m;
+#X text 850 145 source 1;
+#X text 877 70 source 2;
+#X obj 335 584 pp 0 rho_z;
+#X obj 735 215 route head_xy rho_z;
+#X floatatom 890 258 5 0 0 0 - - -;
+#X text 928 258 degree;
+#X obj 496 693 pack;
+#X obj 530 693 t b f;
+#X floatatom 489 676 5 -20 20 0 - - -;
+#X floatatom 532 676 5 -20 20 0 - - -;
+#X text 574 675 m x m;
+#X msg 496 639 \; to_GUI set_src_xy 1 3 -3;
+#X msg 496 714 \; to_GUI set_src_xy 1 \$1 \$2;
+#N canvas 706 69 322 703 colors 1;
+#X msg 47 153 \; to_GUI room_col \$1;
+#X msg 46 291 \; to_GUI head_col \$1;
+#X msg 45 434 \; to_GUI src_col 1 \$1;
+#X msg 45 584 \; to_GUI src_col 2 \$1;
+#N canvas 16 80 189 98 source_color_2 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 45 482 pd source_color_2;
+#N canvas 16 80 189 98 source_color_1 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 45 332 pd source_color_1;
+#N canvas 16 80 189 98 head_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 46 189 pd head_color;
+#N canvas 16 80 189 98 room_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 47 45 pd room_color;
+#X connect 4 0 3 0;
+#X connect 5 0 2 0;
+#X connect 6 0 1 0;
+#X connect 7 0 0 0;
+#X restore 736 555 pd colors;
+#X floatatom 721 415 5 0 0 0 - - -;
+#X msg 721 377 \; to_GUI set_rho 0;
+#X msg 721 433 \; to_GUI set_rho \$1;
+#X text 764 413 degree;
+#X text 184 150 |;
+#X text 184 146 ^;
+#X text 185 133 x;
+#X text 29 326 _;
+#X text 10 331 y <;
+#X msg 497 253 \; to_GUI pix_per_m_ratio 30;
+#X obj 710 696 pack;
+#X obj 744 696 t b f;
+#X floatatom 703 679 5 -20 20 0 - - -;
+#X floatatom 746 679 5 -20 20 0 - - -;
+#X text 788 678 m x m;
+#X msg 710 642 \; to_GUI set_src_xy 2 3 3;
+#X msg 710 717 \; to_GUI set_src_xy 2 \$1 \$2;
+#X floatatom 316 50 5 0.1 10 0 - - -;
+#X msg 316 68 \; to_GUI nr_src \$1;
+#X obj 316 29 + 1;
+#X obj 316 10 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
+-1 0;
+#X text 97 665 IEM KUG;
+#X text 81 653 musil;
+#X text 111 653 @;
+#X text 117 653 iem.at;
+#X text 80 675 Graz \, Austria;
+#X text 32 642 (c) Thomas Musil 2000 - 2006;
+#X text 262 133 |;
+#X text 262 144 |;
+#X text 265 125 ______________;
+#X text 265 142 ______________;
+#X text 346 133 |;
+#X text 346 144 |;
+#X text 262 139 |room_sim_3d 2|;
+#X text 53 59 of the circle-listener object;
+#X text 15 49 shift-mouse-dragging changes the rotation-angle;
+#X connect 0 0 21 0;
+#X connect 0 1 47 0;
+#X connect 2 0 0 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 0;
+#X connect 7 1 6 1;
+#X connect 8 0 6 0;
+#X connect 9 0 7 0;
+#X connect 12 0 11 0;
+#X connect 15 0 14 0;
+#X connect 17 0 18 0;
+#X connect 22 0 23 0;
+#X connect 23 0 48 0;
+#X connect 23 1 30 0;
+#X connect 23 2 34 0;
+#X connect 26 0 24 0;
+#X connect 26 1 25 0;
+#X connect 29 0 27 0;
+#X connect 29 1 28 0;
+#X connect 30 0 29 0;
+#X connect 33 0 31 0;
+#X connect 33 1 32 0;
+#X connect 34 0 33 0;
+#X connect 35 0 41 0;
+#X connect 36 0 35 0;
+#X connect 36 1 35 1;
+#X connect 37 0 35 0;
+#X connect 38 0 36 0;
+#X connect 47 0 21 0;
+#X connect 48 0 26 0;
+#X connect 48 1 49 0;
+#X connect 51 0 57 0;
+#X connect 52 0 51 0;
+#X connect 52 1 51 1;
+#X connect 53 0 51 0;
+#X connect 54 0 52 0;
+#X connect 59 0 61 0;
+#X connect 69 0 75 0;
+#X connect 70 0 69 0;
+#X connect 70 1 69 1;
+#X connect 71 0 69 0;
+#X connect 72 0 70 0;
+#X connect 76 0 77 0;
+#X connect 78 0 76 0;
+#X connect 79 0 78 0;
diff --git a/help/room_sim_3d-help.pd b/help/room_sim_3d-help.pd
new file mode 100644
index 0000000..95232a9
--- /dev/null
+++ b/help/room_sim_3d-help.pd
@@ -0,0 +1,801 @@
+#N canvas 6 5 960 708 10;
+#X obj 44 182 room_sim_3d 2 30 0 1.3 30 24197 12 10 5 123525 140 116
+1 250684 224 186 45 250684 64 158 42;
+#X obj 44 157 r to_GUI;
+#X msg 432 146 \; to_GUI r_ambi 1.4;
+#X obj 508 86 t b f;
+#X floatatom 433 69 5 2 30 0 - - -;
+#X floatatom 510 69 5 2 30 0 - - -;
+#X msg 432 199 \; to_GUI r_ambi \$1;
+#X floatatom 432 181 5 0.1 10 0 - - -;
+#X text 468 180 m;
+#X msg 430 289 \; to_GUI pix_per_m_ratio \$1;
+#X floatatom 430 271 5 5 50 0 - - -;
+#X text 473 269 pix/m;
+#X floatatom 429 362 5 5 150 0 - - -;
+#X msg 429 380 \; to_GUI src_font \$1;
+#X text 472 360 pix;
+#X msg 429 324 \; to_GUI src_font 30;
+#X obj 44 616 s from_GUI;
+#X obj 687 34 r from_GUI;
+#X obj 687 63 route 0 1 2;
+#X floatatom 687 280 5 0 0 0 - - -;
+#X floatatom 727 280 5 0 0 0 - - -;
+#X floatatom 711 209 5 0 0 0 - - -;
+#X floatatom 751 209 5 0 0 0 - - -;
+#X floatatom 735 135 5 0 0 0 - - -;
+#X floatatom 775 135 5 0 0 0 - - -;
+#X obj 514 473 t b f;
+#X floatatom 423 456 5 -20 20 0 - - -;
+#X floatatom 516 456 5 -20 20 0 - - -;
+#X text 802 165 source 1;
+#X text 829 90 source 2;
+#X obj 337 593 pp 0 rho_z;
+#X floatatom 840 263 5 0 0 0 - - -;
+#X text 878 263 degree;
+#X text 186 159 |;
+#X text 186 155 ^;
+#X text 187 142 x;
+#X text 31 335 _;
+#N canvas 698 61 330 711 colors 0;
+#X msg 47 153 \; to_GUI room_col \$1;
+#X msg 46 291 \; to_GUI head_col \$1;
+#X msg 45 434 \; to_GUI src_col 1 \$1;
+#X msg 45 584 \; to_GUI src_col 2 \$1;
+#N canvas 16 80 189 98 source_color_2 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 45 482 pd source_color_2;
+#N canvas 16 80 189 98 source_color_1 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 45 332 pd source_color_1;
+#N canvas 16 80 189 98 head_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 46 189 pd head_color;
+#N canvas 16 80 189 98 room_color 0;
+#X obj 12 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 12 139 0;
+#X obj 12 226 outlet;
+#X obj 12 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1
+-1;
+#X msg 12 160 1;
+#X obj 12 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -66577 -1 -1
+;
+#X obj 60 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261689 -1
+-1;
+#X msg 12 181 2;
+#X msg 60 139 3;
+#X obj 76 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -261681 -1
+-1;
+#X obj 92 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262131 -1
+-1;
+#X obj 108 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
+-1;
+#X obj 124 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -225280 -1
+-1;
+#X msg 76 139 4;
+#X msg 92 139 5;
+#X msg 108 139 6;
+#X msg 124 139 7;
+#X obj 140 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -228992 -1
+-1;
+#X obj 156 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -257472 -1
+-1;
+#X msg 140 139 8;
+#X msg 156 139 9;
+#X obj 28 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -233017 -1
+-1;
+#X obj 28 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -128992 -1
+-1;
+#X obj 28 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -33289 -1 -1
+;
+#X obj 60 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X obj 76 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
+-1;
+#X obj 92 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -241291 -1
+-1;
+#X obj 108 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
+-1;
+#X obj 124 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -44926 -1
+-1;
+#X obj 140 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -62784 -1
+-1;
+#X obj 156 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -250685 -1
+-1;
+#X msg 60 160 13;
+#X msg 76 160 14;
+#X msg 92 160 15;
+#X msg 108 160 16;
+#X msg 124 160 17;
+#X msg 140 160 18;
+#X msg 156 160 19;
+#X msg 28 139 10;
+#X msg 28 160 11;
+#X msg 28 181 12;
+#X obj 44 27 bng 15 250 50 0 empty empty empty 0 -6 0 8 -195568 -1
+-1;
+#X obj 44 43 bng 15 250 50 0 empty empty empty 0 -6 0 8 -99865 -1 -1
+;
+#X obj 44 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1 -1 -1;
+#X obj 60 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -143491 -1
+-1;
+#X obj 76 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90881 -1 -1
+;
+#X obj 92 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -123526 -1
+-1;
+#X obj 108 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -42246 -1
+-1;
+#X obj 124 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -1109 -1 -1
+;
+#X obj 140 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -355 -1 -1
+;
+#X obj 156 59 bng 15 250 50 0 empty empty empty 0 -6 0 8 -90133 -1
+-1;
+#X msg 60 181 23;
+#X msg 76 181 24;
+#X msg 92 181 25;
+#X msg 108 181 26;
+#X msg 124 181 27;
+#X msg 140 181 28;
+#X msg 156 181 29;
+#X msg 44 139 20;
+#X msg 44 160 21;
+#X msg 44 181 22;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 7 0;
+#X connect 6 0 8 0;
+#X connect 7 0 2 0;
+#X connect 8 0 2 0;
+#X connect 9 0 13 0;
+#X connect 10 0 14 0;
+#X connect 11 0 15 0;
+#X connect 12 0 16 0;
+#X connect 13 0 2 0;
+#X connect 14 0 2 0;
+#X connect 15 0 2 0;
+#X connect 16 0 2 0;
+#X connect 17 0 19 0;
+#X connect 18 0 20 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
+#X connect 21 0 38 0;
+#X connect 22 0 39 0;
+#X connect 23 0 40 0;
+#X connect 24 0 31 0;
+#X connect 25 0 32 0;
+#X connect 26 0 33 0;
+#X connect 27 0 34 0;
+#X connect 28 0 35 0;
+#X connect 29 0 36 0;
+#X connect 30 0 37 0;
+#X connect 31 0 2 0;
+#X connect 32 0 2 0;
+#X connect 33 0 2 0;
+#X connect 34 0 2 0;
+#X connect 35 0 2 0;
+#X connect 36 0 2 0;
+#X connect 37 0 2 0;
+#X connect 38 0 2 0;
+#X connect 39 0 2 0;
+#X connect 40 0 2 0;
+#X connect 41 0 58 0;
+#X connect 42 0 59 0;
+#X connect 43 0 60 0;
+#X connect 44 0 51 0;
+#X connect 45 0 52 0;
+#X connect 46 0 53 0;
+#X connect 47 0 54 0;
+#X connect 48 0 55 0;
+#X connect 49 0 56 0;
+#X connect 50 0 57 0;
+#X connect 51 0 2 0;
+#X connect 52 0 2 0;
+#X connect 53 0 2 0;
+#X connect 54 0 2 0;
+#X connect 55 0 2 0;
+#X connect 56 0 2 0;
+#X connect 57 0 2 0;
+#X connect 58 0 2 0;
+#X connect 59 0 2 0;
+#X connect 60 0 2 0;
+#X coords 0 0 1 1 200 100 1;
+#X restore 47 45 pd room_color;
+#X connect 4 0 3 0;
+#X connect 5 0 2 0;
+#X connect 6 0 1 0;
+#X connect 7 0 0 0;
+#X restore 699 418 pd colors;
+#X floatatom 693 349 5 0 0 0 - - -;
+#X msg 693 311 \; to_GUI set_rho 0;
+#X msg 693 367 \; to_GUI set_rho \$1;
+#X text 736 347 degree;
+#X text 11 10 room_sim_3d;
+#X text 212 152 .;
+#X text 209 154 () z;
+#X text 213 149 -;
+#X text 213 150 -;
+#X text 213 158 -;
+#X text 213 159 -;
+#X text 212 151 .;
+#X text 213 152 .;
+#X text 213 151 .;
+#X msg 433 32 \; to_GUI room_dim 12 10 5;
+#X obj 433 86 pack 0 0 0;
+#X text 593 67 m x m x m;
+#X obj 550 87 t b f;
+#X floatatom 552 70 5 2 20 0 - - -;
+#X msg 433 111 \; to_GUI room_dim \$1 \$2 \$3;
+#X msg 431 236 \; to_GUI pix_per_m_ratio 30;
+#X msg 430 419 \; to_GUI set_head_xyz 0 0 1.8;
+#X obj 430 473 pack 0 0 0;
+#X obj 564 473 t b f;
+#X floatatom 566 456 5 0 30 0 - - -;
+#X msg 430 494 \; to_GUI set_head_xyz \$1 \$2 \$3;
+#X text 12 340 y <;
+#X msg 430 538 \; to_GUI set_src_xyz 1 3 -3 1.8;
+#X text 614 454 m x m x m;
+#X text 611 574 m x m x m;
+#X obj 514 592 t b f;
+#X floatatom 423 575 5 -20 20 0 - - -;
+#X floatatom 516 575 5 -20 20 0 - - -;
+#X obj 430 592 pack 0 0 0;
+#X obj 564 592 t b f;
+#X floatatom 566 575 5 0 30 0 - - -;
+#X msg 430 613 \; to_GUI set_src_xyz 1 \$1 \$2 \$3;
+#X text 879 505 m x m x m;
+#X obj 782 523 t b f;
+#X floatatom 691 506 5 -20 20 0 - - -;
+#X floatatom 784 506 5 -20 20 0 - - -;
+#X obj 698 523 pack 0 0 0;
+#X obj 832 523 t b f;
+#X floatatom 834 506 5 0 30 0 - - -;
+#X msg 698 544 \; to_GUI set_src_xyz 2 \$1 \$2 \$3;
+#X msg 698 469 \; to_GUI set_src_xyz 2 3 3 1.8;
+#X obj 735 90 route src_xyz;
+#X obj 711 164 route src_xyz;
+#X obj 687 235 route head_xyz rho_z;
+#X obj 687 258 unpack 0 0 0;
+#X obj 711 187 unpack 0 0 0;
+#X obj 735 113 unpack 0 0 0;
+#X floatatom 767 280 5 0 0 0 - - -;
+#X floatatom 793 209 5 0 0 0 - - -;
+#X floatatom 816 135 5 0 0 0 - - -;
+#X text 860 133 m x m x m;
+#X text 835 207 m x m x m;
+#X text 806 278 m x m x m;
+#X floatatom 316 50 5 0.1 10 0 - - -;
+#X msg 316 68 \; to_GUI nr_src \$1;
+#X obj 316 29 + 1;
+#X obj 316 10 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
+-1 0;
+#X text 97 665 IEM KUG;
+#X text 81 653 musil;
+#X text 111 653 @;
+#X text 117 653 iem.at;
+#X text 80 675 Graz \, Austria;
+#X text 32 642 (c) Thomas Musil 2000 - 2006;
+#X text 262 143 |;
+#X text 262 154 |;
+#X text 265 135 ______________;
+#X text 265 152 ______________;
+#X text 346 143 |;
+#X text 346 154 |;
+#X text 262 149 |room_sim_3d 2|;
+#X text 53 59 of the circle-listener object;
+#X text 15 49 shift-mouse-dragging changes the rotation-angle;
+#X text 13 81 alt-mouse-dragging changes the height of all;
+#X text 32 92 objects \, the size of the objects will change.;
+#X connect 0 0 16 0;
+#X connect 0 1 30 0;
+#X connect 1 0 0 0;
+#X connect 3 0 53 0;
+#X connect 3 1 53 1;
+#X connect 4 0 53 0;
+#X connect 5 0 3 0;
+#X connect 7 0 6 0;
+#X connect 10 0 9 0;
+#X connect 12 0 13 0;
+#X connect 17 0 18 0;
+#X connect 18 0 86 0;
+#X connect 18 1 85 0;
+#X connect 18 2 84 0;
+#X connect 25 0 60 0;
+#X connect 25 1 60 1;
+#X connect 26 0 60 0;
+#X connect 27 0 25 0;
+#X connect 30 0 16 0;
+#X connect 38 0 40 0;
+#X connect 53 0 57 0;
+#X connect 55 0 53 0;
+#X connect 55 1 53 2;
+#X connect 56 0 55 0;
+#X connect 60 0 63 0;
+#X connect 61 0 60 0;
+#X connect 61 1 60 2;
+#X connect 62 0 61 0;
+#X connect 68 0 71 0;
+#X connect 68 1 71 1;
+#X connect 69 0 71 0;
+#X connect 70 0 68 0;
+#X connect 71 0 74 0;
+#X connect 72 0 71 0;
+#X connect 72 1 71 2;
+#X connect 73 0 72 0;
+#X connect 76 0 79 0;
+#X connect 76 1 79 1;
+#X connect 77 0 79 0;
+#X connect 78 0 76 0;
+#X connect 79 0 82 0;
+#X connect 80 0 79 0;
+#X connect 80 1 79 2;
+#X connect 81 0 80 0;
+#X connect 84 0 89 0;
+#X connect 85 0 88 0;
+#X connect 86 0 87 0;
+#X connect 86 1 31 0;
+#X connect 87 0 19 0;
+#X connect 87 1 20 0;
+#X connect 87 2 90 0;
+#X connect 88 0 21 0;
+#X connect 88 1 22 0;
+#X connect 88 2 91 0;
+#X connect 89 0 23 0;
+#X connect 89 1 24 0;
+#X connect 89 2 92 0;
+#X connect 96 0 97 0;
+#X connect 98 0 96 0;
+#X connect 99 0 98 0;
diff --git a/help/vfad_scale-help.pd b/help/vfad_scale-help.pd
new file mode 100644
index 0000000..8fd9599
--- /dev/null
+++ b/help/vfad_scale-help.pd
@@ -0,0 +1,27 @@
+#N canvas 4 20 454 377 10;
+#X obj 82 90 vfad_scale -1;
+#X obj 65 92 vsl 15 121 0 120 0 0 empty empty empty 0 -8 0 8 -262144
+-1 -1 0 1;
+#X obj 65 221 fadtodb;
+#X obj 65 243 - 100;
+#X floatatom 65 264 5 0 0 0 - - -;
+#X text 105 266 dB;
+#X text 10 9 vfad_scale;
+#X text 121 8 vertical fader scale;
+#X text 101 31 for vertical slider with height of 121 pixels;
+#X text 96 312 IEM KUG;
+#X text 80 300 musil;
+#X text 110 300 @;
+#X text 116 300 iem.at;
+#X text 79 322 Graz \, Austria;
+#X text 31 289 (c) Thomas Musil 2000 - 2006;
+#X text 113 84 |;
+#X text 113 95 |;
+#X text 179 84 |;
+#X text 179 95 |;
+#X text 113 90 |vfad_scale|;
+#X text 116 76 ___________;
+#X text 116 93 ___________;
+#X connect 1 0 2 0;
+#X connect 2 0 3 0;
+#X connect 3 0 4 0;
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/cube_sphere.c b/src/cube_sphere.c
new file mode 100644
index 0000000..44bfa94
--- /dev/null
+++ b/src/cube_sphere.c
@@ -0,0 +1,791 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#define IEMGUI_CUBE_SPHERE_MAX 200
+
+/* ---------- cube_sphere my gui-canvas for a window ---------------- */
+
+t_widgetbehavior cube_sphere_widgetbehavior;
+static t_class *cube_sphere_class;
+
+typedef struct _cube_sphere
+{
+ t_iemgui x_gui;
+ int x_fontsize;
+ int x_n_src;
+ int x_null;
+ int x_pix_src_x[IEMGUI_CUBE_SPHERE_MAX];
+ int x_pix_src_y[IEMGUI_CUBE_SPHERE_MAX];
+ int x_col_src[IEMGUI_CUBE_SPHERE_MAX];
+ int x_vis_src[IEMGUI_CUBE_SPHERE_MAX];
+ int x_pos_x;
+ int x_pos_y;
+ t_float x_pos_dx;
+ t_float x_pos_dy;
+ t_float x_pos_dr;
+ int x_sel_index;
+ int x_radius;
+ t_float x_90overradius;
+ void *x_out_para;
+ t_atom x_at[3];
+} t_cube_sphere;
+
+static void cube_sphere_out_all(t_cube_sphere *x)
+{
+ t_float delta, phi, diffr, diffx, diffy, fff=180.0f/3.14159265f;
+ int i, n = x->x_n_src;
+ int rad=x->x_radius;
+
+ for(i=0; i<n; i++)
+ {
+ SETFLOAT(x->x_at, (t_float)(i+1));
+ diffx = (t_float)(x->x_pix_src_x[i] - rad);
+ diffy = (t_float)(x->x_pix_src_y[i] - rad);
+ diffr = sqrt(diffx * diffx + diffy * diffy);
+ delta = 90.0f - x->x_90overradius*diffr*1.01f;
+ if(delta < 0.0f)
+ delta = 0.0f;
+ if(delta > 90.0f)
+ delta = 90.0f;
+ if(diffx == 0.0f)
+ {
+ if(diffy > 0.0f)
+ phi = -180.0f;
+ else
+ phi = 0.0f;
+ }
+ else if(diffx > 0.0f)
+ {
+ if(diffy >= 0.0f)
+ phi = fff*atan(diffx/diffy) - 180.0f;
+ else
+ phi = fff*atan(diffx/diffy);
+ }
+ else /* diffx < 0 */
+ {
+ if(diffy >= 0.0f)
+ phi = fff*atan(diffx/diffy) + 180.0f;
+ else
+ phi = fff*atan(diffx/diffy);
+ }
+ SETFLOAT(x->x_at+1, delta);
+ SETFLOAT(x->x_at+2, phi);
+ outlet_list(x->x_out_para, &s_list, 3, x->x_at);
+ }
+}
+
+static void cube_sphere_out_sel(t_cube_sphere *x)
+{
+ t_float delta, phi, fff=180.0f/3.14159265f;
+ t_float diffr=x->x_pos_dr;
+ t_float diffx=x->x_pos_dx;
+ t_float diffy=x->x_pos_dy;
+ int sel=x->x_sel_index;
+ int n = x->x_n_src;
+ int rad=x->x_radius;
+
+ SETFLOAT(x->x_at, (t_float)(sel+1));
+ delta = 90.0f - x->x_90overradius*diffr*1.01f;
+ if(delta < 0.0f)
+ delta = 0.0f;
+ if(delta > 90.0f)
+ delta = 90.0f;
+ if(diffx == 0.0f)
+ {
+ if(diffy > 0.0f)
+ phi = -180.0f;
+ else
+ phi = 0.0f;
+ }
+ else if(diffx > 0.0f)
+ {
+ if(diffy >= 0.0f)
+ phi = fff*atan(diffx/diffy) - 180.0f;
+ else
+ phi = fff*atan(diffx/diffy);
+ }
+ else /* diffx < 0 */
+ {
+ if(diffy >= 0.0f)
+ phi = fff*atan(diffx/diffy) + 180.0f;
+ else
+ phi = fff*atan(diffx/diffy);
+ }
+ SETFLOAT(x->x_at+1, delta);
+ SETFLOAT(x->x_at+2, phi);
+ outlet_list(x->x_out_para, &s_list, 3, x->x_at);
+}
+
+void cube_sphere_draw_new(t_cube_sphere *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int x2=xpos+x->x_gui.x_w/2;
+ int y2=ypos+x->x_gui.x_h/2;
+ int r3=x->x_radius/3;
+ int i, n=x->x_n_src;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol, x);
+ sys_vgui(".x%x.c create oval %d %d %d %d -fill #%6.6x -tags %xCIRC_AQ\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, x->x_gui.x_bcol, x);
+ sys_vgui(".x%x.c create oval %d %d %d %d -tags %xCIRC_WK\n",
+ canvas, x2-2*r3, y2-2*r3, x2+2*r3, y2+2*r3, x);
+ sys_vgui(".x%x.c create oval %d %d %d %d -tags %xCIRC_PK\n",
+ canvas, x2-r3, y2-r3, x2+r3, y2+r3, x);
+ sys_vgui(".x%x.c create oval %d %d %d %d -tags %xCIRC_NP\n",
+ canvas, x2-2, y2-2, x2+2, y2+2, x);
+ if(x->x_null)
+ {
+ sys_vgui(".x%x.c create text %d %d -text {+} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC0\n",
+ canvas, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0], x->x_fontsize,
+ x->x_col_src[0], x);
+ }
+ else
+ {
+ for(i=0; i<n; i++)
+ {
+ if(x->x_vis_src[i])
+ sys_vgui(".x%x.c create text %d %d -text {%d} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC%d\n",
+ canvas, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i], i+1, x->x_fontsize,
+ x->x_col_src[i], x, i);
+ }
+ }
+}
+
+void cube_sphere_draw_move(t_cube_sphere *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int x2=xpos+x->x_gui.x_w/2;
+ int y2=ypos+x->x_gui.x_h/2;
+ int r3=x->x_radius/3;
+ int i, n=x->x_n_src;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ sys_vgui(".x%x.c coords %xCIRC_AQ %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ sys_vgui(".x%x.c coords %xCIRC_WK %d %d %d %d\n",
+ canvas, x, x2-2*r3, y2-2*r3, x2+2*r3, y2+2*r3);
+ sys_vgui(".x%x.c coords %xCIRC_PK %d %d %d %d\n",
+ canvas, x, x2-r3, y2-r3, x2+r3, y2+r3);
+ sys_vgui(".x%x.c coords %xCIRC_NP %d %d %d %d\n",
+ canvas, x, x2-2, y2-2, x2+2, y2+2);
+ for(i=0; i<n; i++)
+ {
+ if(x->x_vis_src[i])
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ }
+}
+
+void cube_sphere_draw_erase(t_cube_sphere* x, t_glist* glist)
+{
+ int i, n;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui(".x%x.c delete %xCIRC_AQ\n", canvas, x);
+ sys_vgui(".x%x.c delete %xCIRC_WK\n", canvas, x);
+ sys_vgui(".x%x.c delete %xCIRC_PK\n", canvas, x);
+ sys_vgui(".x%x.c delete %xCIRC_NP\n", canvas, x);
+ n = x->x_n_src;
+ for(i=0; i<n; i++)
+ {
+ if(x->x_vis_src[i])
+ sys_vgui(".x%x.c delete %xSRC%d\n", canvas, x, i);
+ }
+}
+
+void cube_sphere_draw_select(t_cube_sphere* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n",
+ canvas, x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
+}
+
+void cube_sphere_draw(t_cube_sphere *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ cube_sphere_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ cube_sphere_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ cube_sphere_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ cube_sphere_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void cube_sphere_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_cube_sphere *x = (t_cube_sphere *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void cube_sphere_save(t_gobj *z, t_binbuf *b)
+{
+ t_cube_sphere *x = (t_cube_sphere *)z;
+ int i, j, c, n=x->x_n_src;
+
+ binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, gensym("cube_sphere"));
+ if(x->x_null)
+ binbuf_addv(b, "iii", 0, x->x_radius, x->x_fontsize);
+ else
+ binbuf_addv(b, "iii", x->x_n_src, x->x_radius, x->x_fontsize);
+ c = x->x_gui.x_bcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "i", j);
+ c = x->x_gui.x_fcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "i", j);
+ for(i=0; i<n; i++)
+ {
+ c = x->x_col_src[i];
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iii", j, x->x_pix_src_x[i], x->x_pix_src_y[i]);
+ }
+ binbuf_addv(b, ";");
+}
+
+static void cube_sphere_motion(t_cube_sphere *x, t_floatarg dx, t_floatarg dy)
+{
+ int sel=x->x_sel_index;
+
+ if(x->x_vis_src[sel])
+ {
+ int i, diffx, diffy, diffr, xx, yy;
+ int rad = x->x_radius;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ x->x_pos_x += (int)dx;
+ x->x_pos_y += (int)dy;
+ x->x_pix_src_x[sel] = x->x_pos_x;
+ x->x_pix_src_y[sel] = x->x_pos_y;
+ diffx = x->x_pix_src_x[sel] - rad;
+ diffy = x->x_pix_src_y[sel] - rad;
+ x->x_pos_dx=(t_float)diffx;
+ x->x_pos_dy=(t_float)diffy;
+ x->x_pos_dr = sqrt(diffx * diffx + diffy * diffy);
+ diffr = (int)(x->x_pos_dr+0.49999f);
+ if(diffr > rad)
+ {
+ xx = rad * diffx;
+ xx /= diffr;
+ yy = rad * diffy;
+ yy /= diffr;
+ x->x_pix_src_y[sel] = rad + yy;
+ x->x_pix_src_x[sel] = rad + xx;
+ }
+ cube_sphere_out_sel(x);
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, sel, xpos+x->x_pix_src_x[sel], ypos+x->x_pix_src_y[sel]);
+ }
+}
+
+static void cube_sphere_click(t_cube_sphere *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ int xpix=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypix=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int cxpos=xpix+x->x_radius;
+ int cypos=ypix+x->x_radius;
+ int w = (int)xpos - xpix;
+ int h = (int)ypos - ypix;
+ int i, n=x->x_n_src;
+ int diff, maxdiff=10000, sel=-1, diffx, diffy, diffr;
+ int fs=x->x_fontsize/2+2;
+
+ diffx = xpos - cxpos;
+ diffy = ypos - cypos;
+ diffr = (int)(sqrt(diffx * diffx + diffy * diffy)+0.49999f);
+ if(diffr <= x->x_radius)
+ {
+ for(i=0; i<n; i++)
+ {
+ if((w >= (x->x_pix_src_x[i]-fs)) && (w <= (x->x_pix_src_x[i]+fs)) && (h >= (x->x_pix_src_y[i]-fs)) && (h <= (x->x_pix_src_y[i]+fs)))
+ {
+ diff = w - x->x_pix_src_x[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ diff = h - x->x_pix_src_y[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ }
+ }
+ if(sel >= 0)
+ {
+ if(x->x_vis_src[sel])
+ {
+ x->x_sel_index = sel;
+ x->x_pos_x = x->x_pix_src_x[sel];
+ x->x_pos_y = x->x_pix_src_y[sel];
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)cube_sphere_motion, 0, xpos, ypos);
+ }
+ }
+ }
+}
+
+static int cube_sphere_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_cube_sphere* x = (t_cube_sphere *)z;
+
+ if(doit)
+ {
+ cube_sphere_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ }
+ return (1);
+}
+
+static void cube_sphere_bang(t_cube_sphere *x)
+{
+ cube_sphere_out_all(x);
+}
+
+static void cube_sphere_src_font(t_cube_sphere *x, t_floatarg ff)
+{
+ int fs=(int)(ff + 0.49999f);
+ int i, n=x->x_n_src;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(fs < 5)
+ fs = 5;
+ if(fs > 150)
+ fs = 150;
+ x->x_fontsize = fs;
+
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ for(i=0; i<n; i++)
+ {
+ if(x->x_vis_src[i])
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, i, fs);
+ }
+ }
+}
+
+static void cube_sphere_src_dp(t_cube_sphere *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float delta, phi;
+ int i, n=x->x_n_src;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 3)
+ {
+ post("cube_sphere ERROR: src_dp-input needs 1 index + 2 float-angles: src_index, delta [degree], phi [degree]");
+ return;
+ }
+ i = (int)atom_getint(argv++)-1;
+ if((i >= 0)&&(i < n))
+ {
+ delta = 90.0f - atom_getfloat(argv++);
+ phi = atom_getfloat(argv);
+ phi /= 180.0f;
+ phi *= 3.14159265f;
+ delta /= x->x_90overradius*0.99;
+ if(delta < 0.0f)
+ delta = 0.0f;
+ if(delta > (t_float)x->x_radius)
+ delta = (t_float)x->x_radius;
+
+ x->x_pix_src_x[i] = x->x_radius - (int)(delta*sin(phi) + 0.49999f);
+ x->x_pix_src_y[i] = x->x_radius - (int)(delta*cos(phi) + 0.49999f);
+ if(glist_isvisible(x->x_gui.x_glist) && x->x_vis_src[i])
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ }
+}
+
+static void cube_sphere_size(t_cube_sphere *x, t_floatarg size)
+{
+ t_float ratio, xx, yy;
+ // t_float ratio, rr;
+ int i, newrad, n=x->x_n_src;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+
+ size /= 6.0f;
+ newrad = (int)(size + 0.4999f);
+ newrad *= 3;
+ if(newrad < 9)
+ newrad = 9;
+ if(newrad > 1800)
+ newrad = 1800;
+
+ ratio = (t_float)newrad / (t_float)x->x_radius;
+
+ for(i=0; i<n; i++)
+ {
+ xx = (t_float)x->x_pix_src_x[i] * ratio;
+ x->x_pix_src_x[i] = (t_int)(xx + 0.4999f);
+
+ yy = (t_float)x->x_pix_src_y[i] * ratio;
+ x->x_pix_src_y[i] = (t_int)(yy + 0.4999f);
+
+ /*xx -= (t_float)newrad;
+ yy -= (t_float)newrad;
+ rr = sqrt(xx*xx + yy*yy);
+ if(rr > (t_float)newrad)
+ {
+
+ }*/
+ }
+
+ x->x_90overradius = 90.0f / (t_float)newrad;
+ x->x_radius = newrad;
+ x->x_gui.x_h = 2*newrad;
+ x->x_gui.x_w = 2*newrad;
+
+ cube_sphere_out_all(x);
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void cube_sphere_vis(t_cube_sphere *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int index, n=x->x_n_src;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int newstate, oldstate;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 2)
+ {
+ post("cube_sphere ERROR: vis-input needs 1 index + 1 visual state");
+ return;
+ }
+ index = (int)atom_getint(argv++) - 1;
+
+ if((index >= 0) && (index < n))
+ {
+ newstate = ((int)atom_getint(argv) ? 1 : 0);
+ oldstate = x->x_vis_src[index];
+
+ if(newstate && !oldstate)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c create text %d %d -text {%d} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC%d\n",
+ canvas, xpos+x->x_pix_src_x[index], ypos+x->x_pix_src_y[index], index+1, x->x_fontsize,
+ x->x_col_src[index], x, index);
+ }
+ else if(!newstate && oldstate)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c delete %xSRC%d\n", canvas, x, index);
+ }
+ x->x_vis_src[index] = newstate;
+ }
+ else if(index < 0)
+ {// if index is -1 : all
+ newstate = ((int)atom_getint(argv) ? 1 : 0);
+ for(index=0; index<n; index++)
+ {
+ oldstate = x->x_vis_src[index];
+ if(newstate && !oldstate)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c create text %d %d -text {%d} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC%d\n",
+ canvas, xpos+x->x_pix_src_x[index], ypos+x->x_pix_src_y[index], index+1, x->x_fontsize,
+ x->x_col_src[index], x, index);
+ }
+ else if(!newstate && oldstate)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c delete %xSRC%d\n", canvas, x, index);
+ }
+ x->x_vis_src[index] = newstate;
+ }
+ }
+}
+
+static void cube_sphere_sphere_col(t_cube_sphere *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_bcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_bcol = my_iemgui_color_hex[col];
+ }
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c itemconfigure %xCIRC_AQ -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+}
+
+static void cube_sphere_frame_col(t_cube_sphere *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_fcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_fcol = my_iemgui_color_hex[col];
+ }
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n",
+ canvas, x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
+}
+
+static void cube_sphere_src_col(t_cube_sphere *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col;
+ int help_col, src_index, n=x->x_n_src;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ src_index = (int)atom_getintarg(0, argc, argv) - 1;
+ if((src_index >= 0) && (src_index < n))
+ {
+ col = (int)atom_getintarg(1, argc, argv);
+ if(col < 0)
+ {
+ help_col = -1 - col;
+ x->x_col_src[src_index] = ((help_col & 0x3f000) << 6)|((help_col & 0xfc0) << 4)|((help_col & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_col_src[src_index] = my_iemgui_color_hex[col];
+ }
+ if((x->x_vis_src[src_index]) && glist_isvisible(x->x_gui.x_glist))
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -fill #%6.6x\n", canvas, x, src_index, x->x_col_src[src_index]);
+ }
+ }
+}
+
+static void cube_sphere_nr_src(t_cube_sphere *x, t_floatarg fnr_src)
+{
+ int n=(int)fnr_src;
+ int old_nr_src, i, j, old_null;
+
+ old_null = x->x_null;
+ if(n <= 0)
+ x->x_null = 1;
+ else
+ x->x_null = 0;
+ if(n < 1)
+ n = 1;
+ if(n > IEMGUI_CUBE_SPHERE_MAX)
+ n = IEMGUI_CUBE_SPHERE_MAX;
+ if((n != x->x_n_src) || (old_null != x->x_null))
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+
+ old_nr_src = x->x_n_src;
+ j = old_nr_src % 7;
+ x->x_n_src = n;
+ for(i=old_nr_src; i<n; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ x->x_vis_src[i] = 1;
+ x->x_pix_src_x[i] = x->x_radius;
+ x->x_pix_src_y[i] = x->x_radius;
+ j++;
+ j %= 7;
+ }
+
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void *cube_sphere_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_cube_sphere *x = (t_cube_sphere *)pd_new(cube_sphere_class);
+ int i, j, n=1, c;
+ t_float xx;
+
+ x->x_null = 1;
+ x->x_radius = 180;
+ if(argc <= 0)
+ {
+ n = 1;
+ x->x_null = 1;
+ x->x_n_src = n;
+ }
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ n = (int)atom_getintarg(0, argc, argv);
+ if(n <= 0)
+ x->x_null = 1;
+ else
+ x->x_null = 0;
+ if(n < 1)
+ n = 1;
+ if(n > IEMGUI_CUBE_SPHERE_MAX)
+ n = IEMGUI_CUBE_SPHERE_MAX;
+ x->x_n_src = n;
+ }
+ if((argc >= 2)&&IS_A_FLOAT(argv,1))
+ {
+ x->x_radius = atom_getintarg(1, argc, argv);
+ xx = x->x_radius / 6.0f;
+ x->x_radius = (int)(xx + 0.4999f);
+ x->x_radius *= 3;
+ if(x->x_radius < 9)
+ x->x_radius = 9;
+ if(x->x_radius > 1800)
+ x->x_radius = 1800;
+ }
+ if(argc == (3*n + 5))
+ {
+ x->x_radius = atom_getintarg(1, argc, argv);
+ x->x_fontsize = (int)atom_getintarg(2, argc, argv);
+ c = (int)atom_getintarg(3, argc, argv);
+ x->x_gui.x_bcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ c = (int)atom_getintarg(4, argc, argv);
+ x->x_gui.x_fcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ for(i=0; i<n; i++)
+ {
+ c = (int)atom_getintarg(5+3*i, argc, argv);
+ x->x_col_src[i] = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_pix_src_x[i] = (int)atom_getintarg(6+3*i, argc, argv);
+ x->x_pix_src_y[i] = (int)atom_getintarg(7+3*i, argc, argv);
+ }
+ }
+ else
+ {
+ x->x_fontsize = 12;
+ x->x_gui.x_bcol = my_iemgui_color_hex[IEM_GUI_COLNR_GREEN];
+ x->x_gui.x_fcol = my_iemgui_color_hex[IEM_GUI_COLNR_L_GREY];
+ j = 0;
+ for(i=0; i<n; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ x->x_pix_src_x[i] = x->x_radius;
+ x->x_pix_src_y[i] = x->x_radius;
+ j++;
+ j %= 7;
+ }
+ }
+
+ x->x_n_src = n;
+ for(i=0; i<n; i++)
+ x->x_vis_src[i] = 1;
+
+ x->x_90overradius = 90.0f / (t_float)x->x_radius;
+ x->x_gui.x_w = 2*x->x_radius;
+ x->x_gui.x_h = 2*x->x_radius;
+
+
+ x->x_gui.x_draw = (t_iemfunptr)cube_sphere_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+
+ x->x_out_para = outlet_new(&x->x_gui.x_obj, &s_list);
+ return (x);
+}
+
+static void cube_sphere_ff(t_cube_sphere *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void cube_sphere_setup(void)
+{
+ cube_sphere_class = class_new(gensym("cube_sphere"), (t_newmethod)cube_sphere_new,
+ (t_method)cube_sphere_ff, sizeof(t_cube_sphere), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)cube_sphere_new, gensym("cube_sphere"), A_GIMME, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_motion, gensym("motion"),
+ A_FLOAT, A_FLOAT, 0);
+ class_addbang(cube_sphere_class, (t_method)cube_sphere_bang);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_sphere_col, gensym("sphere_col"), A_DEFFLOAT, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_frame_col, gensym("frame_col"), A_DEFFLOAT, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_src_col, gensym("src_col"), A_GIMME, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_src_dp, gensym("src_dp"), A_GIMME, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_size, gensym("size"), A_DEFFLOAT, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_vis, gensym("vis"), A_GIMME, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_src_font, gensym("src_font"), A_DEFFLOAT, 0);
+ class_addmethod(cube_sphere_class, (t_method)cube_sphere_nr_src, gensym("nr_src"), A_DEFFLOAT, 0);
+
+ /* if(!iemgui_key_sym2)
+ iemgui_key_sym2 = gensym("#keyname");*/
+ cube_sphere_widgetbehavior.w_getrectfn = cube_sphere_getrect;
+ cube_sphere_widgetbehavior.w_displacefn = iemgui_displace;
+ cube_sphere_widgetbehavior.w_selectfn = iemgui_select;
+ cube_sphere_widgetbehavior.w_activatefn = NULL;
+ cube_sphere_widgetbehavior.w_deletefn = iemgui_delete;
+ cube_sphere_widgetbehavior.w_visfn = iemgui_vis;
+ cube_sphere_widgetbehavior.w_clickfn = cube_sphere_newclick;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(cube_sphere_class, cube_sphere_save);
+#else
+ cube_sphere_widgetbehavior.w_propertiesfn = NULL;
+ cube_sphere_widgetbehavior.w_savefn = cube_sphere_save;
+#endif
+
+ class_setwidget(cube_sphere_class, &cube_sphere_widgetbehavior);
+ class_sethelpsymbol(cube_sphere_class, gensym("iemhelp2/help-cube_sphere"));
+}
diff --git a/src/hfadl_scale.c b/src/hfadl_scale.c
new file mode 100644
index 0000000..c75ac57
--- /dev/null
+++ b/src/hfadl_scale.c
@@ -0,0 +1,203 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <string.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------------------ setup routine ------------------------- */
+
+t_widgetbehavior hfadl_scale_widgetbehavior;
+static t_class *hfadl_scale_class;
+
+
+typedef struct _hfadl_scale
+{
+ t_iemgui x_gui;
+ char x_gif[870];
+} t_hfadl_scale;
+
+static void hfadl_scale_draw_new(t_hfadl_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui("image create photo %xPHOTOIMAGE -format gif -data {%s} -width %d -height %d\n",
+ x, x->x_gif, x->x_gui.x_w, x->x_gui.x_h);
+ sys_vgui(".x%x.c create image %d %d -image %xPHOTOIMAGE -tags %xPHOTO\n",
+ canvas, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2-1, x, x);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos+1,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ IEM_GUI_COLOR_SELECTED, x);
+}
+
+static void hfadl_scale_draw_move(t_hfadl_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xPHOTO %d %d\n",
+ canvas, x, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2-1);
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos+1,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void hfadl_scale_draw_erase(t_hfadl_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui("image delete %xPHOTOIMAGE\n", x);
+ sys_vgui(".x%x.c delete %xPHOTO\n", canvas, x);
+}
+
+static void hfadl_scale_draw_select(t_hfadl_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos+1, xpos + x->x_gui.x_w,
+ ypos + x->x_gui.x_h, IEM_GUI_COLOR_SELECTED, x);
+ }
+ else
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+static void hfadl_scale_draw(t_hfadl_scale *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ hfadl_scale_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ hfadl_scale_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ hfadl_scale_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ hfadl_scale_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void hfadl_scale_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_hfadl_scale *x = (t_hfadl_scale *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist)+1;
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h-1;
+}
+
+static void hfadl_scale_color(t_hfadl_scale *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ x->x_gui.x_lcol = (-1 - i) & 0xffffff;
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui("%xPHOTOIMAGE configure -data {%s}\n", x, x->x_gif);
+ }
+}
+
+static void hfadl_scale_save(t_gobj *z, t_binbuf *b)
+{
+ t_hfadl_scale *x = (t_hfadl_scale *)z;
+
+ binbuf_addv(b, "ssiisi", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("hfadl_scale"), -1 - (((0xfc0000 & x->x_gui.x_lcol) >> 6)|
+ ((0xfc00 & x->x_gui.x_lcol) >> 4)|((0xfc & x->x_gui.x_lcol) >> 2)));
+ binbuf_addv(b, ";");
+}
+
+static void *hfadl_scale_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_hfadl_scale *x = (t_hfadl_scale *)pd_new(hfadl_scale_class);
+
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ {
+ j = -1 - i;
+ x->x_gui.x_lcol = ((j & 0x3f000) << 6)|((j & 0xfc0) << 4)|((j & 0x3f) << 2);
+ }
+ }
+ else
+ x->x_gui.x_lcol = 0;
+ x->x_gui.x_draw = (t_iemfunptr)hfadl_scale_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ x->x_gui.x_w = 126;
+ x->x_gui.x_h = 21;
+ strcpy(x->x_gif, my_iemgui_black_hlscale_gif);
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ x->x_gui.x_fsf.x_selected = 0;
+ return(x);
+}
+
+static void hfadl_scale_ff(t_hfadl_scale *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void hfadl_scale_setup(void)
+{
+ hfadl_scale_class = class_new(gensym("hfadl_scale"), (t_newmethod)hfadl_scale_new,
+ (t_method)hfadl_scale_ff, sizeof(t_hfadl_scale), 0, A_GIMME, 0);
+ class_addmethod(hfadl_scale_class, (t_method)hfadl_scale_color, gensym("color"), A_GIMME, 0);
+ hfadl_scale_widgetbehavior.w_getrectfn = hfadl_scale_getrect;
+ hfadl_scale_widgetbehavior.w_displacefn = iemgui_displace;
+ hfadl_scale_widgetbehavior.w_selectfn = iemgui_select;
+ hfadl_scale_widgetbehavior.w_activatefn = NULL;
+ hfadl_scale_widgetbehavior.w_deletefn = iemgui_delete;
+ hfadl_scale_widgetbehavior.w_visfn = iemgui_vis;
+ hfadl_scale_widgetbehavior.w_clickfn = NULL;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(hfadl_scale_class, hfadl_scale_save);
+#else
+ hfadl_scale_widgetbehavior.w_propertiesfn = NULL;
+ hfadl_scale_widgetbehavior.w_savefn = hfadl_scale_save;
+#endif
+
+ class_setwidget(hfadl_scale_class, &hfadl_scale_widgetbehavior);
+ class_sethelpsymbol(hfadl_scale_class, gensym("iemhelp2/help-hfadl_scale"));
+}
diff --git a/src/hfadr_scale.c b/src/hfadr_scale.c
new file mode 100644
index 0000000..edc6f1e
--- /dev/null
+++ b/src/hfadr_scale.c
@@ -0,0 +1,202 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <string.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------------------ setup routine ------------------------- */
+
+t_widgetbehavior hfadr_scale_widgetbehavior;
+static t_class *hfadr_scale_class;
+
+typedef struct _hfadr_scale
+{
+ t_iemgui x_gui;
+ char x_gif[870];
+} t_hfadr_scale;
+
+static void hfadr_scale_draw_new(t_hfadr_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui("image create photo %xPHOTOIMAGE -format gif -data {%s} -width %d -height %d\n",
+ x, x->x_gif, x->x_gui.x_w, x->x_gui.x_h);
+ sys_vgui(".x%x.c create image %d %d -image %xPHOTOIMAGE -tags %xPHOTO\n",
+ canvas, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2-1, x, x);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos-1, ypos+1,
+ xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h,
+ IEM_GUI_COLOR_SELECTED, x);
+}
+
+static void hfadr_scale_draw_move(t_hfadr_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xPHOTO %d %d\n",
+ canvas, x, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2-1);
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos-1, ypos+1,
+ xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void hfadr_scale_draw_erase(t_hfadr_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui("image delete %xPHOTOIMAGE\n", x);
+ sys_vgui(".x%x.c delete %xPHOTO\n", canvas, x);
+}
+
+static void hfadr_scale_draw_select(t_hfadr_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos-1, ypos+1, xpos + x->x_gui.x_w-1,
+ ypos + x->x_gui.x_h, IEM_GUI_COLOR_SELECTED, x);
+ }
+ else
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+static void hfadr_scale_draw(t_hfadr_scale *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ hfadr_scale_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ hfadr_scale_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ hfadr_scale_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ hfadr_scale_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void hfadr_scale_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_hfadr_scale *x = (t_hfadr_scale *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist)-1;
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist)+1;
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h-1;
+}
+
+static void hfadr_scale_color(t_hfadr_scale *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ x->x_gui.x_lcol = (-1 - i) & 0xffffff;
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui("%xPHOTOIMAGE configure -data {%s}\n", x, x->x_gif);
+ }
+}
+
+static void hfadr_scale_save(t_gobj *z, t_binbuf *b)
+{
+ t_hfadr_scale *x = (t_hfadr_scale *)z;
+
+ binbuf_addv(b, "ssiisi", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("hfadr_scale"), -1 - (((0xfc0000 & x->x_gui.x_lcol) >> 6)|
+ ((0xfc00 & x->x_gui.x_lcol) >> 4)|((0xfc & x->x_gui.x_lcol) >> 2)));
+ binbuf_addv(b, ";");
+}
+
+static void *hfadr_scale_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_hfadr_scale *x = (t_hfadr_scale *)pd_new(hfadr_scale_class);
+
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ {
+ j = -1 - i;
+ x->x_gui.x_lcol = ((j & 0x3f000) << 6)|((j & 0xfc0) << 4)|((j & 0x3f) << 2);
+ }
+ }
+ else
+ x->x_gui.x_lcol = 0;
+ x->x_gui.x_draw = (t_iemfunptr)hfadr_scale_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ x->x_gui.x_w = 126;
+ x->x_gui.x_h = 21;
+ strcpy(x->x_gif, my_iemgui_black_hrscale_gif);
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ x->x_gui.x_fsf.x_selected = 0;
+ return(x);
+}
+
+static void hfadr_scale_ff(t_hfadr_scale *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void hfadr_scale_setup(void)
+{
+ hfadr_scale_class = class_new(gensym("hfadr_scale"), (t_newmethod)hfadr_scale_new,
+ (t_method)hfadr_scale_ff, sizeof(t_hfadr_scale), 0, A_GIMME, 0);
+ class_addmethod(hfadr_scale_class, (t_method)hfadr_scale_color, gensym("color"), A_GIMME, 0);
+ hfadr_scale_widgetbehavior.w_getrectfn = hfadr_scale_getrect;
+ hfadr_scale_widgetbehavior.w_displacefn = iemgui_displace;
+ hfadr_scale_widgetbehavior.w_selectfn = iemgui_select;
+ hfadr_scale_widgetbehavior.w_activatefn = NULL;
+ hfadr_scale_widgetbehavior.w_deletefn = iemgui_delete;
+ hfadr_scale_widgetbehavior.w_visfn = iemgui_vis;
+ hfadr_scale_widgetbehavior.w_clickfn = NULL;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(hfadr_scale_class, hfadr_scale_save);
+#else
+ hfadr_scale_widgetbehavior.w_propertiesfn = NULL;
+ hfadr_scale_widgetbehavior.w_savefn = hfadr_scale_save;
+#endif
+
+ class_setwidget(hfadr_scale_class, &hfadr_scale_widgetbehavior);
+ class_sethelpsymbol(hfadr_scale_class, gensym("iemhelp2/help-hfadr_scale"));
+}
diff --git a/src/iem_event.c b/src/iem_event.c
new file mode 100644
index 0000000..3e68163
--- /dev/null
+++ b/src/iem_event.c
@@ -0,0 +1,473 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#define IEM_GUI_IVNT_COLOR_SELECTED "#0000FF"
+#define IEM_GUI_IVNT_COLOR_NORMAL "#000000"
+
+/* ---------- iem_event ---------------- */
+
+t_widgetbehavior iem_event_widgetbehavior;
+static t_class *iem_event_class;
+
+typedef struct _iem_event
+{
+ t_iemgui x_gui;
+ t_int x_x;
+ t_int x_y;
+ t_int x_doit;
+ t_symbol *x_mouse_shft_alt;
+ t_symbol *x_dragg_x_y;
+ t_symbol *x_key;
+ t_symbol *x_move_x_y;
+ t_atom x_at_out[3];
+} t_iem_event;
+
+static void iem_event_key(void *z, t_floatarg fkey);
+t_widgetbehavior iem_event_widgetbehavior;
+static t_class *iem_event_class;
+
+static void iem_event_draw_new(t_iem_event *x, t_glist *glist)
+{
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline %s -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, IEM_GUI_IVNT_COLOR_SELECTED, x);
+}
+static void iem_event_draw_move(t_iem_event *x, t_glist *glist)
+{
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+}
+
+static void iem_event_draw_erase(t_iem_event* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+static void iem_event_draw_select(t_iem_event *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline %s -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, IEM_GUI_IVNT_COLOR_SELECTED, x);
+ }
+ else
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+void iem_event_draw(t_iem_event *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ iem_event_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ iem_event_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ iem_event_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ iem_event_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void iem_event_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_iem_event *x = (t_iem_event *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void iem_event_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_event *x = (t_iem_event *)z;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ iemgui_all_sym2dollararg(&x->x_gui, srl);
+
+ binbuf_addv(b, "ssiisiiiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("ivnt"), x->x_gui.x_w, x->x_gui.x_h,
+ iem_symargstoint(&x->x_gui.x_isa), iem_fstyletoint(&x->x_gui.x_fsf),
+ srl[0], srl[1]);
+ binbuf_addv(b, ";");
+}
+#else
+static void iem_event_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_event *x = (t_iem_event *)z;
+ int *ip1, *ip2;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ iemgui_all_unique2dollarzero(&x->x_gui, srl);
+ iemgui_all_sym2dollararg(&x->x_gui, srl);
+ ip1 = (int *)(&x->x_gui.x_isa);
+ ip2 = (int *)(&x->x_gui.x_fsf);
+ binbuf_addv(b, "ssiisiiiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("ivnt"), x->x_gui.x_w, x->x_gui.x_h,
+ (*ip1)&IEM_INIT_ARGS_ALL, (*ip2)&IEM_FSTYLE_FLAGS_ALL,
+ srl[0], srl[1]);
+ binbuf_addv(b, ";");
+}
+#endif
+
+static void iem_event_motion(t_iem_event *x, t_floatarg dx, t_floatarg dy)
+{
+ x->x_x += (t_int)dx;
+ x->x_y -= (t_int)dy;
+
+ SETFLOAT(x->x_at_out, (t_float)x->x_x);
+ SETFLOAT(x->x_at_out+1, (t_float)x->x_y);
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_dragg_x_y, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_dragg_x_y, 2, x->x_at_out);
+}
+
+static void iem_event_key(void *z, t_floatarg fkey)
+{
+ t_iem_event *x = z;
+ char c = (char)fkey;
+
+ if(x->x_gui.x_fsf.x_change)
+ {
+ if((c==0))
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ }
+ else if((c=='\n')||(c==13))
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ SETFLOAT(x->x_at_out, 0.0f);
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_key, 1, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_key, 1, x->x_at_out);
+ }
+ else if((c=='\b')||(c==127))
+ {
+ SETFLOAT(x->x_at_out, 127.0f);
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_key, 1, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_key, 1, x->x_at_out);
+ }
+ else
+ {
+ SETFLOAT(x->x_at_out, fkey);
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_key, 1, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_key, 1, x->x_at_out);
+ }
+ }
+}
+
+static int iem_event_click(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_iem_event* x = (t_iem_event *)z;
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if(doit != x->x_doit)
+ {
+ SETFLOAT(x->x_at_out, (t_float)doit);
+ SETFLOAT(x->x_at_out+1, (t_float)shift);
+ SETFLOAT(x->x_at_out+2, (t_float)(alt?1:0));
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_mouse_shft_alt, 3, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_mouse_shft_alt, 3, x->x_at_out);
+ if(doit)
+ x->x_gui.x_fsf.x_change = 1;
+ x->x_doit = doit;
+ }
+
+ x->x_x = xpix - xpos;
+ x->x_y = x->x_gui.x_h - (ypix - ypos);
+ SETFLOAT(x->x_at_out, (t_float)x->x_x);
+ SETFLOAT(x->x_at_out+1, (t_float)x->x_y);
+ if(doit)
+ {
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
+ (t_glistmotionfn)iem_event_motion, iem_event_key, (t_float)xpix, (t_float)ypix);
+
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_dragg_x_y, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_dragg_x_y, 2, x->x_at_out);
+ }
+ else
+ {
+ outlet_anything(x->x_gui.x_obj.ob_outlet, x->x_move_x_y, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, x->x_move_x_y, 2, x->x_at_out);
+ }
+ return (1);
+}
+
+/*static void iem_event_bang(t_iem_event *x)
+{
+outlet_anything(x->x_gui.x_obj.ob_outlet, atom_getsymbol(x->x_matrix), x->x_n_row*x->x_n_column+2, x->x_matrix+1);
+if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+typedmess(x->x_gui.x_snd->s_thing, atom_getsymbol(x->x_matrix), x->x_n_row*x->x_n_column+2, x->x_matrix+1);
+}*/
+
+static void iem_event_delta(t_iem_event *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_event_pos(t_iem_event *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_event_size(t_iem_event *x, t_symbol *s, int ac, t_atom *av)
+{
+ int h, w;
+
+ if((ac >= 2)&&IS_A_FLOAT(av, 0) && IS_A_FLOAT(av, 1))
+ {
+ w = (int)atom_getintarg(0, ac, av);
+ if(w < 4)
+ w = 4;
+ x->x_gui.x_w = w;
+ if(ac > 1)
+ {
+ h = (int)atom_getintarg(1, ac, av);
+ if(h < 4)
+ h = 4;
+ x->x_gui.x_h = h;
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void iem_event_send(t_iem_event *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void iem_event_receive(t_iem_event *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void *iem_event_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_event *x = (t_iem_event *)pd_new(iem_event_class);
+ t_int w=32, h=32;
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ if((argc >= 6)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5)))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(3, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 4, argv);
+ }
+ else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ }
+ x->x_gui.x_draw = (t_iemfunptr)iem_event_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ if(w < 4)
+ w = 4;
+ x->x_gui.x_w = w;
+ if(h < 4)
+ h = 4;
+ x->x_gui.x_h = h;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_mouse_shft_alt = gensym("mouse_shft_alt");
+ x->x_dragg_x_y = gensym("dragg_x_y");
+ x->x_key = gensym("key");
+ x->x_move_x_y = gensym("move_x_y");
+ x->x_x = 0;
+ x->x_y = 0;
+ x->x_doit = 0;
+ return (x);
+}
+#else
+static void *iem_event_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_event *x = (t_iem_event *)pd_new(iem_event_class);
+ t_int w=32, h=32;
+ t_int iinit=0, ifstyle=0;
+ t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
+ t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
+ t_symbol *srl[3];
+ char str[144];
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ srl[0] = gensym("empty");
+ srl[1] = gensym("empty");
+ srl[2] = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ if((argc >= 6)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5)))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ iinit = (int)atom_getintarg(2, argc, argv);
+ ifstyle = (int)atom_getintarg(3, argc, argv);
+ if(IS_A_SYMBOL(argv,4))
+ srl[0] = atom_getsymbolarg(4, argc, argv);
+ else if(IS_A_FLOAT(argv,4))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(4, argc, argv));
+ srl[0] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,5))
+ srl[1] = atom_getsymbolarg(5, argc, argv);
+ else if(IS_A_FLOAT(argv,5))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(5, argc, argv));
+ srl[1] = gensym(str);
+ }
+ }
+ else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ }
+ iinit &= IEM_INIT_ARGS_ALL;
+ ifstyle &= IEM_FSTYLE_FLAGS_ALL;
+
+ x->x_gui.x_draw = (t_iemfunptr)iem_event_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ fstyle->x_snd_able = 1;
+ fstyle->x_rcv_able = 1;
+ if(!strcmp(srl[0]->s_name, "empty"))
+ fstyle->x_snd_able = 0;
+ if(!strcmp(srl[1]->s_name, "empty"))
+ fstyle->x_rcv_able = 0;
+ x->x_gui.x_unique_num = 0;
+ x->x_gui.x_fsf = *fstyle;
+ x->x_gui.x_isa = *init;
+ iemgui_first_dollararg2sym(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ if(w < 4)
+ w = 4;
+ x->x_gui.x_w = w;
+ if(h < 4)
+ h = 4;
+ x->x_gui.x_h = h;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_mouse_shft_alt = gensym("mouse_shft_alt");
+ x->x_dragg_x_y = gensym("dragg_x_y");
+ x->x_key = gensym("key");
+ x->x_move_x_y = gensym("move_x_y");
+ x->x_x = 0;
+ x->x_y = 0;
+ x->x_doit = 0;
+ return (x);
+}
+#endif
+
+static void iem_event_free(t_iem_event *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
+void iem_event_setup(void)
+{
+ iem_event_class = class_new(gensym("ivnt"), (t_newmethod)iem_event_new,
+ (t_method)iem_event_free, sizeof(t_iem_event), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_event_new, gensym("iem_event"),
+ A_GIMME, 0);
+ //class_addbang(iem_event_class,iem_event_bang);
+ class_addmethod(iem_event_class, (t_method)iem_event_motion,
+ gensym("motion"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(iem_event_class, (t_method)iem_event_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(iem_event_class, (t_method)iem_event_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(iem_event_class, (t_method)iem_event_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(iem_event_class, (t_method)iem_event_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(iem_event_class, (t_method)iem_event_receive,
+ gensym("receive"), A_DEFSYM, 0);
+
+ iem_event_widgetbehavior.w_getrectfn = iem_event_getrect;
+ iem_event_widgetbehavior.w_displacefn = iemgui_displace;
+ iem_event_widgetbehavior.w_selectfn = iemgui_select;
+ iem_event_widgetbehavior.w_activatefn = NULL;
+ iem_event_widgetbehavior.w_deletefn = iemgui_delete;
+ iem_event_widgetbehavior.w_visfn = iemgui_vis;
+ iem_event_widgetbehavior.w_clickfn = iem_event_click;
+
+#if((PD_MAJOR_VERSION)&&(PD_MINOR_VERSION < 37))
+ iem_event_widgetbehavior.w_propertiesfn = NULL;
+ iem_event_widgetbehavior.w_savefn = iem_event_save;
+#else
+ class_setsavefn(iem_event_class, iem_event_save);
+#endif
+
+ class_setwidget(iem_event_class, &iem_event_widgetbehavior);
+ class_sethelpsymbol(iem_event_class, gensym("iemhelp2/help-iem_event"));
+}
diff --git a/src/iem_image.c b/src/iem_image.c
new file mode 100644
index 0000000..c15754b
--- /dev/null
+++ b/src/iem_image.c
@@ -0,0 +1,427 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <stdio.h>
+#include <string.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------------------ setup routine ------------------------- */
+
+t_widgetbehavior iem_image_widgetbehavior;
+static t_class *iem_image_class;
+
+typedef struct _iem_image
+{
+ t_iemgui x_gui;
+ t_symbol *x_gifsym;
+ t_atom x_at_out[2];
+} t_iem_image;
+
+static t_symbol *iem_image_calc_size(t_iem_image *x)
+{
+ char dirbuf[MAXPDSTRING], *namebufptr;
+ char namebuf[MAXPDSTRING];
+ unsigned char buf[222];
+ unsigned int i;
+ char *c;
+ int fd;
+ FILE *fh;
+
+ if(!x->x_gifsym || !x->x_gifsym->s_name)
+ {
+ post("iem_image-ERROR: no gifname");
+ x->x_gifsym = (t_symbol *)0;
+ return((t_symbol *)0);
+ }
+ fd = open_via_path(canvas_getdir(glist_getcanvas(x->x_gui.x_glist))->s_name, x->x_gifsym->s_name,
+ "", dirbuf, &namebufptr, MAXPDSTRING, 1);
+ if (fd < 0)
+ {
+ post("iem_image-ERROR: cannot open %s first time", x->x_gifsym->s_name);
+ x->x_gifsym = (t_symbol *)0;
+ return((t_symbol *)0);
+ }
+ else
+ {
+ if(fd >= 0)
+ close(fd);
+ strcpy(namebuf, dirbuf);
+ strcat(namebuf, "/");
+ strcat(namebuf, namebufptr);
+ fh = fopen(namebuf, "r");
+ if(fh == NULL)
+ {
+ post("iem_image-ERROR: cannot open %s second time", namebuf);
+ x->x_gifsym = (t_symbol *)0;
+ return((t_symbol *)0);
+ }
+ else
+ {
+ fread(buf, 22, sizeof(unsigned char), fh);
+ fclose(fh);
+ c = (char *)buf;
+ if((c[0] != 'G')||(c[1] != 'I')||(c[2] != 'F'))
+ {
+ post("iem_image-ERROR: %s is not a GIF-file", namebuf);
+ x->x_gifsym = (t_symbol *)0;
+ return((t_symbol *)0);
+ }
+ i = 256*(unsigned int)buf[7];
+ i += (unsigned int)buf[6];
+ x->x_gui.x_w = (int)i;
+ i = 256*(unsigned int)buf[9];
+ i += (unsigned int)buf[8];
+ x->x_gui.x_h = (int)i;
+ SETFLOAT(x->x_at_out, (t_float)x->x_gui.x_w);
+ SETFLOAT(x->x_at_out+1, (t_float)x->x_gui.x_h);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at_out);
+ return(gensym(namebuf));
+ }
+ }
+}
+
+static void iem_image_draw_new(t_iem_image *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+ t_symbol *correct_name;
+
+ if(correct_name = iem_image_calc_size(x))
+ {
+ sys_vgui("image create photo %xPHOTOIMAGE -file {%s} -format gif -width %d -height %d\n",
+ x, correct_name->s_name, x->x_gui.x_w, x->x_gui.x_h);
+ sys_vgui(".x%x.c create image %d %d -image %xPHOTOIMAGE -tags %xPHOTO\n",
+ canvas, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2, x, x);
+ }
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, IEM_GUI_COLOR_SELECTED, x);
+}
+
+static void iem_image_draw_move(t_iem_image *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gifsym)
+ sys_vgui(".x%x.c coords %xPHOTO %d %d\n", canvas, x, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2);
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void iem_image_draw_erase(t_iem_image* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ if(x->x_gifsym)
+ {
+ sys_vgui("image delete %xPHOTOIMAGE\n", x);
+ sys_vgui(".x%x.c delete %xPHOTO\n", canvas, x);
+ }
+}
+
+static void iem_image_draw_select(t_iem_image* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w,
+ ypos + x->x_gui.x_h, IEM_GUI_COLOR_SELECTED, x);
+ }
+ else
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+static void iem_image_draw(t_iem_image *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ iem_image_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ iem_image_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ iem_image_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ iem_image_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void iem_image_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_iem_image *x = (t_iem_image *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void iem_image_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_image *x = (t_iem_image *)z;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ if(x->x_gifsym)
+ binbuf_addv(b, "ssiissiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_image"), x->x_gifsym, iem_symargstoint(&x->x_gui.x_isa),
+ iem_fstyletoint(&x->x_gui.x_fsf), srl[0], srl[1]);
+ else
+ binbuf_addv(b, "ssiisiiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_image"), 0, iem_symargstoint(&x->x_gui.x_isa),
+ iem_fstyletoint(&x->x_gui.x_fsf), srl[0], srl[1]);
+ binbuf_addv(b, ";");
+}
+#else
+static void iem_image_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_image *x = (t_iem_image *)z;
+ int *ip1, *ip2;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ iemgui_all_unique2dollarzero(&x->x_gui, srl);
+ iemgui_all_sym2dollararg(&x->x_gui, srl);
+ ip1 = (int *)(&x->x_gui.x_isa);
+ ip2 = (int *)(&x->x_gui.x_fsf);
+ if(x->x_gifsym)
+ binbuf_addv(b, "ssiissiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_image"), x->x_gifsym, (*ip1)&IEM_INIT_ARGS_ALL,
+ (*ip2)&IEM_FSTYLE_FLAGS_ALL, srl[0], srl[1]);
+ else
+ binbuf_addv(b, "ssiisiiiss", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_image"), 0, (*ip1)&IEM_INIT_ARGS_ALL,
+ (*ip2)&IEM_FSTYLE_FLAGS_ALL, srl[0], srl[1]);
+ binbuf_addv(b, ";");
+}
+#endif
+
+static void iem_image_clear(t_iem_image *x)
+{
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_gifsym = (t_symbol *)0;
+}
+
+static void iem_image_open(t_iem_image *x, t_symbol *name)
+{
+ if(name && name->s_name)
+ {
+ if(x->x_gifsym)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_gifsym = (t_symbol *)0;
+ }
+ x->x_gifsym = name;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void iem_image_delta(t_iem_image *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_image_pos(t_iem_image *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_image_send(t_iem_image *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void iem_image_receive(t_iem_image *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void *iem_image_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_image *x = (t_iem_image *)pd_new(iem_image_class);
+ t_symbol *gifsym=(t_symbol *)0;
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ if(argc >= 1)
+ {
+ if(IS_A_SYMBOL(argv,0))
+ gifsym = atom_getsymbolarg(0, argc, argv);
+ else if(IS_A_FLOAT(argv,0))
+ gifsym = (t_symbol *)0;
+ }
+ else if(argc >= 5)
+ {
+ if(IS_A_SYMBOL(argv,0))
+ gifsym = atom_getsymbolarg(0, argc, argv);
+ else if(IS_A_FLOAT(argv,0))
+ gifsym = (t_symbol *)0;
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv));
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(2, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 3, argv);
+ }
+
+ x->x_gui.x_draw = (t_iemfunptr)iem_image_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_w = 100;
+ x->x_gui.x_h = 60;
+ x->x_gifsym = gifsym;
+ x->x_gui.x_fsf.x_selected = 0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ return(x);
+}
+#else
+static void *iem_image_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_image *x = (t_iem_image *)pd_new(iem_image_class);
+ t_symbol *gifsym=(t_symbol *)0;
+ t_int iinit=0, ifstyle=0;
+ t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
+ t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
+ t_symbol *srl[3];
+ char str[144];
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ srl[0] = gensym("empty");
+ srl[1] = gensym("empty");
+ srl[2] = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ if(argc >= 1)
+ {
+ if(IS_A_SYMBOL(argv,0))
+ gifsym = atom_getsymbolarg(0, argc, argv);
+ else if(IS_A_FLOAT(argv,0))
+ gifsym = (t_symbol *)0;
+ }
+ else if(argc >= 5)
+ {
+ if(IS_A_SYMBOL(argv,0))
+ gifsym = atom_getsymbolarg(0, argc, argv);
+ else if(IS_A_FLOAT(argv,0))
+ gifsym = (t_symbol *)0;
+ iinit = (int)atom_getintarg(1, argc, argv);
+ ifstyle = (int)atom_getintarg(2, argc, argv);
+ if(IS_A_SYMBOL(argv, 3))
+ srl[0] = atom_getsymbolarg(3, argc, argv);
+ else if(IS_A_FLOAT(argv,3))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(3, argc, argv));
+ srl[0] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,4))
+ srl[1] = atom_getsymbolarg(4, argc, argv);
+ else if(IS_A_FLOAT(argv,4))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(4, argc, argv));
+ srl[1] = gensym(str);
+ }
+ }
+
+ iinit &= IEM_INIT_ARGS_ALL;
+ ifstyle &= IEM_FSTYLE_FLAGS_ALL;
+ x->x_gui.x_draw = (t_iemfunptr)iem_image_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ fstyle->x_snd_able = 1;
+ fstyle->x_rcv_able = 1;
+ if(!strcmp(srl[0]->s_name, "empty"))
+ fstyle->x_snd_able = 0;
+ if(!strcmp(srl[1]->s_name, "empty"))
+ fstyle->x_rcv_able = 0;
+ x->x_gui.x_unique_num = 0;
+ x->x_gui.x_fsf = *fstyle;
+ x->x_gui.x_isa = *init;
+ iemgui_first_dollararg2sym(&x->x_gui, sr);
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_w = 100;
+ x->x_gui.x_h = 60;
+ x->x_gifsym = gifsym;
+ x->x_gui.x_fsf.x_selected = 0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ return(x);
+}
+#endif
+
+static void iem_image_ff(t_iem_image *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void iem_image_setup(void)
+{
+ iem_image_class = class_new(gensym("iem_image"), (t_newmethod)iem_image_new,
+ (t_method)iem_image_ff, sizeof(t_iem_image), 0, A_GIMME, 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_open, gensym("open"), A_SYMBOL, 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_clear, gensym("clear"), 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(iem_image_class, (t_method)iem_image_receive,
+ gensym("receive"), A_DEFSYM, 0);
+
+ iem_image_widgetbehavior.w_getrectfn = iem_image_getrect;
+ iem_image_widgetbehavior.w_displacefn = iemgui_displace;
+ iem_image_widgetbehavior.w_selectfn = iemgui_select;
+ iem_image_widgetbehavior.w_activatefn = NULL;
+ iem_image_widgetbehavior.w_deletefn = iemgui_delete;
+ iem_image_widgetbehavior.w_visfn = iemgui_vis;
+ iem_image_widgetbehavior.w_clickfn = NULL;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(iem_image_class, iem_image_save);
+#else
+ iem_image_widgetbehavior.w_propertiesfn = NULL;
+ iem_image_widgetbehavior.w_savefn = iem_image_save;
+#endif
+
+ class_setwidget(iem_image_class, &iem_image_widgetbehavior);
+ class_sethelpsymbol(iem_image_class, gensym("iemhelp2/help-iem_image"));
+
+ // post("iem_image library loaded!");
+}
diff --git a/src/iem_vu.c b/src/iem_vu.c
new file mode 100644
index 0000000..ec78e2e
--- /dev/null
+++ b/src/iem_vu.c
@@ -0,0 +1,837 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------------------ setup routine ------------------------- */
+
+t_widgetbehavior iem_vu_widgetbehavior;
+static t_class *iem_vu_class;
+
+static int iem_vu_db2i[]=
+{
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 9, 9, 9, 9, 9,10,10,10,10,10,
+ 11,11,11,11,11,12,12,12,12,12,
+ 13,13,13,13,14,14,14,14,15,15,
+ 15,15,16,16,16,16,17,17,17,18,
+ 18,18,19,19,19,20,20,20,21,21,
+ 22,22,23,23,24,24,25,26,27,28,
+ 29,30,31,32,33,33,34,34,35,35,
+ 36,36,37,37,37,38,38,38,39,39,
+ 39,39,39,39,40,40
+};
+
+static int iem_vu_col[]=
+{
+ 0,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+ 15,15,15,15,15,15,15,15,15,15,14,14,13,13,13,13,13,13,13,13,13,13,13,19,19,19
+};
+
+typedef struct _iem_vu
+{
+ t_iemgui x_gui;
+ int x_peak;
+ int x_rms;
+ t_float x_fp;
+ t_float x_fr;
+ short x_scale;
+ short x_old_width;
+ int x_scale_w;
+ int x_scale_h;
+ void *x_out_rms;
+ void *x_out_peak;
+ char x_scale_gif[750];
+ char x_bkgd_gif_bord[990];
+ char x_bkgd_gif_cent[990];
+} t_iem_vu;
+
+static int iem_vu_clip_width(int w)
+{
+ if(w < 8)
+ w = 8;
+ w &= 0xffffffc;
+ return(w);
+}
+
+static void iem_vu_update_rms(t_iem_vu *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ int ypos1=text_ypix(&x->x_gui.x_obj, glist)-1;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c coords %xRCOVER %d %d %d %d\n",
+ glist_getcanvas(glist), x, xpos, ypos1, xpos+x->x_gui.x_w-1,
+ ypos1 + 3*(IEM_VU_STEPS-x->x_rms));
+ }
+}
+
+static void iem_vu_update_peak(t_iem_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(glist_isvisible(glist))
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if(x->x_peak)
+ {
+ int i=iem_vu_col[x->x_peak];
+ int j=ypos + 3*(IEM_VU_STEPS+1-x->x_peak) - 1;
+
+ sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x,
+ xpos, j, xpos+x->x_gui.x_w, j);
+ sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x, my_iemgui_color_hex[i]);
+ }
+ else
+ {
+ int mid=xpos+x->x_gui.x_w/2;
+
+ sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+ sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n",
+ canvas, x, mid, ypos+20, mid, ypos+20);
+ }
+ }
+}
+
+static void iem_vu_cpy(char *src, char *dst, int n)
+{
+ while(n--)
+ *dst++ = *src++;
+}
+
+static void iem_vu_change_bkgd_col(t_iem_vu *x)
+{
+ int i, j;
+ char pix_bkgd_col[10];
+ char pix_led_col[10];
+ char *cvec;
+
+ sprintf(pix_bkgd_col, "#%6.6x ", x->x_gui.x_bcol);
+ cvec = x->x_bkgd_gif_bord;
+ for(i=0; i<122; i++)
+ {
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec += 8;
+ }
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec[7] = 0;
+
+ cvec = x->x_bkgd_gif_cent;
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec += 8;
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec += 8;
+ for(i=IEM_VU_STEPS; i>=1; i--)
+ {
+ j = iem_vu_col[i];
+ sprintf(pix_led_col, "#%6.6x ", my_iemgui_color_hex[j]);
+ iem_vu_cpy(pix_led_col, cvec, 8);
+ cvec += 8;
+ iem_vu_cpy(pix_led_col, cvec, 8);
+ cvec += 8;
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec += 8;
+ }
+ iem_vu_cpy(pix_bkgd_col, cvec, 8);
+ cvec[7] = 0;
+
+ sys_vgui("%xBKGDIMAGE_PROTO put {%s} -to 0 0\n", x, x->x_bkgd_gif_bord);
+ sys_vgui("%xBKGDIMAGE_PROTO put {%s} -to 1 0\n", x, x->x_bkgd_gif_cent);
+ sys_vgui("%xBKGDIMAGE_PROTO put {%s} -to 2 0\n", x, x->x_bkgd_gif_cent);
+ sys_vgui("%xBKGDIMAGE_PROTO put {%s} -to 3 0\n", x, x->x_bkgd_gif_bord);
+}
+
+static void iem_vu_draw_new(t_iem_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int mid=xpos+x->x_gui.x_w/2;
+ int zoom=x->x_gui.x_w/4;
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xBASE\n",
+ canvas, xpos-1, ypos-2, xpos+x->x_gui.x_w, ypos+x->x_gui.x_h+2, x);
+
+ sys_vgui("image create photo %xBKGDIMAGE_PROTO -format gif -width %d -height %d\n",
+ x, 5, 123);
+ sys_vgui("%xBKGDIMAGE_PROTO blank\n", x);
+ iem_vu_change_bkgd_col(x);
+
+ sys_vgui("image create photo %xBKGDIMAGE -format gif -width %d -height %d\n",
+ x, x->x_gui.x_w, x->x_gui.x_h+3);
+ sys_vgui("%xBKGDIMAGE blank\n", x);
+ sys_vgui("%xBKGDIMAGE copy %xBKGDIMAGE_PROTO -zoom %d 1\n", x, x, zoom);
+ sys_vgui(".x%x.c create image %d %d -image %xBKGDIMAGE -tags %xBKGDPHOTO\n",
+ canvas, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2, x, x);
+
+ sys_vgui("image create photo %xSCALEIMAGE -format gif -width %d -height %d\n",
+ x, x->x_scale_w, x->x_scale_h);
+ sys_vgui("%xSCALEIMAGE blank\n", x);
+ if(x->x_scale)
+ {
+ sys_vgui(".x%x.c create image %d %d -image %xSCALEIMAGE -tags %xSCALEPHOTO\n",
+ canvas, xpos+x->x_gui.x_w+x->x_scale_w/2+2, ypos+x->x_gui.x_h/2+2, x, x);
+ my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol);
+ sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif);
+ }
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xRCOVER\n",
+ canvas, xpos, ypos-1, xpos+x->x_gui.x_w-1,
+ ypos-1 + 3*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x);
+ sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xPLED\n",
+ canvas, mid, ypos+10, mid, ypos+10, 2, x->x_gui.x_bcol, x);
+ sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
+ -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas, xpos-1, ypos + x->x_gui.x_h+1,
+ xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2, x, 0);
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas, xpos+x->x_gui.x_w-IOWIDTH, ypos + x->x_gui.x_h+1,
+ xpos+x->x_gui.x_w, ypos + x->x_gui.x_h+2, x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas, xpos-1, ypos-2, xpos + IOWIDTH-1, ypos-1, x, 0);
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas, xpos+x->x_gui.x_w-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w, ypos-1, x, 1);
+ }
+}
+
+static void iem_vu_draw_move(t_iem_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos-1, ypos-2, xpos+x->x_gui.x_w,ypos+x->x_gui.x_h+2);
+ sys_vgui(".x%x.c coords %xBKGDPHOTO %d %d\n",
+ canvas, x, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2);
+ if(x->x_scale)
+ {
+ sys_vgui(".x%x.c coords %xSCALEPHOTO %d %d\n",
+ canvas, x, xpos+x->x_gui.x_w+x->x_scale_w/2+2, ypos+x->x_gui.x_h/2+2);
+ }
+ iem_vu_update_peak(x, glist);
+ iem_vu_update_rms(x, glist);
+ sys_vgui(".x%x.c coords %xLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
+ canvas, x, 0, xpos-1, ypos + x->x_gui.x_h+1,
+ xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2);
+ sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
+ canvas, x, 1,xpos+x->x_gui.x_w-IOWIDTH, ypos + x->x_gui.x_h+1,
+ xpos+x->x_gui.x_w, ypos + x->x_gui.x_h+2);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
+ canvas, x, 0, xpos-1, ypos-2,
+ xpos + IOWIDTH-1, ypos-1);
+ sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
+ canvas, x, 1, xpos+x->x_gui.x_w-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w, ypos-1);
+ }
+}
+
+static void iem_vu_draw_erase(t_iem_vu* x,t_glist* glist)
+{
+ int i;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui(".x%x.c delete %xBKGDPHOTO\n", canvas, x);
+ sys_vgui("image delete %xBKGDIMAGE\n", x);
+ sys_vgui("image delete %xBKGDIMAGE_PROTO\n", x);
+ if(x->x_scale)
+ sys_vgui(".x%x.c delete %xSCALEPHOTO\n", canvas, x);
+ sys_vgui("image delete %xSCALEIMAGE\n", x);
+
+ sys_vgui(".x%x.c delete %xPLED\n", canvas, x);
+ sys_vgui(".x%x.c delete %xRCOVER\n", canvas, x);
+ sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
+ }
+}
+
+static void iem_vu_draw_config(t_iem_vu* x, t_glist* glist)
+{
+ int i, zoom = x->x_gui.x_w / 4;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ iem_vu_change_bkgd_col(x);
+ if(x->x_gui.x_w != x->x_old_width)
+ {
+ x->x_old_width = x->x_gui.x_w;
+ sys_vgui("%xBKGDIMAGE blank\n", x);
+ sys_vgui("%xBKGDIMAGE configure -width %d -height %d\n",
+ x, x->x_gui.x_w, x->x_gui.x_h+3);
+ }
+ sys_vgui("%xBKGDIMAGE copy %xBKGDIMAGE_PROTO -zoom %d 1\n", x, x, zoom);
+
+ my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol);
+ sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif);
+
+ sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+
+ sys_vgui(".x%x.c itemconfigure %xRCOVER -fill #%6.6x -outline #%6.6x\n",
+ canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol);
+ sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x, 2);
+}
+
+static void iem_vu_draw_io(t_iem_vu* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas, xpos-1, ypos-2, xpos + IOWIDTH-1, ypos-1, x, 0);
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas, xpos+x->x_gui.x_w-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w, ypos-1, x, 1);
+ }
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
+ }
+}
+
+static void iem_vu_draw_select(t_iem_vu* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ if(x->x_scale)
+ {
+ my_iemgui_change_scale_col(x->x_scale_gif, IEM_GUI_COLOR_SELECTED);
+ sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif);
+ }
+ sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ if(x->x_scale)
+ {
+ my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol);
+ sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif);
+ }
+ sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void iem_vu_draw(t_iem_vu *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ iem_vu_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ iem_vu_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ iem_vu_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ iem_vu_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ iem_vu_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ iem_vu_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ vu widgetbehaviour----------------------------- */
+
+
+static void iem_vu_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_iem_vu* x = (t_iem_vu*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 1;
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
+ *xp2 = *xp1 + x->x_gui.x_w + 2;
+ *yp2 = *yp1 + x->x_gui.x_h + 4;
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void iem_vu_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_vu *x = (t_iem_vu *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_vu"), /*x->x_gui.x_w+1*/ x->x_gui.x_w, 120,
+ srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[2], x->x_scale, iem_symargstoint(&x->x_gui.x_isa));
+ binbuf_addv(b, ";");
+}
+#else
+static void iem_vu_save(t_gobj *z, t_binbuf *b)
+{
+ t_iem_vu *x = (t_iem_vu *)z;
+ int bflcol[3], *ip1, *ip2;
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ ip1 = (int *)(&x->x_gui.x_isa);
+ ip2 = (int *)(&x->x_gui.x_fsf);
+ binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("iem_vu"), /*x->x_gui.x_w+1*/ x->x_gui.x_w, 120,
+ srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ (*ip2)&IEM_FSTYLE_FLAGS_ALL, x->x_gui.x_fontsize,
+ bflcol[0], bflcol[2], x->x_scale, (*ip1)&IEM_INIT_ARGS_ALL);
+ binbuf_addv(b, ";");
+}
+#endif
+
+static void iem_vu_scale(t_iem_vu *x, t_floatarg fscale)
+{
+ int i, scale = (int)fscale;
+
+ if(scale != 0)
+ scale = 1;
+ if(x->x_scale && !scale)
+ {
+ x->x_scale = scale;
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ sys_vgui(".x%x.c delete %xSCALEPHOTO\n", canvas, x);
+ }
+ }
+ if(!x->x_scale && scale)
+ {
+ x->x_scale = scale;
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+
+ sys_vgui(".x%x.c create image %d %d -image %xSCALEIMAGE -tags %xSCALEPHOTO\n",
+ canvas, xpos+x->x_gui.x_w+x->x_scale_w/2+3, ypos+x->x_gui.x_h/2+2, x, x);
+ my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol);
+ sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif);
+ }
+ }
+}
+
+static void iem_vu_properties(t_gobj *z, t_glist *owner)
+{
+ t_iem_vu *x = (t_iem_vu *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s IEM_VU-METER \
+ --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
+ empty 0.0 empty 0.0 empty %d \
+ %d no_scale scale %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE, 120, 80,
+ 0,/*no_schedule*/
+ x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/
+ "nosndno", srl[1]->s_name,/*no send*/
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+void iem_vu_dialog(t_iem_vu *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int scale = (int)atom_getintarg(4, argc, argv);
+ int sr_flags;
+
+ srl[0] = gensym("empty");
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ // post("srl-flag = %x", sr_flags);
+ x->x_gui.x_fsf.x_snd_able = 0;
+ x->x_gui.x_isa.x_loadinit = 0;
+ x->x_gui.x_w = iem_vu_clip_width(w+1);
+ x->x_gui.x_h = 120;
+ if(scale != 0)
+ scale = 1;
+ iem_vu_scale(x, (t_float)scale);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void iem_vu_size(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iem_vu_clip_width((int)atom_getintarg(0, ac, av)+1);
+ x->x_gui.x_h = 120;
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void iem_vu_delta(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_vu_pos(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_vu_color(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_vu_receive(t_iem_vu *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void iem_vu_label(t_iem_vu *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void iem_vu_label_pos(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_vu_label_font(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void iem_vu_float(t_iem_vu *x, t_floatarg rms)
+{
+ int i;
+
+ if(rms <= IEM_VU_MINDB)
+ x->x_rms = 0;
+ else if(rms >= IEM_VU_MAXDB)
+ x->x_rms = IEM_VU_STEPS;
+ else
+ {
+ int i = (int)(2.0*(rms + IEM_VU_OFFSET));
+ x->x_rms = iem_vu_db2i[i];
+ }
+ i = (int)(100.0*rms + 10000.5);
+ rms = 0.01*(t_float)(i - 10000);
+ x->x_fr = rms;
+ outlet_float(x->x_out_rms, rms);
+ iem_vu_update_rms(x, x->x_gui.x_glist);
+}
+
+static void iem_vu_ft1(t_iem_vu *x, t_floatarg peak)
+{
+ int i;
+
+ if(peak <= IEM_VU_MINDB)
+ x->x_peak = 0;
+ else if(peak >= IEM_VU_MAXDB)
+ x->x_peak = IEM_VU_STEPS;
+ else
+ {
+ int i = (int)(2.0*(peak + IEM_VU_OFFSET));
+ x->x_peak = iem_vu_db2i[i];
+ }
+ i = (int)(100.0*peak + 10000.5);
+ peak = 0.01*(t_float)(i - 10000);
+ x->x_fp = peak;
+ outlet_float(x->x_out_peak, peak);
+ iem_vu_update_peak(x, x->x_gui.x_glist);
+}
+
+static void iem_vu_bang(t_iem_vu *x)
+{
+ outlet_float(x->x_out_peak, x->x_fp);
+ outlet_float(x->x_out_rms, x->x_fr);
+ iem_vu_update_rms(x, x->x_gui.x_glist);
+ iem_vu_update_peak(x, x->x_gui.x_glist);
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void *iem_vu_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_vu *x = (t_iem_vu *)pd_new(iem_vu_class);
+ int bflcol[]={-66577, -1, -1};
+ int w=IEM_GUI_DEFAULTSIZE;
+ int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
+ &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
+ &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ iemgui_new_getnames(&x->x_gui, 1, argv);
+ ldx = (int)atom_getintarg(4, argc, argv);
+ ldy = (int)atom_getintarg(5, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
+ fs = (int)atom_getintarg(7, argc, argv);
+ bflcol[0] = (int)atom_getintarg(8, argc, argv);
+ bflcol[2] = (int)atom_getintarg(9, argc, argv);
+ scale = (int)atom_getintarg(10, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 1, 0);
+ if((argc == 12)&&IS_A_FLOAT(argv,11))
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
+ x->x_gui.x_draw = (t_iemfunptr)iem_vu_draw;
+
+ x->x_gui.x_fsf.x_snd_able = 0;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if (x->x_gui.x_fsf.x_font_style == 1)
+ strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, "courier"); }
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ // x->x_gui.x_w = iem_vu_clip_width(w)-1;
+ x->x_gui.x_w = iem_vu_clip_width(w+1);
+ x->x_old_width = x->x_gui.x_w;
+ x->x_gui.x_h = 120;
+
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ if(scale != 0)
+ scale = 1;
+ x->x_scale = scale;
+ x->x_peak = 0;
+ x->x_rms = 0;
+ x->x_fp = -101.0;
+ x->x_fr = -101.0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
+ x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_scale_w = 14;
+ x->x_scale_h = 129;
+ strcpy(x->x_scale_gif, my_iemgui_black_vscale_gif);
+ x->x_gui.x_fsf.x_selected = 0;
+ return (x);
+}
+#else
+static void *iem_vu_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_vu *x = (t_iem_vu *)pd_new(iem_vu_class);
+ int bflcol[]={-66577, -1, -1};
+ t_symbol *srl[3];
+ int w=IEM_GUI_DEFAULTSIZE;
+ int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
+ int iinit=0, ifstyle=0;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
+ t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
+ char str[144];
+
+ srl[0] = gensym("empty");
+ srl[1] = gensym("empty");
+ srl[2] = gensym("empty");
+
+ if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
+ &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
+ &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ if(IS_A_SYMBOL(argv,2))
+ srl[1] = atom_getsymbolarg(2, argc, argv);
+ else if(IS_A_FLOAT(argv,2))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(2, argc, argv));
+ srl[1] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,3))
+ srl[2] = atom_getsymbolarg(3, argc, argv);
+ else if(IS_A_FLOAT(argv,3))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(3, argc, argv));
+ srl[2] = gensym(str);
+ }
+ ldx = (int)atom_getintarg(4, argc, argv);
+ ldy = (int)atom_getintarg(5, argc, argv);
+ ifstyle = (int)atom_getintarg(6, argc, argv);
+ fs = (int)atom_getintarg(7, argc, argv);
+ bflcol[0] = (int)atom_getintarg(8, argc, argv);
+ bflcol[2] = (int)atom_getintarg(9, argc, argv);
+ scale = (int)atom_getintarg(10, argc, argv);
+ }
+ if((argc == 12)&&IS_A_FLOAT(argv,11))
+ iinit = (int)atom_getintarg(11, argc, argv);
+ x->x_gui.x_draw = (t_iemfunptr)iem_vu_draw;
+ iinit &= IEM_INIT_ARGS_ALL;
+ ifstyle &= IEM_FSTYLE_FLAGS_ALL;
+
+ fstyle->x_snd_able = 0;
+ fstyle->x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ x->x_gui.x_isa = *init;
+ if(!strcmp(srl[1]->s_name, "empty")) fstyle->x_rcv_able = 0;
+ x->x_gui.x_unique_num = 0;
+ if(fstyle->x_font_style == 1)
+ strcpy(x->x_gui.x_font, "helvetica");
+ else if(fstyle->x_font_style == 2)
+ strcpy(x->x_gui.x_font, "times");
+ else
+ {
+ fstyle->x_font_style = 0;
+ strcpy(x->x_gui.x_font, "courier");
+ }
+ x->x_gui.x_fsf = *fstyle;
+ iemgui_first_dollararg2sym(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, srl[1]);
+ x->x_gui.x_snd = srl[0];
+ x->x_gui.x_rcv = srl[1];
+ x->x_gui.x_lab = srl[2];
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ // x->x_gui.x_w = iem_vu_clip_width(w)-1;
+ x->x_gui.x_w = iem_vu_clip_width(w+1);
+ x->x_old_width = x->x_gui.x_w;
+ x->x_gui.x_h = 120;
+
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ if(scale != 0)
+ scale = 1;
+ x->x_scale = scale;
+ x->x_peak = 0;
+ x->x_rms = 0;
+ x->x_fp = -101.0;
+ x->x_fr = -101.0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
+ x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_scale_w = 14;
+ x->x_scale_h = 129;
+ strcpy(x->x_scale_gif, my_iemgui_black_vscale_gif);
+ x->x_gui.x_fsf.x_selected = 0;
+ return (x);
+}
+#endif
+
+static void iem_vu_free(t_iem_vu *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
+void iem_vu_setup(void)
+{
+ iem_vu_class = class_new(gensym("iem_vu"), (t_newmethod)iem_vu_new, (t_method)iem_vu_free,
+ sizeof(t_iem_vu), 0, A_GIMME, 0);
+ class_addbang(iem_vu_class, iem_vu_bang);
+ class_addfloat(iem_vu_class, iem_vu_float);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_scale, gensym("scale"), A_DEFFLOAT, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(iem_vu_class, (t_method)iem_vu_label_font, gensym("label_font"), A_GIMME, 0);
+ iem_vu_widgetbehavior.w_getrectfn = iem_vu_getrect;
+ iem_vu_widgetbehavior.w_displacefn = iemgui_displace;
+ iem_vu_widgetbehavior.w_selectfn = iemgui_select;
+ iem_vu_widgetbehavior.w_activatefn = NULL;
+ iem_vu_widgetbehavior.w_deletefn = iemgui_delete;
+ iem_vu_widgetbehavior.w_visfn = iemgui_vis;
+ iem_vu_widgetbehavior.w_clickfn = NULL;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(iem_vu_class, iem_vu_save);
+ class_setpropertiesfn(iem_vu_class, iem_vu_properties);
+#else
+ iem_vu_widgetbehavior.w_propertiesfn = iem_vu_properties;
+ iem_vu_widgetbehavior.w_savefn = iem_vu_save;
+#endif
+
+ class_setwidget(iem_vu_class, &iem_vu_widgetbehavior);
+ class_sethelpsymbol(iem_vu_class, gensym("iemhelp2/help-iem_vu"));
+}
diff --git a/src/iemgui.c b/src/iemgui.c
new file mode 100644
index 0000000..7e7a963
--- /dev/null
+++ b/src/iemgui.c
@@ -0,0 +1,113 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+
+char my_iemgui_black_vscale_gif[]="R0lGODlhDgCCAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAOAIIAAAL/hI+pa0EBICIIdkRYBCEBgIigEHbEBQSFsCPOIghGxF0EwQkzg6AAEQTfIoxiE3xMvQgK4WMERBDsuIg7owAQEQEEgGKDgRHsuAgICmHHRUBQCB8jguBj6nL7AxITPkZABMGOu4gzCuFHHMUGACP4cRBxByQARBB8NIpN8DF1uf1JTPgYAREE/yIgguBfBEQQjIiwCEJC8C8CIgj+RUAEwceIIPiYutz+gMSEjxEQQfDRIjKNEgCABRCACIKPEJEJlBA+GsUm+Ji63P4kJnyMgAiCfxGISHEIdkRYBCEh+BcBEQT/IiCC4GNEEHxMXW5fkgDAgmBHhEUQEgCICAph5UdcQFAIO+IsgmBE3EUQnDAzCAoQQfAtwig2wcfU5fYkMQAsAAhIQAQEBQmCHwERQAnhR0AEUELYERYBlAAADICQQAQAUAIAMDCCGRvgCD6mLrcriQFgAUBAAiIgKEgQ/AiIAEoIO8IigBLCj4AIoITwIyACKAGAgQElMAAAC4ITQfAxdbldSRyAI9gRFwGUAMAAgJBABABQHAADAwICEAFBQYLgR0AEUAIAAwNKYAAAFgQnguBj6nL7OxIHLgCAkABEBBASAIgAQhIAEUBAAiAiCEgYRBjFAAMAoDhwQfAxdbkdSQEAOw==";
+char my_iemgui_black_hlscale_gif[]="R0lGODlhgwAaAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAACDABoAAAL/hI+py+0Po5y02ouz3rz7D4biKBIJ4WPqcvsDkhD+RQQiUEz4FxGBiAgZEhM+pi63P4kJ3yIgguBDBEQQfItARMRD4hB8CMQLgo8QmZmZDolD8BEiMikhfIhAREREggTBh0C8IPgIkZmZ6ZAgQfARIhIpIXyLiEBEhBBJCJtiE3yg2AQfKDbBt4hABIoJHyMQjRLCR4hIowARBB8iAhGBJIQPgXhB8BEiMzNTIgnhXwQiUkL4GIGIiIckhA+BeEHwESIzM1MiCeFbBKJRAiP4EAERBB9TLYLgY+py+wOSEL5RbIJvEYEIFBM+pi63P4xy0gpITPgRcXcUE/5FBCJQ/0z4FxGIQDHhX0QgAsWEfxGBiIgMSWAAAEZICD5EQATBhwiIIPgQAREEHyIgguBDBEQQfIiACIIPERBB8CECIgh2RAQEJSH4GIERBB8vIo0SGMHHCLygED5eRBolMIIPERBB8CECIghGhEUEAQkzM6AEAGBG8BEi0iiBEXyMwAtKQvARItIogRF8iIAIgg8REEEwIiwiCEiYmQWFsCMg4u5IQvgWAREE/yIQg4IEwb8IxKAgQfAhAiIIPkRABMGIsIggIGFmEBTCj4CIOyMJ4V8ERBB8i0AESmAE3yIQgRIYwYcIiCD4EAERBCPCIoKAhJlFEHyIgAiCDxGIRgmM4FVDBKJRAiP4EIFolMAIPkRABMGHCIgg2BEREJSE4APFJtgRcWcUm+BbRCBSbIJvEYFIsQm+RQQiUEz4FxEEH1OX2x9GOWm1F2e9efcfDMWRLM0TfYgCADs=";
+char my_iemgui_black_hrscale_gif[]="R0lGODlhhgAbAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAACGABsAAAL/hI+py+0Po5y02ouz3rz7D4biSG5EHIJvEYEIFBM+RhB8TF1uf0ASwsfUjCD4FwERBB8iIILgW0QQfExdbn8SEz6mYgTBx4vIpITwISICERFCCBkSwkeITKAQfkQEwcdUjKCE8DEC8SghfAiIQESEEEKGhPARIhMohB8QcXd3SEz4EBaBaCQh/ItANEoI/yICESgmfKPYBB8oNsEHik3wIwg+pm4EwccIxKAQPkJEZmZKiITwESITKIRvEYiIiABJYAQfIiCC4EMEIlJC+Ji6GgQfITKBQvgWgYiIyJCY8C8iECk2wb8Igo+py+0PSEL4mLrc/jDKSesiMeFfRCAC/8WEfxGBCBQT/kUEIlBM+BcRiEAx4UfE3R3FgQsAICQQQfAhAiIIPkRABMGHCIgg+BABEQQfIiCC4EMERBB8iIAIgg8REEEwIiDi7gBJABYARnACIswMSAIj+BABEQQfI/CCQvh4EWmUwAg+RuAFhfAxAtEoAVgAGMEJiDAzIAmM4EMERBB8jMALSkLwESLSKIERfIzAC0pC8C0C0SgBWAAYwQmIMDMgCYzgQwREEPyLQAwKEgT/IhCDggTBvwjEoCBB8CPuzigBWAAYwQmIMDMgCYzgQwREEHyLQARKYATfIhCBEhjBtwhEoARGsCPu7oDiwAUAEBKIIPgQAREEH1YiIILgQwSiUQIj+BCBaJTACD5EIBolMAAAI/iYuhEUwr+IQASKCd8oNsG3iECk2ATfIgKRYhN8iwgEik3wMXW5/WGUk1Z7cdabd//BUBzJ0jzRVF1NogA7";
+
+char my_iemgui_base64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+int my_iemgui_color_hex[]=
+{
+ 16579836, 10526880, 4210752, 16572640, 16572608,
+ 16579784, 14220504, 14220540, 14476540, 16308476,
+ 14737632, 8158332, 2105376, 16525352, 16559172,
+ 15263784, 1370132, 2684148, 3952892, 16003312,
+ 12369084, 6316128, 0, 9177096, 5779456,
+ 7874580, 2641940, 17488, 5256, 5767248
+};
+
+int simularca_color_hex[]=
+{
+ 16003312, 3952892, 2684148, 15263784, 16559172, 16525352, 8158332
+};
+
+void my_iemgui_change_scale_col(char *gif, int color)
+{
+ int i;
+ unsigned int red = (color & 0xff0000) >> 16;
+ unsigned int green = (color & 0xff00) >> 8;
+ unsigned int blue = color & 0xff;
+ t_my_iemgui_3u4 hexbyte;
+
+ hexbyte.b3.dummy = 0;
+
+ hexbyte.b3.byte1 = 0xD6;
+ hexbyte.b3.byte2 = red;
+ hexbyte.b3.byte3 = green;
+ i = hexbyte.h4.hex1;
+ gif[20] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex2;
+ gif[21] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex3;
+ gif[22] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex4;
+ gif[23] = my_iemgui_base64[i];
+
+ hexbyte.b3.byte1 = blue;
+ hexbyte.b3.byte2 = 0xFF;
+ hexbyte.b3.byte3 = 0xFF;
+ i = hexbyte.h4.hex1;
+ gif[24] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex2;
+ gif[25] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex3;
+ gif[26] = my_iemgui_base64[i];
+ i = hexbyte.h4.hex4;
+ gif[27] = my_iemgui_base64[i];
+}
+
+static t_class *iemgui_class;
+
+static void *iemgui_new(void)
+{
+ t_object *x = (t_object *)pd_new(iemgui_class);
+
+ return (x);
+}
+
+//void simularca_2d_setup(void);
+//void simularca_3d_setup(void);
+void room_sim_2d_setup(void);
+void room_sim_3d_setup(void);
+//void simularca_3d_no_z_clip_setup(void);
+void cube_sphere_setup(void);
+void sym_dial_setup(void);
+void iem_image_setup(void);
+void iem_vu_setup(void);
+void hfadl_scale_setup(void);
+void hfadr_scale_setup(void);
+void vfad_scale_setup(void);
+void numberbox_matrix_setup(void);
+void iem_event_setup(void);
+//void toggle_matrix_setup(void);
+
+/* ------------------------ setup routine ------------------------- */
+
+void iemgui_setup(void)
+{
+ // simularca_2d_setup();
+ // simularca_3d_setup();
+ room_sim_2d_setup();
+ room_sim_3d_setup();
+ // simularca_3d_no_z_clip_setup();
+ cube_sphere_setup();
+ sym_dial_setup();
+ iem_image_setup();
+ iem_vu_setup();
+ hfadl_scale_setup();
+ hfadr_scale_setup();
+ vfad_scale_setup();
+ numberbox_matrix_setup();
+ iem_event_setup();
+ // toggle_matrix_setup();
+
+ post("iemgui (R-1.16) library loaded! (c) Thomas Musil 05.2005");
+ post(" musil%ciem.at iem KUG Graz Austria", '@');
+}
diff --git a/src/iemgui.dsp b/src/iemgui.dsp
new file mode 100644
index 0000000..0242b33
--- /dev/null
+++ b/src/iemgui.dsp
@@ -0,0 +1,85 @@
+# Microsoft Developer Studio Project File - Name="iemgui" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) External Target" 0x0106
+
+CFG=iemgui - 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 "iemgui.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 "iemgui.mak" CFG="iemgui - Win32 Debug"
+!MESSAGE
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE
+!MESSAGE "iemgui - Win32 Release" (basierend auf "Win32 (x86) External Target")
+!MESSAGE "iemgui - Win32 Debug" (basierend auf "Win32 (x86) External Target")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+
+!IF "$(CFG)" == "iemgui - 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 "iemgui.exe"
+# PROP Bsc_Name "iemgui.bsc"
+# PROP Target_Dir ""
+
+!ELSEIF "$(CFG)" == "iemgui - 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 "iemgui.exe"
+# PROP Bsc_Name "iemgui.bsc"
+# PROP Target_Dir ""
+
+!ENDIF
+
+# Begin Target
+
+# Name "iemgui - Win32 Release"
+# Name "iemgui - Win32 Debug"
+
+!IF "$(CFG)" == "iemgui - Win32 Release"
+
+!ELSEIF "$(CFG)" == "iemgui - Win32 Debug"
+
+!ENDIF
+
+# Begin Source File
+
+SOURCE=.\makefile_win
+# End Source File
+# End Target
+# End Project
diff --git a/src/iemgui.dsw b/src/iemgui.dsw
new file mode 100644
index 0000000..bf236eb
--- /dev/null
+++ b/src/iemgui.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: "iemgui"=.\iemgui.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/iemgui.h b/src/iemgui.h
new file mode 100644
index 0000000..a436cd5
--- /dev/null
+++ b/src/iemgui.h
@@ -0,0 +1,43 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#ifndef __IEMGUI_H__
+#define __IEMGUI_H__
+
+//t_symbol *iemgui_key_sym2=0;
+
+typedef struct _my_iemgui_4hex
+{
+ unsigned int dummy : 8;
+ unsigned int hex4 : 6;
+ unsigned int hex3 : 6;
+ unsigned int hex2 : 6;
+ unsigned int hex1 : 6;
+} t_my_iemgui_4hex;
+
+typedef struct _my_iemgui_3byte
+{
+ unsigned int dummy : 8;
+ unsigned int byte3 : 8;
+ unsigned int byte2 : 8;
+ unsigned int byte1 : 8;
+} t_my_iemgui_3byte;
+
+typedef union _my_iemgui_3u4
+{
+ t_my_iemgui_4hex h4;
+ t_my_iemgui_3byte b3;
+} t_my_iemgui_3u4;
+
+extern char my_iemgui_black_vscale_gif[];
+extern char my_iemgui_black_hlscale_gif[];
+extern char my_iemgui_black_hrscale_gif[];
+extern char my_iemgui_base64[];
+extern int my_iemgui_color_hex[];
+extern int simularca_color_hex[];
+
+extern void my_iemgui_change_scale_col(char *gif, int color);
+
+#endif
diff --git a/src/iemlib.h b/src/iemlib.h
new file mode 100644
index 0000000..f86c6c9
--- /dev/null
+++ b/src/iemlib.h
@@ -0,0 +1,102 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib.h written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#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 MSW
+int sys_noloadbang;
+//t_symbol *iemgui_key_sym=0;
+#include <io.h>
+#else
+extern int sys_noloadbang;
+//extern t_symbol *iemgui_key_sym;
+#include <unistd.h>
+#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 <machine/endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* BYTE_ORDER */
+#include <sys/types.h>
+#define int32 int32_t
+#endif
+#ifdef __linux__
+
+#include <endian.h>
+
+#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
+#error No byte order defined
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* __BYTE_ORDER */
+
+#include <sys/types.h>
+#define int32 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];
+};
+
+#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 */
+
+#endif
diff --git a/src/makefile b/src/makefile
new file mode 100644
index 0000000..6b77283
--- /dev/null
+++ b/src/makefile
@@ -0,0 +1,58 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+INCLUDE = -I. -I/usr/local/src/pd/src
+
+LDFLAGS = -export-dynamic -shared
+LIB = -ldl -lm -lpthread
+
+#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
+
+SYSTEM = $(shell uname -m)
+
+# the sources
+
+SRC = room_sim_2d.c \
+ room_sim_3d.c \
+ cube_sphere.c \
+ sym_dial.c \
+ iem_image.c \
+ iem_vu.c \
+ hfadl_scale.c \
+ hfadr_scale.c \
+ vfad_scale.c \
+ numberbox_matrix.c \
+ iem_event.c \
+ iemgui.c
+
+TARGET = iemgui.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)
+ mv $(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..6b77283
--- /dev/null
+++ b/src/makefile_linux
@@ -0,0 +1,58 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+INCLUDE = -I. -I/usr/local/src/pd/src
+
+LDFLAGS = -export-dynamic -shared
+LIB = -ldl -lm -lpthread
+
+#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
+
+SYSTEM = $(shell uname -m)
+
+# the sources
+
+SRC = room_sim_2d.c \
+ room_sim_3d.c \
+ cube_sphere.c \
+ sym_dial.c \
+ iem_image.c \
+ iem_vu.c \
+ hfadl_scale.c \
+ hfadr_scale.c \
+ vfad_scale.c \
+ numberbox_matrix.c \
+ iem_event.c \
+ iemgui.c
+
+TARGET = iemgui.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)
+ mv $(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..61d9f44
--- /dev/null
+++ b/src/makefile_win
@@ -0,0 +1,48 @@
+
+all: ..\iemgui.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 = room_sim_2d.c \
+ room_sim_3d.c \
+ cube_sphere.c \
+ sym_dial.c \
+ iem_image.c \
+ iem_vu.c \
+ hfadl_scale.c \
+ hfadr_scale.c \
+ vfad_scale.c \
+ numberbox_matrix.c \
+ iem_event.c \
+ iemgui.c
+
+
+OBJ = $(SRC:.c=.obj)
+
+.c.obj:
+ cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c
+
+..\iemgui.dll: $(OBJ)
+ link $(PD_WIN_L_FLAGS) /dll /export:iemgui_setup \
+ /out:..\iemgui.dll $(OBJ) $(PD_WIN_LIB)
+
+clean:
+ del *.obj
diff --git a/src/numberbox_matrix.c b/src/numberbox_matrix.c
new file mode 100644
index 0000000..9b03f3e
--- /dev/null
+++ b/src/numberbox_matrix.c
@@ -0,0 +1,1382 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#define IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT 10
+#define IEM_GUI_NBXM_DRAW_MODE_UPDATE_ROW 11
+#define IEM_GUI_NBXM_DRAW_MODE_UPDATE_COLUMN 12
+#define IEM_GUI_NBXM_DRAW_MODE_UPDATE_MATRIX 13
+
+#define IEM_GUI_NBXM_COLOR_SELECTED "#0000FF"
+#define IEM_GUI_NBXM_COLOR_NORMAL "#000000"
+#define IEM_GUI_NBXM_COLOR_EDITED "#FF0000"
+
+/* ---------- numberbox_matrix a matrix of number-boxes ----------------
+passive (like set) input messages :
+matrix r c e11 e12 e13 e14 e21 ..... e63 e64
+row i ei1 ei2 ei3 ei4
+col j e1j e2j e3j e4j e5j e6j
+element ir jc e
+list ir jc e
+float e ... for all elements = e
+
+ active messages:
+ bang .... outputs the whole matrix-message
+*/
+
+t_widgetbehavior numberbox_matrix_widgetbehavior;
+static t_class *numberbox_matrix_class;
+
+typedef struct _numberbox_matrix
+{
+ t_iemgui x_gui;
+ t_clock *x_clock_reset;
+ t_clock *x_clock_wait;
+ t_int x_n_column;
+ t_int x_n_row;
+ t_int x_sel_column;
+ t_int x_sel_row;
+ t_int x_update_mode;
+ t_int x_resid;
+ double x_val;
+ double x_min;
+ double x_max;
+ double x_k;
+ char x_buf[IEMGUI_MAX_NUM_LEN];
+ t_int x_numwidth;
+ t_symbol *x_front_color;
+ t_atom *x_matrix;
+ t_atom x_at_out[3];
+} t_numberbox_matrix;
+
+static void numberbox_matrix_key(void *z, t_floatarg fkey);
+t_widgetbehavior numberbox_matrix_widgetbehavior;
+static t_class *numberbox_matrix_class;
+
+static void numberbox_matrix_tick_reset(t_numberbox_matrix *x)
+{
+ if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, x->x_update_mode);
+ }
+}
+
+static void numberbox_matrix_tick_wait(t_numberbox_matrix *x)
+{
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, x->x_update_mode);
+}
+
+void numberbox_matrix_clip_element(t_numberbox_matrix *x, t_atom *av)
+{
+ t_float f=atom_getfloat(av);
+
+ if(f < x->x_min)
+ f = x->x_min;
+ if(f > x->x_max)
+ f = x->x_max;
+
+ SETFLOAT(av, f);
+}
+
+void numberbox_matrix_calc_fontwidth(t_numberbox_matrix *x)
+{
+ int w, f=31;
+
+ if(x->x_gui.x_fsf.x_font_style == 1)
+ f = 27;
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ f = 25;
+
+ w = x->x_gui.x_fontsize * f * x->x_gui.x_w;
+ w /= 36;
+ x->x_numwidth = w + 4;
+}
+
+void numberbox_matrix_ftoa(t_numberbox_matrix *x, t_float g, char *buf)
+{
+ double f=(double)g;
+ int bufsize, is_exp=0, i, idecimal;
+
+ sprintf(buf, "%g", f);
+ bufsize = strlen(buf);
+ if(bufsize >= 5)/* if it is in exponential mode */
+ {
+ i = bufsize - 4;
+ if((buf[i] == 'e') || (buf[i] == 'E'))
+ is_exp = 1;
+ }
+ if(bufsize > x->x_gui.x_w)/* if to reduce */
+ {
+ if(is_exp)
+ {
+ if(x->x_gui.x_w <= 5)
+ {
+ buf[0] = (f < 0.0 ? '-' : '+');
+ buf[1] = 0;
+ }
+ i = bufsize - 4;
+ for(idecimal=0; idecimal < i; idecimal++)
+ if(buf[idecimal] == '.')
+ break;
+ if(idecimal > (x->x_gui.x_w - 4))
+ {
+ buf[0] = (f < 0.0 ? '-' : '+');
+ buf[1] = 0;
+ }
+ else
+ {
+ int new_exp_index=x->x_gui.x_w-4, old_exp_index=bufsize-4;
+
+ for(i=0; i < 4; i++, new_exp_index++, old_exp_index++)
+ buf[new_exp_index] = buf[old_exp_index];
+ buf[x->x_gui.x_w] = 0;
+ }
+
+ }
+ else
+ {
+ for(idecimal=0; idecimal < bufsize; idecimal++)
+ if(buf[idecimal] == '.')
+ break;
+ if(idecimal > x->x_gui.x_w)
+ {
+ buf[0] = (f < 0.0 ? '-' : '+');
+ buf[1] = 0;
+ }
+ else
+ buf[x->x_gui.x_w] = 0;
+ }
+ }
+}
+
+static void numberbox_matrix_output_element(t_numberbox_matrix *x, t_atom *av)
+{
+
+ if(x->x_n_row == 1)
+ {
+ if(x->x_n_column == 1) //nr=1, nc=1
+ {
+ t_float f = atom_getfloat(av);
+
+ outlet_float(x->x_gui.x_obj.ob_outlet, f);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, f);
+ }
+ else // nr=1, nc>1 : duo of jc, element
+ {
+ SETFLOAT(x->x_at_out, (t_float)(x->x_sel_column+1));
+ x->x_at_out[1] = *av;
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at_out);
+ }
+ }
+ else
+ {
+ if(x->x_n_column == 1) // nr>1, nc=1 : duo of ir, element
+ {
+ SETFLOAT(x->x_at_out, (t_float)(x->x_sel_row+1));
+ x->x_at_out[1] = *av;
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at_out);
+ }
+ else // nr>1, nc>1 : trio of ir, jc, element
+ {
+ SETFLOAT(x->x_at_out, (t_float)(x->x_sel_row+1));
+ SETFLOAT(x->x_at_out+1, (t_float)(x->x_sel_column+1));
+ x->x_at_out[2] = *av;
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 3, x->x_at_out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 3, x->x_at_out);
+ }
+ }
+}
+
+static void numberbox_matrix_draw_update(t_numberbox_matrix *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ if(x->x_update_mode == IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT)
+ {
+ t_int ir=x->x_sel_row;
+ t_int jc=x->x_sel_column;
+ t_int k;
+
+ if(x->x_gui.x_fsf.x_change)
+ {
+ if(x->x_buf[0])
+ {
+ char *cp=x->x_buf;
+ int sl = strlen(x->x_buf);
+
+ x->x_buf[sl] = '>';
+ x->x_buf[sl+1] = 0;
+ if(sl >= x->x_gui.x_w)
+ cp += sl - x->x_gui.x_w + 1;
+ sys_vgui(
+ ".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, ir, jc, IEM_GUI_NBXM_COLOR_EDITED, cp);
+ x->x_buf[sl] = 0;
+ }
+ else
+ {
+ k = x->x_sel_row;
+ k *= x->x_n_column;
+ k += x->x_sel_column + 3;
+ numberbox_matrix_ftoa(x, atom_getfloat(x->x_matrix+k), x->x_buf);
+ sys_vgui(".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, ir, jc, IEM_GUI_NBXM_COLOR_EDITED, x->x_buf);
+ x->x_buf[0] = 0;
+ }
+ }
+ else
+ {
+ k = x->x_sel_row;
+ k *= x->x_n_column;
+ k += x->x_sel_column + 3;
+ numberbox_matrix_ftoa(x, atom_getfloat(x->x_matrix+k), x->x_buf);
+ sys_vgui(".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, ir, jc, x->x_front_color->s_name, x->x_buf);
+ x->x_buf[0] = 0;
+ }
+ }
+ else if(x->x_update_mode == IEM_GUI_NBXM_DRAW_MODE_UPDATE_MATRIX)
+ {
+ t_int i, r=x->x_n_row;
+ t_int j, c=x->x_n_column;
+ t_int k = 3;
+
+ for(i=0; i<r; i++)
+ {
+ for(j=0; j<c; j++)
+ {
+ x->x_val = atom_getfloat(x->x_matrix+k);
+ k++;
+ numberbox_matrix_ftoa(x, x->x_val, x->x_buf);
+ sys_vgui(".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, i, j, x->x_front_color->s_name, x->x_buf);
+ }
+ }
+ }
+ else if(x->x_update_mode == IEM_GUI_NBXM_DRAW_MODE_UPDATE_ROW)
+ {
+ t_int ir=x->x_sel_row;
+ t_int j, c=x->x_n_column;
+ t_int k = 3+ir*c;
+
+ for(j=0; j<c; j++)
+ {
+ x->x_val = atom_getfloat(x->x_matrix+k);
+ k++;
+ numberbox_matrix_ftoa(x, x->x_val, x->x_buf);
+ sys_vgui(".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, ir, j, x->x_front_color->s_name, x->x_buf);
+ }
+ }
+ else if(x->x_update_mode == IEM_GUI_NBXM_DRAW_MODE_UPDATE_COLUMN)
+ {
+ t_int i, r=x->x_n_row;
+ t_int c=x->x_n_column;
+ t_int jc=x->x_sel_column;
+ t_int k = 3+jc;
+
+ for(i=0; i<r; i++)
+ {
+ x->x_val = atom_getfloat(x->x_matrix+k);
+ k += c;
+ numberbox_matrix_ftoa(x, x->x_val, x->x_buf);
+ sys_vgui(".x%x.c itemconfigure %xNUMBER_%d_%d -fill %s -text {%s} \n",
+ glist_getcanvas(glist), x, i, jc, x->x_front_color->s_name, x->x_buf);
+ }
+ }
+ }
+}
+
+static void numberbox_matrix_draw_new(t_numberbox_matrix *x, t_glist *glist)
+{
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_int i, j, k, r, c;
+ t_canvas *canvas=glist_getcanvas(glist);
+ t_int h=x->x_gui.x_h, w=x->x_numwidth;
+ t_int hh=h/2, hw=w/2;
+ t_int xx, yy;
+
+ r = x->x_n_row;
+ c = x->x_n_column;
+ for(i=0; i<c; i+=2)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xCOLUMNS_%d\n",
+ canvas, xpos + x->x_numwidth*i, ypos, xpos + x->x_numwidth*(i+1), ypos + x->x_gui.x_h*r, x, i);
+ for(i=0; i<r; i+=2)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xROWS_%d\n",
+ canvas, xpos, ypos + x->x_gui.x_h*i, xpos + x->x_numwidth*c, ypos + x->x_gui.x_h*(i+1), x, i);
+ k = 3;
+ yy = ypos + hh;
+ for(i=0; i<r; i++)
+ {
+ xx = xpos + hw;
+ for(j=0; j<c; j++)
+ {
+ x->x_val = atom_getfloat(x->x_matrix+k);
+ k++;
+ numberbox_matrix_ftoa(x, x->x_val, x->x_buf);
+ sys_vgui(".x%x.c create text %d %d -text {%s} -anchor c \
+ -font {%s %d bold} -fill %s -tags %xNUMBER_%d_%d\n", canvas, xx, yy,
+ x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_front_color->s_name, x, i, j);
+ xx += w;
+ }
+ yy += h;
+ }
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xFRAME\n",
+ canvas, xpos, ypos, xpos + x->x_numwidth*c, ypos + x->x_gui.x_h*r, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h*r-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h*r,
+ x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1,
+ x, 0);
+}
+static void numberbox_matrix_draw_move(t_numberbox_matrix *x, t_glist *glist)
+{
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_int i, j, r, c;
+ t_canvas *canvas=glist_getcanvas(glist);
+ t_int h=x->x_gui.x_h, w=x->x_numwidth;
+ t_int hh=h/2, hw=w/2;
+ t_int xx, yy;
+
+ r = x->x_n_row;
+ c = x->x_n_column;
+
+ for(i=0; i<c; i+=2)
+ sys_vgui(".x%x.c coords %xCOLUMNS_%d %d %d %d %d\n",
+ canvas, x, i, xpos + x->x_numwidth*i, ypos, xpos + x->x_numwidth*(i+1), ypos + x->x_gui.x_h*r);
+ for(i=0; i<r; i+=2)
+ sys_vgui(".x%x.c coords %xROWS_%d %d %d %d %d\n",
+ canvas, x, i, xpos, ypos + x->x_gui.x_h*i, xpos + x->x_numwidth*c, ypos + x->x_gui.x_h*(i+1));
+
+ yy = ypos + hh;
+ for(i=0; i<r; i++)
+ {
+ xx = xpos + hw;
+ for(j=0; j<c; j++)
+ {
+ sys_vgui(".x%x.c coords %xNUMBER_%d_%d %d %d\n",
+ canvas, x, i, j, xx, yy);
+ xx += w;
+ }
+ yy += h;
+ }
+
+ sys_vgui(".x%x.c coords %xFRAME %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_numwidth*c, ypos + x->x_gui.x_h*r);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos + x->x_gui.x_h*r-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h*r);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1);
+}
+
+static void numberbox_matrix_draw_erase(t_numberbox_matrix* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ t_int i, j, r, c;
+
+ r = x->x_n_row;
+ c = x->x_n_column;
+ for(i=0; i<c; i+=2)
+ sys_vgui(".x%x.c delete %xCOLUMNS_%d\n", canvas, x, i);
+ for(i=0; i<r; i+=2)
+ sys_vgui(".x%x.c delete %xROWS_%d\n", canvas, x, i);
+
+ for(i=0; i<r; i++)
+ {
+ for(j=0; j<c; j++)
+ {
+ sys_vgui(".x%x.c delete %xNUMBER_%d_%d\n", canvas, x, i, j);
+ }
+ }
+
+ sys_vgui(".x%x.c delete %xFRAME\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+}
+
+static void numberbox_matrix_draw_select(t_numberbox_matrix *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ /*if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ x->x_buf[0] = 0;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }*/
+ sys_vgui(".x%x.c itemconfigure %xFRAME -outline %s\n",
+ canvas, x, IEM_GUI_NBXM_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%x.c itemconfigure %xFRAME -outline %s\n",
+ canvas, x, IEM_GUI_NBXM_COLOR_NORMAL);
+ }
+}
+
+static void numberbox_matrix_draw_io(t_numberbox_matrix* x,t_glist* glist, int old_snd_rcv_flags)
+{
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+ t_int r=x->x_n_row;
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h*r-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h*r,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+}
+
+void numberbox_matrix_draw(t_numberbox_matrix *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ numberbox_matrix_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ numberbox_matrix_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ numberbox_matrix_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ numberbox_matrix_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ numberbox_matrix_draw_erase(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ numberbox_matrix_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void numberbox_matrix_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_numberbox_matrix *x = (t_numberbox_matrix *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_numwidth*x->x_n_column;
+ *yp2 = *yp1 + x->x_gui.x_h*x->x_n_row;
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void numberbox_matrix_save(t_gobj *z, t_binbuf *b)
+{
+ t_numberbox_matrix *x = (t_numberbox_matrix *)z;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ iemgui_all_sym2dollararg(&x->x_gui, srl);
+
+ binbuf_addv(b, "ssiisiiiiffisssii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("nbxm"), x->x_n_row, x->x_n_column, x->x_gui.x_w, x->x_gui.x_h,
+ x->x_min, x->x_max, iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], x->x_front_color,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize);
+ binbuf_addv(b, ";");
+}
+#else
+static void numberbox_matrix_save(t_gobj *z, t_binbuf *b)
+{
+ t_numberbox_matrix *x = (t_numberbox_matrix *)z;
+ int *ip1, *ip2;
+ t_symbol *srl[3];
+
+ srl[0] = x->x_gui.x_snd;
+ srl[1] = x->x_gui.x_rcv;
+ srl[2] = gensym("empty");
+ iemgui_all_unique2dollarzero(&x->x_gui, srl);
+ iemgui_all_sym2dollararg(&x->x_gui, srl);
+ ip1 = (int *)(&x->x_gui.x_isa);
+ ip2 = (int *)(&x->x_gui.x_fsf);
+ binbuf_addv(b, "ssiisiiiiffisssii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("nbxm"), x->x_n_row, x->x_n_column, x->x_gui.x_w, x->x_gui.x_h,
+ x->x_min, x->x_max, (*ip1)&IEM_INIT_ARGS_ALL,
+ srl[0], srl[1], x->x_front_color,
+ (*ip2)&IEM_FSTYLE_FLAGS_ALL, x->x_gui.x_fontsize);
+ binbuf_addv(b, ";");
+}
+#endif
+
+/*static void numberbox_matrix_properties(t_gobj *z, t_glist *owner)
+{
+t_numberbox_matrix *x = (t_numberbox_matrix *)z;
+char buf[800];
+t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+
+ }
+ sprintf(buf, "pdtk_iemgui_dialog %%s MATRIXBOX \
+ -------dimensions(digits)(pix):------- %d %d width: %d %d height: \
+ -----------output-range:----------- %g min: %g max: %d \
+ %d lin log %d %d log-height: %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, 1, x->x_gui.x_h, 8,
+ x->x_min, x->x_max, 0,
+ -1, -1, -1, -1,
+ srl[0]->s_name, srl[1]->s_name,
+ "no_label", 0, 0,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ -1, 0xffffff & x->x_gui.x_fcol, -1);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}*/
+
+/*static void numberbox_matrix_dialog(t_numberbox_matrix *x, t_symbol *s, int argc,
+t_atom *argv)
+{
+t_symbol *srl[3];
+int w = (int)atom_getintarg(0, argc, argv);
+int h = (int)atom_getintarg(1, argc, argv);
+double min = (double)atom_getfloatarg(2, argc, argv);
+double max = (double)atom_getfloatarg(3, argc, argv);
+int lilo = (int)atom_getintarg(4, argc, argv);
+int log_height = (int)atom_getintarg(6, argc, argv);
+int sr_flags;
+t_int i, r=x->x_n_row;
+t_int j, c=x->x_n_column;
+t_int k = 3;
+
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ if(log_height < 10)
+ log_height = 10;
+ x->x_log_height = log_height;
+ numberbox_matrix_calc_fontwidth(x);
+ for(i=0; i<r; i++)
+ {
+ for(j=0; j<c; j++)
+ {
+ numberbox_matrix_clip(x, x->x_matrix+k);
+ k++;
+ }
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}*/
+
+static void numberbox_matrix_motion(t_numberbox_matrix *x, t_floatarg dx, t_floatarg dy)
+{
+ double k2=1.0;
+ t_int k, res;
+ t_float f;
+
+ k = x->x_sel_row;
+ k *= x->x_n_column;
+ k += x->x_sel_column + 3;
+ f = atom_getfloat(x->x_matrix+k);
+ x->x_resid += (t_int)dy;
+ res = x->x_resid / 2;
+ dy = (t_floatarg)res;
+ x->x_resid = x->x_resid - res*2;
+ if(x->x_gui.x_fsf.x_finemoved)
+ k2 = 0.01;
+ f -= k2*dy;
+
+ SETFLOAT(x->x_matrix+k, f);
+ numberbox_matrix_clip_element(x, x->x_matrix+k);
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ numberbox_matrix_output_element(x, x->x_matrix+k);
+ clock_unset(x->x_clock_reset);
+}
+
+static void numberbox_matrix_key(void *z, t_floatarg fkey)
+{
+ t_numberbox_matrix *x = z;
+ char c=fkey;
+ char buf[3];
+ buf[1] = 0;
+
+ if(c == 0)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ return;
+ }
+ if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')||
+ (c=='e')||(c=='+')||(c=='E'))
+ {
+ if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2))
+ {
+ buf[0] = c;
+ strcat(x->x_buf, buf);
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ }
+ else if((c=='\b')||(c==127))
+ {
+ int sl=strlen(x->x_buf)-1;
+
+ if(sl < 0)
+ sl = 0;
+ x->x_buf[sl] = 0;
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ else if((c=='\n')||(c==13))
+ {
+ t_int k=3+x->x_sel_column+x->x_sel_row*x->x_n_column;
+
+ x->x_val = atof(x->x_buf);
+ SETFLOAT(x->x_matrix+k, x->x_val);
+ x->x_buf[0] = 0;
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+
+ numberbox_matrix_clip_element(x, x->x_matrix+k);
+ numberbox_matrix_output_element(x, x->x_matrix+k);
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ clock_delay(x->x_clock_reset, 3000);
+}
+
+static void numberbox_matrix_click(t_numberbox_matrix *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
+ (t_glistmotionfn)numberbox_matrix_motion, numberbox_matrix_key, xpos, ypos);
+}
+
+static int numberbox_matrix_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_numberbox_matrix* x = (t_numberbox_matrix *)z;
+
+ if(doit)
+ {
+ t_int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ t_int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ //t_int r=x->x_n_row, c=x->x_n_column;
+ t_int w=x->x_numwidth, h=x->x_gui.x_h;
+
+ numberbox_matrix_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
+ (t_floatarg)shift, 0, (t_floatarg)alt);
+ if(shift)
+ x->x_gui.x_fsf.x_finemoved = 1;
+ else
+ x->x_gui.x_fsf.x_finemoved = 0;
+ x->x_sel_column = (xpix - xpos) / w;
+ x->x_sel_row = (ypix - ypos) / h;
+
+ //post("row %d, col %d", x->x_sel_row, x->x_sel_column);
+ if(!x->x_gui.x_fsf.x_change)
+ {
+ clock_delay(x->x_clock_wait, 50);
+ x->x_gui.x_fsf.x_change = 1;
+ clock_delay(x->x_clock_reset, 3000);
+
+ x->x_buf[0] = 0;
+ }
+ else
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ x->x_buf[0] = 0;
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ }
+ return (1);
+}
+
+static void numberbox_matrix_bang(t_numberbox_matrix *x)
+{
+ outlet_anything(x->x_gui.x_obj.ob_outlet, atom_getsymbol(x->x_matrix), x->x_n_row*x->x_n_column+2, x->x_matrix+1);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ typedmess(x->x_gui.x_snd->s_thing, atom_getsymbol(x->x_matrix), x->x_n_row*x->x_n_column+2, x->x_matrix+1);
+}
+
+static void numberbox_matrix_float(t_numberbox_matrix *x, t_floatarg f)
+{
+ t_int i, j, k, r, c;
+
+ r = x->x_n_row;
+ c = x->x_n_column;
+ k = 3;
+ for(i=0; i<r; i++)
+ {
+ for(j=0; j<c; j++)
+ {
+ SETFLOAT(x->x_matrix+k, f);
+ k++;
+ }
+ }
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_MATRIX;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void numberbox_matrix_list(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int ir, jc;
+
+ if((ac >= 3)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)&&IS_A_FLOAT(av,2))
+ {
+ ir = atom_getintarg(0, ac, av);
+ jc = atom_getintarg(1, ac, av);
+ if(ir < 1)
+ ir = 1;
+ if(ir > x->x_n_row)
+ ir = x->x_n_row;
+ if(jc < 1)
+ jc = 1;
+ if(jc > x->x_n_column)
+ jc = x->x_n_column;
+ ir--;
+ jc--;
+ x->x_sel_row = ir;
+ x->x_sel_column = jc;
+ ir *= x->x_n_column;
+ ir += jc + 3;
+ x->x_matrix[ir] = av[2];
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ELEMENT;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+}
+
+static void numberbox_matrix_element(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ numberbox_matrix_list(x, s, ac, av);
+}
+
+static void numberbox_matrix_row(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int i, ir, c=x->x_n_column;
+
+ if(ac <= c){
+ pd_error(x, "numberbox_matrix: bad row (too short)");
+ return;
+ }
+ for(i=0; i<=c; i++)
+ {
+ if(!IS_A_FLOAT(av, i)){
+ pd_error(x, "numberbox_matrix: bad row (not all numbers)");
+ return;
+ }
+ }
+ ir = atom_getintarg(0, ac, av);
+ i=ir;
+ if(ir < 1)
+ ir = 1;
+ if(ir > x->x_n_row)
+ ir = x->x_n_row;
+ if(i!=ir)post("numberbox_matrix: index %d out of range (using %d)", i, ir);
+
+ ir--;
+ x->x_sel_row = ir;
+ ir *= c;
+ ir += 3;
+ for(i=1; i<=c; i++)
+ x->x_matrix[ir++] = av[i];
+
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_ROW;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void numberbox_matrix_col(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int i, ic, r=x->x_n_row, c=x->x_n_column;
+
+ if(ac <= r){
+ pd_error(x, "numberbox_matrix: bad column (too short)");
+ return;
+ }
+ for(i=0; i<=r; i++)
+ {
+ if(!IS_A_FLOAT(av, i)){
+ pd_error(x, "numberbox_matrix: bad row (not all numbers)");
+ return;
+ }
+ }
+
+ ic = atom_getintarg(0, ac, av);
+ i=ic;
+ if(ic < 1)
+ ic = 1;
+ if(ic > c)
+ ic = c;
+ if(i!=ic)post("numberbox_matrix: index %d out of range (using %d)", i, ic);
+
+ ic--;
+ x->x_sel_column = ic;
+ ic += 3;
+ for(i=1; i<=r; i++)
+ {
+ x->x_matrix[ic] = av[i];
+ ic += c;
+ }
+
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_COLUMN;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void numberbox_matrix_matrix(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int i, k, c=0, r=0, C=0;
+ if(ac<3){
+ pd_error(x, "numberbox_matrix: invalid input matrix!");
+ return;
+ }
+ r=atom_getintarg(0, ac, av);
+ c=atom_getintarg(1, ac, av);
+ C=c;
+
+ if(ac != ((c*r)+2))
+ {
+ pd_error(x, "numberbox_matrix: invalid input matrix (incosistent #elements)!");
+ return;
+ }
+ for(i=0; i<ac; i++)
+ {
+ if(!IS_A_FLOAT(av, i)){
+ pd_error(x, "numberbox_matrix: invalid input matrix (not all floats)!");
+ return;
+ }
+ }
+
+ if(r != x->x_n_row)
+ post("numberbox_matrix: #rows do not match %d!=%d", r, x->x_n_row);
+ if(c != x->x_n_column)
+ post("numberbox_matrix: #columns do not match %d!=%d", c, x->x_n_column);
+
+ if(r>x->x_n_row)
+ r=x->x_n_row;
+ if(c>x->x_n_column)
+ c=x->x_n_column;
+
+ for(i=0; i<r; i++)
+ for(k=0; k<c; k++){
+ int out_index=i*(x->x_n_column)+k;
+ int in_index =i*(C)+k;
+ x->x_matrix[3+out_index]=av[2+in_index];
+ }
+
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_MATRIX;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void numberbox_matrix_dim(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ int r=0, c=0;
+
+ if(ac > 0)
+ {
+ r = (int)atom_getintarg(0, ac, av);
+ }
+ if(r < 1)
+ r = 1;
+
+ if(ac > 1)
+ {
+ c = (int)atom_getintarg(1, ac, av);
+ }
+ if(c < 1)
+ c = 1;
+
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ if(x->x_matrix)
+ {
+ if((r*c) != (x->x_n_row*x->x_n_column))
+ x->x_matrix = (t_atom *)resizebytes(x->x_matrix, (x->x_n_row*x->x_n_column+3)*sizeof(t_atom), (r*c+3)*sizeof(t_atom));
+ }
+ x->x_n_row = r;
+ x->x_n_column = c;
+ SETFLOAT(x->x_matrix+1, x->x_n_row);
+ SETFLOAT(x->x_matrix+2, x->x_n_column);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void numberbox_matrix_delta(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void numberbox_matrix_pos(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void numberbox_matrix_size(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ int h, w;
+
+ if((ac >= 2)&&IS_A_FLOAT(av, 0) && IS_A_FLOAT(av, 1))
+ {
+ w = (int)atom_getintarg(0, ac, av);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(ac > 1)
+ {
+ h = (int)atom_getintarg(1, ac, av);
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ }
+ numberbox_matrix_calc_fontwidth(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void numberbox_matrix_font(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int f;
+
+ if((ac >= 2)&&IS_A_FLOAT(av, 0) && IS_A_FLOAT(av, 1))
+ {
+ f = atom_getintarg(1, ac, av);
+ if(f < 4)
+ f = 4;
+ x->x_gui.x_fontsize = f;
+ f = (int)atom_getintarg(0, ac, av);
+ if((f < 0) || (f > 2))
+ f = 0;
+ x->x_gui.x_fsf.x_font_style = f;
+ numberbox_matrix_calc_fontwidth(x);
+ f = (int)atom_getintarg(0, ac, av);
+ if(f == 1)
+ strcpy(x->x_gui.x_font, "helvetica");
+ else if(f == 2)
+ strcpy(x->x_gui.x_font, "times");
+ else
+ {
+ f = 0;
+ strcpy(x->x_gui.x_font, "courier");
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void numberbox_matrix_range(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_int i, j, k, r, c;
+ t_float f;
+
+ r = x->x_n_row;
+ c = x->x_n_column;
+ if((ac >= 2)&&IS_A_FLOAT(av, 0) && IS_A_FLOAT(av, 1))
+ {
+ x->x_min = (double)atom_getfloatarg(0, ac, av);
+ x->x_max = (double)atom_getfloatarg(1, ac, av);
+ if(x->x_min > x->x_max)
+ {
+ x->x_max = (double)atom_getfloatarg(0, ac, av);
+ x->x_min = (double)atom_getfloatarg(1, ac, av);
+ }
+ x->x_k = 1.0;
+ k = 3;
+ for(i=0; i<r; i++)
+ {
+ for(j=0; j<c; j++)
+ {
+ f = atom_getfloat(x->x_matrix+k);
+ if(f > x->x_max)
+ f = x->x_max;
+ if(f < x->x_min)
+ f = x->x_min;
+ SETFLOAT(x->x_matrix+k, f);
+ k++;
+ }
+ }
+ x->x_update_mode = IEM_GUI_NBXM_DRAW_MODE_UPDATE_MATRIX;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+}
+
+static void numberbox_matrix_color(t_numberbox_matrix *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if((ac >= 1)&&IS_A_SYMBOL(av, 0))
+ x->x_front_color = atom_getsymbol(av);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+}
+
+static void numberbox_matrix_send(t_numberbox_matrix *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void numberbox_matrix_receive(t_numberbox_matrix *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void *numberbox_matrix_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_numberbox_matrix *x = (t_numberbox_matrix *)pd_new(numberbox_matrix_class);
+ t_int i, j, n=1, n_row=5, n_column=3, w=3, h=12, fs=8;
+ double min=0.0, max=127.0, mm;
+ t_symbol *front_color;
+ t_int k;
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ front_color = gensym("#000000");// black
+ if((argc >= 12)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6)
+ &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
+ &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
+ &&(IS_A_SYMBOL(argv,9)||IS_A_FLOAT(argv,9))
+ &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11))
+ {
+ n_row = (int)atom_getintarg(0, argc, argv);
+ n_column = (int)atom_getintarg(1, argc, argv);
+ w = (int)atom_getintarg(2, argc, argv);
+ h = (int)atom_getintarg(3, argc, argv);
+ min = (double)atom_getfloatarg(4, argc, argv);
+ max = (double)atom_getfloatarg(5, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(6, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 7, argv);
+ front_color = atom_getsymbolarg(9, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(10, argc, argv));
+ fs = (int)atom_getintarg(11, argc, argv);
+ }
+ else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ n_row = (int)atom_getintarg(0, argc, argv);
+ n_column = (int)atom_getintarg(1, argc, argv);
+ }
+ if(min > max)
+ {
+ mm = min;
+ min = max;
+ max = mm;
+ }
+ x->x_min = min;
+ x->x_max = max;
+ x->x_gui.x_draw = (t_iemfunptr)numberbox_matrix_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0; strcpy(x->x_gui.x_font, "courier"); }
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ if(n_row < 1)
+ n_row = 1;
+ x->x_n_row = n_row;
+ if(n_column < 1)
+ n_column = 1;
+ x->x_n_column = n_column;
+ x->x_front_color = front_color;
+ x->x_buf[0] = 0;
+ numberbox_matrix_calc_fontwidth(x);
+ x->x_matrix = (t_atom *)getbytes((x->x_n_row*x->x_n_column+3)*sizeof(t_atom));
+ SETSYMBOL(x->x_matrix, gensym("matrix"));
+ SETFLOAT(x->x_matrix+1, x->x_n_row);
+ SETFLOAT(x->x_matrix+2, x->x_n_column);
+ k = 3;
+ for(i=0; i<n_row; i++)
+ {
+ for(j=0; j<n_column; j++)
+ {
+ SETFLOAT(x->x_matrix+k, 0.0f);
+ numberbox_matrix_clip_element(x, x->x_matrix+k);
+ k++;
+ }
+ }
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock_reset = clock_new(x, (t_method)numberbox_matrix_tick_reset);
+ x->x_clock_wait = clock_new(x, (t_method)numberbox_matrix_tick_wait);
+ x->x_gui.x_fsf.x_change = 0;
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_resid = 0;
+ return (x);
+}
+#else
+static void *numberbox_matrix_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_numberbox_matrix *x = (t_numberbox_matrix *)pd_new(numberbox_matrix_class);
+ t_int i, j, n=1, n_row=5, n_column=3, w=3, h=12, fs=8;
+ double min=0.0, max=127.0, mm;
+ t_symbol *front_color;
+ t_int iinit=0, ifstyle=0;
+ t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
+ t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
+ t_symbol *srl[3];
+ t_int k;
+ char str[144];
+
+ x->x_gui.x_snd = gensym("empty");
+ x->x_gui.x_rcv = gensym("empty");
+ x->x_gui.x_lab = gensym("empty");
+ srl[0] = gensym("empty");
+ srl[1] = gensym("empty");
+ srl[2] = gensym("empty");
+ x->x_gui.x_fsf.x_font_style = 0;
+ front_color = gensym("#000000");// black
+ if((argc >= 12)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6)
+ &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
+ &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
+ &&(IS_A_SYMBOL(argv,9)||IS_A_FLOAT(argv,9))
+ &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11))
+ {
+ n_row = (int)atom_getintarg(0, argc, argv);
+ n_column = (int)atom_getintarg(1, argc, argv);
+ w = (int)atom_getintarg(2, argc, argv);
+ h = (int)atom_getintarg(3, argc, argv);
+ min = (double)atom_getfloatarg(4, argc, argv);
+ max = (double)atom_getfloatarg(5, argc, argv);
+ iinit = (int)atom_getintarg(6, argc, argv);
+ if(IS_A_SYMBOL(argv,7))
+ srl[0] = atom_getsymbolarg(7, argc, argv);
+ else if(IS_A_FLOAT(argv,7))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(7, argc, argv));
+ srl[0] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,8))
+ srl[1] = atom_getsymbolarg(8, argc, argv);
+ else if(IS_A_FLOAT(argv,8))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(8, argc, argv));
+ srl[1] = gensym(str);
+ }
+ front_color = atom_getsymbolarg(9, argc, argv);
+ ifstyle = (int)atom_getintarg(10, argc, argv);
+ fs = (int)atom_getintarg(11, argc, argv);
+ }
+ else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ n_row = (int)atom_getintarg(0, argc, argv);
+ n_column = (int)atom_getintarg(1, argc, argv);
+ }
+ if(min > max)
+ {
+ mm = min;
+ min = max;
+ max = mm;
+ }
+ x->x_min = min;
+ x->x_max = max;
+ iinit &= IEM_INIT_ARGS_ALL;
+ ifstyle &= IEM_FSTYLE_FLAGS_ALL;
+
+ x->x_gui.x_draw = (t_iemfunptr)numberbox_matrix_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ fstyle->x_snd_able = 1;
+ fstyle->x_rcv_able = 1;
+ if(!strcmp(srl[0]->s_name, "empty"))
+ fstyle->x_snd_able = 0;
+ if(!strcmp(srl[1]->s_name, "empty"))
+ fstyle->x_rcv_able = 0;
+ x->x_gui.x_unique_num = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0; strcpy(x->x_gui.x_font, "courier"); }
+ x->x_gui.x_fsf = *fstyle;
+ x->x_gui.x_isa = *init;
+ iemgui_first_dollararg2sym(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ if(n_row < 1)
+ n_row = 1;
+ x->x_n_row = n_row;
+ if(n_column < 1)
+ n_column = 1;
+ x->x_n_column = n_column;
+ x->x_front_color = front_color;
+ x->x_buf[0] = 0;
+ numberbox_matrix_calc_fontwidth(x);
+ x->x_matrix = (t_atom *)getbytes((x->x_n_row*x->x_n_column+3)*sizeof(t_atom));
+ SETSYMBOL(x->x_matrix, gensym("matrix"));
+ SETFLOAT(x->x_matrix+1, x->x_n_row);
+ SETFLOAT(x->x_matrix+2, x->x_n_column);
+ k = 3;
+ for(i=0; i<n_row; i++)
+ {
+ for(j=0; j<n_column; j++)
+ {
+ SETFLOAT(x->x_matrix+k, 0.0f);
+ numberbox_matrix_clip_element(x, x->x_matrix+k);
+ k++;
+ }
+ }
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock_reset = clock_new(x, (t_method)numberbox_matrix_tick_reset);
+ x->x_clock_wait = clock_new(x, (t_method)numberbox_matrix_tick_wait);
+ x->x_gui.x_fsf.x_change = 0;
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_resid = 0;
+ return (x);
+}
+#endif
+
+static void numberbox_matrix_free(t_numberbox_matrix *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ clock_free(x->x_clock_reset);
+ clock_free(x->x_clock_wait);
+ if(x->x_matrix)
+ freebytes(x->x_matrix, (x->x_n_row*x->x_n_column+3)*sizeof(t_atom));
+ gfxstub_deleteforkey(x);
+}
+
+void numberbox_matrix_setup(void)
+{
+ numberbox_matrix_class = class_new(gensym("nbxm"), (t_newmethod)numberbox_matrix_new,
+ (t_method)numberbox_matrix_free, sizeof(t_numberbox_matrix), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)numberbox_matrix_new, gensym("numberbox_matrix"),
+ A_GIMME, 0);
+ class_addbang(numberbox_matrix_class,numberbox_matrix_bang);
+ class_addfloat(numberbox_matrix_class,numberbox_matrix_float);
+ class_addlist(numberbox_matrix_class, numberbox_matrix_list);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_matrix,
+ gensym("matrix"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_col,
+ gensym("col"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_row,
+ gensym("row"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_element,
+ gensym("element"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_click,
+ gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_motion,
+ gensym("motion"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_dim,
+ gensym("dim"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_range,
+ gensym("range"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_color,
+ gensym("color"), A_GIMME, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_receive,
+ gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(numberbox_matrix_class, (t_method)numberbox_matrix_font,
+ gensym("font"), A_GIMME, 0);
+
+ numberbox_matrix_widgetbehavior.w_getrectfn = numberbox_matrix_getrect;
+ numberbox_matrix_widgetbehavior.w_displacefn = iemgui_displace;
+ numberbox_matrix_widgetbehavior.w_selectfn = iemgui_select;
+ numberbox_matrix_widgetbehavior.w_activatefn = NULL;
+ numberbox_matrix_widgetbehavior.w_deletefn = iemgui_delete;
+ numberbox_matrix_widgetbehavior.w_visfn = iemgui_vis;
+ numberbox_matrix_widgetbehavior.w_clickfn = numberbox_matrix_newclick;
+
+#if((PD_MAJOR_VERSION)&&(PD_MINOR_VERSION < 37))
+ numberbox_matrix_widgetbehavior.w_propertiesfn = NULL;
+ numberbox_matrix_widgetbehavior.w_savefn = numberbox_matrix_save;
+#else
+ class_setsavefn(numberbox_matrix_class, numberbox_matrix_save);
+#endif
+
+ class_setwidget(numberbox_matrix_class, &numberbox_matrix_widgetbehavior);
+ class_sethelpsymbol(numberbox_matrix_class, gensym("iemhelp2/help-numberbox_matrix"));
+}
diff --git a/src/room_sim_2d.c b/src/room_sim_2d.c
new file mode 100644
index 0000000..f74cda5
--- /dev/null
+++ b/src/room_sim_2d.c
@@ -0,0 +1,827 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+
+#define IEM_GUI_ROOMSIM_2D_MAX_NR_SRC 30
+/* ---------- room_sim_2d my gui-canvas for a window ---------------- */
+
+t_widgetbehavior room_sim_2d_widgetbehavior;
+static t_class *room_sim_2d_class;
+
+typedef struct _room_sim_2d
+{
+ t_iemgui x_gui;
+ t_float x_rho_head;
+ int x_fontsize;
+ int x_nr_src;
+ int x_pix_src_x[IEM_GUI_ROOMSIM_2D_MAX_NR_SRC + 1];
+ int x_pix_src_y[IEM_GUI_ROOMSIM_2D_MAX_NR_SRC + 1];
+ int x_col_src[IEM_GUI_ROOMSIM_2D_MAX_NR_SRC + 1];
+ int x_pos_x;
+ int x_pos_y;
+ int x_sel_index;
+ int x_pix_rad;
+ t_float x_cnvrt_roomlx2pixh;
+ t_float x_r_ambi;
+ t_float x_room_x;
+ t_float x_room_y;
+ t_symbol *x_s_head_xy;
+ t_symbol *x_s_src_xy;
+ void *x_out_para;
+ void *x_out_rho;
+ t_atom x_at[6];
+} t_room_sim_2d;
+
+static void room_sim_2d_out_rho(t_room_sim_2d *x)
+{
+ outlet_float(x->x_out_rho, x->x_rho_head);
+}
+
+static void room_sim_2d_out_para(t_room_sim_2d *x)
+{
+ int i, n = x->x_nr_src;
+ int w2=x->x_gui.x_w/2, h2=x->x_gui.x_h/2;
+
+ SETFLOAT(x->x_at, 0.0f);
+ SETSYMBOL(x->x_at+1, x->x_s_head_xy);
+ SETFLOAT(x->x_at+2, (t_float)(h2 - x->x_pix_src_y[0])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+3, (t_float)(w2 - x->x_pix_src_x[0])/x->x_cnvrt_roomlx2pixh);
+ outlet_list(x->x_out_para, &s_list, 4, x->x_at);
+ for(i=1; i<=n; i++)
+ {
+ SETFLOAT(x->x_at, (t_float)i);
+ SETSYMBOL(x->x_at+1, x->x_s_src_xy);
+ SETFLOAT(x->x_at+2, (t_float)(h2 - x->x_pix_src_y[i])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+3, (t_float)(w2 - x->x_pix_src_x[i])/x->x_cnvrt_roomlx2pixh);
+ outlet_list(x->x_out_para, &s_list, 4, x->x_at);
+ }
+}
+
+static void room_sim_2d_draw_update(t_room_sim_2d *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy);
+ }
+}
+
+void room_sim_2d_draw_new(t_room_sim_2d *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ int i, n=x->x_nr_src;
+ int fs=x->x_fontsize;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ x->x_gui.x_bcol, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:IEM_GUI_COLOR_NORMAL, x);
+ for(i=1; i<=n; i++)
+ {
+ sys_vgui(".x%x.c create text %d %d -text {%d} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC%d\n",
+ canvas, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i], i, fs,
+ x->x_col_src[i], x, i);
+ }
+
+ sys_vgui(".x%x.c create oval %d %d %d %d -outline #%6.6x -tags %xHEAD\n",
+ canvas, xpos+x->x_pix_src_x[0]-x->x_pix_rad, ypos+x->x_pix_src_y[0]-x->x_pix_rad,
+ xpos+x->x_pix_src_x[0]+x->x_pix_rad-1, ypos+x->x_pix_src_y[0]+x->x_pix_rad-1,
+ x->x_gui.x_fcol, x);
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xNOSE\n",
+ canvas, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy,
+ x->x_gui.x_fcol, x);
+}
+
+void room_sim_2d_draw_move(t_room_sim_2d *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ int i, n;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ n = x->x_nr_src;
+ for(i=1; i<=n; i++)
+ {
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ }
+
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-x->x_pix_rad, ypos+x->x_pix_src_y[0]-x->x_pix_rad,
+ xpos+x->x_pix_src_x[0]+x->x_pix_rad-1, ypos+x->x_pix_src_y[0]+x->x_pix_rad-1);
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy);
+}
+
+void room_sim_2d_draw_erase(t_room_sim_2d* x, t_glist* glist)
+{
+ int i, n;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ n = x->x_nr_src;
+ for(i=1; i<=n; i++)
+ {
+ sys_vgui(".x%x.c delete %xSRC%d\n", canvas, x, i);
+ }
+ sys_vgui(".x%x.c delete %xHEAD\n", canvas, x);
+ sys_vgui(".x%x.c delete %xNOSE\n", canvas, x);
+}
+
+void room_sim_2d_draw_select(t_room_sim_2d* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ }
+}
+
+void room_sim_2d_draw(t_room_sim_2d *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ room_sim_2d_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ room_sim_2d_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ room_sim_2d_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ room_sim_2d_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ room_sim_2d_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void room_sim_2d_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_room_sim_2d *x = (t_room_sim_2d *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void room_sim_2d_save(t_gobj *z, t_binbuf *b)
+{
+ t_room_sim_2d *x = (t_room_sim_2d *)z;
+ int i, j, c, n=x->x_nr_src;
+
+ binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, gensym("room_sim_2d"));
+ binbuf_addv(b, "ifffi", x->x_nr_src, x->x_cnvrt_roomlx2pixh, x->x_rho_head, x->x_r_ambi, x->x_fontsize);
+ c = x->x_gui.x_bcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iff", j, x->x_room_x, x->x_room_y);
+ c = x->x_gui.x_fcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iii", j, x->x_pix_src_x[0], x->x_pix_src_y[0]);
+ for(i=1; i<=n; i++)
+ {
+ c = x->x_col_src[i];
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iii", j, x->x_pix_src_x[i], x->x_pix_src_y[i]);
+ }
+ binbuf_addv(b, ";");
+}
+
+static void room_sim_2d_motion(t_room_sim_2d *x, t_floatarg dx, t_floatarg dy)
+{
+ int sel=x->x_sel_index;
+ int pixrad=x->x_pix_rad;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ddx, ddy;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(x->x_gui.x_fsf.x_finemoved && (sel == 0))
+ {
+ x->x_rho_head -= dy;
+
+ if(x->x_rho_head <= -180.0f)
+ x->x_rho_head += 360.0f;
+ if(x->x_rho_head > 180.0f)
+ x->x_rho_head -= 360.0f;
+ room_sim_2d_out_rho(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ else if(sel == 0)
+ {
+ x->x_pos_x += (int)dx;
+ x->x_pos_y += (int)dy;
+ x->x_pix_src_x[0] = x->x_pos_x;
+ x->x_pix_src_y[0] = x->x_pos_y;
+ if(x->x_pix_src_x[0] < 0)
+ x->x_pix_src_x[0] = 0;
+ if(x->x_pix_src_x[0] > x->x_gui.x_w)
+ x->x_pix_src_x[0] = x->x_gui.x_w;
+ if(x->x_pix_src_y[0] < 0)
+ x->x_pix_src_y[0] = 0;
+ if(x->x_pix_src_y[0] > x->x_gui.x_h)
+ x->x_pix_src_y[0] = x->x_gui.x_h;
+ room_sim_2d_out_para(x);
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-pixrad, ypos+x->x_pix_src_y[0]-pixrad,
+ xpos+x->x_pix_src_x[0]+pixrad-1, ypos+x->x_pix_src_y[0]+pixrad-1);
+ ddx = -(int)((t_float)pixrad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ ddy = -(int)((t_float)pixrad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+ddx, ypos+x->x_pix_src_y[0]+ddy);
+ }
+ else
+ {
+ x->x_pos_x += (int)dx;
+ x->x_pos_y += (int)dy;
+ x->x_pix_src_x[sel] = x->x_pos_x;
+ x->x_pix_src_y[sel] = x->x_pos_y;
+ if(x->x_pix_src_x[sel] < 0)
+ x->x_pix_src_x[sel] = 0;
+ if(x->x_pix_src_x[sel] > x->x_gui.x_w)
+ x->x_pix_src_x[sel] = x->x_gui.x_w;
+ if(x->x_pix_src_y[sel] < 0)
+ x->x_pix_src_y[sel] = 0;
+ if(x->x_pix_src_y[sel] > x->x_gui.x_h)
+ x->x_pix_src_y[sel] = x->x_gui.x_h;
+ room_sim_2d_out_para(x);
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, sel, xpos+x->x_pix_src_x[sel], ypos+x->x_pix_src_y[sel]);
+ }
+}
+
+static void room_sim_2d_click(t_room_sim_2d *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ int w = (int)xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int h = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int i, n=x->x_nr_src;
+ int pixrad=x->x_pix_rad;
+ int fsi=x->x_fontsize;
+ int diff, maxdiff=10000, sel=-1;
+
+ i = 0;/* head */
+ if((w >= (x->x_pix_src_x[i]-pixrad)) && (w <= (x->x_pix_src_x[i]+pixrad)) && (h >= (x->x_pix_src_y[i]-pixrad)) && (h <= (x->x_pix_src_y[i]+pixrad)))
+ {
+ diff = w - x->x_pix_src_x[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ diff = h - x->x_pix_src_y[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ }
+
+ fsi *= 2;
+ fsi /= 3;
+ for(i=1; i<=n; i++)
+ {
+ if((w >= (x->x_pix_src_x[i]-fsi)) && (w <= (x->x_pix_src_x[i]+fsi)) &&
+ (h >= (x->x_pix_src_y[i]-fsi)) && (h <= (x->x_pix_src_y[i]+fsi)))
+ {
+ diff = w - x->x_pix_src_x[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ diff = h - x->x_pix_src_y[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ }
+ }
+ if(sel >= 0)
+ {
+ x->x_sel_index = sel;
+ x->x_pos_x = x->x_pix_src_x[sel];
+ x->x_pos_y = x->x_pix_src_y[sel];
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)room_sim_2d_motion, 0, xpos, ypos);
+ }
+}
+
+static int room_sim_2d_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_room_sim_2d* x = (t_room_sim_2d *)z;
+
+ if(doit)
+ {
+ room_sim_2d_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ if(shift)
+ {
+ x->x_gui.x_fsf.x_finemoved = 1;
+ room_sim_2d_out_rho(x);
+ }
+ else
+ {
+ x->x_gui.x_fsf.x_finemoved = 0;
+ room_sim_2d_out_para(x);
+ }
+ }
+ return (1);
+}
+
+static void room_sim_2d_bang(t_room_sim_2d *x)
+{
+ room_sim_2d_out_para(x);
+ room_sim_2d_out_rho(x);
+}
+
+static void room_sim_2d_src_font(t_room_sim_2d *x, t_floatarg ff)
+{
+ int fs=(int)(ff + 0.49999f);
+ int i, n=x->x_nr_src;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(fs < 8)
+ fs = 8;
+ if(fs > 250)
+ fs = 250;
+ x->x_fontsize = fs;
+
+ for(i=1; i<=n; i++)
+ {
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, i, fs);
+ }
+}
+
+static void room_sim_2d_set_rho(t_room_sim_2d *x, t_floatarg rho)
+{
+ while(rho <= -180.0f)
+ rho += 360.0f;
+ while(rho > 180.0f)
+ rho -= 360.0f;
+ x->x_rho_head = rho;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void room_sim_2d_rho(t_room_sim_2d *x, t_floatarg rho)
+{
+ room_sim_2d_set_rho(x, rho);
+ room_sim_2d_out_rho(x);
+}
+
+static void room_sim_2d_set_src_xy(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float xsrc, ysrc;
+ t_float roomx2=0.5f*x->x_room_x, roomy2=0.5f*x->x_room_y;
+ int i, n=x->x_nr_src;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int w2=x->x_gui.x_w/2, h2=x->x_gui.x_h/2;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 3)
+ {
+ post("room_sim_2d ERROR: src_xy-input needs 1 index + 2 float-dimensions: src_index, x [m], y [m]");
+ return;
+ }
+ i = (int)atom_getint(argv++);
+ if((i > 0)&&(i <= n))
+ {
+ ysrc = atom_getfloat(argv++);
+ xsrc = atom_getfloat(argv);
+
+ if(xsrc < -roomy2)
+ xsrc = -roomy2;
+ if(xsrc > roomy2)
+ xsrc = roomy2;
+ if(ysrc < -roomx2)
+ ysrc = -roomx2;
+ if(ysrc > roomx2)
+ ysrc = roomx2;
+
+ x->x_pix_src_x[i] = w2 - (int)(x->x_cnvrt_roomlx2pixh * xsrc + 0.49999f);
+ x->x_pix_src_y[i] = h2 - (int)(x->x_cnvrt_roomlx2pixh * ysrc + 0.49999f);
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ }
+}
+
+static void room_sim_2d_src_xy(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ room_sim_2d_set_src_xy(x, s, argc, argv);
+ room_sim_2d_out_para(x);
+}
+
+static void room_sim_2d_set_head_xy(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int pixrad=x->x_pix_rad;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int w2=x->x_gui.x_w/2, h2=x->x_gui.x_h/2;
+ int ddx, ddy;
+ t_float xh, yh;
+ t_float roomx2=0.5f*x->x_room_x, roomy2=0.5f*x->x_room_y;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 2)
+ {
+ post("room_sim_2d ERROR: head_xy-input needs 2 float-dimensions: x [m], y [m]");
+ return;
+ }
+ yh = atom_getfloat(argv++);
+ xh = atom_getfloat(argv);
+
+ if(xh < -roomy2)
+ xh = -roomy2;
+ if(xh > roomy2)
+ xh = roomy2;
+ if(yh < -roomx2)
+ yh = -roomx2;
+ if(yh > roomx2)
+ yh = roomx2;
+ x->x_pix_src_x[0] = w2 - (int)(x->x_cnvrt_roomlx2pixh * xh + 0.49999f);
+ x->x_pix_src_y[0] = h2 - (int)(x->x_cnvrt_roomlx2pixh * yh + 0.49999f);
+
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-pixrad, ypos+x->x_pix_src_y[0]-pixrad,
+ xpos+x->x_pix_src_x[0]+pixrad-1, ypos+x->x_pix_src_y[0]+pixrad-1);
+ ddx = -(int)((t_float)pixrad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ ddy = -(int)((t_float)pixrad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+ddx, ypos+x->x_pix_src_y[0]+ddy);
+}
+
+static void room_sim_2d_head_xy(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ room_sim_2d_set_head_xy(x, s, argc, argv);
+ room_sim_2d_out_para(x);
+}
+
+static void room_sim_2d_room_dim(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, n=x->x_nr_src;
+
+ if(argc < 2)
+ {
+ post("room_sim_2d ERROR: room_dim-input needs 2 float-dimensions: x-Length [m], y-Width [m]");
+ return;
+ }
+ x->x_room_x = atom_getfloat(argv++);
+ x->x_room_y = atom_getfloat(argv);
+
+ if(x->x_room_x < 1.0f)
+ x->x_room_x = 1.0f;
+ if(x->x_room_y < 1.0f)
+ x->x_room_y = 1.0f;
+
+ x->x_gui.x_h = (int)(x->x_cnvrt_roomlx2pixh * (t_float)x->x_room_x + 0.49999f);
+ x->x_gui.x_w = (int)(x->x_cnvrt_roomlx2pixh * (t_float)x->x_room_y + 0.49999f);
+
+ for(i=1; i<=n; i++)
+ {
+ if(x->x_pix_src_x[i] > x->x_gui.x_w)
+ x->x_pix_src_x[i] = x->x_gui.x_w;
+ if(x->x_pix_src_y[i] > x->x_gui.x_h)
+ x->x_pix_src_y[i] = x->x_gui.x_h;
+ }
+
+ room_sim_2d_out_para(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+/*static void room_sim_2d_n_src(t_room_sim_2d *x, t_floatarg fnsrc)
+{
+int n_src=(int)fnsrc;
+
+ if(n_src < 1)
+ n_src = 1;
+ if(n_src > 30)
+ n_src = 30;
+ if(n_src != x->x_nr_src)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_nr_src = n_src;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+ }
+*/
+
+static void room_sim_2d_room_col(t_room_sim_2d *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_bcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_bcol = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+}
+
+static void room_sim_2d_head_col(t_room_sim_2d *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_fcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_fcol = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xHEAD -outline #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+ sys_vgui(".x%x.c itemconfigure %xNOSE -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+}
+
+static void room_sim_2d_src_col(t_room_sim_2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col;
+ int i, j, n=x->x_nr_src;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ j = (int)atom_getintarg(0, argc, argv);
+ if((j > 0)&&(j <= n))
+ {
+ col = (int)atom_getintarg(1, argc, argv);
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_col_src[j] = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_col_src[j] = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -fill #%6.6x\n", canvas, x, j, x->x_col_src[j]);
+ }
+ }
+}
+
+static void room_sim_2d_pix_per_m_ratio(t_room_sim_2d *x, t_floatarg ratio)
+{
+ t_float rr;
+ int i, n=x->x_nr_src;
+
+ if(ratio < 1.0f)
+ ratio = 1.0f;
+ if(ratio > 200.0f)
+ ratio = 200.0f;
+ rr = ratio / x->x_cnvrt_roomlx2pixh;
+ x->x_cnvrt_roomlx2pixh = ratio;
+ x->x_gui.x_w = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_y + 0.49999f);
+ x->x_gui.x_h = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_x + 0.49999f);
+ x->x_pix_rad = (int)(x->x_cnvrt_roomlx2pixh * x->x_r_ambi + 0.49999f);
+ for(i=0; i<=n; i++)
+ {
+ x->x_pix_src_x[i] = (int)((t_float)x->x_pix_src_x[i]*rr + 0.49999f);
+ x->x_pix_src_y[i] = (int)((t_float)x->x_pix_src_y[i]*rr + 0.49999f);
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void room_sim_2d_r_ambi(t_room_sim_2d *x, t_floatarg r_ambi)
+{
+ if(r_ambi < 0.1f)
+ r_ambi = 0.1f;
+ x->x_r_ambi = r_ambi;
+ x->x_pix_rad = (int)(x->x_cnvrt_roomlx2pixh*r_ambi + 0.49999f);
+ room_sim_2d_out_para(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+}
+
+static void room_sim_2d_nr_src(t_room_sim_2d *x, t_floatarg fnr_src)
+{
+ int nr_src = (int)fnr_src;
+ int old_nr_src, i, j;
+
+ if(nr_src < 1)
+ nr_src = 1;
+ else if(nr_src > IEM_GUI_ROOMSIM_2D_MAX_NR_SRC)
+ nr_src = IEM_GUI_ROOMSIM_2D_MAX_NR_SRC;
+
+ if(nr_src != x->x_nr_src)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+
+ old_nr_src = x->x_nr_src;
+ x->x_nr_src = nr_src;
+ j = (old_nr_src + 1) % 7;
+ for(i=old_nr_src+1; i<=nr_src; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ if(i & 1)
+ x->x_pix_src_x[i] = 125 + (IEM_GUI_ROOMSIM_2D_MAX_NR_SRC - i)*4;
+ else
+ x->x_pix_src_x[i] = 125 - (IEM_GUI_ROOMSIM_2D_MAX_NR_SRC - i)*4;
+ x->x_pix_src_y[i] = 100;
+ j++;
+ j %= 7;
+ }
+
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void *room_sim_2d_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_room_sim_2d *x = (t_room_sim_2d *)pd_new(room_sim_2d_class);
+ int i, j, n=1, c;
+
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ n = (int)atom_getintarg(0, argc, argv);
+ if(n < 1)
+ n = 1;
+ if(n > IEM_GUI_ROOMSIM_2D_MAX_NR_SRC)
+ n = IEM_GUI_ROOMSIM_2D_MAX_NR_SRC;
+ x->x_nr_src = n;
+ }
+ if(argc == (3*n + 11))
+ {
+ x->x_cnvrt_roomlx2pixh = atom_getfloatarg(1, argc, argv);
+ x->x_rho_head = atom_getfloatarg(2, argc, argv);
+ x->x_r_ambi = atom_getfloatarg(3, argc, argv);
+ x->x_fontsize = (int)atom_getintarg(4, argc, argv);
+ c = (int)atom_getintarg(5, argc, argv);
+ x->x_gui.x_bcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_room_x = atom_getfloatarg(6, argc, argv);
+ x->x_room_y = atom_getfloatarg(7, argc, argv);
+ c = (int)atom_getintarg(8, argc, argv);
+ x->x_gui.x_fcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_pix_src_x[0] = (int)atom_getintarg(9, argc, argv);
+ x->x_pix_src_y[0] = (int)atom_getintarg(10, argc, argv);
+ for(i=1; i<=n; i++)
+ {
+ c = (int)atom_getintarg(8+3*i, argc, argv);
+ x->x_col_src[i] = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_pix_src_x[i] = (int)atom_getintarg(9+3*i, argc, argv);
+ x->x_pix_src_y[i] = (int)atom_getintarg(10+3*i, argc, argv);
+ }
+ }
+ else
+ {
+ x->x_cnvrt_roomlx2pixh = 25.0f;
+ x->x_rho_head = 0.0f;
+ x->x_r_ambi = 1.4f;
+ x->x_fontsize = 12;
+ x->x_gui.x_bcol = my_iemgui_color_hex[IEM_GUI_COLNR_GREEN];
+ x->x_room_x = 12.0f;
+ x->x_room_y = 10.0f;
+ x->x_gui.x_fcol = my_iemgui_color_hex[IEM_GUI_COLNR_D_ORANGE];
+ x->x_pix_src_x[0] = 125;
+ x->x_pix_src_y[0] = 200;
+ j = 0;
+ for(i=1; i<=n; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ if(i & 1)
+ x->x_pix_src_x[i] = 125 + (IEM_GUI_ROOMSIM_2D_MAX_NR_SRC - i)*4;
+ else
+ x->x_pix_src_x[i] = 125 - (IEM_GUI_ROOMSIM_2D_MAX_NR_SRC - i)*4;
+ x->x_pix_src_y[i] = 100;
+ j++;
+ j %= 7;
+ }
+ }
+
+ x->x_gui.x_w = (int)(x->x_room_y*x->x_cnvrt_roomlx2pixh + 0.49999f);
+ x->x_gui.x_h = (int)(x->x_room_x*x->x_cnvrt_roomlx2pixh + 0.49999f);
+ x->x_pix_rad = (int)(x->x_r_ambi*x->x_cnvrt_roomlx2pixh + 0.49999f);
+
+ x->x_gui.x_draw = (t_iemfunptr)room_sim_2d_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+
+ x->x_out_para = outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_out_rho = outlet_new(&x->x_gui.x_obj, &s_float);
+
+ x->x_s_head_xy = gensym("head_xy");
+ x->x_s_src_xy = gensym("src_xy");
+ return (x);
+}
+
+static void room_sim_2d_ff(t_room_sim_2d *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void room_sim_2d_setup(void)
+{
+ room_sim_2d_class = class_new(gensym("room_sim_2d"), (t_newmethod)room_sim_2d_new,
+ (t_method)room_sim_2d_ff, sizeof(t_room_sim_2d), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)room_sim_2d_new, gensym("room_sim_2d"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_motion, gensym("motion"),
+ A_FLOAT, A_FLOAT, 0);
+ class_addbang(room_sim_2d_class, (t_method)room_sim_2d_bang);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_room_dim, gensym("room_dim"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_r_ambi, gensym("r_ambi"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_room_col, gensym("room_col"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_head_col, gensym("head_col"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_src_col, gensym("src_col"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_rho, gensym("rho"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_src_xy, gensym("src_xy"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_head_xy, gensym("head_xy"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_set_rho, gensym("set_rho"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_set_src_xy, gensym("set_src_xy"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_set_head_xy, gensym("set_head_xy"), A_GIMME, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_pix_per_m_ratio, gensym("pix_per_m_ratio"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_src_font, gensym("src_font"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_2d_class, (t_method)room_sim_2d_nr_src, gensym("nr_src"), A_DEFFLOAT, 0);
+
+ room_sim_2d_widgetbehavior.w_getrectfn = room_sim_2d_getrect;
+ room_sim_2d_widgetbehavior.w_displacefn = iemgui_displace;
+ room_sim_2d_widgetbehavior.w_selectfn = iemgui_select;
+ room_sim_2d_widgetbehavior.w_activatefn = NULL;
+ room_sim_2d_widgetbehavior.w_deletefn = iemgui_delete;
+ room_sim_2d_widgetbehavior.w_visfn = iemgui_vis;
+ room_sim_2d_widgetbehavior.w_clickfn = room_sim_2d_newclick;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(room_sim_2d_class, room_sim_2d_save);
+#else
+ room_sim_2d_widgetbehavior.w_propertiesfn = NULL;
+ room_sim_2d_widgetbehavior.w_savefn = room_sim_2d_save;
+#endif
+
+ class_setwidget(room_sim_2d_class, &room_sim_2d_widgetbehavior);
+ class_sethelpsymbol(room_sim_2d_class, gensym("iemhelp2/help-room_sim_2d"));
+}
diff --git a/src/room_sim_3d.c b/src/room_sim_3d.c
new file mode 100644
index 0000000..c0fa168
--- /dev/null
+++ b/src/room_sim_3d.c
@@ -0,0 +1,966 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#define IEM_GUI_ROOMSIM_3D_MAX_NR_SRC 30
+
+/* ---------- room_sim_3d my gui-canvas for a window ---------------- */
+
+t_widgetbehavior room_sim_3d_widgetbehavior;
+static t_class *room_sim_3d_class;
+
+typedef struct _room_sim_3d
+{
+ t_iemgui x_gui;
+ t_float x_rho_head;
+ int x_fontsize;
+ int x_nr_src;
+ int x_pix_src_x[IEM_GUI_ROOMSIM_3D_MAX_NR_SRC+1];
+ int x_pix_src_y[IEM_GUI_ROOMSIM_3D_MAX_NR_SRC+1];
+ int x_pix_src_z[IEM_GUI_ROOMSIM_3D_MAX_NR_SRC+1];
+ int x_col_src[IEM_GUI_ROOMSIM_3D_MAX_NR_SRC+1];
+ int x_pos_x;
+ int x_pos_y;
+ int x_pos_z;
+ int x_height_z;
+ int x_sel_index;
+ int x_pix_rad;
+ t_float x_cnvrt_roomlx2pixh;
+ t_float x_r_ambi;
+ t_float x_room_x;
+ t_float x_room_y;
+ t_float x_room_z;
+ void *x_out_para;
+ void *x_out_rho;
+ t_symbol *x_s_head_xyz;
+ t_symbol *x_s_src_xyz;
+ t_atom x_at[6];
+} t_room_sim_3d;
+
+static void room_sim_3d_out_rho(t_room_sim_3d *x)
+{
+ outlet_float(x->x_out_rho, x->x_rho_head);
+}
+
+static void room_sim_3d_out_para(t_room_sim_3d *x)
+{
+ int i, n = x->x_nr_src;
+ int w2=x->x_gui.x_w/2, h2=x->x_gui.x_h/2;
+
+ SETFLOAT(x->x_at, 0.0f);
+ SETSYMBOL(x->x_at+1, x->x_s_head_xyz);
+ SETFLOAT(x->x_at+2, (t_float)(h2 - x->x_pix_src_y[0])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+3, (t_float)(w2 - x->x_pix_src_x[0])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+4, (t_float)(x->x_pix_src_z[0])/x->x_cnvrt_roomlx2pixh);
+ outlet_list(x->x_out_para, &s_list, 5, x->x_at);
+ for(i=1; i<=n; i++)
+ {
+ SETFLOAT(x->x_at, (t_float)i);
+ SETSYMBOL(x->x_at+1, x->x_s_src_xyz);
+ SETFLOAT(x->x_at+2, (t_float)(h2 - x->x_pix_src_y[i])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+3, (t_float)(w2 - x->x_pix_src_x[i])/x->x_cnvrt_roomlx2pixh);
+ SETFLOAT(x->x_at+4, (t_float)(x->x_pix_src_z[i])/x->x_cnvrt_roomlx2pixh);
+ outlet_list(x->x_out_para, &s_list, 5, x->x_at);
+ }
+}
+
+static void room_sim_3d_draw_update(t_room_sim_3d *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy);
+ }
+}
+
+void room_sim_3d_draw_new(t_room_sim_3d *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int rad2;
+ int i, n=x->x_nr_src;
+ int fsi, fs=x->x_fontsize;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ x->x_gui.x_bcol, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:IEM_GUI_COLOR_NORMAL, x);
+ for(i=1; i<=n; i++)
+ {
+ fsi = H2 + (H + 2 * x->x_pix_src_z[i]) * x->x_pix_src_z[i];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c create text %d %d -text {%d} -anchor c \
+ -font {times %d bold} -fill #%6.6x -tags %xSRC%d\n",
+ canvas, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i], i, fsi,
+ x->x_col_src[i], x, i);
+ }
+
+ sys_vgui(".x%x.c create oval %d %d %d %d -outline #%6.6x -tags %xHEAD\n",
+ canvas, xpos+x->x_pix_src_x[0]-x->x_pix_rad, ypos+x->x_pix_src_y[0]-x->x_pix_rad,
+ xpos+x->x_pix_src_x[0]+x->x_pix_rad-1, ypos+x->x_pix_src_y[0]+x->x_pix_rad-1,
+ x->x_gui.x_fcol, x);
+ rad2 = H2 + (H + 2 * x->x_pix_src_z[0]) * x->x_pix_src_z[0];
+ rad2 *= x->x_pix_rad;
+ rad2 /= 8*H2;
+ sys_vgui(".x%x.c create oval %d %d %d %d -outline #%6.6x -tags %xHEAD2\n",
+ canvas, xpos+x->x_pix_src_x[0]-rad2, ypos+x->x_pix_src_y[0]-rad2,
+ xpos+x->x_pix_src_x[0]+rad2-1, ypos+x->x_pix_src_y[0]+rad2-1,
+ x->x_gui.x_fcol, x);
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xNOSE\n",
+ canvas, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy,
+ x->x_gui.x_fcol, x);
+}
+
+void room_sim_3d_draw_move(t_room_sim_3d *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int dx, dy;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int rad2;
+ int i, n=x->x_nr_src;
+ int fsi, fs=x->x_fontsize;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ n = x->x_nr_src;
+ for(i=1; i<=n; i++)
+ {
+ fsi = H2 + (H + 2 * x->x_pix_src_z[i]) * x->x_pix_src_z[i];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, i, fsi);
+ }
+
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-x->x_pix_rad, ypos+x->x_pix_src_y[0]-x->x_pix_rad,
+ xpos+x->x_pix_src_x[0]+x->x_pix_rad-1, ypos+x->x_pix_src_y[0]+x->x_pix_rad-1);
+ rad2 = H2 + (H + 2 * x->x_pix_src_z[0]) * x->x_pix_src_z[0];
+ rad2 *= x->x_pix_rad;
+ rad2 /= 8*H2;
+ sys_vgui(".x%x.c coords %xHEAD2 %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-rad2, ypos+x->x_pix_src_y[0]-rad2,
+ xpos+x->x_pix_src_x[0]+rad2-1, ypos+x->x_pix_src_y[0]+rad2-1);
+ dx = -(int)((t_float)x->x_pix_rad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ dy = -(int)((t_float)x->x_pix_rad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+dx, ypos+x->x_pix_src_y[0]+dy);
+}
+
+void room_sim_3d_draw_erase(t_room_sim_3d* x, t_glist* glist)
+{
+ int i, n;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ n = x->x_nr_src;
+ for(i=1; i<=n; i++)
+ {
+ sys_vgui(".x%x.c delete %xSRC%d\n", canvas, x, i);
+ }
+ sys_vgui(".x%x.c delete %xHEAD\n", canvas, x);
+ sys_vgui(".x%x.c delete %xHEAD2\n", canvas, x);
+ sys_vgui(".x%x.c delete %xNOSE\n", canvas, x);
+}
+
+void room_sim_3d_draw_select(t_room_sim_3d* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ }
+}
+
+void room_sim_3d_draw(t_room_sim_3d *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ room_sim_3d_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ room_sim_3d_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ room_sim_3d_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ room_sim_3d_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ room_sim_3d_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void room_sim_3d_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_room_sim_3d *x = (t_room_sim_3d *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void room_sim_3d_save(t_gobj *z, t_binbuf *b)
+{
+ t_room_sim_3d *x = (t_room_sim_3d *)z;
+ int i, j, c, n=x->x_nr_src;
+
+ binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, gensym("room_sim_3d"));
+ binbuf_addv(b, "ifffi", x->x_nr_src, x->x_cnvrt_roomlx2pixh, x->x_rho_head, x->x_r_ambi, x->x_fontsize);
+ c = x->x_gui.x_bcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "ifff", j, x->x_room_x, x->x_room_y, x->x_room_z);
+ c = x->x_gui.x_fcol;
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iiii", j, x->x_pix_src_x[0], x->x_pix_src_y[0], x->x_pix_src_z[0]);
+ for(i=1; i<=n; i++)
+ {
+ c = x->x_col_src[i];
+ j = (((0xfc0000 & c) >> 6)|((0xfc00 & c) >> 4)|((0xfc & c) >> 2));
+ binbuf_addv(b, "iiii", j, x->x_pix_src_x[i], x->x_pix_src_y[i], x->x_pix_src_z[i]);
+ }
+ binbuf_addv(b, ";");
+}
+
+static void room_sim_3d_motion(t_room_sim_3d *x, t_floatarg dx, t_floatarg dy)
+{
+ int i, n=x->x_nr_src;
+ int pixrad=x->x_pix_rad;
+ int sel=x->x_sel_index;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ddx, ddy;
+ int fs=x->x_fontsize, fsi;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int rad2;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(x->x_gui.x_fsf.x_finemoved && (sel == 0))
+ {
+ if(x->x_gui.x_fsf.x_steady)/*alt-key, rhoy, rhox*/
+ {
+ }
+ else
+ {
+ x->x_rho_head -= dy;
+ if(x->x_rho_head <= -180.0f)
+ x->x_rho_head += 360.0f;
+ if(x->x_rho_head > 180.0f)
+ x->x_rho_head -= 360.0f;
+ room_sim_3d_out_rho(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ }
+ else if(sel == 0)
+ {
+ if(x->x_gui.x_fsf.x_steady)/*alt-key, move head in z*/
+ {
+ x->x_pix_src_x[0] = x->x_pos_x;
+ x->x_pix_src_y[0] = x->x_pos_y;
+ x->x_pix_src_z[0] -= (int)dy;
+ if(x->x_pix_src_z[0] < 0)
+ x->x_pix_src_z[0] = 0;
+ if(x->x_pix_src_z[0] > x->x_height_z)
+ x->x_pix_src_z[0] = x->x_height_z;
+ }
+ else
+ {
+ x->x_pix_src_z[0] = x->x_pos_z;
+ x->x_pos_x += (int)dx;
+ x->x_pos_y += (int)dy;
+ x->x_pix_src_x[0] = x->x_pos_x;
+ x->x_pix_src_y[0] = x->x_pos_y;
+ if(x->x_pix_src_x[0] < 0)
+ x->x_pix_src_x[0] = 0;
+ if(x->x_pix_src_x[0] > x->x_gui.x_w)
+ x->x_pix_src_x[0] = x->x_gui.x_w;
+ if(x->x_pix_src_y[0] < 0)
+ x->x_pix_src_y[0] = 0;
+ if(x->x_pix_src_y[0] > x->x_gui.x_h)
+ x->x_pix_src_y[0] = x->x_gui.x_h;
+ }
+ room_sim_3d_out_para(x);
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-pixrad, ypos+x->x_pix_src_y[0]-pixrad,
+ xpos+x->x_pix_src_x[0]+pixrad-1, ypos+x->x_pix_src_y[0]+pixrad-1);
+ rad2 = H2 + (H + 2 * x->x_pix_src_z[0]) * x->x_pix_src_z[0];
+ rad2 *= x->x_pix_rad;
+ rad2 /= 8*H2;
+ sys_vgui(".x%x.c coords %xHEAD2 %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-rad2, ypos+x->x_pix_src_y[0]-rad2,
+ xpos+x->x_pix_src_x[0]+rad2-1, ypos+x->x_pix_src_y[0]+rad2-1);
+ ddx = -(int)((t_float)pixrad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ ddy = -(int)((t_float)pixrad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+ddx, ypos+x->x_pix_src_y[0]+ddy);
+ }
+ else
+ {
+ if(x->x_gui.x_fsf.x_steady)/*alt-key, move src in z*/
+ {
+ x->x_pix_src_z[sel] -= (int)dy;
+ if(x->x_pix_src_z[sel] < 0)
+ x->x_pix_src_z[sel] = 0;
+ if(x->x_pix_src_z[sel] > x->x_height_z)
+ x->x_pix_src_z[sel] = x->x_height_z;
+
+ room_sim_3d_out_para(x);
+ fsi = H2 + (H + 2 * x->x_pix_src_z[sel]) * x->x_pix_src_z[sel];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, sel, fsi);
+ }
+ else
+ {
+ x->x_pos_x += (int)dx;
+ x->x_pos_y += (int)dy;
+ x->x_pix_src_x[sel] = x->x_pos_x;
+ x->x_pix_src_y[sel] = x->x_pos_y;
+ x->x_pix_src_z[sel] = x->x_pos_z;
+ if(x->x_pix_src_x[sel] < 0)
+ x->x_pix_src_x[sel] = 0;
+ if(x->x_pix_src_x[sel] > x->x_gui.x_w)
+ x->x_pix_src_x[sel] = x->x_gui.x_w;
+ if(x->x_pix_src_y[sel] < 0)
+ x->x_pix_src_y[sel] = 0;
+ if(x->x_pix_src_y[sel] > x->x_gui.x_h)
+ x->x_pix_src_y[sel] = x->x_gui.x_h;
+
+ room_sim_3d_out_para(x);
+ fsi = H2 + (H + 2 * x->x_pix_src_z[sel]) * x->x_pix_src_z[sel];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, sel, xpos+x->x_pix_src_x[sel], ypos+x->x_pix_src_y[sel]);
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, sel, fsi);
+ }
+ }
+}
+
+static void room_sim_3d_click(t_room_sim_3d *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ int w = (int)xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int h = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int i, n=x->x_nr_src;
+ int pixrad=x->x_pix_rad;
+ int fs=x->x_fontsize, fsi;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int diff, maxdiff=10000, sel=-1;
+
+ i = 0;/* head */
+ if((w >= (x->x_pix_src_x[i]-pixrad)) && (w <= (x->x_pix_src_x[i]+pixrad)) && (h >= (x->x_pix_src_y[i]-pixrad)) && (h <= (x->x_pix_src_y[i]+pixrad)))
+ {
+ diff = w - x->x_pix_src_x[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ diff = h - x->x_pix_src_y[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ }
+
+ for(i=1; i<=n; i++)
+ {
+ fsi = H2 + (H + 2 * x->x_pix_src_z[i]) * x->x_pix_src_z[i];
+ fsi *= fs;
+ fsi /= 2*H2;
+ if(fsi < fs)
+ fsi = fs;
+ fsi *= 2;
+ fsi /= 3;
+ if((w >= (x->x_pix_src_x[i]-fsi)) && (w <= (x->x_pix_src_x[i]+fsi)) &&
+ (h >= (x->x_pix_src_y[i]-fsi)) && (h <= (x->x_pix_src_y[i]+fsi)))
+ {
+ diff = w - x->x_pix_src_x[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ diff = h - x->x_pix_src_y[i];
+ if(diff < 0)
+ diff *= -1;
+ if(diff < maxdiff)
+ {
+ maxdiff = diff;
+ sel = i;
+ }
+ }
+ }
+ if(sel >= 0)
+ {
+ x->x_sel_index = sel;
+ x->x_pos_x = x->x_pix_src_x[sel];
+ x->x_pos_y = x->x_pix_src_y[sel];
+ x->x_pos_z = x->x_pix_src_z[sel];
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)room_sim_3d_motion, 0, xpos, ypos);
+ }
+}
+
+static int room_sim_3d_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_room_sim_3d* x = (t_room_sim_3d *)z;
+
+ if(doit)
+ {
+ room_sim_3d_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ if(alt)
+ x->x_gui.x_fsf.x_steady = 1;
+ else
+ x->x_gui.x_fsf.x_steady = 0;
+
+ if(shift)
+ {
+ x->x_gui.x_fsf.x_finemoved = 1;
+ room_sim_3d_out_rho(x);
+ }
+ else
+ {
+ x->x_gui.x_fsf.x_finemoved = 0;
+ room_sim_3d_out_para(x);
+ }
+ }
+ return (1);
+}
+
+static void room_sim_3d_bang(t_room_sim_3d *x)
+{
+ room_sim_3d_out_para(x);
+ room_sim_3d_out_rho(x);
+}
+
+static void room_sim_3d_src_font(t_room_sim_3d *x, t_floatarg ff)
+{
+ int fs=(int)(ff + 0.49999f), fsi;
+ int i, n=x->x_nr_src;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(fs < 8)
+ fs = 8;
+ if(fs > 250)
+ fs = 250;
+ x->x_fontsize = fs;
+
+ for(i=1; i<=n; i++)
+ {
+ fsi = H2 + (H + 2 * x->x_pix_src_z[i]) * x->x_pix_src_z[i];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, i, fsi);
+ }
+}
+
+static void room_sim_3d_set_rho(t_room_sim_3d *x, t_floatarg rhoz)
+{
+ while(rhoz <= -180.0f)
+ rhoz += 360.0f;
+ while(rhoz > 180.0f)
+ rhoz -= 360.0f;
+ x->x_rho_head = rhoz;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void room_sim_3d_rho(t_room_sim_3d *x, t_floatarg rhoz)
+{
+ room_sim_3d_set_rho(x, rhoz);
+ room_sim_3d_out_rho(x);
+}
+
+static void room_sim_3d_set_src_xyz(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float xsrc, ysrc, zsrc;
+ t_float roomx2=0.5f*x->x_room_x, roomy2=0.5f*x->x_room_y, roomz=x->x_room_z;
+ int i, n=x->x_nr_src;
+ int pixrad=x->x_pix_rad;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int w2=x->x_gui.x_w/2, h2=x->x_gui.x_h/2;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int fsi, fs=x->x_fontsize;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 4)
+ {
+ post("room_sim_3d ERROR: src_xyz-input needs 1 index + 3 float-dimensions: src_index, x [m], y [m], z [m]");
+ return;
+ }
+ i = (int)atom_getint(argv++);
+ if((i > 0)&&(i <= n))
+ {
+ ysrc = atom_getfloat(argv++);
+ xsrc = atom_getfloat(argv++);
+ zsrc = atom_getfloat(argv);
+
+ if(xsrc < -roomy2)
+ xsrc = -roomy2;
+ if(xsrc > roomy2)
+ xsrc = roomy2;
+ if(ysrc < -roomx2)
+ ysrc = -roomx2;
+ if(ysrc > roomx2)
+ ysrc = roomx2;
+ if(zsrc < 0.0f)
+ zsrc = 0.0f;
+ if(zsrc > roomz)
+ zsrc = roomz;
+
+ x->x_pix_src_x[i] = w2 - (int)(x->x_cnvrt_roomlx2pixh * xsrc + 0.49999f);
+ x->x_pix_src_y[i] = h2 - (int)(x->x_cnvrt_roomlx2pixh * ysrc + 0.49999f);
+ x->x_pix_src_z[i] = (int)(x->x_cnvrt_roomlx2pixh * zsrc + 0.49999f);
+
+ fsi = H2 + (H + 2 * x->x_pix_src_z[i]) * x->x_pix_src_z[i];
+ fsi *= fs;
+ fsi /= 2*H2;
+ sys_vgui(".x%x.c coords %xSRC%d %d %d\n",
+ canvas, x, i, xpos+x->x_pix_src_x[i], ypos+x->x_pix_src_y[i]);
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -font {times %d bold}\n", canvas, x, i, fsi);
+ }
+}
+
+static void room_sim_3d_src_xyz(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ room_sim_3d_set_src_xyz(x, s, argc, argv);
+ room_sim_3d_out_para(x);
+}
+
+static void room_sim_3d_set_head_xyz(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float roomx2=0.5f*x->x_room_x, roomy2=0.5f*x->x_room_y, roomz=x->x_room_z;
+ int pixrad=x->x_pix_rad;
+ int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ int ddx, ddy;
+ int H=(int)(0.5f * x->x_room_z * x->x_cnvrt_roomlx2pixh + 0.49999f);
+ int H2=H*H;
+ int rad2;
+ t_float xh, yh, zh;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(argc < 3)
+ {
+ post("room_sim_3d ERROR: head_xyz-input needs 3 float-dimensions: x [m], y [m], z [m]");
+ return;
+ }
+ yh = atom_getfloat(argv++);
+ xh = atom_getfloat(argv++);
+ zh = atom_getfloat(argv);
+ if(xh < -roomy2)
+ xh = -roomy2;
+ if(xh > roomy2)
+ xh = roomy2;
+ if(yh < -roomx2)
+ yh = -roomx2;
+ if(yh > roomx2)
+ yh = roomx2;
+ if(zh < 0.0f)
+ zh = 0.0f;
+ if(zh > roomz)
+ zh = roomz;
+ x->x_pix_src_x[0] = x->x_gui.x_w/2 - (int)(x->x_cnvrt_roomlx2pixh * xh + 0.49999f);
+ x->x_pix_src_y[0] = x->x_gui.x_h/2 - (int)(x->x_cnvrt_roomlx2pixh * yh + 0.49999f);
+ x->x_pix_src_z[0] = (int)(x->x_cnvrt_roomlx2pixh * zh + 0.49999f);
+
+ sys_vgui(".x%x.c coords %xHEAD %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-pixrad, ypos+x->x_pix_src_y[0]-pixrad,
+ xpos+x->x_pix_src_x[0]+pixrad-1, ypos+x->x_pix_src_y[0]+pixrad-1);
+ rad2 = H2 + (H + 2 * x->x_pix_src_z[0]) * x->x_pix_src_z[0];
+ rad2 *= pixrad;
+ rad2 /= 8*H2;
+ sys_vgui(".x%x.c coords %xHEAD2 %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0]-rad2, ypos+x->x_pix_src_y[0]-rad2,
+ xpos+x->x_pix_src_x[0]+rad2-1, ypos+x->x_pix_src_y[0]+rad2-1);
+ ddx = -(int)((t_float)pixrad*(t_float)sin(x->x_rho_head*0.0174533f) + 0.49999f);
+ ddy = -(int)((t_float)pixrad*(t_float)cos(x->x_rho_head*0.0174533f) + 0.49999f);
+ sys_vgui(".x%x.c coords %xNOSE %d %d %d %d\n",
+ canvas, x, xpos+x->x_pix_src_x[0], ypos+x->x_pix_src_y[0],
+ xpos+x->x_pix_src_x[0]+ddx, ypos+x->x_pix_src_y[0]+ddy);
+}
+
+static void room_sim_3d_head_xyz(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ room_sim_3d_set_head_xyz(x, s, argc, argv);
+ room_sim_3d_out_para(x);
+}
+
+static void room_sim_3d_room_dim(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, n=x->x_nr_src;
+
+ if(argc < 3)
+ {
+ post("room_sim_3d ERROR: room_dim-input needs 3 float-dimensions: x-Length [m], y-Width [m], z-Height [m]");
+ return;
+ }
+ x->x_room_x = atom_getfloat(argv++);
+ x->x_room_y = atom_getfloat(argv++);
+ x->x_room_z = atom_getfloat(argv);
+
+ if(x->x_room_x < 1.0f)
+ x->x_room_x = 1.0f;
+ if(x->x_room_y < 1.0f)
+ x->x_room_y = 1.0f;
+ if(x->x_room_z < 1.0f)
+ x->x_room_z = 1.0f;
+
+ x->x_gui.x_h = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_x + 0.49999f);
+ x->x_gui.x_w = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_y + 0.49999f);
+ x->x_height_z = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_z + 0.49999f);
+ x->x_pix_rad = (int)(x->x_cnvrt_roomlx2pixh * x->x_r_ambi + 0.49999f);
+
+ for(i=0; i<=n; i++)
+ {
+ if(x->x_pix_src_x[i] > x->x_gui.x_w)
+ x->x_pix_src_x[i] = x->x_gui.x_w;
+ if(x->x_pix_src_y[i] > x->x_gui.x_h)
+ x->x_pix_src_y[i] = x->x_gui.x_h;
+ if(x->x_pix_src_z[i] > x->x_height_z)
+ x->x_pix_src_z[i] = x->x_height_z;
+ }
+
+ room_sim_3d_out_para(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void room_sim_3d_room_col(t_room_sim_3d *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_bcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_bcol = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+}
+
+static void room_sim_3d_head_col(t_room_sim_3d *x, t_floatarg fcol)
+{
+ int col=(int)fcol;
+ int i;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_gui.x_fcol = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_gui.x_fcol = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xHEAD -outline #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+ sys_vgui(".x%x.c itemconfigure %xHEAD2 -outline #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+ sys_vgui(".x%x.c itemconfigure %xNOSE -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+}
+
+static void room_sim_3d_src_col(t_room_sim_3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col;
+ int i, j, n=x->x_nr_src;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
+ {
+ j = (int)atom_getintarg(0, argc, argv);
+ if((j > 0)&&(j <= n))
+ {
+ col = (int)atom_getintarg(1, argc, argv);
+ if(col < 0)
+ {
+ i = -1 - col;
+ x->x_col_src[j] = ((i & 0x3f000) << 6)|((i & 0xfc0) << 4)|((i & 0x3f) << 2);
+ }
+ else
+ {
+ if(col > 29)
+ col = 29;
+ x->x_col_src[j] = my_iemgui_color_hex[col];
+ }
+ sys_vgui(".x%x.c itemconfigure %xSRC%d -fill #%6.6x\n", canvas, x, j, x->x_col_src[j]);
+ }
+ }
+}
+
+static void room_sim_3d_pix_per_m_ratio(t_room_sim_3d *x, t_floatarg ratio)
+{
+ t_float rr;
+ int i, n=x->x_nr_src;
+
+ if(ratio < 1.0f)
+ ratio = 1.0f;
+ if(ratio > 200.0f)
+ ratio = 200.0f;
+ rr = ratio / x->x_cnvrt_roomlx2pixh;
+ x->x_cnvrt_roomlx2pixh = ratio;
+ x->x_gui.x_w = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_y + 0.49999f);
+ x->x_gui.x_h = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_x + 0.49999f);
+ x->x_height_z = (int)(x->x_cnvrt_roomlx2pixh * x->x_room_z + 0.49999f);
+ x->x_pix_rad = (int)(x->x_cnvrt_roomlx2pixh * x->x_r_ambi + 0.49999f);
+ for(i=0; i<=n; i++)
+ {
+ x->x_pix_src_x[i] = (int)((t_float)x->x_pix_src_x[i]*rr + 0.49999f);
+ x->x_pix_src_y[i] = (int)((t_float)x->x_pix_src_y[i]*rr + 0.49999f);
+ x->x_pix_src_z[i] = (int)((t_float)x->x_pix_src_z[i]*rr + 0.49999f);
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void room_sim_3d_r_ambi(t_room_sim_3d *x, t_floatarg r_ambi)
+{
+ if(r_ambi < 0.1f)
+ r_ambi = 0.1f;
+ x->x_r_ambi = r_ambi;
+ x->x_pix_rad = (int)(x->x_cnvrt_roomlx2pixh*r_ambi + 0.49999f);
+ room_sim_3d_out_para(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+}
+
+static void room_sim_3d_nr_src(t_room_sim_3d *x, t_floatarg fnr_src)
+{
+ int nr_src = (int)fnr_src;
+ int old_nr_src, i, j;
+
+ if(nr_src < 1)
+ nr_src = 1;
+ else if(nr_src > IEM_GUI_ROOMSIM_3D_MAX_NR_SRC)
+ nr_src = IEM_GUI_ROOMSIM_3D_MAX_NR_SRC;
+
+ if(nr_src != x->x_nr_src)
+ {
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+
+ old_nr_src = x->x_nr_src;
+ x->x_nr_src = nr_src;
+ j = (old_nr_src + 1) % 7;
+ for(i=old_nr_src+1; i<=nr_src; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ if(i & 1)
+ x->x_pix_src_x[i] = 125 + (IEM_GUI_ROOMSIM_3D_MAX_NR_SRC - i)*4;
+ else
+ x->x_pix_src_x[i] = 125 - (IEM_GUI_ROOMSIM_3D_MAX_NR_SRC - i)*4;
+ x->x_pix_src_y[i] = 100;
+ x->x_pix_src_z[i] = 42;
+ j++;
+ j %= 7;
+ }
+
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void *room_sim_3d_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_room_sim_3d *x = (t_room_sim_3d *)pd_new(room_sim_3d_class);
+ int i, j, n=1, c;
+
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ n = (int)atom_getintarg(0, argc, argv);
+ if(n < 1)
+ n = 1;
+ if(n > IEM_GUI_ROOMSIM_3D_MAX_NR_SRC)
+ n = IEM_GUI_ROOMSIM_3D_MAX_NR_SRC;
+ x->x_nr_src = n;
+ }
+ if(argc == (4*n + 13))
+ {
+ x->x_cnvrt_roomlx2pixh = atom_getfloatarg(1, argc, argv);
+ x->x_rho_head = atom_getfloatarg(2, argc, argv);
+ x->x_r_ambi = atom_getfloatarg(3, argc, argv);
+ x->x_fontsize = (int)atom_getintarg(4, argc, argv);
+ c = (int)atom_getintarg(5, argc, argv);
+ x->x_gui.x_bcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_room_x = atom_getfloatarg(6, argc, argv);
+ x->x_room_y = atom_getfloatarg(7, argc, argv);
+ x->x_room_z = atom_getfloatarg(8, argc, argv);
+ c = (int)atom_getintarg(9, argc, argv);
+ x->x_gui.x_fcol = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_pix_src_x[0] = (int)atom_getintarg(10, argc, argv);
+ x->x_pix_src_y[0] = (int)atom_getintarg(11, argc, argv);
+ x->x_pix_src_z[0] = (int)atom_getintarg(12, argc, argv);
+ j = 13;
+ for(i=1; i<=n; i++)
+ {
+ c = (int)atom_getintarg(j, argc, argv);
+ j++;
+ x->x_col_src[i] = ((c & 0x3f000) << 6)|((c & 0xfc0) << 4)|((c & 0x3f) << 2);
+ x->x_pix_src_x[i] = (int)atom_getintarg(j, argc, argv);
+ j++;
+ x->x_pix_src_y[i] = (int)atom_getintarg(j, argc, argv);
+ j++;
+ x->x_pix_src_z[i] = (int)atom_getintarg(j, argc, argv);
+ j++;
+ }
+ }
+ else
+ {
+ x->x_cnvrt_roomlx2pixh = 25.0f;
+ x->x_rho_head = 0.0f;
+ x->x_r_ambi = 1.4f;
+ x->x_fontsize = 12;
+ x->x_gui.x_bcol = my_iemgui_color_hex[IEM_GUI_COLNR_GREEN];
+ x->x_room_x = 12.0f;
+ x->x_room_y = 10.0f;
+ x->x_room_z = 5.0f;
+ x->x_gui.x_fcol = my_iemgui_color_hex[IEM_GUI_COLNR_D_ORANGE];
+ x->x_pix_src_x[0] = 125;
+ x->x_pix_src_y[0] = 200;
+ x->x_pix_src_z[0] = 42;
+ j = 0;
+ for(i=1; i<=n; i++)
+ {
+ x->x_col_src[i] = simularca_color_hex[j];
+ if(i & 1)
+ x->x_pix_src_x[i] = 125 + (IEM_GUI_ROOMSIM_3D_MAX_NR_SRC - i)*4;
+ else
+ x->x_pix_src_x[i] = 125 - (IEM_GUI_ROOMSIM_3D_MAX_NR_SRC - i)*4;
+ x->x_pix_src_y[i] = 100;
+ x->x_pix_src_z[i] = 42;
+ j++;
+ j %= 7;
+ }
+ }
+
+ x->x_gui.x_w = (int)(x->x_room_y*x->x_cnvrt_roomlx2pixh + 0.49999f);
+ x->x_gui.x_h = (int)(x->x_room_x*x->x_cnvrt_roomlx2pixh + 0.49999f);
+ x->x_height_z = (int)(x->x_room_z*x->x_cnvrt_roomlx2pixh + 0.49999f);
+ x->x_pix_rad = (int)(x->x_r_ambi*x->x_cnvrt_roomlx2pixh + 0.49999f);
+
+ x->x_gui.x_draw = (t_iemfunptr)room_sim_3d_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+
+ x->x_out_para = outlet_new(&x->x_gui.x_obj, &s_list);
+ x->x_out_rho = outlet_new(&x->x_gui.x_obj, &s_float);
+
+ x->x_s_head_xyz = gensym("head_xyz");
+ x->x_s_src_xyz = gensym("src_xyz");
+ return (x);
+}
+
+static void room_sim_3d_ff(t_room_sim_3d *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void room_sim_3d_setup(void)
+{
+ room_sim_3d_class = class_new(gensym("room_sim_3d"), (t_newmethod)room_sim_3d_new,
+ (t_method)room_sim_3d_ff, sizeof(t_room_sim_3d), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)room_sim_3d_new, gensym("room_sim_3d"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_motion, gensym("motion"),
+ A_FLOAT, A_FLOAT, 0);
+ class_addbang(room_sim_3d_class, (t_method)room_sim_3d_bang);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_room_dim, gensym("room_dim"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_r_ambi, gensym("r_ambi"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_room_col, gensym("room_col"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_head_col, gensym("head_col"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_src_col, gensym("src_col"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_rho, gensym("rho"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_src_xyz, gensym("src_xyz"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_head_xyz, gensym("head_xyz"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_set_rho, gensym("set_rho"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_set_src_xyz, gensym("set_src_xyz"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_set_head_xyz, gensym("set_head_xyz"), A_GIMME, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_pix_per_m_ratio, gensym("pix_per_m_ratio"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_src_font, gensym("src_font"), A_DEFFLOAT, 0);
+ class_addmethod(room_sim_3d_class, (t_method)room_sim_3d_nr_src, gensym("nr_src"), A_DEFFLOAT, 0);
+
+ room_sim_3d_widgetbehavior.w_getrectfn = room_sim_3d_getrect;
+ room_sim_3d_widgetbehavior.w_displacefn = iemgui_displace;
+ room_sim_3d_widgetbehavior.w_selectfn = iemgui_select;
+ room_sim_3d_widgetbehavior.w_activatefn = NULL;
+ room_sim_3d_widgetbehavior.w_deletefn = iemgui_delete;
+ room_sim_3d_widgetbehavior.w_visfn = iemgui_vis;
+ room_sim_3d_widgetbehavior.w_clickfn = room_sim_3d_newclick;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(room_sim_3d_class, room_sim_3d_save);
+#else
+ room_sim_3d_widgetbehavior.w_propertiesfn = NULL;
+ room_sim_3d_widgetbehavior.w_savefn = room_sim_3d_save;
+#endif
+
+ class_setwidget(room_sim_3d_class, &room_sim_3d_widgetbehavior);
+ class_sethelpsymbol(room_sim_3d_class, gensym("iemhelp2/help-room_sim_3d"));
+}
diff --git a/src/sym_dial.c b/src/sym_dial.c
new file mode 100644
index 0000000..6f3dfe1
--- /dev/null
+++ b/src/sym_dial.c
@@ -0,0 +1,931 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include "t_tk.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#define IEM_SDL_FLASH_TIME 200
+
+t_widgetbehavior sym_dial_widgetbehavior;
+static t_class *sym_dial_class;
+
+typedef struct _sym_dial
+{
+ t_iemgui x_gui;
+ t_clock *x_clock;
+ void *x_outlet;
+ int x_index;
+ t_symbol **x_syms;
+ int x_ac;
+ int x_max_ac;
+ int x_symwidth;
+ int x_snd_flt0_sym1;
+
+} t_sym_dial;
+
+/* widget helper functions */
+
+static void sym_dial_draw_swap(t_sym_dial *x, t_glist *glist, int swap)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n",
+ canvas, x,
+ swap?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ sys_vgui(".x%x.c itemconfigure %xSYMBOL -fill #%6.6x\n",
+ canvas, x,
+ swap?x->x_gui.x_bcol:x->x_gui.x_fcol);
+}
+
+static void sym_dial_tick(t_sym_dial *x)
+{
+ sym_dial_draw_swap(x, x->x_gui.x_glist, 0);
+}
+
+static void sym_dial_inc(t_sym_dial *x)
+{
+ x->x_index = (x->x_index + 1) % x->x_ac;
+}
+
+void sym_dial_calc_fontwidth(t_sym_dial *x)
+{
+ int w, f=31;
+
+ if(x->x_gui.x_fsf.x_font_style == 1)
+ f = 27;
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ f = 25;
+
+ w = x->x_gui.x_fontsize * f * x->x_gui.x_w;
+ w /= 36;
+ x->x_symwidth = w + (x->x_gui.x_h / 2) + 4;
+}
+
+static void sym_dial_draw_update(t_sym_dial *x, t_glist *glist)
+{
+ if (glist_isvisible(glist))
+ {
+ char string[200];
+ int l;
+
+ strcpy(string, x->x_syms[x->x_index]->s_name);
+ l = strlen(string);
+ if(l > x->x_gui.x_w)
+ {
+ string[x->x_gui.x_w-1] = '~';
+ string[x->x_gui.x_w] = 0;
+ }
+ sys_vgui(".x%x.c itemconfigure %xSYMBOL -fill #%6.6x -text {%s} \n",
+ glist_getcanvas(glist), x,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol,
+ string);
+ }
+}
+
+static void sym_dial_draw_new(t_sym_dial *x, t_glist *glist)
+{
+ int half=x->x_gui.x_h/2, d=x->x_gui.x_h/34;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+ char string[200];
+ int l;
+
+ strcpy(string, x->x_syms[x->x_index]->s_name);
+ l = strlen(string);
+ if(l > x->x_gui.x_w)
+ {
+ string[x->x_gui.x_w] = '~';
+ string[x->x_gui.x_w+1] = 0;
+ }
+
+ sys_vgui(".x%x.c create polygon %d %d %d %d %d %d %d %d %d %d %d %d -outline #%6.6x -fill #%6.6x -tags %xBASE\n",
+ canvas, xpos-1, ypos,
+ xpos + x->x_symwidth-4, ypos,
+ xpos + x->x_symwidth, ypos+4,
+ xpos + x->x_symwidth, ypos + x->x_gui.x_h,
+ xpos-1, ypos + x->x_gui.x_h,
+ xpos+half-1, ypos+half,
+ IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x);
+ sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
+ -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
+ sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
+ -font {%s %d bold} -fill #%6.6x -tags %xSYMBOL\n",
+ canvas, xpos+half+2, ypos+half+d,
+ string, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_fcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h,
+ x, 0);
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos+x->x_symwidth-IOWIDTH, ypos + x->x_gui.x_h-1,
+ xpos+x->x_symwidth, ypos + x->x_gui.x_h, x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas, xpos, ypos, xpos+IOWIDTH, ypos+1, x, 0);
+}
+
+static void sym_dial_draw_move(t_sym_dial *x, t_glist *glist)
+{
+ int half = x->x_gui.x_h/2, d=x->x_gui.x_h/34;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d %d %d %d %d %d %d %d %d\n",
+ canvas, x, xpos-1, ypos,
+ xpos + x->x_symwidth-4, ypos,
+ xpos + x->x_symwidth, ypos+4,
+ xpos + x->x_symwidth, ypos + x->x_gui.x_h,
+ xpos-1, ypos + x->x_gui.x_h,
+ xpos+half-1, ypos+half);
+ sys_vgui(".x%x.c coords %xLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ sys_vgui(".x%x.c coords %xSYMBOL %d %d\n",
+ canvas, x, xpos+half+2, ypos+half+d);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h);
+ sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
+ canvas, x, 1,
+ xpos+x->x_symwidth-IOWIDTH, ypos + x->x_gui.x_h-1,
+ xpos+x->x_symwidth, ypos + x->x_gui.x_h);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1);
+}
+
+static void sym_dial_draw_erase(t_sym_dial* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
+ sys_vgui(".x%x.c delete %xSYMBOL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+}
+
+static void sym_dial_draw_config(t_sym_dial* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%x.c itemconfigure %xSYMBOL -font {%s %d bold} -fill #%6.6x \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
+ sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas,
+ x, x->x_gui.x_bcol);
+}
+
+static void sym_dial_draw_io(t_sym_dial* x,t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h,
+ x, 0);
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
+ canvas,
+ xpos+x->x_symwidth-IOWIDTH, ypos + x->x_gui.x_h-1,
+ xpos+x->x_symwidth, ypos + x->x_gui.x_h,
+ x, 1);
+ }
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
+ sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
+ }
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
+}
+
+static void sym_dial_draw_select(t_sym_dial *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ // pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym2);
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%x.c itemconfigure %xSYMBOL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ // pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym2);
+ sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ sys_vgui(".x%x.c itemconfigure %xSYMBOL -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+ }
+}
+
+void sym_dial_draw(t_sym_dial *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sym_dial_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ sym_dial_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ sym_dial_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ sym_dial_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ sym_dial_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ sym_dial_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ sym_dial_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ vsl widgetbehaviour----------------------------- */
+
+static void sym_dial_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_sym_dial* x = (t_sym_dial*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_symwidth;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void sym_dial_save(t_gobj *z, t_binbuf *b)
+{
+ t_sym_dial *x = (t_sym_dial *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+ int i;
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiiisssiiiiiiiii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("sdl"), x->x_gui.x_w, x->x_gui.x_h,
+ iem_symargstoint(&x->x_gui.x_isa), x->x_snd_flt0_sym1,
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2],
+ x->x_index, x->x_ac);
+ for(i=0; i<x->x_ac; i++) /*16 + ac syms*/
+ {
+ binbuf_addv(b, "s", x->x_syms[i]);
+ }
+ binbuf_addv(b, ";");
+}
+#else
+static void sym_dial_save(t_gobj *z, t_binbuf *b)
+{
+ t_sym_dial *x = (t_sym_dial *)z;
+ int bflcol[3], *ip1, *ip2;
+ t_symbol *srl[3];
+ int i;
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ ip1 = (int *)(&x->x_gui.x_isa);
+ ip2 = (int *)(&x->x_gui.x_fsf);
+ binbuf_addv(b, "ssiisiiiisssiiiiiiiii", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("sdl"), x->x_gui.x_w, x->x_gui.x_h,
+ (*ip1)&IEM_INIT_ARGS_ALL, x->x_snd_flt0_sym1,
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ (*ip2)&IEM_FSTYLE_FLAGS_ALL, x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2],
+ x->x_index, x->x_ac);
+ for(i=0; i<x->x_ac; i++) /*16 + ac syms*/
+ {
+ binbuf_addv(b, "s", x->x_syms[i]);
+ }
+ binbuf_addv(b, ";");
+}
+#endif
+
+static void sym_dial_properties(t_gobj *z, t_glist *owner)
+{
+ t_sym_dial *x = (t_sym_dial *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s SYM_DIAL \
+ -------dimensions(digits)(pix):------- %d %d width: %d %d height: \
+ empty 0 empty 0 empty 0 \
+ %d snd_flt snd_sym %d %d empty -1 \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, 1, x->x_gui.x_h, 8,
+ /*no_schedule*/
+ x->x_snd_flt0_sym1, x->x_gui.x_isa.x_loadinit, -1,/*no multi, but iem-characteristic*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void sym_dial_out(t_sym_dial *x)
+{
+ outlet_symbol(x->x_outlet, x->x_syms[x->x_index]);
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_index);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ {
+ if(x->x_snd_flt0_sym1)
+ pd_symbol(x->x_gui.x_snd->s_thing, x->x_syms[x->x_index]);
+ else
+ pd_float(x->x_gui.x_snd->s_thing, x->x_index);
+ }
+}
+
+static void sym_dial_bang(t_sym_dial *x)
+{
+ sym_dial_inc(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ sym_dial_out(x);
+}
+
+static void sym_dial_dialog(t_sym_dial *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int h = (int)atom_getintarg(1, argc, argv);
+ int snd_fs = (int)atom_getintarg(4, argc, argv);
+ int sr_flags;
+
+ if(snd_fs != 0) snd_fs = 1;
+ x->x_snd_flt0_sym1 = snd_fs;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ sym_dial_calc_fontwidth(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void sym_dial_click(t_sym_dial *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ sym_dial_inc(x);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ sym_dial_draw_swap(x, x->x_gui.x_glist, 1);
+ clock_delay(x->x_clock, IEM_SDL_FLASH_TIME);
+ sym_dial_out(x);
+}
+
+static int sym_dial_newclick(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ if(doit)
+ {
+ sym_dial_click((t_sym_dial *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ }
+ return (1);
+}
+
+static void sym_dial_set(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{
+ if(ac > 0)
+ {
+ int i=0;
+
+ if(IS_A_FLOAT(av, 0))
+ {
+ i=(int)atom_getintarg(0, ac, av);
+ if(i < 0)
+ i = 0;
+ else if(i >= x->x_ac)
+ i = x->x_ac - 1;
+ x->x_index = i;
+ }
+ else if(IS_A_SYMBOL(av, 0))
+ {
+ t_symbol *s=atom_getsymbolarg(0, ac, av);
+ for(i=0; i<x->x_ac; i++)
+ {
+ if(x->x_syms[i] == s)
+ break;
+ }
+ x->x_index = i;
+ }
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void sym_dial_float(t_sym_dial *x, t_floatarg f)
+{
+ int i=(int)f;
+
+ if(i < 0)
+ i = 0;
+ else if(i >= x->x_ac)
+ i = x->x_ac - 1;
+ x->x_index = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ if(x->x_gui.x_fsf.x_put_in2out)
+ sym_dial_out(x);
+}
+
+static void sym_dial_symbol(t_sym_dial *x, t_symbol *s)
+{
+ int i;
+
+ for(i=0; i<x->x_ac; i++)
+ {
+ if(x->x_syms[i] == s)
+ break;
+ }
+ x->x_index = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ if(x->x_gui.x_fsf.x_put_in2out)
+ sym_dial_out(x);
+}
+
+static void sym_dial_size(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{
+ int h, w;
+
+ w = (int)atom_getintarg(0, ac, av);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(ac > 1)
+ {
+ h = (int)atom_getintarg(1, ac, av);
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ }
+ sym_dial_calc_fontwidth(x);
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void sym_dial_delta(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void sym_dial_pos(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void sym_dial_color(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void sym_dial_send(t_sym_dial *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void sym_dial_receive(t_sym_dial *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void sym_dial_label(t_sym_dial *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void sym_dial_label_pos(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void sym_dial_label_font(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{
+ int f = (int)atom_getintarg(1, ac, av);
+
+ if(f < 4)
+ f = 4;
+ x->x_gui.x_fontsize = f;
+ f = (int)atom_getintarg(0, ac, av);
+ if((f < 0) || (f > 2))
+ f = 0;
+ x->x_gui.x_fsf.x_font_style = f;
+ sym_dial_calc_fontwidth(x);
+ iemgui_label_font((void *)x, &x->x_gui, s, ac, av);
+}
+
+static void sym_dial_send_sym(t_sym_dial *x)
+{
+ x->x_snd_flt0_sym1 = 1;
+}
+
+static void sym_dial_send_flt(t_sym_dial *x)
+{
+ x->x_snd_flt0_sym1 = 0;
+}
+
+static void sym_dial_init(t_sym_dial *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void sym_dial_loadbang(t_sym_dial *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ sym_dial_bang(x);
+ }
+}
+
+static void sym_dial_set_item_name(t_sym_dial *x, t_symbol *name, t_float findex)
+{
+ int i = (int)findex;
+
+ if(i < 0)
+ i = 0;
+ else if(i >= x->x_max_ac)
+ {
+ x->x_syms = (t_symbol **)t_resizebytes(x->x_syms, x->x_max_ac * sizeof(t_symbol *),
+ x->x_max_ac * (2*sizeof(t_symbol *)));
+ x->x_max_ac *= 2;
+ }
+ if(i >= x->x_ac)
+ {
+ t_symbol *default_sym=gensym("no_entry");
+ int j;
+
+ for(j=x->x_ac; j<i; j++)
+ x->x_syms[j] = default_sym;
+ x->x_ac++;
+ }
+ x->x_syms[i] = gensym(name->s_name);
+ if(i == x->x_index)
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+/*static void sym_dial_list(t_sym_dial *x, t_symbol *s, int ac, t_atom *av)
+{
+int l=iemgui_list((void *)x, &x->x_gui, s, ac, av);
+
+ if(l < 0)
+ {
+ if((ac==2)&&(IS_A_FLOAT(av,0))&&(IS_A_SYMBOL(av,1)))
+ {
+ sym_dial_float(x, atom_getfloatarg(0, ac, av));
+ }
+ }
+ if(l > 0)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}*/
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+static void *sym_dial_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_sym_dial *x = (t_sym_dial *)pd_new(sym_dial_class);
+ int bflcol[]={-262144, -1, -1};
+ int w=6, h=14, ac=0, i, j;
+ int snd_fs=0, f=0, ldx=59, ldy=7;
+ int fs=9, index=0;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if((argc >= 16)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
+ &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
+ &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
+ snd_fs = (int)atom_getintarg(3, argc, argv);
+ iemgui_new_getnames(&x->x_gui, 4, argv);
+ ldx = (int)atom_getintarg(7, argc, argv);
+ ldy = (int)atom_getintarg(8, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
+ fs = (int)atom_getintarg(10, argc, argv);
+ bflcol[0] = (int)atom_getintarg(11, argc, argv);
+ bflcol[1] = (int)atom_getintarg(12, argc, argv);
+ bflcol[2] = (int)atom_getintarg(13, argc, argv);
+ index = atom_getintarg(14, argc, argv);
+ ac = (int)atom_getintarg(15, argc, argv);
+ if((ac+16) == argc)
+ {
+ x->x_ac = ac;
+ x->x_max_ac = ac;
+ x->x_syms = (t_symbol **)getbytes(x->x_max_ac * sizeof(t_symbol *));
+ for(i=0, j=16; i<ac; i++, j++)
+ {
+ if(IS_A_SYMBOL(argv, j))
+ x->x_syms[i] = atom_getsymbolarg(j, argc, argv);
+ else if(IS_A_FLOAT(argv, j))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(j, argc, argv));
+ x->x_syms[i] = gensym(str);
+ }
+ }
+ }
+ }
+ else
+ {
+ iemgui_new_getnames(&x->x_gui, 1, 0);
+ x->x_ac = 1;
+ x->x_max_ac = 10;
+ x->x_syms = (t_symbol **)getbytes(x->x_max_ac * sizeof(t_symbol *));
+ x->x_syms[0] = gensym("sdl");
+ index = 0;
+ }
+
+ x->x_gui.x_draw = (t_iemfunptr)sym_dial_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_index = index;
+ else
+ x->x_index = 0;
+ if(snd_fs != 0)
+ snd_fs = 1;
+ x->x_snd_flt0_sym1 = snd_fs;
+
+ if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1)
+ strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ strcpy(x->x_gui.x_font, "times");
+ else
+ {
+ x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, "courier");
+ }
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ sym_dial_calc_fontwidth(x);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock = clock_new(x, (t_method)sym_dial_tick);
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_outlet = outlet_new(&x->x_gui.x_obj, &s_symbol);
+ return (x);
+}
+#else
+static void *sym_dial_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_sym_dial *x = (t_sym_dial *)pd_new(sym_dial_class);
+ int bflcol[]={-262144, -1, -1};
+ t_symbol *srl[3];
+ int w=6, h=14, ac=0, i, j;
+ int snd_fs=0, f=0, ldx=59, ldy=7;
+ int fs=9, iinit=0, ifstyle=0, index=0;
+ t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
+ t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
+ char str[144];
+
+ srl[0] = gensym("empty");
+ srl[1] = gensym("empty");
+ srl[2] = gensym("empty");
+
+ if((argc >= 16)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
+ &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
+ &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ iinit = (int)atom_getintarg(2, argc, argv);
+ snd_fs = (int)atom_getintarg(3, argc, argv);
+ srl[0] = atom_getsymbolarg(4, argc, argv);
+ srl[1] = atom_getsymbolarg(5, argc, argv);
+ srl[2] = atom_getsymbolarg(6, argc, argv);
+ if(IS_A_SYMBOL(argv,4))
+ srl[0] = atom_getsymbolarg(4, argc, argv);
+ else if(IS_A_FLOAT(argv,4))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(4, argc, argv));
+ srl[0] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,5))
+ srl[1] = atom_getsymbolarg(5, argc, argv);
+ else if(IS_A_FLOAT(argv,5))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(5, argc, argv));
+ srl[1] = gensym(str);
+ }
+ if(IS_A_SYMBOL(argv,6))
+ srl[2] = atom_getsymbolarg(6, argc, argv);
+ else if(IS_A_FLOAT(argv,6))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(6, argc, argv));
+ srl[2] = gensym(str);
+ }
+ ldx = (int)atom_getintarg(7, argc, argv);
+ ldy = (int)atom_getintarg(8, argc, argv);
+ ifstyle = (int)atom_getintarg(9, argc, argv);
+ fs = (int)atom_getintarg(10, argc, argv);
+ bflcol[0] = (int)atom_getintarg(11, argc, argv);
+ bflcol[1] = (int)atom_getintarg(12, argc, argv);
+ bflcol[2] = (int)atom_getintarg(13, argc, argv);
+ index = atom_getintarg(14, argc, argv);
+ ac = (int)atom_getintarg(15, argc, argv);
+ if((ac+16) == argc)
+ {
+ x->x_ac = ac;
+ x->x_max_ac = ac;
+ x->x_syms = (t_symbol **)getbytes(x->x_max_ac * sizeof(t_symbol *));
+ for(i=0, j=16; i<ac; i++, j++)
+ {
+ if(IS_A_SYMBOL(argv, j))
+ x->x_syms[i] = atom_getsymbolarg(j, argc, argv);
+ else if(IS_A_FLOAT(argv, j))
+ {
+ sprintf(str, "%d", (int)atom_getintarg(j, argc, argv));
+ x->x_syms[i] = gensym(str);
+ }
+ }
+ }
+ }
+ else
+ {
+ x->x_ac = 1;
+ x->x_max_ac = 10;
+ x->x_syms = (t_symbol **)getbytes(x->x_max_ac * sizeof(t_symbol *));
+ x->x_syms[0] = gensym("sdl");
+ index = 0;
+ }
+
+ x->x_gui.x_draw = (t_iemfunptr)sym_dial_draw;
+ iinit &= IEM_INIT_ARGS_ALL;
+ ifstyle &= IEM_FSTYLE_FLAGS_ALL;
+ fstyle->x_snd_able = 1;
+ fstyle->x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ x->x_gui.x_isa = *init;
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_index = index;
+ else
+ x->x_index = 0;
+ if(snd_fs != 0) snd_fs = 1;
+ x->x_snd_flt0_sym1 = snd_fs;
+ if(!strcmp(srl[0]->s_name, "empty")) fstyle->x_snd_able = 0;
+ if(!strcmp(srl[1]->s_name, "empty")) fstyle->x_rcv_able = 0;
+ x->x_gui.x_unique_num = 0;
+ if(fstyle->x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(fstyle->x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { fstyle->x_font_style = 0;
+ strcpy(x->x_gui.x_font, "courier"); }
+ x->x_gui.x_fsf = *fstyle;
+ iemgui_first_dollararg2sym(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, srl[1]);
+ x->x_gui.x_snd = srl[0];
+ x->x_gui.x_rcv = srl[1];
+ x->x_gui.x_lab = srl[2];
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ sym_dial_calc_fontwidth(x);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock = clock_new(x, (t_method)sym_dial_tick);
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_outlet = outlet_new(&x->x_gui.x_obj, &s_symbol);
+ return (x);
+}
+#endif
+
+static void sym_dial_free(t_sym_dial *x)
+{
+ // if(x->x_gui.x_fsf.x_selected)
+ // pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym2);
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ freebytes(x->x_syms, x->x_max_ac * sizeof(t_symbol *));
+ clock_free(x->x_clock);
+}
+
+void sym_dial_setup(void)
+{
+ sym_dial_class = class_new(gensym("sdl"), (t_newmethod)sym_dial_new,
+ (t_method)sym_dial_free, sizeof(t_sym_dial), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)sym_dial_new, gensym("sym_dial"), A_GIMME, 0);
+ class_addbang(sym_dial_class,sym_dial_bang);
+ class_addfloat(sym_dial_class,sym_dial_float);
+ // class_addlist(sym_dial_class, sym_dial_list);
+ class_addsymbol(sym_dial_class, sym_dial_symbol);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_loadbang, gensym("loadbang"), 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_set, gensym("set"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_send_flt, gensym("send_flt"), 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_send_sym, gensym("send_sym"), 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_init, gensym("init"), A_FLOAT, 0);
+ class_addmethod(sym_dial_class, (t_method)sym_dial_set_item_name, gensym("set_item_name"), A_SYMBOL, A_FLOAT, 0);
+ // if(!iemgui_key_sym2)
+ // iemgui_key_sym2 = gensym("#keyname");
+ sym_dial_widgetbehavior.w_getrectfn = sym_dial_getrect;
+ sym_dial_widgetbehavior.w_displacefn = iemgui_displace;
+ sym_dial_widgetbehavior.w_selectfn = iemgui_select;
+ sym_dial_widgetbehavior.w_activatefn = NULL;
+ sym_dial_widgetbehavior.w_deletefn = iemgui_delete;
+ sym_dial_widgetbehavior.w_visfn = iemgui_vis;
+ sym_dial_widgetbehavior.w_clickfn = sym_dial_newclick;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(sym_dial_class, sym_dial_save);
+ class_setpropertiesfn(sym_dial_class, sym_dial_properties);
+#else
+ sym_dial_widgetbehavior.w_savefn = sym_dial_save;
+ sym_dial_widgetbehavior.w_propertiesfn = sym_dial_properties;
+#endif
+
+ class_setwidget(sym_dial_class, &sym_dial_widgetbehavior);
+ class_sethelpsymbol(sym_dial_class, gensym("iemhelp2/help-sym_dial"));
+}
diff --git a/src/vfad_scale.c b/src/vfad_scale.c
new file mode 100644
index 0000000..2ee0659
--- /dev/null
+++ b/src/vfad_scale.c
@@ -0,0 +1,202 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemgui written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iemgui.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <string.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------------------ setup routine ------------------------- */
+
+t_widgetbehavior vfad_scale_widgetbehavior;
+static t_class *vfad_scale_class;
+
+typedef struct _vfad_scale
+{
+ t_iemgui x_gui;
+ char x_gif[720];
+} t_vfad_scale;
+
+static void vfad_scale_draw_new(t_vfad_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui("image create photo %xPHOTOIMAGE -format gif -data {%s} -width %d -height %d\n",
+ x, x->x_gif, x->x_gui.x_w, x->x_gui.x_h);
+ sys_vgui(".x%x.c create image %d %d -image %xPHOTOIMAGE -tags %xPHOTO\n",
+ canvas, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2, x, x);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ IEM_GUI_COLOR_SELECTED, x);
+}
+
+static void vfad_scale_draw_move(t_vfad_scale *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%x.c coords %xPHOTO %d %d\n",
+ canvas, x, xpos+x->x_gui.x_w/2, ypos+x->x_gui.x_h/2);
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void vfad_scale_draw_erase(t_vfad_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+ sys_vgui("image delete %xPHOTOIMAGE\n", x);
+ sys_vgui(".x%x.c delete %xPHOTO\n", canvas, x);
+}
+
+static void vfad_scale_draw_select(t_vfad_scale* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
+ canvas, xpos, ypos, xpos + x->x_gui.x_w,
+ ypos + x->x_gui.x_h, IEM_GUI_COLOR_SELECTED, x);
+ }
+ else
+ sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
+}
+
+static void vfad_scale_draw(t_vfad_scale *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ vfad_scale_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ vfad_scale_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ vfad_scale_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ vfad_scale_draw_erase(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void vfad_scale_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_vfad_scale *x = (t_vfad_scale *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void vfad_scale_color(t_vfad_scale *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ x->x_gui.x_lcol = (-1 - i) & 0xffffff;
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ if(glist_isvisible(x->x_gui.x_glist))
+ sys_vgui("%xPHOTOIMAGE configure -data {%s}\n", x, x->x_gif);
+ }
+}
+
+static void vfad_scale_save(t_gobj *z, t_binbuf *b)
+{
+ t_vfad_scale *x = (t_vfad_scale *)z;
+
+ binbuf_addv(b, "ssiisi", gensym("#X"),gensym("obj"),
+ (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
+ gensym("vfad_scale"), -1 - (((0xfc0000 & x->x_gui.x_lcol) >> 6)|
+ ((0xfc00 & x->x_gui.x_lcol) >> 4)|((0xfc & x->x_gui.x_lcol) >> 2)));
+ binbuf_addv(b, ";");
+}
+
+static void *vfad_scale_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_vfad_scale *x = (t_vfad_scale *)pd_new(vfad_scale_class);
+
+ if((argc >= 1)&&IS_A_FLOAT(argv,0))
+ {
+ int j, i = (int)atom_getintarg(0, argc, argv);
+
+ if(i >= 0)
+ {
+ j = iemgui_modulo_color(i);
+ x->x_gui.x_lcol = my_iemgui_color_hex[j];
+ }
+ else
+ {
+ j = -1 - i;
+ x->x_gui.x_lcol = ((j & 0x3f000) << 6)|((j & 0xfc0) << 4)|((j & 0x3f) << 2);
+ }
+ }
+ else
+ x->x_gui.x_lcol = 0;
+ x->x_gui.x_draw = (t_iemfunptr)vfad_scale_draw;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ x->x_gui.x_w = 12;
+ x->x_gui.x_h = 126;
+ strcpy(x->x_gif, my_iemgui_black_vscale_gif);
+ my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
+ x->x_gui.x_fsf.x_selected = 0;
+ return(x);
+}
+
+static void vfad_scale_ff(t_vfad_scale *x)
+{
+ gfxstub_deleteforkey(x);
+}
+
+void vfad_scale_setup(void)
+{
+ vfad_scale_class = class_new(gensym("vfad_scale"), (t_newmethod)vfad_scale_new,
+ (t_method)vfad_scale_ff, sizeof(t_vfad_scale), 0, A_GIMME, 0);
+ class_addmethod(vfad_scale_class, (t_method)vfad_scale_color, gensym("color"), A_GIMME, 0);
+ vfad_scale_widgetbehavior.w_getrectfn = vfad_scale_getrect;
+ vfad_scale_widgetbehavior.w_displacefn = iemgui_displace;
+ vfad_scale_widgetbehavior.w_selectfn = iemgui_select;
+ vfad_scale_widgetbehavior.w_activatefn = NULL;
+ vfad_scale_widgetbehavior.w_deletefn = iemgui_delete;
+ vfad_scale_widgetbehavior.w_visfn = iemgui_vis;
+ vfad_scale_widgetbehavior.w_clickfn = NULL;
+
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+ class_setsavefn(vfad_scale_class, vfad_scale_save);
+#else
+ vfad_scale_widgetbehavior.w_propertiesfn = NULL;
+ vfad_scale_widgetbehavior.w_savefn = vfad_scale_save;
+#endif
+
+ class_setwidget(vfad_scale_class, &vfad_scale_widgetbehavior);
+ class_sethelpsymbol(vfad_scale_class, gensym("iemhelp2/help-vfad_scale"));
+}