diff --git a/externals/Makefile b/externals/Makefile index a19b2b048dc5d4895606de0f85c378f1ce8ddd1d..e7ea11fc9ae4593f14e6f976f87f6c3fbe47129b 100644 --- a/externals/Makefile +++ b/externals/Makefile @@ -1779,65 +1779,16 @@ toxy_clean: #------------------------------------------------------------------------------# # UNAUTHORIZED -UNAUTHORIZED_NAME=unauthorized -# these need to be created before compiling the C -UNAUTHORIZED_TKFILES = $(wildcard $(externals_src)/unauthorized/*/*.tk) -%.tk2c: %.tk - bash $(externals_src)/unauthorized/tk2c.bash < $*.tk > $*.tk2c - -# a number of objects don't compile under MinGW (yet? they used to, but the -# needed changes were overwritten, so they are in CVS -ifeq ($(OS_NAME),windows) -UNAUTHORIZED_OBJECTS := $(wildcard $(externals_src)/unauthorized/[abdg-oqrw]*/*.c)\ -$(wildcard $(externals_src)/unauthorized/c?[a-np-z]*/*.c) -else - ifeq ($(OS_NAME),darwin) - # [cooled~] crashes Pd on Mac OS X, [vocoder~] doesn't compile - UNAUTHORIZED_OBJECTS := $(wildcard $(externals_src)/unauthorized/[abd-uw-z]*/*.c)\ - $(wildcard $(externals_src)/unauthorized/c?[a-np-z]*/*.c) - else - # GNU/Linux, BSD, IRIX, etc. - UNAUTHORIZED_OBJECTS := $(wildcard $(externals_src)/unauthorized/*/*.c) - endif -endif - - -# [vocoder~] is built separately since its made from a number of files -UNAUTHORIZED_VOCODER = $(wildcard $(externals_src)/unauthorized/vocoder*/*.c) - $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION): $(UNAUTHORIZED_VOCODER:.c=.o) - $(CC) $(LDFLAGS) -o $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION) \ - $(UNAUTHORIZED_VOCODER:.c=.o) $(LIBS) - -unauthorized: $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION) \ -$(UNAUTHORIZED_TKFILES:.tk=.tk2c) $(UNAUTHORIZED_OBJECTS:.c=.$(EXTENSION)) +unauthorized: + make -C $(externals_src)/unauthorized CFLAGS="$(CFLAGS)" \ + PD_PATH=$(pd_src) PD_INCLUDE=$(pd_src)/src -unauthorized_install: unauthorized - install -d $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME) - $(scripts_src)/generate-libdir-metafile.sh $(DESTDIR)$(objectsdir) $(UNAUTHORIZED_NAME) \ - --author "Yves Degoyon" \ - --license "GNU GPL" \ - --description "GUI and streaming objects" - install -p $(externals_src)/unauthorized/*/*.$(EXTENSION) \ - $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME) - install -p $(externals_src)/unauthorized/*/*.pd \ - $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME) - install -p $(externals_src)/unauthorized/*/*.pls \ - $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME) - install -d $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME)/blm - install -p $(externals_src)/unauthorized/blinkenlights/blm/*.* \ - $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME)/blm - install -d $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME)/manual - install -p $(externals_src)/unauthorized/*/*.txt \ - $(DESTDIR)$(objectsdir)/$(UNAUTHORIZED_NAME)/manual +unauthorized_install: + make -C $(externals_src)/unauthorized \ + DESTDIR="$(DESTDIR)" objectsdir="$(objectsdir)" install unauthorized_clean: - -rm -f -- $(UNAUTHORIZED_OBJECTS:.c=.$(EXTENSION)) - -rm -f -- $(UNAUTHORIZED_OBJECTS:.c=.o) - -rm -f -- $(UNAUTHORIZED_VOCODER:.c=.$(EXTENSION)) - -rm -f -- $(UNAUTHORIZED_VOCODER:.c=.o) - -rm -f -- $(externals_src)/unauthorized/*/*.bak - -rm -f -- $(externals_src)/*/*.*~ - -rm -f -- $(externals_src)/*.*~ + make -C $(externals_src)/unauthorized clean #------------------------------------------------------------------------------# diff --git a/externals/unauthorized/COPYING b/externals/unauthorized/LICENSE.txt similarity index 81% rename from externals/unauthorized/COPYING rename to externals/unauthorized/LICENSE.txt index 2128a66ea7d038eecac13febce1a26b3da3b7159..d159169d1050894d3ea3b98e1c965c4058208fe1 100644 --- a/externals/unauthorized/COPYING +++ b/externals/unauthorized/LICENSE.txt @@ -1,280 +1,339 @@ - 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 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/externals/unauthorized/Makefile b/externals/unauthorized/Makefile index 4cff73fb40682b67fda4226498b37eb8a522625b..5b2c9734d847156d1d796abaf1f09f7134fa5401 100644 --- a/externals/unauthorized/Makefile +++ b/externals/unauthorized/Makefile @@ -1,216 +1,440 @@ -CC=gcc - -EXT=$(shell uname -s | sed -e 's/^[lL]/pd_l/' | sed -e 's/^[dD]/pd_d/' | sed -e 's/MINGW.*/dll/') - -# This is Miller's default install location -INSTALL_PREFIX=/usr/local/lib/pd - -# find all files to compile -TARGETS=$(subst .tk,.tk2c,$(wildcard */*.tk)) $(subst .c,.$(EXT),$(wildcard */*.c)) - -current: $(TARGETS) - @echo "Making $(TARGETS)" - -.SUFFIXES: .pd_linux .pd_darwin .pd_irix5 .pd_irix6 .dll .tk .tk2c - -# ----------------------- Common ------------------------ - -.tk.tk2c: - bash ./tk2c.bash < $*.tk > $*.tk2c - - -# ----------------------- MinGW ----------------------- - -pd_nt: $(TARGETS) - -MINGW_CFLAGS = -DPD -DUNIX -DICECAST -DWANT_WINSOCK2_H \ - -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes -g \ - -Wno-unused -Wno-parentheses -Wno-switch \ - -mno-cygwin -c -DBUILD_DLL -MINGW_CFLAGS = -DPD -DNT -DICECAST -funroll-loops \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch - -MINGW_INCLUDE = -I../../src -I../../pd/src -IC:/msys/1.0/include - - -MINGW_LDFLAGS = -shared -L../../pd/bin -LC:/msys/1.0/lib \ - -lpd -logg -lvorbis -lspeex -lpthreadGC2 - - -.c.dll: - $(CC) -mms-bitfields $(MINGW_CFLAGS) $(DEFINES) $(MINGW_INCLUDE) \ - -o "$*.o" -c "$*.c" - gcc $(MINGW_LDFLAGS) -o "$*.dll" "$*.o" - strip --strip-unneeded "$*.dll" - rm "$*.o" - - -#.c.dll: CURRENT_DIR = `echo $* | cut -d '/' -f 1` -# $(CC) $(MINGW_CFLAGS) $(MINGW_INCLUDE) -o $*.o -c $*.c -# ld --export-dynamic -shared -o $*.dll $*.o -lc -lm $(MINGW_LFLAGS) -# strip --strip-unneeded $*.dll -# dllwrap --target=i386-mingw32 -mno-cygwin --output-lib=lib$*.a \ -# --dllname=$*.dll --driver-name=gcc $*.o $(MINGW_LFLAGS) -# -rm $*.o - - -# ----------------------- Windows ----------------------- - -# PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -# VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -# PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -# PDNTLDIR = $(VC)\lib -# PDNTLIB = $(PDNTLDIR)\libc.lib \ -# $(PDNTLDIR)\oldnames.lib \ -# $(PDNTLDIR)\kernel32.lib \ -# \ftp\pd\bin\pd.lib - -# .c.ont: -# cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - -# .c.dll: -# cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c -# need to find a way to replace $(CSYM) -# link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) -#======= -# $(CC) $(WINCFLAGS) $(WININCLUDE) -o $*.o -c $*.c -# gcc -shared -o $*.dll $*.o ../../bin/pd.dll -lwsock32 -lmp3lame -lpthread -# -rm $*.o -#>>>>>>> 1.10 - - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.oi5: - $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - -.c.pd_irix5: - $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.oi6: - $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - -.c.pd_irix6: - $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(TARGETS) - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -fPIC -Wall -W -Wno-shadow -Wstrict-prototypes -g \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src -I../../pd/src - -.c.pd_linux: - $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - -rm $*.o - -# ----------------------- Mac OSX ----------------------- - -pd_darwin: $(TARGETS) - -# I added these defines since Darwin doesn't have this signals. I do -# not know whether the objects will work, but they will compile. -# -DMSG_NOSIGNAL=0 -DSOL_TCP=0 -# I got this from here: http://www.holwegner.com/forum/viewtopic.php?t=4 -# -DARWINCFLAGS = -DPD -DUNIX \ - -O2 -Wall -W -Wshadow -Wstrict-prototypes -Wno-unused -Wno-parentheses \ - -Wno-switch - -## if you point the linker to the pd binary, then it can check the symbols, -## and therefore allow for a two-level namespace, and that makes Darwin happy -## but this doesn't work for some of the files yet. -DARWINLINKFLAGS = -bundle -bundle_loader ../../pd/bin/pd -DARWINLIBS = -L/sw/lib -logg -lvorbis -lmp3lame -lspeex -#DARWINLINKFLAGS = -bundle -undefined suppress -flat_namespace - -DARWININCLUDE = -I../../src -I../../pd/src -I/sw/include - -.c.pd_darwin: - $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c - $(CC) $(DARWINLINKFLAGS) -o $*.pd_darwin $*.o $(DARWINLIBS) - chmod a-x "$*.pd_darwin" - strip -u -r $*.pd_darwin - -rm $*.o - -# added by Hans-Christoph Steiner -# to generate MacOS X packages - -PACKAGE_PREFIX = pd-unauthorized -PACKAGE_VERSION = $(shell date +20%y.%m.%d) -PACKAGE_NAME = $(PACKAGE_PREFIX)-$(PACKAGE_VERSION) - -darwin_pkg_license: - # generate HTML version of License - echo "" > License.html - sed -e 's/^$$/\/g' COPYING >> License.html - echo "" >> License.html - -darwin_pkg_clean: - -sudo rm -Rf installroot/ $(PACKAGE_PREFIX)*.pkg/ - -rm -f $(PACKAGE_PREFIX)-*.info 1 License.html - -# install into MSP's default: /usr/local/lib - -darwin_pkg: pd_darwin darwin_pkg_clean darwin_pkg_license -# set up installroot dir - test -d installroot/pd/doc/5.reference || mkdir -p installroot/pd/doc/5.reference - install -m644 --group=staff */*.pd installroot/pd/doc/5.reference - install -m644 --group=staff */*.txt installroot/pd/doc/5.reference - install -m644 --group=staff */*.pls installroot/pd/doc/5.reference - cp -Rf blinkenlights/blm installroot/pd/doc/5.reference - test -d installroot/pd/extra || mkdir -p installroot/pd/extra - install -m644 --group=staff */*.pd_darwin installroot/pd/extra - cp -f pd-unauthorized.info $(PACKAGE_NAME).info -# delete cruft - -find installroot -name .DS_Store -delete - -rm -f 1 -# set proper permissions - sudo chown -R root:staff installroot - package installroot $(PACKAGE_NAME).info -d . -ignoreDSStore -# install pkg docs - install -m 644 License.html $(PACKAGE_NAME).pkg/Contents/Resources - sudo chown -R root:staff $(PACKAGE_NAME).pkg/Contents/Resources - - -# ---------------------------------------------------------- - -install: - cp */*.pd $(INSTALL_PREFIX)/doc/5.reference +## Pd library template version 1.0.12 +# For instructions on how to use this template, see: +# http://puredata.info/docs/developer/MakefileTemplate +LIBRARY_NAME = unauthorized + +# add your .c source files, one object per file, to the SOURCES +# variable, help files will be included automatically, and for GUI +# objects, the matching .tcl file too +SOURCES = audience~.c beatify~.c blinkenlights.c compressor~.c cooled~.c countund.c disto~.c exciter.c filterbank~.c formant~.c grid.c mp3cast~.c mp3fileout~.c mp3streamin~.c mp3streamout~.c mp3write~.c pianoroll.c playlist.c probalizer.c randomblock~.c samplebox~.c scratcher~.c scrolllist.c sonogram~.c speexin~.c speexout~.c spigot~.c wahwah~.c + +SOURCES_linux = mp3amp~.c +SOURCES_macosx = mp3amp~.c + +# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will +# be included automatically +PDOBJECTS = + +# example patches and related files, in the 'examples' subfolder +EXAMPLES = analyze-100.pd mrandtab.pd randtab.pd resynth-64.pd setosc.pd speaker.gif test-streaming-mp3.pd wanderer.gif xmms.pd yesterday.txt + +# manuals and related files, in the 'manual' subfolder +MANUAL = disto~.txt + +# if you want to include any other files in the source and binary tarballs, +# list them here. This can be anything from header files, test patches, +# documentation, etc. README.txt and LICENSE.txt are required and therefore +# automatically included +EXTRA_DIST = audience~.h exciter.h filterbank~.h interface.h g_grid.h mpg123.h mpglib.h pianoroll.h probalizer.h timeval.h + +# unit tests and related files here, in the 'unittests' subfolder +UNITTESTS = + + + +#------------------------------------------------------------------------------# +# +# things you might need to edit if you are using other C libraries +# +#------------------------------------------------------------------------------# + +ALL_CFLAGS = -I"$(PD_INCLUDE)" +ALL_LDFLAGS = +SHARED_LDFLAGS = +ALL_LIBS = -lspeex -lmp3lame -lpthread + + +#------------------------------------------------------------------------------# +# +# you shouldn't need to edit anything below here, if we did it right :) +# +#------------------------------------------------------------------------------# + +# these can be set from outside without (usually) breaking the build +CFLAGS = -Wall -W -g +LDFLAGS = +LIBS = + +# get library version from meta file +LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) + +ALL_CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"' + +PD_INCLUDE = $(PD_PATH)/include/pd +# where to install the library, overridden below depending on platform +prefix = /usr/local +libdir = $(prefix)/lib +pkglibdir = $(libdir)/pd-externals +objectsdir = $(pkglibdir) + +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) -p -m 644 +INSTALL_DATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -p -m 755 -d + +ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ + $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) + +DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) +ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION) + +UNAME := $(shell uname -s) +ifeq ($(UNAME),Darwin) + CPU := $(shell uname -p) + ifeq ($(CPU),arm) # iPhone/iPod Touch + SOURCES += $(SOURCES_iphoneos) + EXTENSION = pd_darwin + SHARED_EXTENSION = dylib + OS = iphoneos + PD_PATH = /Applications/Pd-extended.app/Contents/Resources + IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin + CC=$(IPHONE_BASE)/gcc + CPP=$(IPHONE_BASE)/cpp + CXX=$(IPHONE_BASE)/g++ + ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk + IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 + OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer + ALL_CFLAGS := $(IPHONE_CFLAGS) $(ALL_CFLAGS) + ALL_LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) + SHARED_LDFLAGS += -arch armv6 -dynamiclib -undefined dynamic_lookup $(ISYSROOT) + ALL_LIBS += -lc $(LIBS_iphoneos) + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) + else # Mac OS X + SOURCES += $(SOURCES_macosx) + EXTENSION = pd_darwin + SHARED_EXTENSION = dylib + OS = macosx + PD_PATH = /Applications/Pd-extended.app/Contents/Resources + OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast +# build universal 32-bit on 10.4 and 32/64 on newer + ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) + FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 + else + FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + SOURCES += $(SOURCES_iphoneos) + endif + ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include + # if the 'pd' binary exists, check the linking against it to aid with stripping + BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd) + ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib + SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \ + -install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0 + ALL_LIBS += -lc $(LIBS_macosx) + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) +# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much + pkglibdir=$(HOME)/Library/Pd + endif +endif +# Tho Android uses Linux, we use this fake uname to provide an easy way to +# setup all this things needed to cross-compile for Android using the NDK +ifeq ($(UNAME),ANDROID) + CPU := arm + SOURCES += $(SOURCES_android) + EXTENSION = pd_linux + SHARED_EXTENSION = so + OS = android + PD_PATH = /usr + NDK_BASE := /usr/local/android-ndk + NDK_PLATFORM_VERSION := 5 + NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm + NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]') + NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86 + CC := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT) + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += + LDFLAGS += -rdynamic -shared + SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared + LIBS += -lc $(LIBS_android) + STRIP := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-strip \ + --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq ($(UNAME),Linux) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + SHARED_EXTENSION = so + OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + ALL_CFLAGS += -fPIC + ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared + ALL_LIBS += -lc $(LIBS_linux) + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq ($(UNAME),GNU) + # GNU/Hurd, should work like GNU/Linux for basically all externals + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + SHARED_EXTENSION = so + OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + ALL_CFLAGS += -fPIC + ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) + ALL_LIBS += -lc $(LIBS_linux) + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq ($(UNAME),GNU/kFreeBSD) + # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + SHARED_EXTENSION = so + OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + ALL_CFLAGS += -fPIC + ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) + ALL_LIBS += -lc $(LIBS_linux) + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_cygwin) + EXTENSION = dll + SHARED_EXTENSION = dll + OS = cygwin + PD_PATH = $(shell cygpath $$PROGRAMFILES)/pd + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + ALL_CFLAGS += + ALL_LDFLAGS += -rdynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" + SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) + ALL_LIBS += -lc -lpd $(LIBS_cygwin) + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif +ifeq (MINGW,$(findstring MINGW,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_windows) + EXTENSION = dll + SHARED_EXTENSION = dll + OS = windows + PD_PATH = $(shell cd "$$PROGRAMFILES/pd" && pwd) + # MinGW doesn't seem to include cc so force gcc + CC=gcc + OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer + ALL_CFLAGS += -mms-bitfields + ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" + SHARED_LDFLAGS += -shared + ALL_LIBS += -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 $(LIBS_windows) + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif + +# in case somebody manually set the HELPPATCHES above +HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd) + +ALL_CFLAGS := $(ALL_CFLAGS) $(CFLAGS) $(OPT_CFLAGS) +ALL_LDFLAGS := $(LDFLAGS) $(ALL_LDFLAGS) +ALL_LIBS := $(LIBS) $(ALL_LIBS) + +SHARED_SOURCE ?= $(wildcard lib$(LIBRARY_NAME).c) +SHARED_HEADER ?= $(shell test ! -e $(LIBRARY_NAME).h || echo $(LIBRARY_NAME).h) +SHARED_LIB ?= $(SHARED_SOURCE:.c=.$(SHARED_EXTENSION)) +SHARED_TCL_LIB = $(wildcard lib$(LIBRARY_NAME).tcl) + +.PHONY = install libdir_install single_install install-doc install-examples install-manual install-unittests clean distclean dist etags $(LIBRARY_NAME) + +all: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) + +%.o: %.c + $(CC) $(ALL_CFLAGS) -o "$*.o" -c "$*.c" + +%.$(EXTENSION): %.o $(SHARED_LIB) + $(CC) $(ALL_LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(ALL_LIBS) $(SHARED_LIB) + chmod a-x "$*.$(EXTENSION)" + +# this links everything into a single binary file +$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o lib$(LIBRARY_NAME).o + $(CC) $(ALL_LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) \ + $(LIBRARY_NAME).o lib$(LIBRARY_NAME).o $(ALL_LIBS) + chmod a-x $(LIBRARY_NAME).$(EXTENSION) + +$(SHARED_LIB): $(SHARED_SOURCE:.c=.o) + $(CC) $(SHARED_LDFLAGS) -o $(SHARED_LIB) $(SHARED_SOURCE:.c=.o) $(LIBS) + +install: libdir_install + +# The meta and help files are explicitly installed to make sure they are +# actually there. Those files are not optional, then need to be there. +libdir_install: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) install-doc install-examples install-manual install-unittests + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SOURCES))" || (\ + $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ + $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) + test -z "$(strip $(SHARED_LIB))" || \ + $(INSTALL_DATA) $(SHARED_LIB) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(wildcard $(SOURCES:.c=.tcl)))" || \ + $(INSTALL_DATA) $(wildcard $(SOURCES:.c=.tcl)) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SHARED_TCL_LIB))" || \ + $(INSTALL_DATA) $(SHARED_TCL_LIB) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + +# install library linked as single binary +single_install: $(LIBRARY_NAME) install-doc install-examples install-manual install-unittests + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) + +install-doc: + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(HELPPATCHES) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt + $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt + +install-examples: + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ + done + +install-manual: + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ + done + +install-unittests: + test -z "$(strip $(UNITTESTS))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/unittests && \ + for file in $(UNITTESTS); do \ + $(INSTALL_DATA) unittests/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/unittests; \ + done clean: -# delete emacs backup files - -rm -f */*.?~ */*.~?.?.~ -# delete compile products - -rm -f *.o *.pd_* *.dll *.tk2c core so_locations ChangeLog - -rm -f */*.?~ */*.o */*.pd_* */*.dll */*.tk2c */.*.swp */core so_locations -# delete autoconf/automake product - -rm -Rf */autom4te.cache - + -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) $(SHARED_SOURCE:.c=.o) + -rm -f -- $(SOURCES:.c=.$(EXTENSION)) + -rm -f -- $(LIBRARY_NAME).o + -rm -f -- $(LIBRARY_NAME).$(EXTENSION) + -rm -f -- $(SHARED_LIB) + +distclean: clean + -rm -f -- $(DISTBINDIR).tar.gz + -rm -rf -- $(DISTBINDIR) + -rm -f -- $(DISTDIR).tar.gz + -rm -rf -- $(DISTDIR) + -rm -f -- $(ORIGDIR).tar.gz + -rm -rf -- $(ORIGDIR) + + +$(DISTBINDIR): + $(INSTALL_DIR) $(DISTBINDIR) + +libdir: all $(DISTBINDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) + $(INSTALL_DATA) $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER) $(DISTBINDIR) + $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) +# tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) + +$(DISTDIR): + $(INSTALL_DIR) $(DISTDIR) + +$(ORIGDIR): + $(INSTALL_DIR) $(ORIGDIR) + +dist: $(DISTDIR) + $(INSTALL_DATA) Makefile $(DISTDIR) + $(INSTALL_DATA) README.txt $(DISTDIR) + $(INSTALL_DATA) LICENSE.txt $(DISTDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) + test -z "$(strip $(ALLSOURCES))" || \ + $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) + test -z "$(strip $(wildcard $(ALLSOURCES:.c=.tcl)))" || \ + $(INSTALL_DATA) $(wildcard $(ALLSOURCES:.c=.tcl)) $(DISTDIR) + test -z "$(strip $(wildcard $(LIBRARY_NAME).c))" || \ + $(INSTALL_DATA) $(LIBRARY_NAME).c $(DISTDIR) + test -z "$(strip $(SHARED_HEADER))" || \ + $(INSTALL_DATA) $(SHARED_HEADER) $(DISTDIR) + test -z "$(strip $(SHARED_SOURCE))" || \ + $(INSTALL_DATA) $(SHARED_SOURCE) $(DISTDIR) + test -z "$(strip $(SHARED_TCL_LIB))" || \ + $(INSTALL_DATA) $(SHARED_TCL_LIB) $(DISTDIR) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) + test -z "$(strip $(HELPPATCHES))" || \ + $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DISTDIR)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ + done + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DISTDIR)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ + done + test -z "$(strip $(UNITTESTS))" || \ + $(INSTALL_DIR) $(DISTDIR)/unittests && \ + for file in $(UNITTESTS); do \ + $(INSTALL_DATA) unittests/$$file $(DISTDIR)/unittests; \ + done + tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) + +# make a Debian source package +dpkg-source: + debclean + make distclean dist + mv $(DISTDIR) $(ORIGDIR) + tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) + rm -f -- $(DISTDIR).tar.gz + rm -rf -- $(DISTDIR) $(ORIGDIR) + cd .. && dpkg-source -b $(LIBRARY_NAME) + +etags: TAGS + +TAGS: $(wildcard $(PD_INCLUDE)/*.h) $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER) + etags $(wildcard $(PD_INCLUDE)/*.h) + etags -a *.h $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER) + etags -a --language=none --regex="/proc[ \t]+\([^ \t]+\)/\1/" *.tcl + +showsetup: + @echo "CC: $(CC)" + @echo "CFLAGS: $(CFLAGS)" + @echo "LDFLAGS: $(LDFLAGS)" + @echo "LIBS: $(LIBS)" + @echo "ALL_CFLAGS: $(ALL_CFLAGS)" + @echo "ALL_LDFLAGS: $(ALL_LDFLAGS)" + @echo "ALL_LIBS: $(ALL_LIBS)" + @echo "PD_INCLUDE: $(PD_INCLUDE)" + @echo "PD_PATH: $(PD_PATH)" + @echo "objectsdir: $(objectsdir)" + @echo "LIBRARY_NAME: $(LIBRARY_NAME)" + @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" + @echo "SOURCES: $(SOURCES)" + @echo "SHARED_HEADER: $(SHARED_HEADER)" + @echo "SHARED_SOURCE: $(SHARED_SOURCE)" + @echo "SHARED_LIB: $(SHARED_LIB)" + @echo "SHARED_TCL_LIB: $(SHARED_TCL_LIB)" + @echo "PDOBJECTS: $(PDOBJECTS)" + @echo "ALLSOURCES: $(ALLSOURCES)" + @echo "ALLSOURCES TCL: $(wildcard $(ALLSOURCES:.c=.tcl))" + @echo "UNAME: $(UNAME)" + @echo "CPU: $(CPU)" + @echo "pkglibdir: $(pkglibdir)" + @echo "DISTDIR: $(DISTDIR)" + @echo "ORIGDIR: $(ORIGDIR)" diff --git a/externals/unauthorized/README.txt b/externals/unauthorized/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..1791a334f3da62a057efcbcf8cd5fe91ecd2b43e --- /dev/null +++ b/externals/unauthorized/README.txt @@ -0,0 +1,301 @@ + +unauthorized is a library of GUI objects and a handful of objects for working +with streaming and mp3s. The home page for the GPL version is here: + +http://puredata.info/community/projects/software/unauthorized + +unauthorized has split into two versions because of a change of +licensing. This version, maintained in the pure-data SVN, remains GPLv2 +while the original author Yves Degoyon has split off a version with a +non-free license. + +To get the new non-free version, download it from its new CVS repository: + + export CVSROOT=:pserver:anonymous at giss.tv:/home/cvs + cvs co pidip + cvs co unauthorized + +original sources available from http://ydegoyon.free.fr/software.html + +Installing +---------- + +there is no configure scripts, you need to install : + + * pd headers in /usr/include ( m_pd.h and g_canvas.h ) + * libmp3lame-dev for the mp3 externals + * libspeex-dev for the speex external + * sources of stk in /usr/src/stk for stk externals ( optional ) + +have fun! +sevy ( ydegoyon@gmail.com ) +Copyright 2002 Yves Degoyon + +Included Objects +------------- + +audience~ : 2-dimensional audience simulation ( also called 2 dollars spatialization !!! ) + +beatify~ : modulate amplitude of a sound + the idea was borrowed from musicscript, + an excellent sound generation tool. + ( http://musicscript.sourceforge.net, author : David Piott ) + +blinkenlight : a blinken lights films player ( but also a pixel grid ) + This object displays blinken lights movies, and lets you handle a + grid of pixels. It is also a "Telecran" !! There is a movies + archive @ http://www.blinkenlights.de/gallery/index.en.html + +compressor~ : a compressor of audio signals + +cooled : a micro sound editor + This object displays a sound, lets you play a part of it and do + some cut and paste operations. + +disto~ : a kind of effect used in pop music, use it elsewhere + the algorithm was taken from Digital Effects (DISTORT3), a guitar + effects software for DOS which rocks, written by Alexey Smoli + http://st.karelia.ru/~smlalx/ + +exciter : a bang-events sequencer + the need for it sprung out of a talking with Nicolas Lhommet. + +filterbank~ : filterbank outputs frequency response for a range of filters + +formant~ is a formant synthesis generator external for pd + +grid : 2-dimensional control object, ala "kaospad" + +mp3amp~ is a MPEG I Layer III (mp3) icecast/shoutcast client for Pure Data + mp3amp~ has been compiled for Linux using LAME 3.92. + The newest version of LAME can be found at sourceforge.net + + PLEASE NOTE: This software may contain patented alogrithm (at + least patented in some countries). It may be not allowed to + sell/use products based on this source code in these + countries. Check this out first! + + COPYRIGHT of MP3 music: Please note, that the duplicating of + copyrighted music without explicit permission violates the rights + of the owner. + + Using mp3amp~ external for Pure Data + + Open the help-mp3amp~.pd to understand how it works. Open the + help-graphic-mp3amp~.pd if you want to see the status of the + incoming stream. + + BUGS : + a/ certainly, not all bitrates will work, + that's too tedious to test, 128, 256, 320 are ok. + + b/ cannot instantiate more than 10 decoders, if needed change + MAX_DECODERS in the code + +mp3cast~ is a MPEG I Layer III (mp3) streaming external for pd (by Miller +Puckette) that connects to a SHOUTcast or IceCast server. + + Using mp3cast~ external for Pure Data + + Open the help-mp3cast~.pd to understand how it works. + In this patch, you must send the messages to mp3cast~ + in the following order : + + 1/ password ***** + 2/ icecast | mp3cast + 3/ connect host port + 4/ pd dsp 1 + + Parameters sent to mp3cast~ object : + + Sampling Rate (Hz): Possible values are 48000, 44100 and 32000. If + Pd runs at a different sampling rate, LAME will resample the + signal. Default value for mp3 sampling rate is Pd's sampling rate. + + Bitrate (kbit/s): Possible values are 32, 40, 48, 56, 64, 80, 96, + 112, 128, 160, 192, 224, 256 and 320. Default is 224. + + Mode: Possible values are 0 (stereo), 1 (joint stereo, the + default), 2 (dual channel) and 3 (mono). + + Password: The default is 'pd', can be changed with a message + "passwd yourpassword". + + Server: Use message "connect name_of_your_server.com port" to + connect (same as with Pd's netsend). 'port' is the number + specified in the server's config file. Attention (for SHOUTcast + users): The actual port number used is one higher! Standard would + be 8000 resulting in a socket at port 8001!!! Bare this in mind + when configuring proxys or using mp3cast~ in connection with + netsend / netreceive. For IceCast, the port number used is the + same as specified. + + Outlet: The outlet outputs an int, 1 if connected to SHOUTcast + server, 0 if not. This could be used to build an automatic + reconnect mechanism. + + Other things: mp3cast~ prints the current status (connection, + login, LAME status) to the pd window. To see the current settings, + send it a message "print" and mp3 settings will be displayed. + Note that changing any mp3 settings will require to disconnect and + reconnect again! This has to be done manually. + + Known problems: If you turn off audio processing when you are + connected with the server, no data will be sent to it. This will + make the server disconnect after a certain time ('no data' error + in server log). mp3cast~ does not recongnise this and attempts to + keep on streaming. To avoid this set 'AutoDumpSourceTime' in the + servers config file to a fairly high value preventing the server + from closing the socket to fast. + + ALLOWED QUALITY FACTOR : + + -q = 0...9. Default -q 5 + -q 0: Highest quality, very slow + -q 9: Poor quality, but fast + -h Same as -q 2. Recommended. + -f Same as -q 7. Fast, ok quality + + ALLOWED SAMPLERATE/BITRATES + + MPEG-1 layer III sample frequencies (kHz): 32 48 44.1 + bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 + + MPEG-2 layer III sample frequencies (kHz): 16 24 22.05 + bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 + + MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025 + bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 + +mp3live~ is a peer-to-peer mp3 streamer package consisting of three + objects : mp3streamout~, mp3fileout~ and mp3streamin~. + + using mp3live~ external for Pure Data + + Open the mp3live~-help.pd to understand how it works. + + A note about MPEG encoding : + + ALLOWED QUALITY FACTOR : + + -q = 0...9. Default -q 5 + -q 0: Highest quality, very slow + -q 9: Poor quality, but fast + -h Same as -q 2. Recommended. + -f Same as -q 7. Fast, ok quality + + ALLOWED BITRATES : + + bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 + + BUGS : + + 1. You cannot create more than MAX_DECODERS mp3streamin~ + objects. The actual value is 100. + + 2. Current version of lame ( 3.92 ) produces a lot of errors for + quality < 5. Blame it on lame !!!! + + 3. Mono is not supported. Some additional code should be added for + mp3streamin~. Blame it on me !!! + + 4. Resampling is not supported. Blame it on me !!! + +mp3write~ is a MPEG I Layer III (mp3) file writer. + + using mp3write~ external for Pure Data + + Open the help-mp3write~.pd to understand how it works. + In this patch, you must send the messages to mp3write~ + in the following order : + + 1/ append|truncate if you wish to change file creation options ( default is append ) + 2/ open /my/file + 3/ start + 5/ pd dsp 1 + 4/ stop : the tag is written at this stage + + Parameters sent to mp3write~ object : + + Sampling Rate (Hz): Possible values are 48000, 44100 and 32000. If + Pd runs at a different sampling rate, LAME will resample the + signal. Default value for mp3 sampling rate is Pd's sampling rate. + + Bitrate (kbit/s): Possible values are 32, 40, 48, 56, 64, 80, 96, + 112, 128, 160, 192, 224, 256 and 320. Default is 224. + + Mode: Possible values are 0 (stereo), 1 (joint stereo, the + default), 2 (dual channel) and 3 (mono). + + Outlet: The outlet outputs an int, which the number of bytes + written in this session. this might be different from file size + if you're using append mode. + + Known Problems : All combinations of samplerate, bitrate, quality + factor will not be accepted. + + ALLOWED QUALITY FACTOR : + + -q = 0...9. Default -q 5 + -q 0: Highest quality, very slow + -q 9: Poor quality, but fast + -h Same as -q 2. Recommended. + -f Same as -q 7. Fast, ok quality + + ALLOWED SAMPLERATE/BITRATES + + MPEG-1 layer III sample frequencies (kHz): 32 48 44.1 + bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 + + MPEG-2 layer III sample frequencies (kHz): 16 24 22.05 + bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 + + MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025 + bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 + + Furthermore, it seems that high quality factors will not work with + this release of lame ( 3.92 ). The same errors can be obtained + with the command line : lame -q 1 file.wav outputs errors and + mp3write can't do better. + +pianoroll : a graphical sequencer controller + +playlist : choose a file in 1 click with space, numeric, characters + you can also send a seek message to select a file automatically. + +probalizer : outputs integer values according to a drawn probability curve + +samplebox~ : an opaque box to record and playback a sound ( with speed variations ) + +scratcher~ : records a sound and, then, let's you scratch it with your mouse. + +scrolllist : displays and scrolls a text in a patch window + +sonogram~ : displays, plays back and lets you modify a recorded sonogram. + + The real and imaginery part of an fft~ is stored in a sonogram~ + and, then, you can apply modifications to it or do mouse-based + graphic modifications. The set of modifications provided for now + consists of matrix operations but it will be improved soon. + +speex~ is a voice quality streamer using Speex library consisting of + two objects : speexin~ and speexout~. A big thanx to Jean-Marc + Valin, author of Speex who helped me fixing encoding/decoding + problems. + + PLEASE NOTE: The speex codec is patent free unlike GSM codecs. + that's the main reason why it's been choosen. ( + it allows very + low throughputs like 8kbits/s ). + +spigot~ : a signal router. + +vocoder~ : vocoder filter for PD inspired by xvox ( http://simon.morlat.free.fr ) +i used xvox version 0.2.1, but you don't need to install it, +everything needed is bundled here. + +wahwah~ : a kind of effect used in psychedelic music, use it elsewhere + + the algorithm was taken from Digital Effects, a guitar effects + software for DOS which rocks, written by Alexey Smoli ( + http://st.karelia.ru/~smlalx/ ) + diff --git a/externals/unauthorized/SConscript b/externals/unauthorized/SConscript deleted file mode 100644 index 40a1c74cd1b78a788497fedac76f8f21c481d40d..0000000000000000000000000000000000000000 --- a/externals/unauthorized/SConscript +++ /dev/null @@ -1,17 +0,0 @@ -import glob -import os -import re -Import('env prefix') - -for tk in glob.glob('*/*.tk'): - (dir, file) = os.path.split(tk) - filename = re.sub("\.tk$","",file) - cmd = "./tk2c.bash < " + dir + "/" + file + " > " + dir + "/" + filename + ".tk2c" - os.popen(cmd) - -for extra in glob.glob('*/*.c'): - unauthorized = env.SharedLibrary(target = re.sub("\.c$","",os.path.basename(extra)), source = extra) - env.Alias('install', env.Install(os.path.join(prefix, 'extra'), unauthorized)) - Default(unauthorized) - -env.Alias('install', env.Install(os.path.join(prefix, 'doc/unauthorized'), glob.glob('*/*.pd'))) diff --git a/externals/unauthorized/audience~/audience~-help.pd b/externals/unauthorized/audience~-help.pd similarity index 100% rename from externals/unauthorized/audience~/audience~-help.pd rename to externals/unauthorized/audience~-help.pd diff --git a/externals/unauthorized/audience~.c b/externals/unauthorized/audience~.c new file mode 100644 index 0000000000000000000000000000000000000000..27a52b1c609046529ed268210da62600848ccfbc --- /dev/null +++ b/externals/unauthorized/audience~.c @@ -0,0 +1,1069 @@ +/* Copyright (c) 2002 Yves Degoyon. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ +/* */ +/* audience.c written by Yves Degoyon 2002 */ +/* 2-dimensional audience simulation */ +/* ( simulates spatialization and interferences ) */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* Made while listening to : */ +/* */ +/* Shalaby Effect -- Instrumentals */ +/* Honey Bane -- I Wish I Could Be Me */ +/* ---------------------------------------------------------------------------- */ + + +#include +#include +#include +#include +#include +#include "m_pd.h" +#include "m_imp.h" +#include "g_canvas.h" + +#include "audience~.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + +#define DEFAULT_AUDIENCE_WIDTH 200 +#define DEFAULT_AUDIENCE_HEIGHT 200 +#define DEFAULT_AUDIENCE_NBINPUTS 4 +#define DEFAULT_AUDIENCE_NBOUTPUTS 2 +#define DEFAULT_AUDIENCE_ATTENUATION 0.01 + +#define LISTENER_WIDTH 15 +#define LISTENER_HEIGHT 20 +#define SPEAKER_WIDTH 15 +#define SPEAKER_HEIGHT 20 + +// sound propagates at the speed of 340 m/s, isn't it ?? +#define SOUNDSPEED 340.0 + +// a pixel is 0.1 meter +#define PIXELSIZE 0.1 + +static char *audience_version = "audience : 2d audience simulation, version 0.7 (ydegoyon@free.fr)"; + +t_widgetbehavior audience_widgetbehavior; +static t_class *audience_class_tilde; + +static int guidebug=0; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ + post(a,b,c,d,e,f);\ + sys_vgui(a,b,c,d,e,f) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g );\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ + post(a,b,c,d,e,f,g,h );\ + sys_vgui(a,b,c,d,e,f,g,h) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i );\ + sys_vgui(a,b,c,d,e,f,g,h,i) + +/* drawing functions */ +static void audience_draw_update(t_audience_tilde *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int ei; + + for ( ei=0; eix_nbinputs; ei++ ) + { + SYS_VGUI6(".x%lx.c coords %xISPEAKER%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] + ); + SYS_VGUI6(".x%lx.c coords %xSPEAKERNUM%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2 + ); + } + for ( ei=0; eix_nboutputs; ei++ ) + { + SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + ); + SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2 + ); + } +} + +static void audience_draw_new(t_audience_tilde *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + int ei; + + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #EAF1E2 -tags %xAAUDIENCE\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, + x); + // create captions + SYS_VGUI5(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0m\" -tags %xBLCAPTION\n", + canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x ); + SYS_VGUI6(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xBRCAPTION\n", + canvas, text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x->x_width, x ); + SYS_VGUI6(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xULCAPTION\n", + canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist), x->x_height, x ); + + // draw all outlets + if ( x->x_nboutputs > 1 ) + { + for ( ei=0; eix_nboutputs; ei++ ) + { + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", + canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2, + x, ei); + } + } + else + { + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", + canvas, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2, + x, 0); + } + // draw all inlets + for ( ei=0; eix_nbinputs+1; ei++ ) + { + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN%d\n", + canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs), + text_ypix(&x->x_obj, glist) - 2, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5, + text_ypix(&x->x_obj, glist), + x, ei); + } + // create speaker images + for ( ei=0; eix_nbinputs; ei++ ) + { + SYS_VGUI6("image create photo %xSPEAKER%d -file {%s/examples/speaker.gif} -format gif -width %d -height %d\n", + x, ei, audience_class_tilde->c_externdir->s_name, SPEAKER_WIDTH, SPEAKER_HEIGHT ); + SYS_VGUI8(".x%lx.c create image %d %d -image %xSPEAKER%d -tags %xISPEAKER%d\n", + canvas, + text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei], + x, ei, x, ei ); + SYS_VGUI7(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"s%d\" -tags %xSPEAKERNUM%d\n", + canvas, text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2, ei+1, x, ei ); + } + // create listener images + for ( ei=0; eix_nboutputs; ei++ ) + { + SYS_VGUI6("image create photo %xLISTENER%d -file {%s/examples/wanderer.gif} -format gif -width %d -height %d\n", + x, ei, audience_class_tilde->c_externdir->s_name, LISTENER_WIDTH, LISTENER_HEIGHT ); + SYS_VGUI8(".x%lx.c create image %d %d -image %xLISTENER%d -tags %xILISTENER%d\n", + canvas, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei], + x, ei, x, ei ); + SYS_VGUI7(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"l%d\" -tags %xLISTENERNUM%d\n", + canvas, text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2, ei+1, x, ei ); + } + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void audience_draw_move(t_audience_tilde *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int ei; + + SYS_VGUI7(".x%lx.c coords %xAAUDIENCE %d %d %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height); + SYS_VGUI5(".x%lx.c coords %xBLCAPTION %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10); + SYS_VGUI5(".x%lx.c coords %xBRCAPTION %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10 ); + SYS_VGUI5(".x%lx.c coords %xULCAPTION %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) ); + + for ( ei=0; eix_nbinputs+1; ei++ ) + { + SYS_VGUI8(".x%lx.c coords %xIN%d %d %d %d %d\n", + canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs), + text_ypix(&x->x_obj, glist) - 2, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5, + text_ypix(&x->x_obj, glist) + ); + } + for ( ei=0; eix_nbinputs+1; ei++ ) + { + SYS_VGUI6(".x%lx.c coords %xISPEAKER%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] + ); + SYS_VGUI6(".x%lx.c coords %xSPEAKERNUM%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2 + ); + } + if ( x->x_nboutputs > 1 ) + { + for ( ei=0; eix_nboutputs; ei++ ) + { + SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n", + canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2 + ); + SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + ); + SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n", + canvas, x, ei, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2 + ); + } + } + else + { + SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n", + canvas, x, 0, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2 + ); + SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n", + canvas, x, 0, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[0], + text_ypix(&x->x_obj, glist) + x->x_outputs_y[0] + ); + SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n", + canvas, x, 0, + text_xpix(&x->x_obj, glist) + x->x_outputs_x[0] + LISTENER_WIDTH/2, + text_ypix(&x->x_obj, glist) + x->x_outputs_y[0] + LISTENER_HEIGHT/2 + ); + } + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void audience_draw_erase(t_audience_tilde* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + int ei; + + SYS_VGUI3(".x%lx.c delete %xAAUDIENCE\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xBLCAPTION\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xBRCAPTION\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xULCAPTION\n", canvas, x); + for ( ei=0; eix_nbinputs+1; ei++ ) + { + SYS_VGUI4(".x%lx.c delete %xIN%d\n", canvas, x, ei ); + } + for ( ei=0; eix_nbinputs; ei++ ) + { + SYS_VGUI4(".x%lx.c delete %xISPEAKER%d\n", canvas, x, ei ); + SYS_VGUI4(".x%lx.c delete %xSPEAKERNUM%d\n", canvas, x, ei ); + // SYS_VGUI3("image delete %xSPEAKER%d\n", x, ei ); + } + for ( ei=0; eix_nboutputs; ei++ ) + { + SYS_VGUI4(".x%lx.c delete %xOUT%d\n", canvas, x, ei ); + SYS_VGUI4(".x%lx.c delete %xILISTENER%d\n", canvas, x, ei ); + SYS_VGUI4(".x%lx.c delete %xLISTENERNUM%d\n", canvas, x, ei ); + // SYS_VGUI3("image delete %xLISTENER%d\n", x, ei ); + } +} + +static void audience_draw_select(t_audience_tilde* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if(x->x_selected) + { + /* sets the item in blue */ + SYS_VGUI3(".x%lx.c itemconfigure %xAAUDIENCE -outline #0000FF\n", canvas, x); + } + else + { + SYS_VGUI3(".x%lx.c itemconfigure %xAAUDIENCE -outline #000000\n", canvas, x); + } +} + +/* ------------------------ audience widgetbehaviour----------------------------- */ + + +static void audience_getrect(t_gobj *z, t_glist *owner, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_audience_tilde* x = (t_audience_tilde*)z; + + *xp1 = text_xpix(&x->x_obj, owner); + *yp1 = text_ypix(&x->x_obj, owner); + *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; + *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; +} + +static void audience_save(t_gobj *z, t_binbuf *b) +{ + t_audience_tilde *x = (t_audience_tilde *)z; + t_int ii; + + binbuf_addv(b, "ssiisiiiifi", gensym("#X"),gensym("obj"), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, + atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), + x->x_width, x->x_height, + x->x_nbinputs, x->x_nboutputs, x->x_attenuation, x->x_applydelay ); + for ( ii=0; iix_nbinputs; ii++ ) + { + binbuf_addv(b, "ii", x->x_inputs_x[ii], x->x_inputs_y[ii] ); + } + for ( ii=0; iix_nboutputs; ii++ ) + { + binbuf_addv(b, "ii", x->x_outputs_x[ii], x->x_outputs_y[ii] ); + } + binbuf_addv(b, ";"); +} + +static void audience_properties(t_gobj *z, t_glist *owner) +{ + char buf[800]; + t_audience_tilde *x=(t_audience_tilde *)z; + + sprintf(buf, "pdtk_audience_dialog %%s %d %d %d\n", + (int)x->x_width, (int)x->x_height, (int)x->x_nboutputs + ); + // post("audience_properties : %s", buf ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); +} + +static void audience_select(t_gobj *z, t_glist *glist, int selected) +{ + t_audience_tilde *x = (t_audience_tilde *)z; + + x->x_selected = selected; + audience_draw_select( x, glist ); +} + +static void audience_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_audience_tilde *x = (t_audience_tilde *)z; + + // post( "audience~ : vis : %d", vis ); + if (vis) + { + audience_draw_new( x, glist ); + } + else + { + audience_draw_erase( x, glist ); + } +} + +static void audience_dialog(t_audience_tilde *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int onbinputs = x->x_nbinputs; + t_int onboutputs = x->x_nboutputs; + t_int owidth = x->x_width; + t_int oheight = x->x_height; + t_int bi, ei; + t_int dspstate; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if ( !x ) + { + post( "audience~ : error :tried to set properties on an unexisting object" ); + } + if ( argc != 3 ) + { + post( "audience : error in the number of arguments ( %d instead of 3 )", argc ); + return; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT ) + { + post( "audience~ : wrong arguments" ); + return; + } + + dspstate = canvas_suspend_dsp(); + audience_draw_erase(x, x->x_glist); + + x->x_width = (int)argv[0].a_w.w_float; + if ( x->x_width < 10 ) x->x_width = 10; + x->x_height = (int)argv[1].a_w.w_float; + if ( x->x_height < 10 ) x->x_height = 10; + x->x_nboutputs = (int)argv[2].a_w.w_float; + if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1; + + // re-allocate audio buffers if needed + if ( ( owidth != x->x_width ) || ( oheight != x->x_height ) ) + { + if ( x->x_audiobuffer ) + { + for ( ei=0; eix_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) ); + } + freebytes( x->x_audiobuffer, onbinputs*sizeof(t_float*) ); + } + // allocate audio buffer + x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) ); + if ( !x->x_audiobuffer ) + { + post( "audience~ : could not allocate audio buffer" ); + return; + } + x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 ) + + pow( x->x_height, 2 ) ) ) / SOUNDSPEED ) + * ( (float ) sys_getsr() ) ); + post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize ); + for ( bi=0; bix_nbinputs; bi++ ) + { + x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) ); + if ( !x->x_audiobuffer[bi] ) + { + post( "audience~ : could not allocate audio buffer" ); + return; + } + } + x->x_audiowritepos = 0; + } + + // re-allocate inlets : CRASHES PD,I GUESS IT'S NOT SUPPORTED + if ( onbinputs != x->x_nbinputs ) + { + // post( "audience~ : cleaning up old inlets" ); + if ( x->x_inputs ) + { + for ( ei=0; eix_inputs[ei] ); + } + freebytes( x->x_inputs, onbinputs*sizeof(t_inlet*) ); + } + if ( x->x_inputs_x ) + { + freebytes( x->x_inputs_x, onbinputs*sizeof(t_int) ); + } + if ( x->x_inputs_y ) + { + freebytes( x->x_inputs_y, onbinputs*sizeof(t_int) ); + } + // post( "audience~ : creating new ones" ); + x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) ); + x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); + x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); + if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y ) + { + error( "audience~ : fatal : could not create new object" ); + return; + } + for ( bi=0; bix_nbinputs; bi++ ) + { + // post( "audience~ : allocating input ! %d", bi ); + x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + } + } + + // re-allocate outlets + if ( onboutputs != x->x_nboutputs ) + { + // post( "audience~ : cleaning up old outlets" ); + if ( x->x_outputs ) + { + for ( ei=0; eix_outputs[ei] ); + // outlet_free( x->x_outputs[ei] ); + } + freebytes( x->x_outputs, onboutputs*sizeof(t_outlet*) ); + } + if ( x->x_outputs_x ) + { + freebytes( x->x_outputs_x, onboutputs*sizeof(t_int) ); + } + if ( x->x_outputs_y ) + { + freebytes( x->x_outputs_y, onboutputs*sizeof(t_int) ); + } + // post( "audience~ : creating new ones" ); + x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) ); + x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); + x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); + if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y ) + { + // error( "audience~ : fatal : could not create new object" ); + return; + } + for ( bi=0; bix_nboutputs; bi++ ) + { + x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal ); + } + // set default coordinates + if ( x->x_nboutputs > 1 ) + { + for ( ei=0; eix_nboutputs; ei++ ) + { + x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 ); + x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2; + } + } + else + { + x->x_outputs_x[0] = x->x_width; + x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2; + } + } + + canvas_fixlinesfor( canvas, (t_text*)x ); + audience_draw_new(x, x->x_glist); + canvas_resume_dsp(dspstate); +} + +static void audience_delete(t_gobj *z, t_glist *glist) +{ + t_audience_tilde *x = (t_audience_tilde *)z; + + // post( "audience~ : delete" ); + audience_draw_erase( x, glist ); + canvas_deletelinesfor(glist, (t_text *)z); +} + +static void audience_displace(t_gobj *z, t_glist *glist, int dx, int dy) +{ + t_audience_tilde *x = (t_audience_tilde *)z; + int xold = text_xpix(&x->x_obj, glist); + int yold = text_ypix(&x->x_obj, glist); + + // post( "audience_displace dx=%d dy=%d", dx, dy ); + + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; + if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix) + { + audience_draw_move(x, x->x_glist); + } +} + +static void audience_motion(t_audience_tilde *x, t_floatarg dx, t_floatarg dy) +{ + // post( "audience_motion dx=%f dy=%f", dx, dy ); + + switch( x->x_type_selected ) + { + case AUDIENCE_INPUT: + x->x_inputs_x[ x->x_nselected ] += dx; + if ( x->x_inputs_x[ x->x_nselected ] < 0 ) x->x_inputs_x[ x->x_nselected ] = 0; + if ( x->x_inputs_x[ x->x_nselected ] > x->x_width ) x->x_inputs_x[ x->x_nselected ] = x->x_width; + x->x_inputs_y[ x->x_nselected ] += dy; + if ( x->x_inputs_y[ x->x_nselected ] < 0 ) x->x_inputs_y[ x->x_nselected ] = 0; + if ( x->x_inputs_y[ x->x_nselected ] > x->x_height ) x->x_inputs_y[ x->x_nselected ] = x->x_height; + break; + case AUDIENCE_OUTPUT: + x->x_outputs_x[ x->x_nselected ] += dx; + if ( x->x_outputs_x[ x->x_nselected ] < 0 ) x->x_outputs_x[ x->x_nselected ] = 0; + if ( x->x_outputs_x[ x->x_nselected ] > x->x_width ) x->x_outputs_x[ x->x_nselected ] = x->x_width; + x->x_outputs_y[ x->x_nselected ] += dy; + if ( x->x_outputs_y[ x->x_nselected ] < 0 ) x->x_outputs_y[ x->x_nselected ] = 0; + if ( x->x_outputs_y[ x->x_nselected ] > x->x_height ) x->x_outputs_y[ x->x_nselected ] = x->x_height; + break; + } + + audience_draw_update(x, x->x_glist); +} + +static int audience_click(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_audience_tilde* x = (t_audience_tilde *)z; + t_int bi; + + // post( "audience_click doit=%d x=%d y=%d", doit, xpix, ypix ); + if ( doit) + { + t_int relx = xpix-text_xpix(&x->x_obj, glist); + t_int rely = ypix-text_ypix(&x->x_obj, glist); + + // post( "audience~ : relx : %d : rely : %d", relx, rely ); + x->x_type_selected = AUDIENCE_NONE; + x->x_nselected = -1; + for ( bi=0; bix_nbinputs; bi++ ) + { + if ( ( abs( relx - x->x_inputs_x[bi] ) < SPEAKER_WIDTH ) && + ( abs( rely - x->x_inputs_y[bi] ) < SPEAKER_HEIGHT ) ) + { + x->x_type_selected = AUDIENCE_INPUT; + x->x_nselected = bi; + break; + } + } + if ( x->x_type_selected == AUDIENCE_NONE ) + { + for ( bi=0; bix_nboutputs; bi++ ) + { + if ( ( abs( relx - x->x_outputs_x[bi] ) < LISTENER_WIDTH ) && + ( abs( rely - x->x_outputs_y[bi] ) < LISTENER_HEIGHT ) ) + { + x->x_type_selected = AUDIENCE_OUTPUT; + x->x_nselected = bi; + break; + } + } + } + audience_draw_update(x, glist); + glist_grab(glist, &x->x_obj.te_g, (t_glistmotionfn)audience_motion, + 0, xpix, ypix); + } + return (1); +} + +static t_audience_tilde *audience_new(t_symbol *s, int argc, t_atom *argv) +{ + t_int bi, ei; + t_audience_tilde *x; + t_pd *x2; + char *str; + + // post( "audience_new : create : %s argc =%d", s->s_name, argc ); + + x = (t_audience_tilde *)pd_new(audience_class_tilde); + // new audience created from the gui + if ( argc != 0 ) + { + if ( argc < 5 ) + { + post( "audience~ : error in the number of arguments ( %d )", argc ); + return NULL; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) + { + post( "audience~ : wrong arguments" ); + return NULL; + } + + x->x_width = (int)argv[0].a_w.w_float; + if ( x->x_width < 10 ) x->x_width = 10; + x->x_height = (int)argv[1].a_w.w_float; + if ( x->x_height < 10 ) x->x_height = 10; + x->x_nbinputs = (int)argv[2].a_w.w_float; + if ( x->x_nbinputs < 1 ) x->x_nbinputs = 1; + x->x_nboutputs = (int)argv[3].a_w.w_float; + if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1; + x->x_attenuation = argv[4].a_w.w_float; + if ( x->x_attenuation < 0 ) x->x_attenuation = 0; + x->x_applydelay = argv[5].a_w.w_float; + } + else + { + x->x_width = DEFAULT_AUDIENCE_WIDTH; + x->x_height = DEFAULT_AUDIENCE_HEIGHT; + x->x_nbinputs = DEFAULT_AUDIENCE_NBINPUTS; + x->x_nboutputs = DEFAULT_AUDIENCE_NBOUTPUTS; + x->x_attenuation = DEFAULT_AUDIENCE_ATTENUATION; + x->x_applydelay = 0; + } + + // create inlets and outlets + x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) ); + x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); + x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); + if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y ) + { + post( "audience~ : could not allocate outputs" ); + return NULL; + } + for ( bi=0; bix_nboutputs; bi++ ) + { + x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal ); + } + x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) ); + x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); + x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); + if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y ) + { + post( "audience~ : could not allocate inputs" ); + return NULL; + } + for ( bi=0; bix_nbinputs; bi++ ) + { + x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + } + + // allocate audio buffer + x->x_audiowritepos = 0; + x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) ); + if ( !x->x_audiobuffer ) + { + post( "audience~ : could not allocate audio buffer" ); + return NULL; + } + x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 ) + + pow( x->x_height, 2 ) ) ) / SOUNDSPEED ) + * ( (float ) sys_getsr() ) ); + post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize ); + for ( bi=0; bix_nbinputs; bi++ ) + { + x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) ); + if ( !x->x_audiobuffer[bi] ) + { + post( "audience~ : could not allocate audio buffer" ); + return NULL; + } + } + + if ( argc == 0 ) + { + // set default coordinates + if ( x->x_nbinputs > 1 ) + { + for ( ei=0; eix_nbinputs; ei++ ) + { + x->x_inputs_x[ei] = (ei+1) * (x->x_width - 5) / x->x_nbinputs; + x->x_inputs_y[ei] = SPEAKER_HEIGHT/2; + } + } + else + { + x->x_inputs_x[0] = x->x_width; + x->x_inputs_y[0] = SPEAKER_HEIGHT/2; + } + + if ( x->x_nboutputs > 1 ) + { + for ( ei=0; eix_nboutputs; ei++ ) + { + x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 ); + x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2; + } + } + else + { + x->x_outputs_x[0] = x->x_width; + x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2; + } + } + else + { + t_int ai = 6; + + // restore coordinates from arguments + for ( ei=0; eix_nbinputs; ei++ ) + { + x->x_inputs_x[ei] = argv[ai++].a_w.w_float; + x->x_inputs_y[ei] = argv[ai++].a_w.w_float; + } + for ( ei=0; eix_nboutputs; ei++ ) + { + x->x_outputs_x[ei] = argv[ai++].a_w.w_float; + x->x_outputs_y[ei] = argv[ai++].a_w.w_float; + } + } + + x->x_glist = (t_glist *) canvas_getcurrent(); + x->x_type_selected = AUDIENCE_NONE; + x->x_nselected = -1; + + // post( "audience~ : new object : inlets : %d : outlets : %d : attenuation : %f", x->x_nbinputs, x->x_nboutputs, x->x_attenuation ); + return (x); +} + +static void audience_free(t_audience_tilde *x) +{ + t_int ei; + + if ( x->x_outputs ) + { + for ( ei=0; eix_nboutputs; ei++ ) + { + outlet_free( x->x_outputs[ei] ); + } + freebytes( x->x_outputs, x->x_nboutputs*sizeof(t_outlet*) ); + } + if ( x->x_inputs ) + { + for ( ei=0; eix_nbinputs; ei++ ) + { + inlet_free( x->x_inputs[ei] ); + } + freebytes( x->x_inputs, x->x_nbinputs*sizeof(t_outlet*) ); + } + if ( x->x_audiobuffer ) + { + for ( ei=0; eix_nbinputs; ei++ ) + { + freebytes( x->x_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) ); + } + freebytes( x->x_audiobuffer, x->x_nbinputs*sizeof(t_float*) ); + } +} + +static t_int *audience_perform(t_int *w) +{ + t_int ii, oi, op; + t_audience_tilde *x = (t_audience_tilde*)(w[1]); + t_int bsize = w[2]; + + { + // save input sounds in the audio buffer + for ( ii=0; iix_nbinputs; ii++ ) + { + t_float* isound = (t_float*)w[ii+3]; + + if ( x->x_audiobuffer[ii] ) + { + op = 0; + while ( op < bsize ) + { + *(x->x_audiobuffer[ii] + x->x_audiowritepos + op ) = *(isound + op); + op++; + } + } + } + + // set outputs + for ( oi=0; oix_nboutputs; oi++ ) + { + t_float* osound = (t_float*)w[oi+3+x->x_nbinputs]; + + // zeroing output + memset( osound, 0x00, bsize*sizeof( t_float ) ); + + for ( ii=0; iix_nbinputs; ii++ ) + { + t_int delay; + t_int dist; + t_int readpos; + t_int maxwritepos; + + maxwritepos = ( x->x_audiobuffersize / bsize ) * bsize; + dist = sqrt( pow( (x->x_outputs_x[oi] - x->x_inputs_x[ii]), 2 ) + + pow( (x->x_outputs_y[oi] - x->x_inputs_y[ii]), 2 ) ); + delay = ( t_int ) ( ( ( ( t_float ) dist ) * ( (float ) sys_getsr() ) ) / SOUNDSPEED ); + delay = ( delay / bsize ) * bsize; // set a block frontier + if ( x->x_applydelay ) + { + if ( x->x_audiowritepos >= delay ) + { + readpos = x->x_audiowritepos - delay; + } + else + { + readpos = maxwritepos - delay + x->x_audiowritepos; + } + } + else + { + readpos = x->x_audiowritepos; + } + // if ( ii == 0 ) + // { + // post( "audience~ : dist : %d : delay : %d : readpos : %d : writepos : %d", + // dist, delay, readpos, x->x_audiowritepos ); + // } + + op = 0; + while ( op < bsize ) + { + if ( ( readpos < x->x_audiobuffersize ) && ( readpos >= 0 ) ) + { + if ( 1.0-x->x_attenuation*dist < 0 ) + { + *(osound+op) += 0.0; + } + else + { + *(osound+op) += *(x->x_audiobuffer[ii] + readpos + op)*(1.0-x->x_attenuation*dist); + } + } + else + { + error( "audience~ : delay : %d : wrong readpos !!! : %d >= %d or < 0", (int)delay, (int)readpos, (int)x->x_audiobuffersize ); + } + op++; + } + } + } + + // update write position + if ( x->x_audiowritepos + bsize > x->x_audiobuffersize - bsize ) + { + // post( "audience~ : write back to zero @ %d", x->x_audiowritepos ); + x->x_audiowritepos = 0; + } + else + { + x->x_audiowritepos += bsize; + } + + } + + return (w+x->x_nbinputs+x->x_nboutputs+3); +} + +static void audience_dsp(t_audience_tilde *x, t_signal **sp) +{ + switch ( x->x_nbinputs+x->x_nboutputs ) + { + case 2 : + dsp_add(audience_perform, 4, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec ); + break; + + case 3 : + dsp_add(audience_perform, 5, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec ); + break; + + case 4 : + dsp_add(audience_perform, 6, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec ); + break; + + case 5 : + dsp_add(audience_perform, 7, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[5]->s_vec ); + break; + + case 6 : + dsp_add(audience_perform, 8, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, + sp[5]->s_vec, sp[6]->s_vec ); + break; + + case 7 : + dsp_add(audience_perform, 9, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, + sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec ); + break; + + case 8 : + dsp_add(audience_perform, 10, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, + sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec ); + break; + + case 9 : + dsp_add(audience_perform, 11, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, + sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec, sp[9]->s_vec ); + break; + + case 10 : + dsp_add(audience_perform, 12, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, + sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec, + sp[9]->s_vec, sp[10]->s_vec ); + break; + + default : + post( "audience~ : number of inlets/outlets not supported" ); + break; + } +} + +// set attenuation +static void audience_attenuation(t_audience_tilde *x, t_floatarg fattenuation ) +{ + if ( fattenuation < 0 ) + { + post( "audience~ : error : wrong attenuation : %f", fattenuation ); + return; + } + x->x_attenuation = fattenuation; +} + +// set delay +static void audience_delay(t_audience_tilde *x, t_floatarg fdelay ) +{ + if ( fdelay == 0. ) + { + x->x_applydelay = 0; + } + else + { + x->x_applydelay = 1; + } +} + +void audience_tilde_setup(void) +{ + logpost(NULL, 4, "%s", audience_version ); + audience_class_tilde = class_new(gensym("audience~"), (t_newmethod)audience_new, + (t_method)audience_free, sizeof(t_audience_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN( audience_class_tilde, t_audience_tilde, x_f ); + class_addmethod(audience_class_tilde, (t_method)audience_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(audience_class_tilde, (t_method)audience_dialog, gensym("dialog"), A_GIMME, 0); + class_addmethod(audience_class_tilde, (t_method)audience_attenuation, gensym("attenuation"), A_DEFFLOAT, 0); + class_addmethod(audience_class_tilde, (t_method)audience_delay, gensym("delay"), A_DEFFLOAT, 0); + audience_widgetbehavior.w_getrectfn = audience_getrect; + audience_widgetbehavior.w_displacefn = audience_displace; + audience_widgetbehavior.w_selectfn = audience_select; + audience_widgetbehavior.w_activatefn = NULL; + audience_widgetbehavior.w_deletefn = audience_delete; + audience_widgetbehavior.w_visfn = audience_vis; + audience_widgetbehavior.w_clickfn = audience_click; + +#if PD_MINOR_VERSION >= 37 + class_setpropertiesfn(audience_class_tilde, audience_properties); + class_setsavefn(audience_class_tilde, audience_save); +#else + audience_widgetbehavior.w_propertiesfn = audience_properties; + audience_widgetbehavior.w_savefn = audience_save; +#endif + + class_setwidget(audience_class_tilde, &audience_widgetbehavior); + + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + audience_class_tilde->c_externdir->s_name, audience_class_tilde->c_name->s_name); +} diff --git a/externals/unauthorized/audience~/audience~.h b/externals/unauthorized/audience~.h similarity index 100% rename from externals/unauthorized/audience~/audience~.h rename to externals/unauthorized/audience~.h diff --git a/externals/unauthorized/audience~/audience~.tk b/externals/unauthorized/audience~.tcl similarity index 97% rename from externals/unauthorized/audience~/audience~.tk rename to externals/unauthorized/audience~.tcl index 5f99998c3bbc2f4331d8a159e0f54b77cfac40ec..49ea0bd9900ca8e558a3b6a3adc45523da705b81 100644 --- a/externals/unauthorized/audience~/audience~.tk +++ b/externals/unauthorized/audience~.tcl @@ -17,13 +17,13 @@ proc audience_apply {id} { [eval concat $$var_graph_nboutputs] \ \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc audience_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc audience_ok {id} { @@ -44,7 +44,7 @@ proc pdtk_audience_dialog {id width height nboutputs} { set $var_graph_height $height set $var_graph_nboutputs $nboutputs - toplevel $id -class [winfo class .] + toplevel $id wm title $id {audience} wm protocol $id WM_DELETE_WINDOW [concat audience_cancel $id] diff --git a/externals/unauthorized/audience~/INSTALL b/externals/unauthorized/audience~/INSTALL deleted file mode 100644 index a1a03e038b4f608a637991eb687725592e9625e9..0000000000000000000000000000000000000000 --- a/externals/unauthorized/audience~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/audience~ - -make clean - -make - -make install - -open help-audience~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/audience~/Makefile b/externals/unauthorized/audience~/Makefile deleted file mode 100644 index 66d322fc51f31c2183d106cf74eca012e5153516..0000000000000000000000000000000000000000 --- a/externals/unauthorized/audience~/Makefile +++ /dev/null @@ -1,85 +0,0 @@ -NAME=audience~ -CSYM=audience~ - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes -g \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk > $*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - ln -sf `pwd`/speaker.gif /tmp - ln -sf `pwd`/wanderer.gif /tmp - -clean: - rm -f *.o *.pd_* *.tk2c core diff --git a/externals/unauthorized/audience~/README b/externals/unauthorized/audience~/README deleted file mode 100644 index e0e638239b00632ddaa6e57a482508f325565682..0000000000000000000000000000000000000000 --- a/externals/unauthorized/audience~/README +++ /dev/null @@ -1,20 +0,0 @@ -***************************************************************************** -Version 0.01 -copyright 2002 Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -audience~ : 2-dimensional audience simulation ( also called 2 dollars spatialization !!! ) - -To install audience~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/audience~/audience~.c b/externals/unauthorized/audience~/audience~.c deleted file mode 100644 index 2679f4895522d1f455c57804becf4d97d08b3ed2..0000000000000000000000000000000000000000 --- a/externals/unauthorized/audience~/audience~.c +++ /dev/null @@ -1,1063 +0,0 @@ -/* Copyright (c) 2002 Yves Degoyon. */ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ -/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -/* */ -/* audience.c written by Yves Degoyon 2002 */ -/* 2-dimensional audience simulation */ -/* ( simulates spatialization and interferences ) */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* Made while listening to : */ -/* */ -/* Shalaby Effect -- Instrumentals */ -/* Honey Bane -- I Wish I Could Be Me */ -/* ---------------------------------------------------------------------------- */ - - -#include -#include -#include -#include -#include -#include "m_pd.h" -#include "m_imp.h" -#include "g_canvas.h" - -#include "audience~.h" - -#ifdef NT -#include -#else -#include -#endif - -#define DEFAULT_AUDIENCE_WIDTH 200 -#define DEFAULT_AUDIENCE_HEIGHT 200 -#define DEFAULT_AUDIENCE_NBINPUTS 4 -#define DEFAULT_AUDIENCE_NBOUTPUTS 2 -#define DEFAULT_AUDIENCE_ATTENUATION 0.01 - -#define LISTENER_WIDTH 15 -#define LISTENER_HEIGHT 20 -#define SPEAKER_WIDTH 15 -#define SPEAKER_HEIGHT 20 - -// sound propagates at the speed of 340 m/s, isn't it ?? -#define SOUNDSPEED 340.0 - -// a pixel is 0.1 meter -#define PIXELSIZE 0.1 - -static char *audience_version = "audience : 2d audience simulation, version 0.7 (ydegoyon@free.fr)"; - -t_widgetbehavior audience_widgetbehavior; -static t_class *audience_class_tilde; - -static int guidebug=0; - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g );\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h );\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i );\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -/* drawing functions */ -static void audience_draw_update(t_audience_tilde *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int ei; - - for ( ei=0; eix_nbinputs; ei++ ) - { - SYS_VGUI6(".x%x.c coords %xISPEAKER%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - ); - SYS_VGUI6(".x%x.c coords %xSPEAKERNUM%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2 - ); - } - for ( ei=0; eix_nboutputs; ei++ ) - { - SYS_VGUI6(".x%x.c coords %xILISTENER%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] - ); - SYS_VGUI6(".x%x.c coords %xLISTENERNUM%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2 - ); - } -} - -static void audience_draw_new(t_audience_tilde *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - int ei; - - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #EAF1E2 -tags %xAAUDIENCE\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, - x); - // create captions - SYS_VGUI5(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0m\" -tags %xBLCAPTION\n", - canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x ); - SYS_VGUI6(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xBRCAPTION\n", - canvas, text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x->x_width, x ); - SYS_VGUI6(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xULCAPTION\n", - canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist), x->x_height, x ); - - // draw all outlets - if ( x->x_nboutputs > 1 ) - { - for ( ei=0; eix_nboutputs; ei++ ) - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", - canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2, - x, ei); - } - } - else - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", - canvas, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2, - x, 0); - } - // draw all inlets - for ( ei=0; eix_nbinputs+1; ei++ ) - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN%d\n", - canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs), - text_ypix(&x->x_obj, glist) - 2, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5, - text_ypix(&x->x_obj, glist), - x, ei); - } - // create speaker images - for ( ei=0; eix_nbinputs; ei++ ) - { - SYS_VGUI5("image create photo %xSPEAKER%d -file /tmp/speaker.gif -format gif -width %d -height %d\n", - x, ei, SPEAKER_WIDTH, SPEAKER_HEIGHT ); - SYS_VGUI8(".x%x.c create image %d %d -image %xSPEAKER%d -tags %xISPEAKER%d\n", - canvas, - text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei], - x, ei, x, ei ); - SYS_VGUI7(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"s%d\" -tags %xSPEAKERNUM%d\n", - canvas, text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2, ei+1, x, ei ); - } - // create listener images - for ( ei=0; eix_nboutputs; ei++ ) - { - SYS_VGUI5("image create photo %xLISTENER%d -file /tmp/wanderer.gif -format gif -width %d -height %d\n", - x, ei, LISTENER_WIDTH, LISTENER_HEIGHT ); - SYS_VGUI8(".x%x.c create image %d %d -image %xLISTENER%d -tags %xILISTENER%d\n", - canvas, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei], - x, ei, x, ei ); - SYS_VGUI7(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"l%d\" -tags %xLISTENERNUM%d\n", - canvas, text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2, ei+1, x, ei ); - } - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void audience_draw_move(t_audience_tilde *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int ei; - - SYS_VGUI7(".x%x.c coords %xAAUDIENCE %d %d %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height); - SYS_VGUI5(".x%x.c coords %xBLCAPTION %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10); - SYS_VGUI5(".x%x.c coords %xBRCAPTION %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10 ); - SYS_VGUI5(".x%x.c coords %xULCAPTION %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) ); - - for ( ei=0; eix_nbinputs+1; ei++ ) - { - SYS_VGUI8(".x%x.c coords %xIN%d %d %d %d %d\n", - canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs), - text_ypix(&x->x_obj, glist) - 2, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5, - text_ypix(&x->x_obj, glist) - ); - } - for ( ei=0; eix_nbinputs+1; ei++ ) - { - SYS_VGUI6(".x%x.c coords %xISPEAKER%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - ); - SYS_VGUI6(".x%x.c coords %xSPEAKERNUM%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2 - ); - } - if ( x->x_nboutputs > 1 ) - { - for ( ei=0; eix_nboutputs; ei++ ) - { - SYS_VGUI8(".x%x.c coords %xOUT%d %d %d %d %d\n", - canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2 - ); - SYS_VGUI6(".x%x.c coords %xILISTENER%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei], - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] - ); - SYS_VGUI6(".x%x.c coords %xLISTENERNUM%d %d %d\n", - canvas, x, ei, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2 - ); - } - } - else - { - SYS_VGUI8(".x%x.c coords %xOUT%d %d %d %d %d\n", - canvas, x, 0, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2 - ); - SYS_VGUI6(".x%x.c coords %xILISTENER%d %d %d\n", - canvas, x, 0, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[0], - text_ypix(&x->x_obj, glist) + x->x_outputs_y[0] - ); - SYS_VGUI6(".x%x.c coords %xLISTENERNUM%d %d %d\n", - canvas, x, 0, - text_xpix(&x->x_obj, glist) + x->x_outputs_x[0] + LISTENER_WIDTH/2, - text_ypix(&x->x_obj, glist) + x->x_outputs_y[0] + LISTENER_HEIGHT/2 - ); - } - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void audience_draw_erase(t_audience_tilde* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - int ei; - - SYS_VGUI3(".x%x.c delete %xAAUDIENCE\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xBLCAPTION\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xBRCAPTION\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xULCAPTION\n", canvas, x); - for ( ei=0; eix_nbinputs+1; ei++ ) - { - SYS_VGUI4(".x%x.c delete %xIN%d\n", canvas, x, ei ); - } - for ( ei=0; eix_nbinputs; ei++ ) - { - SYS_VGUI4(".x%x.c delete %xISPEAKER%d\n", canvas, x, ei ); - SYS_VGUI4(".x%x.c delete %xSPEAKERNUM%d\n", canvas, x, ei ); - // SYS_VGUI3("image delete %xSPEAKER%d\n", x, ei ); - } - for ( ei=0; eix_nboutputs; ei++ ) - { - SYS_VGUI4(".x%x.c delete %xOUT%d\n", canvas, x, ei ); - SYS_VGUI4(".x%x.c delete %xILISTENER%d\n", canvas, x, ei ); - SYS_VGUI4(".x%x.c delete %xLISTENERNUM%d\n", canvas, x, ei ); - // SYS_VGUI3("image delete %xLISTENER%d\n", x, ei ); - } -} - -static void audience_draw_select(t_audience_tilde* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if(x->x_selected) - { - /* sets the item in blue */ - SYS_VGUI3(".x%x.c itemconfigure %xAAUDIENCE -outline #0000FF\n", canvas, x); - } - else - { - SYS_VGUI3(".x%x.c itemconfigure %xAAUDIENCE -outline #000000\n", canvas, x); - } -} - -/* ------------------------ audience widgetbehaviour----------------------------- */ - - -static void audience_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - t_audience_tilde* x = (t_audience_tilde*)z; - - *xp1 = text_xpix(&x->x_obj, owner); - *yp1 = text_ypix(&x->x_obj, owner); - *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; - *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; -} - -static void audience_save(t_gobj *z, t_binbuf *b) -{ - t_audience_tilde *x = (t_audience_tilde *)z; - t_int ii; - - binbuf_addv(b, "ssiisiiiifi", gensym("#X"),gensym("obj"), - (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_width, x->x_height, - x->x_nbinputs, x->x_nboutputs, x->x_attenuation, x->x_applydelay ); - for ( ii=0; iix_nbinputs; ii++ ) - { - binbuf_addv(b, "ii", x->x_inputs_x[ii], x->x_inputs_y[ii] ); - } - for ( ii=0; iix_nboutputs; ii++ ) - { - binbuf_addv(b, "ii", x->x_outputs_x[ii], x->x_outputs_y[ii] ); - } - binbuf_addv(b, ";"); -} - -static void audience_properties(t_gobj *z, t_glist *owner) -{ - char buf[800]; - t_audience_tilde *x=(t_audience_tilde *)z; - - sprintf(buf, "pdtk_audience_dialog %%s %d %d %d\n", - x->x_width, x->x_height, x->x_nboutputs - ); - // post("audience_properties : %s", buf ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); -} - -static void audience_select(t_gobj *z, t_glist *glist, int selected) -{ - t_audience_tilde *x = (t_audience_tilde *)z; - - x->x_selected = selected; - audience_draw_select( x, glist ); -} - -static void audience_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_audience_tilde *x = (t_audience_tilde *)z; - - // post( "audience~ : vis : %d", vis ); - if (vis) - { - audience_draw_new( x, glist ); - } - else - { - audience_draw_erase( x, glist ); - } -} - -static void audience_dialog(t_audience_tilde *x, t_symbol *s, int argc, t_atom *argv) -{ - t_int onbinputs = x->x_nbinputs; - t_int onboutputs = x->x_nboutputs; - t_int owidth = x->x_width; - t_int oheight = x->x_height; - t_int bi, ei; - t_int dspstate; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if ( !x ) { - post( "audience~ : error :tried to set properties on an unexisting object" ); - } - if ( argc != 3 ) - { - post( "audience : error in the number of arguments ( %d instead of 3 )", argc ); - return; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT ) { - post( "audience~ : wrong arguments" ); - return; - } - - dspstate = canvas_suspend_dsp(); - audience_draw_erase(x, x->x_glist); - - x->x_width = (int)argv[0].a_w.w_float; - if ( x->x_width < 10 ) x->x_width = 10; - x->x_height = (int)argv[1].a_w.w_float; - if ( x->x_height < 10 ) x->x_height = 10; - x->x_nboutputs = (int)argv[2].a_w.w_float; - if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1; - - // re-allocate audio buffers if needed - if ( ( owidth != x->x_width ) || ( oheight != x->x_height ) ) - { - if ( x->x_audiobuffer ) - { - for ( ei=0; eix_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) ); - } - freebytes( x->x_audiobuffer, onbinputs*sizeof(t_float*) ); - } - // allocate audio buffer - x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) ); - if ( !x->x_audiobuffer ) - { - post( "audience~ : could not allocate audio buffer" ); - return; - } - x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 ) - + pow( x->x_height, 2 ) ) ) / SOUNDSPEED ) - * ( (float ) sys_getsr() ) ); - post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize ); - for ( bi=0; bix_nbinputs; bi++ ) - { - x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) ); - if ( !x->x_audiobuffer[bi] ) - { - post( "audience~ : could not allocate audio buffer" ); - return; - } - } - x->x_audiowritepos = 0; - } - - // re-allocate inlets : CRASHES PD,I GUESS IT'S NOT SUPPORTED - if ( onbinputs != x->x_nbinputs ) - { - // post( "audience~ : cleaning up old inlets" ); - if ( x->x_inputs ) - { - for ( ei=0; eix_inputs[ei] ); - } - freebytes( x->x_inputs, onbinputs*sizeof(t_inlet*) ); - } - if ( x->x_inputs_x ) - { - freebytes( x->x_inputs_x, onbinputs*sizeof(t_int) ); - } - if ( x->x_inputs_y ) - { - freebytes( x->x_inputs_y, onbinputs*sizeof(t_int) ); - } - // post( "audience~ : creating new ones" ); - x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) ); - x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); - x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); - if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y ) - { - error( "audience~ : fatal : could not create new object" ); - return; - } - for ( bi=0; bix_nbinputs; bi++ ) - { - // post( "audience~ : allocating input ! %d", bi ); - x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - } - } - - // re-allocate outlets - if ( onboutputs != x->x_nboutputs ) - { - // post( "audience~ : cleaning up old outlets" ); - if ( x->x_outputs ) - { - for ( ei=0; eix_outputs[ei] ); - // outlet_free( x->x_outputs[ei] ); - } - freebytes( x->x_outputs, onboutputs*sizeof(t_outlet*) ); - } - if ( x->x_outputs_x ) - { - freebytes( x->x_outputs_x, onboutputs*sizeof(t_int) ); - } - if ( x->x_outputs_y ) - { - freebytes( x->x_outputs_y, onboutputs*sizeof(t_int) ); - } - // post( "audience~ : creating new ones" ); - x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) ); - x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); - x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); - if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y ) - { - // error( "audience~ : fatal : could not create new object" ); - return; - } - for ( bi=0; bix_nboutputs; bi++ ) - { - x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal ); - } - // set default coordinates - if ( x->x_nboutputs > 1 ) - { - for ( ei=0; eix_nboutputs; ei++ ) - { - x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 ); - x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2; - } - } - else - { - x->x_outputs_x[0] = x->x_width; - x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2; - } - } - - canvas_fixlinesfor( canvas, (t_text*)x ); - audience_draw_new(x, x->x_glist); - canvas_resume_dsp(dspstate); -} - -static void audience_delete(t_gobj *z, t_glist *glist) -{ - t_audience_tilde *x = (t_audience_tilde *)z; - - // post( "audience~ : delete" ); - audience_draw_erase( x, glist ); - canvas_deletelinesfor(glist, (t_text *)z); -} - -static void audience_displace(t_gobj *z, t_glist *glist, int dx, int dy) -{ - t_audience_tilde *x = (t_audience_tilde *)z; - int xold = text_xpix(&x->x_obj, glist); - int yold = text_ypix(&x->x_obj, glist); - - // post( "audience_displace dx=%d dy=%d", dx, dy ); - - x->x_obj.te_xpix += dx; - x->x_obj.te_ypix += dy; - if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix) - { - audience_draw_move(x, x->x_glist); - } -} - -static void audience_motion(t_audience_tilde *x, t_floatarg dx, t_floatarg dy) -{ - // post( "audience_motion dx=%f dy=%f", dx, dy ); - - switch( x->x_type_selected ) - { - case AUDIENCE_INPUT: - x->x_inputs_x[ x->x_nselected ] += dx; - if ( x->x_inputs_x[ x->x_nselected ] < 0 ) x->x_inputs_x[ x->x_nselected ] = 0; - if ( x->x_inputs_x[ x->x_nselected ] > x->x_width ) x->x_inputs_x[ x->x_nselected ] = x->x_width; - x->x_inputs_y[ x->x_nselected ] += dy; - if ( x->x_inputs_y[ x->x_nselected ] < 0 ) x->x_inputs_y[ x->x_nselected ] = 0; - if ( x->x_inputs_y[ x->x_nselected ] > x->x_height ) x->x_inputs_y[ x->x_nselected ] = x->x_height; - break; - case AUDIENCE_OUTPUT: - x->x_outputs_x[ x->x_nselected ] += dx; - if ( x->x_outputs_x[ x->x_nselected ] < 0 ) x->x_outputs_x[ x->x_nselected ] = 0; - if ( x->x_outputs_x[ x->x_nselected ] > x->x_width ) x->x_outputs_x[ x->x_nselected ] = x->x_width; - x->x_outputs_y[ x->x_nselected ] += dy; - if ( x->x_outputs_y[ x->x_nselected ] < 0 ) x->x_outputs_y[ x->x_nselected ] = 0; - if ( x->x_outputs_y[ x->x_nselected ] > x->x_height ) x->x_outputs_y[ x->x_nselected ] = x->x_height; - break; - } - - audience_draw_update(x, x->x_glist); -} - -static int audience_click(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) -{ - t_audience_tilde* x = (t_audience_tilde *)z; - t_int bi; - - // post( "audience_click doit=%d x=%d y=%d", doit, xpix, ypix ); - if ( doit) - { - t_int relx = xpix-text_xpix(&x->x_obj, glist); - t_int rely = ypix-text_ypix(&x->x_obj, glist); - - // post( "audience~ : relx : %d : rely : %d", relx, rely ); - x->x_type_selected = AUDIENCE_NONE; - x->x_nselected = -1; - for ( bi=0; bix_nbinputs; bi++ ) - { - if ( ( abs( relx - x->x_inputs_x[bi] ) < SPEAKER_WIDTH ) && - ( abs( rely - x->x_inputs_y[bi] ) < SPEAKER_HEIGHT ) ) { - x->x_type_selected = AUDIENCE_INPUT; - x->x_nselected = bi; - break; - } - } - if ( x->x_type_selected == AUDIENCE_NONE ) - { - for ( bi=0; bix_nboutputs; bi++ ) - { - if ( ( abs( relx - x->x_outputs_x[bi] ) < LISTENER_WIDTH ) && - ( abs( rely - x->x_outputs_y[bi] ) < LISTENER_HEIGHT ) ) { - x->x_type_selected = AUDIENCE_OUTPUT; - x->x_nselected = bi; - break; - } - } - } - audience_draw_update(x, glist); - glist_grab(glist, &x->x_obj.te_g, (t_glistmotionfn)audience_motion, - 0, xpix, ypix); - } - return (1); -} - -static t_audience_tilde *audience_new(t_symbol *s, int argc, t_atom *argv) -{ - t_int bi, ei; - t_audience_tilde *x; - t_pd *x2; - char *str; - - // post( "audience_new : create : %s argc =%d", s->s_name, argc ); - - x = (t_audience_tilde *)pd_new(audience_class_tilde); - // new audience created from the gui - if ( argc != 0 ) - { - if ( argc < 5 ) - { - post( "audience~ : error in the number of arguments ( %d )", argc ); - return NULL; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) { - post( "audience~ : wrong arguments" ); - return NULL; - } - - x->x_width = (int)argv[0].a_w.w_float; - if ( x->x_width < 10 ) x->x_width = 10; - x->x_height = (int)argv[1].a_w.w_float; - if ( x->x_height < 10 ) x->x_height = 10; - x->x_nbinputs = (int)argv[2].a_w.w_float; - if ( x->x_nbinputs < 1 ) x->x_nbinputs = 1; - x->x_nboutputs = (int)argv[3].a_w.w_float; - if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1; - x->x_attenuation = argv[4].a_w.w_float; - if ( x->x_attenuation < 0 ) x->x_attenuation = 0; - x->x_applydelay = argv[5].a_w.w_float; - } - else - { - x->x_width = DEFAULT_AUDIENCE_WIDTH; - x->x_height = DEFAULT_AUDIENCE_HEIGHT; - x->x_nbinputs = DEFAULT_AUDIENCE_NBINPUTS; - x->x_nboutputs = DEFAULT_AUDIENCE_NBOUTPUTS; - x->x_attenuation = DEFAULT_AUDIENCE_ATTENUATION; - x->x_applydelay = 0; - } - - // create inlets and outlets - x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) ); - x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); - x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) ); - if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y ) - { - post( "audience~ : could not allocate outputs" ); - return NULL; - } - for ( bi=0; bix_nboutputs; bi++ ) - { - x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal ); - } - x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) ); - x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); - x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) ); - if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y ) - { - post( "audience~ : could not allocate inputs" ); - return NULL; - } - for ( bi=0; bix_nbinputs; bi++ ) - { - x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - } - - // allocate audio buffer - x->x_audiowritepos = 0; - x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) ); - if ( !x->x_audiobuffer ) - { - post( "audience~ : could not allocate audio buffer" ); - return NULL; - } - x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 ) - + pow( x->x_height, 2 ) ) ) / SOUNDSPEED ) - * ( (float ) sys_getsr() ) ); - post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize ); - for ( bi=0; bix_nbinputs; bi++ ) - { - x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) ); - if ( !x->x_audiobuffer[bi] ) - { - post( "audience~ : could not allocate audio buffer" ); - return NULL; - } - } - - if ( argc == 0 ) - { - // set default coordinates - if ( x->x_nbinputs > 1 ) - { - for ( ei=0; eix_nbinputs; ei++ ) - { - x->x_inputs_x[ei] = (ei+1) * (x->x_width - 5) / x->x_nbinputs; - x->x_inputs_y[ei] = SPEAKER_HEIGHT/2; - } - } - else - { - x->x_inputs_x[0] = x->x_width; - x->x_inputs_y[0] = SPEAKER_HEIGHT/2; - } - - if ( x->x_nboutputs > 1 ) - { - for ( ei=0; eix_nboutputs; ei++ ) - { - x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 ); - x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2; - } - } - else - { - x->x_outputs_x[0] = x->x_width; - x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2; - } - } - else - { - t_int ai = 6; - - // restore coordinates from arguments - for ( ei=0; eix_nbinputs; ei++ ) - { - x->x_inputs_x[ei] = argv[ai++].a_w.w_float; - x->x_inputs_y[ei] = argv[ai++].a_w.w_float; - } - for ( ei=0; eix_nboutputs; ei++ ) - { - x->x_outputs_x[ei] = argv[ai++].a_w.w_float; - x->x_outputs_y[ei] = argv[ai++].a_w.w_float; - } - } - - x->x_glist = (t_glist *) canvas_getcurrent(); - x->x_type_selected = AUDIENCE_NONE; - x->x_nselected = -1; - - // post( "audience~ : new object : inlets : %d : outlets : %d : attenuation : %f", x->x_nbinputs, x->x_nboutputs, x->x_attenuation ); - return (x); -} - -static void audience_free(t_audience_tilde *x) -{ - t_int ei; - - if ( x->x_outputs ) - { - for ( ei=0; eix_nboutputs; ei++ ) - { - outlet_free( x->x_outputs[ei] ); - } - freebytes( x->x_outputs, x->x_nboutputs*sizeof(t_outlet*) ); - } - if ( x->x_inputs ) - { - for ( ei=0; eix_nbinputs; ei++ ) - { - inlet_free( x->x_inputs[ei] ); - } - freebytes( x->x_inputs, x->x_nbinputs*sizeof(t_outlet*) ); - } - if ( x->x_audiobuffer ) - { - for ( ei=0; eix_nbinputs; ei++ ) - { - freebytes( x->x_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) ); - } - freebytes( x->x_audiobuffer, x->x_nbinputs*sizeof(t_float*) ); - } -} - -static t_int *audience_perform(t_int *w) -{ - t_int ii, oi, op; - t_audience_tilde *x = (t_audience_tilde*)(w[1]); - t_int bsize = w[2]; - - { - // save input sounds in the audio buffer - for ( ii=0; iix_nbinputs; ii++ ) - { - t_float* isound = (t_float*)w[ii+3]; - - if ( x->x_audiobuffer[ii] ) - { - op = 0; - while ( op < bsize ) - { - *(x->x_audiobuffer[ii] + x->x_audiowritepos + op ) = *(isound + op); - op++; - } - } - } - - // set outputs - for ( oi=0; oix_nboutputs; oi++ ) - { - t_float* osound = (t_float*)w[oi+3+x->x_nbinputs]; - - // zeroing output - memset( osound, 0x00, bsize*sizeof( t_float ) ); - - for ( ii=0; iix_nbinputs; ii++ ) - { - t_int delay; - t_int dist; - t_int readpos; - t_int maxwritepos; - - maxwritepos = ( x->x_audiobuffersize / bsize ) * bsize; - dist = sqrt( pow( (x->x_outputs_x[oi] - x->x_inputs_x[ii]), 2 ) - + pow( (x->x_outputs_y[oi] - x->x_inputs_y[ii]), 2 ) ); - delay = ( t_int ) ( ( ( ( t_float ) dist ) * ( (float ) sys_getsr() ) ) / SOUNDSPEED ); - delay = ( delay / bsize ) * bsize; // set a block frontier - if ( x->x_applydelay ) - { - if ( x->x_audiowritepos >= delay ) - { - readpos = x->x_audiowritepos - delay; - } - else - { - readpos = maxwritepos - delay + x->x_audiowritepos; - } - } - else - { - readpos = x->x_audiowritepos; - } - // if ( ii == 0 ) - // { - // post( "audience~ : dist : %d : delay : %d : readpos : %d : writepos : %d", - // dist, delay, readpos, x->x_audiowritepos ); - // } - - op = 0; - while ( op < bsize ) - { - if ( ( readpos < x->x_audiobuffersize ) && ( readpos >= 0 ) ) - { - if ( 1.0-x->x_attenuation*dist < 0 ) - { - *(osound+op) += 0.0; - } - else - { - *(osound+op) += *(x->x_audiobuffer[ii] + readpos + op)*(1.0-x->x_attenuation*dist); - } - } - else - { - error( "audience~ : delay : %d : wrong readpos !!! : %d >= %d or < 0", delay, readpos, x->x_audiobuffersize ); - } - op++; - } - } - } - - // update write position - if ( x->x_audiowritepos + bsize > x->x_audiobuffersize - bsize ) - { - // post( "audience~ : write back to zero @ %d", x->x_audiowritepos ); - x->x_audiowritepos = 0; - } - else - { - x->x_audiowritepos += bsize; - } - - } - - return (w+x->x_nbinputs+x->x_nboutputs+3); -} - -static void audience_dsp(t_audience_tilde *x, t_signal **sp) -{ - switch ( x->x_nbinputs+x->x_nboutputs ) - { - case 2 : - dsp_add(audience_perform, 4, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec ); - break; - - case 3 : - dsp_add(audience_perform, 5, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec ); - break; - - case 4 : - dsp_add(audience_perform, 6, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec ); - break; - - case 5 : - dsp_add(audience_perform, 7, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[5]->s_vec ); - break; - - case 6 : - dsp_add(audience_perform, 8, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, - sp[5]->s_vec, sp[6]->s_vec ); - break; - - case 7 : - dsp_add(audience_perform, 9, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, - sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec ); - break; - - case 8 : - dsp_add(audience_perform, 10, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, - sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec ); - break; - - case 9 : - dsp_add(audience_perform, 11, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, - sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec, sp[9]->s_vec ); - break; - - case 10 : - dsp_add(audience_perform, 12, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, - sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec, - sp[9]->s_vec, sp[10]->s_vec ); - break; - - default : - post( "audience~ : number of inlets/outlets not supported" ); - break; - } -} - -// set attenuation -static void audience_attenuation(t_audience_tilde *x, t_floatarg fattenuation ) -{ - if ( fattenuation < 0 ) - { - post( "audience~ : error : wrong attenuation : %f", fattenuation ); - return; - } - x->x_attenuation = fattenuation; -} - -// set delay -static void audience_delay(t_audience_tilde *x, t_floatarg fdelay ) -{ - if ( fdelay == 0. ) - { - x->x_applydelay = 0; - } - else - { - x->x_applydelay = 1; - } -} - -void audience_tilde_setup(void) -{ - post( audience_version ); -#include "audience~.tk2c" - audience_class_tilde = class_new(gensym("audience~"), (t_newmethod)audience_new, - (t_method)audience_free, sizeof(t_audience_tilde), 0, A_GIMME, 0); - CLASS_MAINSIGNALIN( audience_class_tilde, t_audience_tilde, x_f ); - class_addmethod(audience_class_tilde, (t_method)audience_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(audience_class_tilde, (t_method)audience_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(audience_class_tilde, (t_method)audience_attenuation, gensym("attenuation"), A_DEFFLOAT, 0); - class_addmethod(audience_class_tilde, (t_method)audience_delay, gensym("delay"), A_DEFFLOAT, 0); - audience_widgetbehavior.w_getrectfn = audience_getrect; - audience_widgetbehavior.w_displacefn = audience_displace; - audience_widgetbehavior.w_selectfn = audience_select; - audience_widgetbehavior.w_activatefn = NULL; - audience_widgetbehavior.w_deletefn = audience_delete; - audience_widgetbehavior.w_visfn = audience_vis; - audience_widgetbehavior.w_clickfn = audience_click; - -#if PD_MINOR_VERSION >= 37 - class_setpropertiesfn(audience_class_tilde, audience_properties); - class_setsavefn(audience_class_tilde, audience_save); -#else - audience_widgetbehavior.w_propertiesfn = audience_properties; - audience_widgetbehavior.w_savefn = audience_save; -#endif - - class_setwidget(audience_class_tilde, &audience_widgetbehavior); - -} diff --git a/externals/unauthorized/audience~/audience~.tk2c b/externals/unauthorized/audience~/audience~.tk2c deleted file mode 100644 index 0682e31430044c247de15d289888f62302f1b13a..0000000000000000000000000000000000000000 --- a/externals/unauthorized/audience~/audience~.tk2c +++ /dev/null @@ -1,69 +0,0 @@ -// ########### audience procedures -- ydegoyon@free.fr ######### -sys_gui("proc audience_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_nboutputs [concat graph_nboutputs_$vid]\n"); -sys_gui("global $var_graph_nboutputs\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_nboutputs] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc audience_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc audience_ok {id} {\n"); -sys_gui("audience_apply $id\n"); -sys_gui("audience_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_audience_dialog {id width height nboutputs} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_nboutputs [concat graph_nboutputs_$vid]\n"); -sys_gui("global $var_graph_nboutputs\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_nboutputs $nboutputs\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {audience}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat audience_cancel $id]\n"); -sys_gui("label $id.label -text {2$ SPACE PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"audience_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"audience_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"audience_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.1rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.1rangef.lwidth $id.1rangef.width -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.2rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.2rangef.lheight $id.2rangef.height -side left\n"); -sys_gui("frame $id.3rangef\n"); -sys_gui("pack $id.3rangef -side top\n"); -sys_gui("label $id.3rangef.lnboutputs -text \"Nb Listeners :\"\n"); -sys_gui("entry $id.3rangef.nboutputs -textvariable $var_graph_nboutputs -width 7\n"); -sys_gui("pack $id.3rangef.lnboutputs $id.3rangef.nboutputs -side left\n"); -sys_gui("bind $id.1rangef.width [concat audience_ok $id]\n"); -sys_gui("bind $id.2rangef.height [concat audience_ok $id]\n"); -sys_gui("bind $id.3rangef.nboutputs [concat audience_ok $id]\n"); -sys_gui("focus $id.1rangef.width\n"); -sys_gui("}\n"); -// ########### audience procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/beatify~/beatify~-help.pd b/externals/unauthorized/beatify~-help.pd similarity index 100% rename from externals/unauthorized/beatify~/beatify~-help.pd rename to externals/unauthorized/beatify~-help.pd diff --git a/externals/unauthorized/beatify~/beatify~.c b/externals/unauthorized/beatify~.c similarity index 84% rename from externals/unauthorized/beatify~/beatify~.c rename to externals/unauthorized/beatify~.c index 51ac5b6714b600452787f9eac7845da8547c5964..394a60520b33edad8ba601feaaf34d42fac0c33c 100644 --- a/externals/unauthorized/beatify~/beatify~.c +++ b/externals/unauthorized/beatify~.c @@ -54,60 +54,65 @@ static t_class *beatify_class; static void beatify_attack(t_beatify *x, t_floatarg fattack ) { - if (fattack < 1.0) + if (fattack < 1.0) { - x->x_attack = 1.0; + x->x_attack = 1.0; } else { - x->x_attack = fattack; + x->x_attack = fattack; } } static void beatify_sustain(t_beatify *x, t_floatarg fsustain ) { - if (fsustain < 0.0) + if (fsustain < 0.0) { - x->x_sustain = 0.0; + x->x_sustain = 0.0; } else { - x->x_sustain = fsustain; + x->x_sustain = fsustain; } } static void beatify_decay(t_beatify *x, t_floatarg fdecay ) { - if (fdecay < 1.0) + if (fdecay < 1.0) { - x->x_decay = 1.0; + x->x_decay = 1.0; } else { - x->x_decay = fdecay; + x->x_decay = fdecay; } } static void beatify_size(t_beatify *x, t_floatarg fsize ) { - if (fsize < 100.0) + if (fsize < 100.0) { - x->x_size = 100.0; + x->x_size = 100.0; } else { - x->x_size = fsize; + x->x_size = fsize; } } static void beatify_gamplitude(t_beatify *x, t_floatarg fgamplitude ) { - if (fgamplitude < 0.0) { - x->x_gamplitude = 0.0; - } else if (fgamplitude > 1.0) { - x->x_gamplitude = 1.0; - } else { - x->x_gamplitude = fgamplitude; + if (fgamplitude < 0.0) + { + x->x_gamplitude = 0.0; + } + else if (fgamplitude > 1.0) + { + x->x_gamplitude = 1.0; + } + else + { + x->x_gamplitude = fgamplitude; } } @@ -137,22 +142,24 @@ static t_int *beatify_perform(t_int *w) t_beatify *x = (t_beatify*)(w[4]); t_float adelta = 0., ddelta = 0.; - while (n--) { - if ( x->x_current>=x->x_size ) - { + while (n--) + { + if ( x->x_current>=x->x_size ) + { adelta = (x->x_gamplitude-x->x_vol)/x->x_attack; ddelta = x->x_gamplitude/x->x_decay; x->x_current = 0; - } - if ( x->x_currentx_attack ) x->x_vol+= adelta; - if ( x->x_current>x->x_attack+x->x_sustain && x->x_currentx_attack+x->x_sustain+x->x_decay ) - { - x->x_vol-= ddelta; - } - x->x_current++; + } + if ( x->x_currentx_attack ) x->x_vol+= adelta; + if ( x->x_current>x->x_attack+x->x_sustain && x->x_currentx_attack+x->x_sustain+x->x_decay ) + { + x->x_vol-= ddelta; + } + x->x_current++; - *(out) = *(in)*x->x_vol; - out++; in++; + *(out) = *(in)*x->x_vol; + out++; + in++; } return (w+5); } @@ -164,9 +171,9 @@ static void beatify_dsp(t_beatify *x, t_signal **sp) void beatify_tilde_setup(void) { - post( beatify_version ); + logpost(NULL, 4, "%s", beatify_version ); beatify_class = class_new(gensym("beatify~"), (t_newmethod)beatify_new, 0, - sizeof(t_beatify), 0, 0); + sizeof(t_beatify), 0, 0); CLASS_MAINSIGNALIN( beatify_class, t_beatify, x_f ); class_addmethod(beatify_class, (t_method)beatify_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(beatify_class, (t_method)beatify_attack, gensym("attack"), A_FLOAT, 0); diff --git a/externals/unauthorized/beatify~/COPYING b/externals/unauthorized/beatify~/COPYING deleted file mode 100644 index 2128a66ea7d038eecac13febce1a26b3da3b7159..0000000000000000000000000000000000000000 --- a/externals/unauthorized/beatify~/COPYING +++ /dev/null @@ -1,280 +0,0 @@ - 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 diff --git a/externals/unauthorized/beatify~/INSTALL b/externals/unauthorized/beatify~/INSTALL deleted file mode 100644 index db33979918c6ec1d52302e90a30e1c87451f1df1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/beatify~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/beatify~ - -make clean - -make - -make install - -open help-beatify~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/beatify~/Makefile b/externals/unauthorized/beatify~/Makefile deleted file mode 100644 index 10ebafcbc277737bcdee3beae921f30e9ee6586f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/beatify~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=beatify~ -CSYM=beatify~ - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/beatify~/README b/externals/unauthorized/beatify~/README deleted file mode 100644 index fcde9d08bc043821c39790e5304746d95cb47b98..0000000000000000000000000000000000000000 --- a/externals/unauthorized/beatify~/README +++ /dev/null @@ -1,24 +0,0 @@ -Version 0.01 -copyright 2002 by Yves Degoyon. - -tarballs and updates available @ http://ydegoyon.free.fr - -beatify~ : modulate amplitude of a sound - -the idea was borrowed from musicscript, -an excellent sound generation tool. -( http://musicscript.sourceforge.net, author : David Piott ) - -To install beatify~, follow the steps from INSTALL - -This software is published under GPL terms, see COPYING -for rights restrictions. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - diff --git a/externals/unauthorized/blinkenlights/blinkenlights-help.pd b/externals/unauthorized/blinkenlights-help.pd similarity index 100% rename from externals/unauthorized/blinkenlights/blinkenlights-help.pd rename to externals/unauthorized/blinkenlights-help.pd diff --git a/externals/unauthorized/blinkenlights.c b/externals/unauthorized/blinkenlights.c new file mode 100644 index 0000000000000000000000000000000000000000..312639b79f5bdb2ee5103e774c70be4ed44bc7b7 --- /dev/null +++ b/externals/unauthorized/blinkenlights.c @@ -0,0 +1,894 @@ +/* ---------------------- blinkenlights~ -------------------------------------- */ +/* */ +/* Blinkenlights is a BL movies player but also a pixel grid */ +/* Written by Yves Degoyon (ydegoyon@free.fr). */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* Currently listening : */ +/* Pop Group : We Are All Prostitutes */ +/* Culturcide : Bruce */ +/* ---------------------------------------------------------------------------- */ + +//added functions: +//"static void blinkenlights_findframes(t_blinkenlights *x)" +//this is to remember the frame positions in the .blm file + +//"static void blinkenlights_goto(t_blinkenlights* x, t_float frame)" +//with a "goto $1" message, you can stratch the blm film. note that the +//range of $1 is 0 to 1 + + +#include +#include +#include +#include +#include +#include +#include +#ifndef __APPLE__ +#include +#endif +#include +#include +#include +#include + +#include "m_pd.h" /* standard pd stuff */ +#include "g_canvas.h" /* some pd's graphical functions */ + +/* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_fopen fopen +#define sys_fclose fclose +#define sys_close close +#endif + +static char *blinkenlights_version = "blinkenlights: a blinkenlights movies player version 0.2 ( bugs @ ydegoyon@free.fr and chun@goto10.org )"; + +static int guidebug=0; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ + post(a,b,c,d,e,f);\ + sys_vgui(a,b,c,d,e,f) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g);\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ + post(a,b,c,d,e,f,g,h);\ + sys_vgui(a,b,c,d,e,f,g,h) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i);\ + sys_vgui(a,b,c,d,e,f,g,h,i) + +#define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j);\ + sys_vgui(a,b,c,d,e,f,g,h,i,j) + +#define BL_BACKGROUND_COLOR "#000000" +#define BL_FOREGROUND_COLOR "#00FF00" +#define BL_MAX_LENGTH 1024 + +static t_class *blinkenlights_class; + +typedef struct _blinkenlights +{ + t_object x_obj; + t_int x_width; /* number of pixels ( width ) */ + t_int x_height; /* number of pixels ( height) */ + t_int x_xsize; /* x size of each pixel */ + t_int x_ysize; /* y size of each pixel */ + char *x_background; /* color of the background #RRGGBB */ + char *x_foreground; /* color of the foreground #RRGGBB */ + t_int x_ecanvas; /* flag that indicates if the canvas has been created */ + t_glist *x_glist; /* graphic context */ + FILE *x_filed; /* file descriptor */ + t_int x_timer; /* timer read from bl movie */ + t_int *x_frame; /* frame contents */ + t_clock *x_clock; /* clock used for reading frames */ + t_outlet *outlet_bang; + t_int frame_no; + t_int frame_pos[BL_MAX_LENGTH]; + t_clock *x_clock2; + t_int x_timer2; + t_float frame_inc; + +} t_blinkenlights; + +static void blinkenlights_close(t_blinkenlights *x); + +/* clean up */ +static void blinkenlights_free(t_blinkenlights *x) +{ + post( "blinkenlights : freeing colors" ); + if ( x->x_background ) freebytes( x->x_background, 8 ); + if ( x->x_foreground ) freebytes( x->x_foreground, 8 ); + post( "blinkenlights : closing file" ); + blinkenlights_close(x); + post( "blinkenlights : cancelling clock" ); + if ( x->x_clock != NULL ) + { + clock_unset( x->x_clock ); + clock_free( x->x_clock ); + } + if ( x->x_clock2 != NULL ) + { + clock_unset( x->x_clock2 ); + clock_free( x->x_clock2 ); + } + post( "blinkenlights : done" ); +} + +static void *blinkenlights_new(t_float fwidth, t_float fheight, t_float fxpixsize, t_float fypixsize ) +{ + t_blinkenlights *x = (t_blinkenlights *)pd_new(blinkenlights_class); + if ( fwidth <= 0 ) + { + post( "blinkenlights: wrong creation argument : width : %f", fwidth ); + return NULL; + } + if ( fheight <= 0 ) + { + post( "blinkenlights: wrong creation argument : height : %f", fheight ); + return NULL; + } + if ( fxpixsize <= 0 ) + { + post( "blinkenlights: wrong creation argument : x pixel size : %f", fxpixsize ); + return NULL; + } + if ( fypixsize <= 0 ) + { + post( "blinkenlights: wrong creation argument : y pixel size : %f", fypixsize ); + return NULL; + } + x->x_width = (int) fwidth; + x->x_height = (int) fheight; + x->x_xsize = (int) fxpixsize; + x->x_ysize = (int) fypixsize; + x->x_ecanvas = 0; + x->x_filed = NULL; + x->x_frame = NULL; + x->x_clock = NULL; + x->x_glist = (t_glist *) canvas_getcurrent(); + x->x_background = (char*) getbytes( 8 ); + strncpy( x->x_background, BL_BACKGROUND_COLOR, 7 ); + x->x_background[7] = '\0'; + x->x_foreground = (char*) getbytes( 8 ); + strncpy( x->x_foreground, BL_FOREGROUND_COLOR, 7 ); + x->x_foreground[7] = '\0'; + x->x_timer2 = 40; + x->frame_inc = 0; + + x->outlet_bang = outlet_new(&x->x_obj, &s_bang); + + return(x); +} + +static void blinkenlights_draw_new(t_blinkenlights* x) +{ + t_canvas *canvas=glist_getcanvas(x->x_glist); + t_int xi, yi; + + SYS_VGUI4("toplevel .x%lx -width %d -height %d -borderwidth 0 -background #000000\n", x, + x->x_width*x->x_xsize, x->x_height*x->x_ysize ); + SYS_VGUI2("frame .x%lx.m -relief raised -bd 2\n", x); + SYS_VGUI2("wm title .x%lx blinkenlights\n", x); + + SYS_VGUI4("canvas .x%lx.c -width %d -height %d\n", + x, + x->x_width*x->x_xsize, x->x_height*x->x_ysize ); + x->x_ecanvas = 1; + + for ( xi=1; xi<=x->x_width; xi++ ) + { + for ( yi=1; yi<=x->x_height; yi++ ) + { + SYS_VGUI10(".x%lx.c create rectangle %d %d %d %d -fill %s -outline #555555 -tags %xPIX%.5d%.5d\n", + x, + (xi-1)*x->x_xsize, (yi-1)*x->x_ysize, + xi*x->x_xsize, yi*x->x_ysize, + x->x_background, + x, xi, yi); + } + } + + SYS_VGUI2("pack .x%lx.c -side left -expand 1 -fill both\n", x); + SYS_VGUI2("pack .x%lx.m -side top -fill x\n", x); + SYS_VGUI2("wm geometry .x%lx +0+0\n", x); + SYS_VGUI2("wm geometry .x%lx +0+0\n", x); + +} + +static void blinkenlights_create(t_blinkenlights* x) +{ + + if ( x->x_ecanvas ) + { + post("blinkenlights : create : canvas already exists" ); + return; + } + + blinkenlights_draw_new(x); + +} + +static void blinkenlights_erase(t_blinkenlights* x) +{ + t_canvas *canvas=glist_getcanvas(x->x_glist); + t_int xi, yi; + + for ( xi=1; xi<=x->x_width; xi++ ) + { + for ( yi=1; yi<=x->x_height; yi++ ) + { + SYS_VGUI5(".x%lx.c delete %xPIX%.5d%.5d\n", x, x, xi, yi); + } + } + SYS_VGUI2("destroy .x%lx\n", x); + x->x_ecanvas=0; +} + +static void blinkenlights_destroy(t_blinkenlights* x) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : destroy : canvas does not exist" ); + return; + } + + blinkenlights_erase(x); +} + +static void blinkenlights_width(t_blinkenlights* x, t_float fwidth) +{ + if ( fwidth <= 0 ) + { + post( "blinkenlights~: wrong width : ignored" ); + return; + } + else + { + if ( x->x_width == (int)fwidth ) return; + x->x_width=(int)fwidth; + } + if (x->x_ecanvas) blinkenlights_erase( x ); + blinkenlights_draw_new( x ); +} + +static void blinkenlights_height(t_blinkenlights* x, t_float fheight) +{ + if ( fheight <= 0 ) + { + post( "blinkenlights~: wrong height : ignored" ); + return; + } + else + { + if ( x->x_height == (int)fheight ) return; + x->x_height=(int)fheight; + } + if (x->x_ecanvas) blinkenlights_erase( x ); + blinkenlights_draw_new( x ); +} + +static void blinkenlights_xsize(t_blinkenlights* x, t_float fxsize) +{ + if ( fxsize <= 0 ) + { + post( "blinkenlights~: wrong x pixel size : ignored" ); + return; + } + else + { + if ( x->x_xsize == (int)fxsize ) return; + x->x_xsize=(int)fxsize; + } + if (x->x_ecanvas) blinkenlights_erase( x ); + blinkenlights_draw_new( x ); +} + +static void blinkenlights_ysize(t_blinkenlights* x, t_float fysize) +{ + if ( fysize <= 0 ) + { + post( "blinkenlights~: wrong y pixel size : ignored" ); + return; + } + else + { + if ( x->x_ysize == (int)fysize ) return; + x->x_ysize=(int)fysize; + } + if (x->x_ecanvas) blinkenlights_erase( x ); + blinkenlights_draw_new( x ); +} + +static void blinkenlights_background(t_blinkenlights* x, t_float fR, t_float fG, t_float fB) +{ + if ( fR <0 || fR>255 ) + { + post("blinkenlights : wrong color component : fR : %d", fR); + return; + } + if ( fG <0 || fG>255 ) + { + post("blinkenlights : wrong color component : fG : %d", fG); + return; + } + if ( fB <0 || fB>255 ) + { + post("blinkenlights : wrong color component : fB : %d", fB); + return; + } + sprintf( x->x_background, "#%.2x%.2x%.2x", (int)fR, (int)fG, (int)fB ); + post("blinkenlights : background color set to : %s", x->x_background ); +} + +static void blinkenlights_foreground(t_blinkenlights* x, t_float fR, t_float fG, t_float fB) +{ + if ( fR <0 || fR>255 ) + { + post("blinkenlights : wrong color component : fR : %d", fR); + return; + } + if ( fG <0 || fG>255 ) + { + post("blinkenlights : wrong color component : fG : %d", fG); + return; + } + if ( fB <0 || fB>255 ) + { + post("blinkenlights : wrong color component : fB : %d", fB); + return; + } + sprintf( x->x_foreground, "#%.2x%.2x%.2x", (int)fR, (int)fG, (int)fB ); + post("blinkenlights : foreground color set to : %s", x->x_foreground ); +} + +static void blinkenlights_pixon(t_blinkenlights* x, t_float fX, t_float fY) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : pixon : canvas does not exist" ); + return; + } + if ( fX<1 || fX>x->x_width ) + { + post("blinkenlights : pixon : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); + return; + } + if ( fY<1 || fY>x->x_height ) + { + post("blinkenlights : pixon : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); + return; + } + SYS_VGUI6(".x%lx.c itemconfigure %xPIX%.5d%.5d -fill %s\n", x, x, (int)fX, (int)fY, x->x_foreground ); +} + +static void blinkenlights_pixoff(t_blinkenlights* x, t_float fX, t_float fY) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : pixoff : canvas does not exist" ); + return; + } + if ( fX<1 || fX>x->x_width ) + { + post("blinkenlights : pixoff : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); + return; + } + if ( fY<1 || fY>x->x_height ) + { + post("blinkenlights : pixoff : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); + return; + } + SYS_VGUI6(".x%lx.c itemconfigure %xPIX%.5d%.5d -fill %s\n", x, x, (int)fX, (int)fY, x->x_background ); +} + +static void blinkenlights_pixel(t_blinkenlights* x, t_float fX, t_float fY, t_float fR, t_float fG, t_float fB) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : pixel : canvas does not exist" ); + return; + } + if ( fX<1 || fX>x->x_width ) + { + post("blinkenlights : pixel : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); + return; + } + if ( fY<1 || fY>x->x_height ) + { + post("blinkenlights : pixel : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); + return; + } + if ( fR <0 || fR>255 ) + { + post("blinkenlights : pixel : wrong color component : fR : %d", fR); + return; + } + if ( fG <0 || fG>255 ) + { + post("blinkenlights : pixel : wrong color component : fG : %d", fG); + return; + } + if ( fB <0 || fB>255 ) + { + post("blinkenlights : pixel : wrong color component : fB : %d", fB); + return; + } + SYS_VGUI8(".x%lx.c itemconfigure %xPIX%.5d%.5d -fill #%.2X%.2X%.2X\n", x, x, (int)fX, (int)fY, (int)fR, (int)fG, (int)fB ); +} + +static void blinkenlights_clear(t_blinkenlights* x) +{ + t_int xi, yi; + + for ( xi=1; xi<=x->x_width; xi++ ) + { + for ( yi=1; yi<=x->x_height; yi++ ) + { + blinkenlights_pixoff( x, xi, yi ); + } + } +} + +/* close the current movie */ +static void blinkenlights_close(t_blinkenlights *x) +{ + /* closing previous file descriptor */ + if ( x->x_filed != NULL ) + { + if(fclose(x->x_filed) < 0) + { + perror( "blinkenlights : closing file" ); + } + x->x_filed = NULL; + } + if ( x->x_frame ) + { + freebytes( x->x_frame, x->x_width*x->x_height*sizeof(t_int) ); + x->x_frame = NULL; + } +} + +/* read the next frame */ +static void blinkenlights_readframe(t_blinkenlights *x) +{ + char *lineread = (char*) getbytes( BL_MAX_LENGTH ); + t_int flineno = 0; + t_int width, height, nwidth; + + //post( "blinkenlights: being readframe:>%s<", lineread ); + + if ( !x->x_ecanvas ) + { + post("blinkenlights : next : canvas does not exist" ); + return; + } + + if ( x->x_filed == NULL ) + { + post( "blinkenlights : no file is opened for reading a frame" ); + blinkenlights_close(x); + return; + } + + // skip header and empty lines + while ( lineread[0] == '#' || lineread[0] == '\n' || lineread[0] == '\0' ) + { + + //post( "blinkenlights : skipped line : >%s<", lineread ); + if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == 0 ) + { + post( "blinkenlights : end of file detected : looping..." ); + fseek( x->x_filed, 0L, SEEK_SET ); + outlet_bang(x->outlet_bang); + } + } + + if ( lineread[0] != '@' ) + { + post( "blinkenlights : format error : should find a time lime here : @XXX : got : >%s<", lineread ); + blinkenlights_close(x); + return; + } + else + { + x->x_timer = atoi( lineread+1 ); + // post( "blinkenlights : setting timer to %d", x->x_timer ); + } + + // read the contents of one frame + + // when reading first frame the height and width are read from the file + height = 0; + width = 0; + while ( 1 ) + { + + if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == NULL ) + { + post( "blinkenlights : EOF not expected here !!! "); + blinkenlights_close(x); + return; + } + else + { + if ( (lineread[0] == '\0') || (lineread[0] == '#') || (lineread[0] == '\n') ) break; + // post( "blinkenlights : lineread : %s", lineread ); + + nwidth = strlen( lineread )-1; // because of the carriage return + flineno++; + height = flineno; + if ( ( nwidth != width ) && ( width != 0 ) ) + { + post( "blinkenlights : weird file : width has changed (nwidth=%d) (width=%d)", nwidth, width ); + blinkenlights_close( x ); + return; + } + width = nwidth; + if ( x->x_frame != NULL ) + { + t_int pint = 0; + t_int newvalue; + + while ( pint < width ) + { + newvalue = (int) *(lineread+pint) - 48 /* ascii value for '0' */; + if ( newvalue != *(x->x_frame+(flineno-1)*x->x_width+pint ) ) + { + *(x->x_frame+(flineno-1)*x->x_width+pint ) = newvalue; + switch ( newvalue ) + { + case 0: + // post( "pixoff %d %d", pint+1, flineno ); + blinkenlights_pixoff( x, pint+1, flineno ); + break; + case 1: + // post( "pixon %d %d", pint+1, flineno ); + blinkenlights_pixon( x, pint+1, flineno ); + break; + default: + // post("blinkenlights : wrong value found for pixel : %d (c=%c)", newvalue, *(lineread+pint) ); + break; + } + } + pint++; + } + } + if ( x->x_frame == NULL ) x->x_height++; + } + } + if ( x->x_frame == NULL ) + { + if ( x->x_filed != NULL ) if ( fseek(x->x_filed, 0L, SEEK_SET) < 0 ) + { + post( "blinkenlights : could not rewind file" ); + blinkenlights_close( x ); + return; + } + blinkenlights_width(x, width); + blinkenlights_height(x, height); + x->x_frame = ( t_int* ) getbytes( x->x_width*x->x_height*sizeof(t_int) ); + blinkenlights_readframe(x); + } + + if ( lineread ) freebytes( lineread, BL_MAX_LENGTH ); +} +//------------------------------------------------------------------------- +//--chun's functions begin here... +//------------------------------------------------------------------------- +/* remember all the frame positions */ +static void blinkenlights_findframes(t_blinkenlights *x) +{ + int i =0; + + x->frame_no = 0; + + for(i=0;; i++) + { + char *lineread = (char*) getbytes( BL_MAX_LENGTH ); + + fgets( lineread, BL_MAX_LENGTH, x->x_filed ); + if(strlen(lineread) == 0) break; + + if(lineread[0] == '@') + { + x->frame_pos[x->frame_no] = ftell(x->x_filed); + x->frame_no++; + } + if (lineread) freebytes( lineread, BL_MAX_LENGTH ); + } + fseek( x->x_filed, 0L, SEEK_SET ); + post("the end:: %d frames!", x->frame_no); +} + +//------------------------------------------------------------------------- +static void blinkenlights_goto(t_blinkenlights* x) +{ +//char *lineread = (char*) getbytes( BL_MAX_LENGTH ); + char lineread[BL_MAX_LENGTH]; + int current_frame = x->frame_pos[(int)(x->frame_inc * (x->frame_no-1))]; + int i, n, width, newvalue, height, nwidth; + + t_int flineno = 0; + + fseek(x->x_filed, current_frame, SEEK_SET); + + height = 0; + width = 0; + while ( 1 ) + { + + if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == NULL ) + { + post( "blinkenlights : EOF not expected here !!! "); + blinkenlights_close(x); + return; + } + else + { + if ( (lineread[0] == '\0') || (lineread[0] == '#') || (lineread[0] == '\n') ) break; + // post( "blinkenlights : lineread : %s", lineread ); + + nwidth = strlen( lineread )-1; // because of the carriage return + flineno++; + height = flineno; + if ( ( nwidth != width ) && ( width != 0 ) ) + { + post( "blinkenlights : weird file : width has changed (nwidth=%d) (width=%d)", nwidth, width ); + blinkenlights_close( x ); + return; + } + width = nwidth; + if ( x->x_frame != NULL ) + { + t_int pint = 0; + t_int newvalue; + + while ( pint < width ) + { + newvalue = (int) *(lineread+pint) - 48 /* ascii value for '0' */; + if ( newvalue != *(x->x_frame+(flineno-1)*x->x_width+pint ) ) + { + *(x->x_frame+(flineno-1)*x->x_width+pint ) = newvalue; + switch ( newvalue ) + { + case 0: + // post( "pixoff %d %d", pint+1, flineno ); + blinkenlights_pixoff( x, pint+1, flineno ); + break; + case 1: + // post( "pixon %d %d", pint+1, flineno ); + blinkenlights_pixon( x, pint+1, flineno ); + break; + default: + // post("blinkenlights : wrong value found for pixel : %d (c=%c)", newvalue, *(lineread+pint) ); + break; + } + } + pint++; + } + } + if ( x->x_frame == NULL ) x->x_height++; + } + } + if ( x->x_frame == NULL ) + { + if ( x->x_filed != NULL ) if ( fseek(x->x_filed, 0L, SEEK_SET) < 0 ) + { + post( "blinkenlights : could not rewind file" ); + blinkenlights_close( x ); + return; + } + blinkenlights_width(x, width); + blinkenlights_height(x, height); + x->x_frame = ( t_int* ) getbytes( x->x_width*x->x_height*sizeof(t_int) ); + blinkenlights_readframe(x); + } + +} + +static void blinkenlights_frame_pos(t_blinkenlights* x, t_float pos) +{ + if(pos > 1 | pos < 0) post ("dude, don't be crazy!"); + else x->frame_inc = pos;; +//post("frame %d", x->frame_inc); +} + +static void blinkenlights_timer2(t_blinkenlights* x, t_float timer) +{ + x->x_timer2 = timer; +//post("frame %d", x->frame_inc); +} + +/* open movie */ +static void blinkenlights_open(t_blinkenlights *x, t_symbol *sfile) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : open : canvas does not exist" ); + return; + } + + //---------------------------------- + /* closing previous file descriptor */ + if ( x->x_filed != NULL ) + { + if(fclose(x->x_filed) < 0) + { + perror( "blinkenlights : closing file" ); + } + x->x_filed = NULL; + } + if ( x->x_frame ) + { + blinkenlights_clear(x); + } + + //-------------------------------- + + if ( ( x->x_filed = sys_fopen( sfile->s_name, "r" ) ) == NULL ) + { + error( "blinkenlights : cannot open >%s<", sfile->s_name); + return; + } + post( "blinkenlights : opened >%s<", sfile->s_name); + // don't read the first frame when open.. + //blinkenlights_readframe(x); + blinkenlights_findframes(x); +} + +/* play frames */ +static void blinkenlights_playframes(t_blinkenlights *x) +{ + blinkenlights_readframe( x ); + clock_delay( x->x_clock, (double)x->x_timer ); +} + +/* play frames2 */ +static void blinkenlights_playframes2(t_blinkenlights *x) +{ + blinkenlights_goto(x); + clock_delay( x->x_clock2, (double)x->x_timer2 ); +} + +/* play movie */ +static void blinkenlights_play(t_blinkenlights *x) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : play : canvas does not exist" ); + return; + } + + if ( x->x_filed == NULL ) + { + post( "blinkenlights : no file is opened for playing" ); + blinkenlights_close(x); + return; + } + + if ( x->x_clock == NULL ) x->x_clock = clock_new( x, (t_method)blinkenlights_playframes); + clock_delay( x->x_clock, (double)x->x_timer ); +} + +/* vj movie */ +static void blinkenlights_vj(t_blinkenlights *x, t_float start_vj) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : play : canvas does not exist" ); + return; + } + + if ( x->x_filed == NULL ) + { + post( "blinkenlights : no file is opened for playing" ); + blinkenlights_close(x); + return; + } + + if(start_vj) + { + if ( x->x_clock2 == NULL ) x->x_clock2 = clock_new( x, (t_method)blinkenlights_playframes2); + clock_delay( x->x_clock2, (double)x->x_timer2 ); + } + else + { + clock_unset( x->x_clock2 ); + } +} + +/* stop movie */ +static void blinkenlights_stop(t_blinkenlights *x) +{ + if ( !x->x_ecanvas ) + { + post("blinkenlights : play : canvas does not exist" ); + return; + } + + if ( x->x_filed == NULL ) + { + post( "blinkenlights : no file is opened for playing" ); + blinkenlights_close(x); + return; + } + + if ( x->x_clock != NULL ) + { + clock_unset( x->x_clock ); + } +} + +/* jump to next frame */ +static void blinkenlights_next(t_blinkenlights *x) +{ + blinkenlights_readframe(x); +} + +void blinkenlights_setup(void) +{ + logpost(NULL, 4, "%s", blinkenlights_version); + blinkenlights_class = class_new(gensym("blinkenlights"), (t_newmethod)blinkenlights_new, + (t_method)blinkenlights_free, + sizeof(t_blinkenlights), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_width, gensym("width"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_height, gensym("height"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_xsize, gensym("xsize"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_ysize, gensym("ysize"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_open, gensym("open"), A_SYMBOL, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_create, gensym("create"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_destroy, gensym("destroy"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_next, gensym("next"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_play, gensym("play"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_stop, gensym("stop"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_frame_pos, gensym("goto"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_vj, gensym("vj"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_timer2, gensym("timer2"), A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_background, gensym("background"), A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_foreground, gensym("foreground"), A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_destroy, gensym("destroy"), 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixon, gensym("pixon"), A_FLOAT, A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixoff, gensym("pixoff"), A_FLOAT, A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixel, gensym("pixel"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod( blinkenlights_class, (t_method)blinkenlights_clear, gensym("clear"), 0); +} diff --git a/externals/unauthorized/blinkenlights/INSTALL b/externals/unauthorized/blinkenlights/INSTALL deleted file mode 100644 index 218e1252793005e73c908457662115a389592b26..0000000000000000000000000000000000000000 --- a/externals/unauthorized/blinkenlights/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/blinkenlights - -make clean - -make - -make install - -open help-blinkenlights.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/blinkenlights/Makefile b/externals/unauthorized/blinkenlights/Makefile deleted file mode 100644 index d0b355ab152e4e77ec16abfca934bf8704c665e5..0000000000000000000000000000000000000000 --- a/externals/unauthorized/blinkenlights/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=blinkenlights -CSYM=blinkenlights_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch -g #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/blinkenlights/README b/externals/unauthorized/blinkenlights/README deleted file mode 100644 index 44a5b25268ac8e6255c548d127543ba26e7dcc18..0000000000000000000000000000000000000000 --- a/externals/unauthorized/blinkenlights/README +++ /dev/null @@ -1,26 +0,0 @@ -***************************************************************************** -Version 0.1 -copyleft 2002 by Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -blinkenlight : a blinken lights films player ( but also a pixel grid ) - -This object displays blinken lights movies, and lets you handle -a grid of pixels. -It is also a "Telecran" !! - -There is a movies archive @ http://www.blinkenlights.de/gallery/index.en.html - -To install blinkenlights, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware, your mental health -or your hearing due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/blinkenlights/blinkenlights.c b/externals/unauthorized/blinkenlights/blinkenlights.c deleted file mode 100644 index e0878b6d1a2bddf05f59b4df2488166c02751f8f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/blinkenlights/blinkenlights.c +++ /dev/null @@ -1,869 +0,0 @@ -/* ---------------------- blinkenlights~ -------------------------------------- */ -/* */ -/* Blinkenlights is a BL movies player but also a pixel grid */ -/* Written by Yves Degoyon (ydegoyon@free.fr). */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* Currently listening : */ -/* Pop Group : We Are All Prostitutes */ -/* Culturcide : Bruce */ -/* ---------------------------------------------------------------------------- */ - -//added functions: -//"static void blinkenlights_findframes(t_blinkenlights *x)" -//this is to remember the frame positions in the .blm file - -//"static void blinkenlights_goto(t_blinkenlights* x, t_float frame)" -//with a "goto $1" message, you can stratch the blm film. note that the -//range of $1 is 0 to 1 - - -#include -#include -#include -#include -#include -#include -#include -#ifndef __APPLE__ -#include -#endif -#include -#include -#include -#include - -#include "m_pd.h" /* standard pd stuff */ -#include "g_canvas.h" /* some pd's graphical functions */ - -static char *blinkenlights_version = "blinkenlights: a blinkenlights movies player version 0.2 ( bugs @ ydegoyon@free.fr and chun@goto10.org )"; - -static int guidebug=0; - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g);\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h);\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i);\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -#define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j);\ - sys_vgui(a,b,c,d,e,f,g,h,i,j) - -#define BL_BACKGROUND_COLOR "#000000" -#define BL_FOREGROUND_COLOR "#00FF00" -#define BL_MAX_LENGTH 1024 - -static t_class *blinkenlights_class; - -typedef struct _blinkenlights -{ - t_object x_obj; - t_int x_width; /* number of pixels ( width ) */ - t_int x_height; /* number of pixels ( height) */ - t_int x_xsize; /* x size of each pixel */ - t_int x_ysize; /* y size of each pixel */ - char *x_background; /* color of the background #RRGGBB */ - char *x_foreground; /* color of the foreground #RRGGBB */ - t_int x_ecanvas; /* flag that indicates if the canvas has been created */ - t_glist *x_glist; /* graphic context */ - FILE *x_filed; /* file descriptor */ - t_int x_timer; /* timer read from bl movie */ - t_int *x_frame; /* frame contents */ - t_clock *x_clock; /* clock used for reading frames */ - t_outlet *outlet_bang; - t_int frame_no; - t_int frame_pos[BL_MAX_LENGTH]; - t_clock *x_clock2; - t_int x_timer2; - t_float frame_inc; - -} t_blinkenlights; - -static void blinkenlights_close(t_blinkenlights *x); - - /* clean up */ -static void blinkenlights_free(t_blinkenlights *x) -{ - post( "blinkenlights : freeing colors" ); - if ( x->x_background ) freebytes( x->x_background, 8 ); - if ( x->x_foreground ) freebytes( x->x_foreground, 8 ); - post( "blinkenlights : closing file" ); - blinkenlights_close(x); - post( "blinkenlights : cancelling clock" ); - if ( x->x_clock != NULL ) - { - clock_unset( x->x_clock ); - clock_free( x->x_clock ); - } - if ( x->x_clock2 != NULL ) - { - clock_unset( x->x_clock2 ); - clock_free( x->x_clock2 ); - } - post( "blinkenlights : done" ); -} - -static void *blinkenlights_new(t_float fwidth, t_float fheight, t_float fxpixsize, t_float fypixsize ) -{ - t_blinkenlights *x = (t_blinkenlights *)pd_new(blinkenlights_class); - if ( fwidth <= 0 ) { - post( "blinkenlights: wrong creation argument : width : %f", fwidth ); - return NULL; - } - if ( fheight <= 0 ) { - post( "blinkenlights: wrong creation argument : height : %f", fheight ); - return NULL; - } - if ( fxpixsize <= 0 ) { - post( "blinkenlights: wrong creation argument : x pixel size : %f", fxpixsize ); - return NULL; - } - if ( fypixsize <= 0 ) { - post( "blinkenlights: wrong creation argument : y pixel size : %f", fypixsize ); - return NULL; - } - x->x_width = (int) fwidth; - x->x_height = (int) fheight; - x->x_xsize = (int) fxpixsize; - x->x_ysize = (int) fypixsize; - x->x_ecanvas = 0; - x->x_filed = NULL; - x->x_frame = NULL; - x->x_clock = NULL; - x->x_glist = (t_glist *) canvas_getcurrent(); - x->x_background = (char*) getbytes( 8 ); - strncpy( x->x_background, BL_BACKGROUND_COLOR, 7 ); - x->x_background[7] = '\0'; - x->x_foreground = (char*) getbytes( 8 ); - strncpy( x->x_foreground, BL_FOREGROUND_COLOR, 7 ); - x->x_foreground[7] = '\0'; - x->x_timer2 = 40; - x->frame_inc = 0; - - x->outlet_bang = outlet_new(&x->x_obj, &s_bang); - - return(x); -} - -static void blinkenlights_draw_new(t_blinkenlights* x) -{ - t_canvas *canvas=glist_getcanvas(x->x_glist); - t_int xi, yi; - - SYS_VGUI4("toplevel .x%x -width %d -height %d -borderwidth 0 -background #000000 -class [winfo class .]\n", x, - x->x_width*x->x_xsize, x->x_height*x->x_ysize ); - SYS_VGUI2("frame .x%x.m -relief raised -bd 2\n", x); - SYS_VGUI2("wm title .x%x blinkenlights\n", x); - - SYS_VGUI4("canvas .x%x.c -width %d -height %d\n", - x, - x->x_width*x->x_xsize, x->x_height*x->x_ysize ); - x->x_ecanvas = 1; - - for ( xi=1; xi<=x->x_width; xi++ ) - { - for ( yi=1; yi<=x->x_height; yi++ ) - { - SYS_VGUI10(".x%x.c create rectangle %d %d %d %d -fill %s -outline #555555 -tags %xPIX%.5d%.5d\n", - x, - (xi-1)*x->x_xsize, (yi-1)*x->x_ysize, - xi*x->x_xsize, yi*x->x_ysize, - x->x_background, - x, xi, yi); - } - } - - SYS_VGUI2("pack .x%x.c -side left -expand 1 -fill both\n", x); - SYS_VGUI2("pack .x%x.m -side top -fill x\n", x); - SYS_VGUI2("wm geometry .x%x +0+0\n", x); - SYS_VGUI2("wm geometry .x%x +0+0\n", x); - -} - -static void blinkenlights_create(t_blinkenlights* x) -{ - - if ( x->x_ecanvas ) - { - post("blinkenlights : create : canvas already exists" ); - return; - } - - blinkenlights_draw_new(x); - -} - -static void blinkenlights_erase(t_blinkenlights* x) -{ - t_canvas *canvas=glist_getcanvas(x->x_glist); - t_int xi, yi; - - for ( xi=1; xi<=x->x_width; xi++ ) - { - for ( yi=1; yi<=x->x_height; yi++ ) - { - SYS_VGUI5(".x%x.c delete %xPIX%.5d%.5d\n", x, x, xi, yi); - } - } - SYS_VGUI2("destroy .x%x\n", x); - x->x_ecanvas=0; -} - -static void blinkenlights_destroy(t_blinkenlights* x) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : destroy : canvas does not exist" ); - return; - } - - blinkenlights_erase(x); -} - -static void blinkenlights_width(t_blinkenlights* x, t_float fwidth) -{ - if ( fwidth <= 0 ) { - post( "blinkenlights~: wrong width : ignored" ); - return; - } else { - if ( x->x_width == (int)fwidth ) return; - x->x_width=(int)fwidth; - } - if (x->x_ecanvas) blinkenlights_erase( x ); - blinkenlights_draw_new( x ); -} - -static void blinkenlights_height(t_blinkenlights* x, t_float fheight) -{ - if ( fheight <= 0 ) { - post( "blinkenlights~: wrong height : ignored" ); - return; - } else { - if ( x->x_height == (int)fheight ) return; - x->x_height=(int)fheight; - } - if (x->x_ecanvas) blinkenlights_erase( x ); - blinkenlights_draw_new( x ); -} - -static void blinkenlights_xsize(t_blinkenlights* x, t_float fxsize) -{ - if ( fxsize <= 0 ) { - post( "blinkenlights~: wrong x pixel size : ignored" ); - return; - } else { - if ( x->x_xsize == (int)fxsize ) return; - x->x_xsize=(int)fxsize; - } - if (x->x_ecanvas) blinkenlights_erase( x ); - blinkenlights_draw_new( x ); -} - -static void blinkenlights_ysize(t_blinkenlights* x, t_float fysize) -{ - if ( fysize <= 0 ) { - post( "blinkenlights~: wrong y pixel size : ignored" ); - return; - } else { - if ( x->x_ysize == (int)fysize ) return; - x->x_ysize=(int)fysize; - } - if (x->x_ecanvas) blinkenlights_erase( x ); - blinkenlights_draw_new( x ); -} - -static void blinkenlights_background(t_blinkenlights* x, t_float fR, t_float fG, t_float fB) -{ - if ( fR <0 || fR>255 ) - { - post("blinkenlights : wrong color component : fR : %d", fR); - return; - } - if ( fG <0 || fG>255 ) - { - post("blinkenlights : wrong color component : fG : %d", fG); - return; - } - if ( fB <0 || fB>255 ) - { - post("blinkenlights : wrong color component : fB : %d", fB); - return; - } - sprintf( x->x_background, "#%.2x%.2x%.2x", (int)fR, (int)fG, (int)fB ); - post("blinkenlights : background color set to : %s", x->x_background ); -} - -static void blinkenlights_foreground(t_blinkenlights* x, t_float fR, t_float fG, t_float fB) -{ - if ( fR <0 || fR>255 ) - { - post("blinkenlights : wrong color component : fR : %d", fR); - return; - } - if ( fG <0 || fG>255 ) - { - post("blinkenlights : wrong color component : fG : %d", fG); - return; - } - if ( fB <0 || fB>255 ) - { - post("blinkenlights : wrong color component : fB : %d", fB); - return; - } - sprintf( x->x_foreground, "#%.2x%.2x%.2x", (int)fR, (int)fG, (int)fB ); - post("blinkenlights : foreground color set to : %s", x->x_foreground ); -} - -static void blinkenlights_pixon(t_blinkenlights* x, t_float fX, t_float fY) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : pixon : canvas does not exist" ); - return; - } - if ( fX<1 || fX>x->x_width ) - { - post("blinkenlights : pixon : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); - return; - } - if ( fY<1 || fY>x->x_height ) - { - post("blinkenlights : pixon : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); - return; - } - SYS_VGUI6(".x%x.c itemconfigure %xPIX%.5d%.5d -fill %s\n", x, x, (int)fX, (int)fY, x->x_foreground ); -} - -static void blinkenlights_pixoff(t_blinkenlights* x, t_float fX, t_float fY) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : pixoff : canvas does not exist" ); - return; - } - if ( fX<1 || fX>x->x_width ) - { - post("blinkenlights : pixoff : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); - return; - } - if ( fY<1 || fY>x->x_height ) - { - post("blinkenlights : pixoff : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); - return; - } - SYS_VGUI6(".x%x.c itemconfigure %xPIX%.5d%.5d -fill %s\n", x, x, (int)fX, (int)fY, x->x_background ); -} - -static void blinkenlights_pixel(t_blinkenlights* x, t_float fX, t_float fY, t_float fR, t_float fG, t_float fB) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : pixel : canvas does not exist" ); - return; - } - if ( fX<1 || fX>x->x_width ) - { - post("blinkenlights : pixel : wrong x coordinate : %d : should be in [1,%d]", (int)fX, x->x_width ); - return; - } - if ( fY<1 || fY>x->x_height ) - { - post("blinkenlights : pixel : wrong y coordinate : %d : should be in [1,%d]", (int)fY, x->x_height ); - return; - } - if ( fR <0 || fR>255 ) - { - post("blinkenlights : pixel : wrong color component : fR : %d", fR); - return; - } - if ( fG <0 || fG>255 ) - { - post("blinkenlights : pixel : wrong color component : fG : %d", fG); - return; - } - if ( fB <0 || fB>255 ) - { - post("blinkenlights : pixel : wrong color component : fB : %d", fB); - return; - } - SYS_VGUI8(".x%x.c itemconfigure %xPIX%.5d%.5d -fill #%.2X%.2X%.2X\n", x, x, (int)fX, (int)fY, (int)fR, (int)fG, (int)fB ); -} - -static void blinkenlights_clear(t_blinkenlights* x) -{ - t_int xi, yi; - - for ( xi=1; xi<=x->x_width; xi++ ) - { - for ( yi=1; yi<=x->x_height; yi++ ) - { - blinkenlights_pixoff( x, xi, yi ); - } - } -} - - /* close the current movie */ -static void blinkenlights_close(t_blinkenlights *x) -{ - /* closing previous file descriptor */ - if ( x->x_filed != NULL ) { - if(fclose(x->x_filed) < 0) - { - perror( "blinkenlights : closing file" ); - } - x->x_filed = NULL; - } - if ( x->x_frame ) - { - freebytes( x->x_frame, x->x_width*x->x_height*sizeof(t_int) ); - x->x_frame = NULL; - } -} - - /* read the next frame */ -static void blinkenlights_readframe(t_blinkenlights *x) -{ - char *lineread = (char*) getbytes( BL_MAX_LENGTH ); - t_int flineno = 0; - t_int width, height, nwidth; - - //post( "blinkenlights: being readframe:>%s<", lineread ); - - if ( !x->x_ecanvas ) - { - post("blinkenlights : next : canvas does not exist" ); - return; - } - - if ( x->x_filed == NULL ) - { - post( "blinkenlights : no file is opened for reading a frame" ); - blinkenlights_close(x); - return; - } - - // skip header and empty lines - while ( lineread[0] == '#' || lineread[0] == '\n' || lineread[0] == '\0' ) - { - - //post( "blinkenlights : skipped line : >%s<", lineread ); - if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == 0 ) - { - post( "blinkenlights : end of file detected : looping..." ); - fseek( x->x_filed, 0L, SEEK_SET ); - outlet_bang(x->outlet_bang); - } - } - - if ( lineread[0] != '@' ) - { - post( "blinkenlights : format error : should find a time lime here : @XXX : got : >%s<", lineread ); - blinkenlights_close(x); - return; - } - else - { - x->x_timer = atoi( lineread+1 ); - // post( "blinkenlights : setting timer to %d", x->x_timer ); - } - - // read the contents of one frame - - // when reading first frame the height and width are read from the file - height = 0; - width = 0; - while ( 1 ) - { - - if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == NULL ) - { - post( "blinkenlights : EOF not expected here !!! "); - blinkenlights_close(x); - return; - } - else - { - if ( (lineread[0] == '\0') || (lineread[0] == '#') || (lineread[0] == '\n') ) break; - // post( "blinkenlights : lineread : %s", lineread ); - - nwidth = strlen( lineread )-1; // because of the carriage return - flineno++; - height = flineno; - if ( ( nwidth != width ) && ( width != 0 ) ) - { - post( "blinkenlights : weird file : width has changed (nwidth=%d) (width=%d)", nwidth, width ); - blinkenlights_close( x ); - return; - } - width = nwidth; - if ( x->x_frame != NULL ) - { - t_int pint = 0; - t_int newvalue; - - while ( pint < width ) - { - newvalue = (int) *(lineread+pint) - 48 /* ascii value for '0' */; - if ( newvalue != *(x->x_frame+(flineno-1)*x->x_width+pint ) ) - { - *(x->x_frame+(flineno-1)*x->x_width+pint ) = newvalue; - switch ( newvalue ) - { - case 0: - // post( "pixoff %d %d", pint+1, flineno ); - blinkenlights_pixoff( x, pint+1, flineno ); - break; - case 1: - // post( "pixon %d %d", pint+1, flineno ); - blinkenlights_pixon( x, pint+1, flineno ); - break; - default: - // post("blinkenlights : wrong value found for pixel : %d (c=%c)", newvalue, *(lineread+pint) ); - break; - } - } - pint++; - } - } - if ( x->x_frame == NULL ) x->x_height++; - } - } - if ( x->x_frame == NULL ) - { - if ( x->x_filed != NULL ) if ( fseek(x->x_filed, 0L, SEEK_SET) < 0 ) - { - post( "blinkenlights : could not rewind file" ); - blinkenlights_close( x ); - return; - } - blinkenlights_width(x, width); - blinkenlights_height(x, height); - x->x_frame = ( t_int* ) getbytes( x->x_width*x->x_height*sizeof(t_int) ); - blinkenlights_readframe(x); - } - - if ( lineread ) freebytes( lineread, BL_MAX_LENGTH ); -} -//------------------------------------------------------------------------- -//--chun's functions begin here... -//------------------------------------------------------------------------- -/* remember all the frame positions */ -static void blinkenlights_findframes(t_blinkenlights *x) -{ - int i =0; - - x->frame_no = 0; - - for(i=0;;i++) - { - char *lineread = (char*) getbytes( BL_MAX_LENGTH ); - - fgets( lineread, BL_MAX_LENGTH, x->x_filed ); - if(strlen(lineread) == 0) break; - - if(lineread[0] == '@') - { - x->frame_pos[x->frame_no] = ftell(x->x_filed); - x->frame_no++; - } - if (lineread) freebytes( lineread, BL_MAX_LENGTH ); - } - fseek( x->x_filed, 0L, SEEK_SET ); - post("the end:: %d frames!", x->frame_no); -} - -//------------------------------------------------------------------------- -static void blinkenlights_goto(t_blinkenlights* x) -{ - //char *lineread = (char*) getbytes( BL_MAX_LENGTH ); - char lineread[BL_MAX_LENGTH]; - int current_frame = x->frame_pos[(int)(x->frame_inc * (x->frame_no-1))]; - int i, n, width, newvalue, height, nwidth; - - t_int flineno = 0; - - fseek(x->x_filed, current_frame, SEEK_SET); - - height = 0; - width = 0; - while ( 1 ) - { - - if ( fgets( lineread, BL_MAX_LENGTH, x->x_filed ) == NULL ) - { - post( "blinkenlights : EOF not expected here !!! "); - blinkenlights_close(x); - return; - } - else - { - if ( (lineread[0] == '\0') || (lineread[0] == '#') || (lineread[0] == '\n') ) break; - // post( "blinkenlights : lineread : %s", lineread ); - - nwidth = strlen( lineread )-1; // because of the carriage return - flineno++; - height = flineno; - if ( ( nwidth != width ) && ( width != 0 ) ) - { - post( "blinkenlights : weird file : width has changed (nwidth=%d) (width=%d)", nwidth, width ); - blinkenlights_close( x ); - return; - } - width = nwidth; - if ( x->x_frame != NULL ) - { - t_int pint = 0; - t_int newvalue; - - while ( pint < width ) - { - newvalue = (int) *(lineread+pint) - 48 /* ascii value for '0' */; - if ( newvalue != *(x->x_frame+(flineno-1)*x->x_width+pint ) ) - { - *(x->x_frame+(flineno-1)*x->x_width+pint ) = newvalue; - switch ( newvalue ) - { - case 0: - // post( "pixoff %d %d", pint+1, flineno ); - blinkenlights_pixoff( x, pint+1, flineno ); - break; - case 1: - // post( "pixon %d %d", pint+1, flineno ); - blinkenlights_pixon( x, pint+1, flineno ); - break; - default: - // post("blinkenlights : wrong value found for pixel : %d (c=%c)", newvalue, *(lineread+pint) ); - break; - } - } - pint++; - } - } - if ( x->x_frame == NULL ) x->x_height++; - } - } - if ( x->x_frame == NULL ) - { - if ( x->x_filed != NULL ) if ( fseek(x->x_filed, 0L, SEEK_SET) < 0 ) - { - post( "blinkenlights : could not rewind file" ); - blinkenlights_close( x ); - return; - } - blinkenlights_width(x, width); - blinkenlights_height(x, height); - x->x_frame = ( t_int* ) getbytes( x->x_width*x->x_height*sizeof(t_int) ); - blinkenlights_readframe(x); - } - -} - -static void blinkenlights_frame_pos(t_blinkenlights* x, t_float pos) -{ - if(pos > 1 | pos < 0) post ("dude, don't be crazy!"); - else x->frame_inc = pos;; - //post("frame %d", x->frame_inc); -} - -static void blinkenlights_timer2(t_blinkenlights* x, t_float timer) -{ - x->x_timer2 = timer; - //post("frame %d", x->frame_inc); -} - - /* open movie */ -static void blinkenlights_open(t_blinkenlights *x, t_symbol *sfile) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : open : canvas does not exist" ); - return; - } - - //---------------------------------- - /* closing previous file descriptor */ - if ( x->x_filed != NULL ) { - if(fclose(x->x_filed) < 0) - { - perror( "blinkenlights : closing file" ); - } - x->x_filed = NULL; - } - if ( x->x_frame ) - { - blinkenlights_clear(x); - } - - //-------------------------------- - - if ( ( x->x_filed = fopen( sfile->s_name, "r" ) ) == NULL ) - { - error( "blinkenlights : cannot open >%s<", sfile->s_name); - return; - } - post( "blinkenlights : opened >%s<", sfile->s_name); - // don't read the first frame when open.. - //blinkenlights_readframe(x); - blinkenlights_findframes(x); -} - - /* play frames */ -static void blinkenlights_playframes(t_blinkenlights *x) -{ - blinkenlights_readframe( x ); - clock_delay( x->x_clock, (double)x->x_timer ); -} - -/* play frames2 */ -static void blinkenlights_playframes2(t_blinkenlights *x) -{ - blinkenlights_goto(x); - clock_delay( x->x_clock2, (double)x->x_timer2 ); -} - - /* play movie */ -static void blinkenlights_play(t_blinkenlights *x) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : play : canvas does not exist" ); - return; - } - - if ( x->x_filed == NULL ) - { - post( "blinkenlights : no file is opened for playing" ); - blinkenlights_close(x); - return; - } - - if ( x->x_clock == NULL ) x->x_clock = clock_new( x, (t_method)blinkenlights_playframes); - clock_delay( x->x_clock, (double)x->x_timer ); -} - - /* vj movie */ -static void blinkenlights_vj(t_blinkenlights *x, t_float start_vj) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : play : canvas does not exist" ); - return; - } - - if ( x->x_filed == NULL ) - { - post( "blinkenlights : no file is opened for playing" ); - blinkenlights_close(x); - return; - } - - if(start_vj) - { - if ( x->x_clock2 == NULL ) x->x_clock2 = clock_new( x, (t_method)blinkenlights_playframes2); - clock_delay( x->x_clock2, (double)x->x_timer2 ); - } - else - { - clock_unset( x->x_clock2 ); - } -} - - /* stop movie */ -static void blinkenlights_stop(t_blinkenlights *x) -{ - if ( !x->x_ecanvas ) - { - post("blinkenlights : play : canvas does not exist" ); - return; - } - - if ( x->x_filed == NULL ) - { - post( "blinkenlights : no file is opened for playing" ); - blinkenlights_close(x); - return; - } - - if ( x->x_clock != NULL ) - { - clock_unset( x->x_clock ); - } -} - - /* jump to next frame */ -static void blinkenlights_next(t_blinkenlights *x) -{ - blinkenlights_readframe(x); -} - -void blinkenlights_setup(void) -{ - post(blinkenlights_version); - blinkenlights_class = class_new(gensym("blinkenlights"), (t_newmethod)blinkenlights_new, - (t_method)blinkenlights_free, - sizeof(t_blinkenlights), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_width, gensym("width"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_height, gensym("height"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_xsize, gensym("xsize"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_ysize, gensym("ysize"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_open, gensym("open"), A_SYMBOL, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_create, gensym("create"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_destroy, gensym("destroy"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_next, gensym("next"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_play, gensym("play"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_stop, gensym("stop"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_frame_pos, gensym("goto"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_vj, gensym("vj"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_timer2, gensym("timer2"), A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_background, gensym("background"), A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_foreground, gensym("foreground"), A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_destroy, gensym("destroy"), 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixon, gensym("pixon"), A_FLOAT, A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixoff, gensym("pixoff"), A_FLOAT, A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_pixel, gensym("pixel"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod( blinkenlights_class, (t_method)blinkenlights_clear, gensym("clear"), 0); -} diff --git a/externals/unauthorized/blinkenlights/blm/get-blms b/externals/unauthorized/blinkenlights/blm/get-blms old mode 100755 new mode 100644 diff --git a/externals/unauthorized/compressor~/compressor~-help.pd b/externals/unauthorized/compressor~-help.pd similarity index 100% rename from externals/unauthorized/compressor~/compressor~-help.pd rename to externals/unauthorized/compressor~-help.pd diff --git a/externals/unauthorized/compressor~/compressor~.c b/externals/unauthorized/compressor~.c similarity index 91% rename from externals/unauthorized/compressor~/compressor~.c rename to externals/unauthorized/compressor~.c index b8462d2d51c4e70f075fe5da831ed481f8cd34a4..2b776e4258d4bc09efeff6e9793287ebc30fe248 100644 --- a/externals/unauthorized/compressor~/compressor~.c +++ b/externals/unauthorized/compressor~.c @@ -47,17 +47,17 @@ static t_class *compressor_class; static void compressor_strength(t_compressor *x, t_floatarg fstrength ) { - if (fstrength < -1.0) + if (fstrength < -1.0) { - x->x_strength = -1.0; + x->x_strength = -1.0; } - else if (fstrength > 5) + else if (fstrength > 5) { - x->x_strength = 5; + x->x_strength = 5; } else { - x->x_strength = fstrength; + x->x_strength = fstrength; } x->x_pifactor = pow( M_PI, x->x_strength ); } @@ -81,9 +81,11 @@ static t_int *compressor_perform(t_int *w) t_float isample_fact = x->x_pifactor; t_float osample_fact = 2.0 / M_PI; - while (n--) { - *out = atan (*in * isample_fact) * osample_fact; - out++; in++; + while (n--) + { + *out = atan (*in * isample_fact) * osample_fact; + out++; + in++; } return (w+5); } @@ -95,9 +97,9 @@ static void compressor_dsp(t_compressor *x, t_signal **sp) void compressor_tilde_setup(void) { - post( compressor_version ); + logpost(NULL, 4, "%s", compressor_version ); compressor_class = class_new(gensym("compressor~"), (t_newmethod)compressor_new, 0, - sizeof(t_compressor), 0, 0); + sizeof(t_compressor), 0, 0); CLASS_MAINSIGNALIN( compressor_class, t_compressor, x_f ); class_addmethod(compressor_class, (t_method)compressor_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(compressor_class, (t_method)compressor_strength, gensym("strength"), A_FLOAT, 0); diff --git a/externals/unauthorized/compressor~/INSTALL b/externals/unauthorized/compressor~/INSTALL deleted file mode 100644 index 8139fba0996882a4d9ad7f36f5f381b18f83a6ad..0000000000000000000000000000000000000000 --- a/externals/unauthorized/compressor~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/compressor~ - -make clean - -make - -make install - -open help-compressor~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/compressor~/Makefile b/externals/unauthorized/compressor~/Makefile deleted file mode 100644 index 572abe7978aa13f9262db69b098d049b7a023bea..0000000000000000000000000000000000000000 --- a/externals/unauthorized/compressor~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=compressor~ -CSYM=compressor~ - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/compressor~/README b/externals/unauthorized/compressor~/README deleted file mode 100644 index 401ee0f1f945f4b0c764508d440c0415e61b6e05..0000000000000000000000000000000000000000 --- a/externals/unauthorized/compressor~/README +++ /dev/null @@ -1,19 +0,0 @@ -Version 0.01 -copyright 2002 by Yves Degoyon. - -tarballs and updates available @ http://ydegoyon.free.fr - -compressor~ : a compressor of audio signals - -To install compressor~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - diff --git a/externals/unauthorized/cooled~/cooled~-help.pd b/externals/unauthorized/cooled~-help.pd similarity index 100% rename from externals/unauthorized/cooled~/cooled~-help.pd rename to externals/unauthorized/cooled~-help.pd diff --git a/externals/unauthorized/cooled~.c b/externals/unauthorized/cooled~.c new file mode 100644 index 0000000000000000000000000000000000000000..0d346346008834ecf935680468df7eb4d159dd92 --- /dev/null +++ b/externals/unauthorized/cooled~.c @@ -0,0 +1,1491 @@ +/*------------------------ cooled~ -------------------------------------------- */ +/* */ +/* cooled~ : display sound, play parts and modify it with cut and paste */ +/* constructor : cooled~ | cooled~ */ +/* */ +/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* "I am the fly in the ointment" -- Wire + 154 */ +/* Komet -- Instrumentals */ +/* ---------------------------------------------------------------------------- */ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __APPLE__ +# include +#else +# include +#endif + +#ifdef _WIN32 +# define M_PI 3.14159265358979323846 +# include +#endif + +#ifndef _MSC_VER +# include +#endif + +#include "m_pd.h" +#include "m_imp.h" +#include "g_canvas.h" + + +static int guidebug=0; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ + post(a,b,c,d,e,f);\ + sys_vgui(a,b,c,d,e,f) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g );\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ + post(a,b,c,d,e,f,g,h );\ + sys_vgui(a,b,c,d,e,f,g,h) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i );\ + sys_vgui(a,b,c,d,e,f,g,h,i) + +#define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j );\ + sys_vgui(a,b,c,d,e,f,g,h,i,j) + +#define SYS_VGUI11(a,b,c,d,e,f,g,h,i,j,k) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j,k );\ + sys_vgui(a,b,c,d,e,f,g,h,i,j,k) + +#define THREAD_SLEEP_TIME 10000 // 10000 us = 10 ms +#define COOLED_BGCOLOR "#000000" +#define COOLED_FGCOLOR "#34E112" +#define COOLED_FRCOLOR "#FFFFFF" + +#define COOLED_DEFAULT_SIZE 1024 +#define COOLED_DEFAULT_WIDTH 400 +#define COOLED_DEFAULT_HEIGHT 200 + +static char *cooled_version = "cooled~: version 0.13, written by Yves Degoyon (ydegoyon@free.fr)"; + +static t_class *cooled_class; +t_widgetbehavior cooled_widgetbehavior; + +typedef struct _cooled +{ + t_object x_obj; + + int x_size; /* size of the stored sound */ + t_float x_readpos; /* data's playing position */ + int x_writepos; /* data's recording position */ + t_float x_readstart; /* data's starting position for reading */ + t_float x_readend; /* data's ending position for reading */ + int x_play; /* playing on/off flag */ + t_float x_readspeed; /* speed increment */ + t_float x_record; /* flag to start recording process */ + t_float x_allocate; /* flag to indicate pending allocation */ + t_float x_empty; /* flag to indicate it's a brand new sound */ + t_float *x_rdata; /* table containing right channel samples */ + t_float *x_ldata; /* table containing leftt channel samples */ + t_outlet *x_end; /* outlet for end of restitution */ + t_outlet *x_recend; /* outlet for end of recording */ + t_outlet *x_sampstart; /* outlet for sample number [ start ] when selecting */ + t_outlet *x_sampend; /* outlet for sample number [ end ] when selecting */ + t_float *x_rsemp; /* temporary sample buffer ( right ) */ + t_float *x_lsemp; /* temporary sample buffer ( left ) */ + char* x_gifdata; /* buffer to store graphic data */ + char* x_guicommand; /* buffer to store gui command */ + int x_draw; /* drawing option */ + + /* graphical data block */ + int x_width; /* graphical width */ + int x_height; /* graphical height */ + int x_selected; /* flag to remember if we are seleted or not */ + int x_erase; /* flag used when an erase is needed */ + int x_redraw; /* flag used when drawing is needed */ + t_glist *x_glist; /* keep graphic context for various operations */ + int x_zoom; /* zoom factor */ + pthread_t x_updatechild; /* thread id for the update child */ + int x_updatestart; /* starting position for update */ + int x_updateend; /* ending position for update */ + int x_xpos; /* stuck x position */ + int x_ypos; /* stuck y position */ + int x_shifted; /* remember shift state from last click */ + int x_alted; /* remember alt state from last click */ + int x_xdraw; /* x drawing position */ + int x_edraw; /* end of drawing */ + + t_float x_f; /* float needed for signal input */ + +} t_cooled; + +/* ------------------------ drawing functions ---------------------------- */ + +static void cooled_update_block(t_cooled *x, t_glist *glist, int bnumber) +{ + int hi, i=0; + t_float fspectrum=0.0; + int phase=0; + char color[8]; + + memset( x->x_gifdata, 0x0, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + + // update cooled~ + for ( hi=x->x_height-1; hi>=0; hi-- ) + { + if ( ( hi == x->x_height/4) || ( hi == 3*x->x_height/4) ) + { + sprintf( color, "%s ", COOLED_FGCOLOR ); + } + else if ( hi == x->x_height/2) + { + sprintf( color, "%s ", COOLED_FRCOLOR ); + } + else + { + sprintf( color, "%s ", COOLED_BGCOLOR ); + } + for ( i=0; ix_zoom; i++ ) + { + strncpy( x->x_gifdata+(hi*x->x_zoom+i)*8, color, 8 ); + } + } + + // set all points + { + int fsamp = ( bnumber * x->x_size ) / x->x_width; + int lsamp = ( ( bnumber+1) * x->x_size ) / x->x_width; + int si; + + // post ( "cooled~ : updating samples [%d,%d]", fsamp, lsamp ); + + for ( si=fsamp; six_height/4 + ( *(x->x_rdata+si) * (x->x_height/4) ) - 1; + + if ( rind > x->x_height - 1 ) rind = x->x_height - 1; + if ( rind < x->x_height/2 ) rind = x->x_height/2; + + sprintf( color, "%s ", COOLED_FGCOLOR ); + for ( i=0; ix_zoom; i++ ) + { + strncpy( x->x_gifdata+(rind*x->x_zoom+i)*8, color, 8 ); + } + } + + // calculate left channel index + { + int lind = x->x_height/4 + ( *(x->x_ldata+si) * (x->x_height/4) ) - 1; + + if ( lind > x->x_height/2 - 1 ) lind = x->x_height/2 - 1; + if ( lind < 0 ) lind = 0; + + sprintf( color, "%s ", COOLED_FGCOLOR ); + for ( i=0; ix_zoom; i++ ) + { + strncpy( x->x_gifdata+(lind*x->x_zoom+i)*8, color, 8 ); + } + } + } + } + + for ( i=0; ix_zoom; i++ ) + { + sprintf( x->x_guicommand, "COOLEDIMAGE%lx put {%s} -to %d 0\n", (long unsigned int)x, x->x_gifdata, (bnumber*x->x_zoom)+i ); + if ( glist_isvisible( x->x_glist ) ) + sys_gui( x->x_guicommand ); + } + +} + +static void cooled_erase_block(t_cooled *x, t_glist *glist, int sample ) +{ + t_canvas *canvas=glist_getcanvas(glist); + int hi; + t_float fspectrum=0.0; + char fillColor[ 16 ]; + + for ( hi=0; hix_height; hi++) + { + { + int i; + + for ( i=0; ix_zoom; i++ ) + { + strcpy( x->x_gifdata+i*sizeof("#FFFFFF "), strcat( COOLED_BGCOLOR, " ") ); + } + if ( glist_isvisible( x->x_glist ) ) + SYS_VGUI5("COOLEDIMAGE%x put {%s} -to %d %d\n", x, x->x_gifdata, + sample*x->x_zoom, (x->x_height-hi)*x->x_zoom ); + } + } +} + +static void *cooled_do_update_part(void *tdata) +{ + t_cooled *x = (t_cooled*) tdata; + t_canvas *canvas=glist_getcanvas(x->x_glist); + int si; + int nbpoints = 0; + t_float percentage = 0, opercentage = 0; + + // loose synchro + usleep( THREAD_SLEEP_TIME ); + + // check bounds + if ( x->x_updateend > x->x_size-1 ) x->x_updateend = x->x_size-1; + if ( x->x_updatestart < 0 ) x->x_updatestart = 0; + + post("cooled~ : ok, let's go [updating %d, %d]", x->x_updatestart, x->x_updateend ); + + if ( x->x_erase ) + { + for ( si=x->x_updatestart; si<=x->x_updateend; si++ ) + { + cooled_erase_block(x, x->x_glist, si); + nbpoints++; + percentage = (nbpoints*100/(x->x_updateend-x->x_updatestart+1)); + if ( (percentage == (int) percentage) && ((int)percentage%5 == 0) && ( percentage != opercentage ) ) + { + // post( "cooled~ : erase part : %d %% completed", (int)percentage ); + opercentage = percentage; + } + } + } + + percentage = opercentage = nbpoints = 0; + + if ( x->x_redraw ) + { + for ( si=x->x_updatestart; si<=x->x_updateend; si++ ) + { + cooled_update_block(x, x->x_glist, si); + nbpoints++; + percentage = (nbpoints*100/(x->x_updateend-x->x_updatestart+1)); + if ( (percentage == (int) percentage) && ((int)percentage%5 == 0) && ( percentage != opercentage ) ) + { + // post( "cooled~ : update part : %d %% completed", (int)percentage ); + opercentage = percentage; + } + } + } + + if ( glist_isvisible( x->x_glist ) ) + { + SYS_VGUI3( ".x%lx.c delete rectangle %xCLIPZONE\n", + canvas, x); + if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) + { + SYS_VGUI7( ".x%lx.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", + canvas, x->x_xpos+(int)(x->x_readstart*(x->x_width)/100 ), + x->x_ypos, x->x_xpos+(int)(x->x_readend*(x->x_width)/100 ), + x->x_ypos+x->x_height*x->x_zoom, x ); + } + // set borders in black + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLED -outline #000000\n", canvas, x); + } + +#ifndef _WIN32 + post("cooled~ : child thread %d ended", (int)x->x_updatechild ); + x->x_updatechild = 0; +#endif + return NULL; +} + +static void cooled_update_part(t_cooled *x, t_glist *glist, int bstart, int bend, + int erase, int redraw, int keepframe) +{ + pthread_attr_t update_child_attr; + t_canvas *canvas=glist_getcanvas(x->x_glist); + +#ifndef _WIN32 + if ( x->x_updatechild != 0 ) + { + // post( "cooled~ : error : no update is possible for now" ); + return; + } +#endif + x->x_updatestart = bstart; + x->x_updateend = bend; + if ( !keepframe ) + { + x->x_erase = 0; + } + else + { + x->x_erase = erase; + } + x->x_redraw = redraw; + // recreate the square if needed + if ( glist_isvisible( x->x_glist ) ) + { + if ( ( bstart == 0 ) && ( bend == x->x_width-1 ) && !keepframe ) + { + SYS_VGUI3(".x%lx.c delete %xCOOLEDL\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xCOOLEDR\n", canvas, x ); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDR\n", + canvas, x->x_xpos, x->x_ypos, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height/2*x->x_zoom, + x); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDL\n", + canvas, x->x_xpos, + x->x_ypos + x->x_height/2*x->x_zoom, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height*x->x_zoom, + x); + SYS_VGUI2("image delete COOLEDIMAGE%x\n", x ); + SYS_VGUI3(".x%lx.c delete ICOOLEDIMAGE%x\n", canvas, x ); + SYS_VGUI4("image create photo COOLEDIMAGE%x -format gif -width %d -height %d\n", + x, x->x_width*x->x_zoom, x->x_height*x->x_zoom ); + SYS_VGUI2("COOLEDIMAGE%x blank\n", x ); + SYS_VGUI6(".x%lx.c create image %d %d -image COOLEDIMAGE%x -tags ICOOLEDIMAGE%x\n", + canvas, + x->x_xpos+(x->x_width*x->x_zoom)/2, + x->x_ypos+(x->x_height*x->x_zoom)/2, x, x ); + canvas_fixlinesfor( canvas, (t_text*)x ); + } + // set borders in red + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLED -outline #FF0000\n", canvas, x); + } + + // launch update thread + if ( pthread_attr_init( &update_child_attr ) < 0 ) + { + post( "cooled~ : could not launch update thread" ); + perror( "pthread_attr_init" ); + return; + } + if ( pthread_attr_setdetachstate( &update_child_attr, PTHREAD_CREATE_DETACHED ) < 0 ) + { + post( "cooled~ : could not launch update thread" ); + perror( "pthread_attr_setdetachstate" ); + return; + } + if ( pthread_create( &x->x_updatechild, &update_child_attr, cooled_do_update_part, x ) < 0 ) + { + post( "cooled~ : could not launch update thread" ); + perror( "pthread_create" ); + return; + } + else + { + // post( "cooled~ : drawing thread %d launched", (int)x->x_updatechild ); + } +} + +static void cooled_draw_new(t_cooled *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + x->x_xpos=text_xpix(&x->x_obj, glist); + x->x_ypos=text_ypix(&x->x_obj, glist); + x->x_xdraw=text_xpix(&x->x_obj, glist); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDR\n", + canvas, x->x_xpos, x->x_ypos, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height/2*x->x_zoom, + x); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDL\n", + canvas, x->x_xpos, + x->x_ypos + x->x_height/2*x->x_zoom, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height*x->x_zoom, + x); + SYS_VGUI4("image create photo COOLEDIMAGE%x -format gif -width %d -height %d\n", + x, x->x_width*x->x_zoom, x->x_height*x->x_zoom ); + SYS_VGUI2("COOLEDIMAGE%x blank\n", x ); + SYS_VGUI6(".x%lx.c create image %d %d -image COOLEDIMAGE%x -tags ICOOLEDIMAGE%x\n", + canvas, + x->x_xpos+(x->x_width*x->x_zoom)/2, + x->x_ypos+(x->x_height*x->x_zoom)/2, x, x ); + if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 0); + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void cooled_draw_delete(t_cooled *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if ( glist_isvisible( glist ) ) + { + SYS_VGUI3( ".x%lx.c delete %xCAPTURE\n", canvas, x ); + if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) + { + SYS_VGUI3( ".x%lx.c delete rectangle %xCLIPZONE\n", canvas, x); + } + SYS_VGUI3( ".x%lx.c delete line %xINSERTHERE\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xCOOLEDR\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xCOOLEDL\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete ICOOLEDIMAGE%x\n", canvas, x ); + SYS_VGUI2("image delete COOLEDIMAGE%x\n", x ); + } +} + +static void cooled_draw_move(t_cooled *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if ( glist_isvisible( x->x_glist ) ) + { + SYS_VGUI7(".x%lx.c coords %xCOOLEDR %d %d %d %d\n", + canvas, x, + x->x_xpos, x->x_ypos, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height/2*x->x_zoom); + SYS_VGUI7(".x%lx.c coords %xCOOLEDL %d %d %d %d\n", + canvas, x, + x->x_xpos, + x->x_ypos + x->x_height/2*x->x_zoom, + x->x_xpos + x->x_width*x->x_zoom, + x->x_ypos + x->x_height*x->x_zoom ); + if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) + { + SYS_VGUI7(".x%lx.c coords %xCLIPZONE %d %d %d %d\n", + canvas, x, + x->x_xpos+(int)(x->x_readstart*(x->x_width)/100*x->x_zoom ), + x->x_ypos, + x->x_xpos+(int)(x->x_readend*(x->x_width)/100*x->x_zoom ), + x->x_ypos+x->x_height*x->x_zoom ); + } + SYS_VGUI7(".x%lx.c coords %xINSERTHERE %d %d %d %d\n", + canvas, x, + x->x_xdraw, + x->x_ypos, + x->x_xdraw, + x->x_ypos+x->x_height*x->x_zoom ); + SYS_VGUI5(".x%lx.c coords ICOOLEDIMAGE%x %d %d\n", + canvas, x, + x->x_xpos+((x->x_width*x->x_zoom)/2), + (x->x_ypos+((x->x_height*x->x_zoom)/2)) ); + canvas_fixlinesfor( canvas, (t_text*)x ); + } +} + +static void cooled_draw_select(t_cooled* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if ( glist_isvisible( x->x_glist ) ) + { + if(x->x_selected) + { + /* sets the item in blue */ + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLEDR -outline #0000FF\n", canvas, x); + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLEDL -outline #0000FF\n", canvas, x); + } + else + { + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLEDR -outline #000000\n", canvas, x); + SYS_VGUI3(".x%lx.c itemconfigure %xCOOLEDL -outline #000000\n", canvas, x); + } + } +} + +/* ------------------------ widget callbacks ----------------------------- */ + + +/* setting the starting point for reading ( in percent ) */ +static void cooled_readstart(t_cooled *x, t_floatarg fstart) +{ + t_float startpoint = fstart; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if (startpoint < 0) startpoint = 0; + if (startpoint > 100) startpoint = 100; + x->x_readstart = startpoint; + // set readspeed sign + if ( ( x->x_readstart > x->x_readend ) && ( x->x_readspeed > 0 ) ) x->x_readspeed = -x->x_readspeed; + if ( ( x->x_readstart < x->x_readend ) && ( x->x_readspeed < 0 ) ) x->x_readspeed = -x->x_readspeed; + if ( glist_isvisible( x->x_glist ) ) + { + SYS_VGUI3( ".x%lx.c delete rectangle %xCLIPZONE\n", + canvas, x); + if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) + { + SYS_VGUI7( ".x%lx.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", + canvas, x->x_xpos+(int)(x->x_readstart*x->x_width*x->x_zoom/100 ), + x->x_ypos, x->x_xpos+(int)(x->x_readend*x->x_width*x->x_zoom/100 ), + x->x_ypos+x->x_height*x->x_zoom, x ); + } + } + outlet_float( x->x_sampstart, (x->x_readstart*x->x_size)/100 ); +} + +/* setting the ending point for reading ( in percent ) */ +static void cooled_readend(t_cooled *x, t_floatarg fend) +{ + t_float endpoint = fend; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if (endpoint < 0) endpoint = 0; + if (endpoint > 100) endpoint = 100; + x->x_readend = endpoint; + // set readspeed sign + if ( ( x->x_readstart > x->x_readend ) && ( x->x_readspeed > 0 ) ) x->x_readspeed = -x->x_readspeed; + if ( ( x->x_readstart < x->x_readend ) && ( x->x_readspeed < 0 ) ) x->x_readspeed = -x->x_readspeed; + if ( glist_isvisible( x->x_glist ) ) + { + SYS_VGUI3( ".x%lx.c delete rectangle %xCLIPZONE\n", + canvas, x); + if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) + { + SYS_VGUI7( ".x%lx.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", + canvas, + x->x_xpos+(int)(x->x_readstart*x->x_width*x->x_zoom/100 ), + x->x_ypos, x->x_xpos+(int)(x->x_readend*x->x_width*x->x_zoom/100 ), + x->x_ypos+x->x_height*x->x_zoom, x ); + } + } + outlet_float( x->x_sampend, (x->x_readend*x->x_size)/100 ); +} + +static void cooled_getrect(t_gobj *z, t_glist *owner, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_cooled* x = (t_cooled*)z; + + *xp1 = x->x_xpos; + *yp1 = x->x_ypos; + *xp2 = x->x_xpos+x->x_width*x->x_zoom; + *yp2 = x->x_ypos+x->x_height*x->x_zoom+1; +} + +static void cooled_save(t_gobj *z, t_binbuf *b) +{ + t_cooled *x = (t_cooled *)z; + + binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"), + (int)x->x_obj.te_xpix, (int)x->x_obj.te_ypix, + atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), + x->x_size, x->x_width, x->x_height, x->x_draw ); + binbuf_addv(b, ";"); +} + +static void cooled_select(t_gobj *z, t_glist *glist, int selected) +{ + t_cooled *x = (t_cooled *)z; + + x->x_selected = selected; + cooled_draw_select( x, glist ); +} + +static void cooled_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_cooled *x = (t_cooled *)z; + t_rtext *y; + + if (vis) + { + cooled_draw_new( x, glist ); + } + else + { + // erase all points + cooled_draw_delete( x, glist ); + } +} + +static void cooled_delete(t_gobj *z, t_glist *glist) +{ + canvas_deletelinesfor(glist, (t_text *)z); +} + +static void cooled_displace(t_gobj *z, t_glist *glist, int dx, int dy) +{ + t_cooled *x = (t_cooled *)z; + int xold = x->x_xpos; + int yold = x->x_ypos; + + x->x_xpos += dx; + x->x_ypos += dy; + + if ( ( x->x_xpos != xold ) || ( x->x_ypos != yold ) ) + { + cooled_draw_move( x, glist ); + } + +} + +static void cooled_motion(t_cooled *x, t_floatarg dx, t_floatarg dy) +{ + // post( "cooled_motion @ [%d,%d] dx=%f dy=%f alt=%d", x->x_xdraw, x->x_ydraw, dx, dy, x->x_alted ); + if ( dx != 0 ) + { + cooled_readstart( x, ((t_float)( x->x_xdraw - x->x_xpos ) * 100 )/ (t_float)( x->x_width * x->x_zoom ) ); + x->x_edraw += dx; + cooled_readend( x, ((t_float)( x->x_edraw - x->x_xpos ) * 100 )/ (t_float)( x->x_width * x->x_zoom ) ); + } +} + +/* erase data form readstart to readend */ +static void cooled_erase( t_cooled *x ) +{ + int startsamp, endsamp, si; + int lreadstart = x->x_readstart, lreadend = x->x_readend; + + if (x->x_allocate) + { + post( "cooled~ : error : cannot erase while re-allocation" ); + return; + } + // post( "cooled~ : erase" ); + if ( lreadstart <= lreadend ) + { + startsamp = (lreadstart*x->x_size)/100; + endsamp = (lreadend*x->x_size)/100; + } + else + { + startsamp = (lreadend*x->x_size)/100; + endsamp = (lreadstart*x->x_size)/100; + } + + for ( si=startsamp; si<=endsamp; si++ ) + { + *(x->x_rdata+si) = 0.; + *(x->x_ldata+si) = 0.; + } + if ( x->x_draw ) cooled_update_part(x, x->x_glist, startsamp*x->x_width/x->x_size, endsamp*(x->x_width-1)/x->x_size, 0, 1, 1); +} +/* paste data form readstart to readend */ +static void cooled_paste( t_cooled *x ) +{ + int startsamp, endsamp, si, inssamp, hlimit, csize; + int lreadstart = x->x_readstart, lreadend = x->x_readend; + + if (x->x_allocate) + { + post( "cooled~ : error : cannot paste while re-allocation" ); + return; + } + if ( lreadstart <= lreadend ) + { + startsamp = (lreadstart*x->x_size)/100; + endsamp = (lreadend*x->x_size)/100; + } + else + { + startsamp = (lreadend*x->x_size)/100; + endsamp = (lreadstart*x->x_size)/100; + } + + // insert data at insertion point + inssamp = ( x->x_xdraw - x->x_xpos) * x->x_size / ( x->x_width * x->x_zoom ); + // post( "cooled~ : replace [%d,%d] to %d", startsamp, endsamp, inssamp ); + csize=endsamp-startsamp; + for ( si=0; si<=csize; si++ ) + { + if ( ( si + inssamp >= x->x_size ) || ( startsamp + si >= x->x_size ) ) break; + *(x->x_rsemp+si) = *(x->x_rdata+startsamp+si); + *(x->x_lsemp+si) = *(x->x_ldata+startsamp+si); + } + hlimit = si; + for ( si=0 ; si<=hlimit; si++ ) + { + *(x->x_rdata+inssamp+si) += *(x->x_rsemp+si); + *(x->x_ldata+inssamp+si) += *(x->x_lsemp+si); + } + + // post( "cooled~ : updating [%d,%d]", inssamp*x->x_width/x->x_size, (inssamp+hlimit)*x->x_width/x->x_size ); + if ( x->x_draw ) cooled_update_part(x, x->x_glist, inssamp*x->x_width/x->x_size, (inssamp+hlimit)*(x->x_width-1)/x->x_size, 0, 1, 1); +} +/* replace data form readstart to readend */ +static void cooled_replace( t_cooled *x ) +{ + int startsamp, endsamp, si, inssamp, hlimit, csize; + int lreadstart = x->x_readstart, lreadend = x->x_readend; + + if (x->x_allocate) + { + post( "cooled~ : error : cannot replace while re-allocation" ); + return; + } + if ( lreadstart <= lreadend ) + { + startsamp = (lreadstart*x->x_size)/100; + endsamp = (lreadend*x->x_size)/100; + } + else + { + startsamp = (lreadend*x->x_size)/100; + endsamp = (lreadstart*x->x_size)/100; + } + + // insert data at insertion point + inssamp = ( x->x_xdraw - x->x_xpos) * x->x_size / ( x->x_width * x->x_zoom ); + // post( "cooled~ : replace [%d,%d] to %d", startsamp, endsamp, inssamp ); + csize=endsamp-startsamp; + for ( si=0; si<=csize; si++ ) + { + if ( ( si + inssamp >= x->x_size ) || ( startsamp + si >= x->x_size ) ) break; + *(x->x_rsemp+si) = *(x->x_rdata+startsamp+si); + *(x->x_lsemp+si) = *(x->x_ldata+startsamp+si); + } + hlimit = si; + for ( si=0 ; si<=hlimit; si++ ) + { + *(x->x_rdata+inssamp+si) = *(x->x_rsemp+si); + *(x->x_ldata+inssamp+si) = *(x->x_lsemp+si); + } + + // post( "cooled~ : updating [%d,%d]", inssamp*x->x_width/x->x_size, (inssamp+hlimit)*x->x_width/x->x_size ); + if ( x->x_draw ) cooled_update_part(x, x->x_glist, inssamp*x->x_width/x->x_size, (inssamp+hlimit)*(x->x_width-1)/x->x_size, 0, 1, 1); + +} + +/* call editor's property dialog */ +static void cooled_properties(t_gobj *z, t_glist *owner) +{ + char buf[800]; + t_cooled *x=(t_cooled *)z; + + sprintf(buf, "pdtk_cooled_dialog %%s %d %d %d\n", + x->x_width, x->x_height, x->x_draw); + // post("cooled_properties : %s", buf ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); +} + +/* handle properties change */ +static void cooled_dialog(t_cooled *x, t_symbol *s, int argc, t_atom *argv) +{ + if ( !x ) + { + post( "cooled~ : error :tried to set properties on an unexisting object" ); + } + if ( argc != 3 ) + { + post( "cooled~ : error in the number of arguments ( %d instead of 3 )", argc ); + return; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || argv[2].a_type != A_FLOAT ) + { + post( "cooled~ : wrong arguments" ); + return; + } + cooled_draw_delete(x, x->x_glist); + if ( x->x_gifdata != NULL ) + { + freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_gifdata = NULL; + } + if ( x->x_guicommand != NULL ) + { + freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_guicommand = NULL; + } + x->x_width = (int)argv[0].a_w.w_float; + if ( x->x_width < 0 ) x->x_width = 100; + x->x_height = (int)argv[1].a_w.w_float; + if ( x->x_height < 0 ) x->x_height = 100; + x->x_draw = (int)argv[2].a_w.w_float; + if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return; + } + else + { + post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + cooled_draw_new(x, x->x_glist); +} + +/* handle clicks */ +static int cooled_click(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_cooled* x = (t_cooled *)z; + int pipos; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + // post( "cooled_click : x=%d y=%d doit=%d alt=%d, shift=%d", xpix, ypix, doit, alt, shift ); + if ( doit ) + { + if ( shift && alt ) + { + cooled_paste(x); + } + else if ( shift ) + { + cooled_replace(x); + } + else if ( alt ) + { + cooled_erase(x); + } + else + { + x->x_xdraw = xpix; + x->x_edraw = xpix; + x->x_shifted = shift; + x->x_alted = alt; + // activate motion callback + glist_grab( glist, &x->x_obj.te_g, (t_glistmotionfn)cooled_motion, + 0, xpix, ypix ); + + // draw insertion line + if ( glist_isvisible( x->x_glist ) ) + { + SYS_VGUI3( ".x%lx.c delete line %xINSERTHERE\n", + canvas, x); + SYS_VGUI7( ".x%lx.c create line %d %d %d %d -fill #00FFFF -tags %xINSERTHERE -width 2\n", + canvas, x->x_xdraw, + x->x_ypos, x->x_xdraw, + x->x_ypos+x->x_height*x->x_zoom, x ); + } + + } + + } + else + { + // nothing + } + return (1); + +} + +/* clean up */ +static void cooled_free(t_cooled *x) +{ + if ( x->x_rdata != NULL ) + { + freebytes(x->x_rdata, x->x_size*sizeof(float) ); + post( "Freed %d bytes", x->x_size*sizeof(float) ); + x->x_rdata = NULL; + } + if ( x->x_ldata != NULL ) + { + freebytes(x->x_ldata, x->x_size*sizeof(float) ); + post( "Freed %d bytes", x->x_size*sizeof(float) ); + x->x_ldata = NULL; + } + if ( x->x_rsemp != NULL ) + { + freebytes(x->x_rsemp, x->x_size*sizeof(float) ); + post( "Freed %d bytes", x->x_size*sizeof(float) ); + x->x_rsemp = NULL; + } + if ( x->x_lsemp != NULL ) + { + freebytes(x->x_lsemp, x->x_size*sizeof(float) ); + post( "Freed %d bytes", x->x_size*sizeof(float) ); + x->x_lsemp = NULL; + } + if ( x->x_gifdata != NULL ) + { + freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_gifdata = NULL; + } + if ( x->x_guicommand != NULL ) + { + freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_guicommand = NULL; + } +} + +/* allocate tables for storing sound and temporary copy */ +static int cooled_allocate(t_cooled *x) +{ + int fi; + + if ( !(x->x_rdata = getbytes( x->x_size*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); + } + if ( !(x->x_ldata = getbytes( x->x_size*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); + } + if ( !(x->x_rsemp = getbytes( x->x_size*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); + } + if ( !(x->x_lsemp = getbytes( x->x_size*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); + } + if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + + return 0; +} + +/* allocate tables for storing sound and temporary copy */ +static int cooled_reallocate(t_cooled *x, int ioldsize, int inewsize) +{ + int fi, csize; + t_float *prdata=x->x_rdata, *pldata=x->x_ldata, *prsemp=x->x_rsemp, *plsemp=x->x_lsemp; + + if ( !(x->x_rdata = getbytes( inewsize*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); + } + if ( !(x->x_ldata = getbytes( inewsize*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); + } + if ( !(x->x_rsemp = getbytes( inewsize*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); + } + if ( !(x->x_lsemp = getbytes( inewsize*sizeof(float) ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return -1; + } + else + { + post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); + } + + if ( ioldsize <= inewsize ) + { + csize = ioldsize; + } + else + { + csize = inewsize; + } + memcpy( x->x_rdata, prdata, csize*sizeof(float) ); + memcpy( x->x_ldata, pldata, csize*sizeof(float) ); + memcpy( x->x_rsemp, prsemp, csize*sizeof(float) ); + memcpy( x->x_lsemp, plsemp, csize*sizeof(float) ); + + if ( prdata != NULL ) + { + freebytes(prdata, ioldsize*sizeof(float) ); + post( "Freed %d bytes", ioldsize*sizeof(float) ); + } + if ( pldata != NULL ) + { + freebytes(pldata, ioldsize*sizeof(float) ); + post( "Freed %d bytes", ioldsize*sizeof(float) ); + } + if ( prsemp != NULL ) + { + freebytes(prsemp, ioldsize*sizeof(float) ); + post( "Freed %d bytes", ioldsize*sizeof(float) ); + } + if ( plsemp != NULL ) + { + freebytes(plsemp, ioldsize*sizeof(float) ); + post( "Freed %d bytes", ioldsize*sizeof(float) ); + } + + return 0; +} + +/* records and playback the sound */ +static t_int *cooled_perform(t_int *w) +{ + t_float *lin = (t_float *)(w[1]); + t_float *rin = (t_float *)(w[2]); + t_float *rout = (t_float *)(w[3]); + t_float *lout = (t_float *)(w[4]); + int is; + int n = (int)(w[5]); /* number of samples */ + int startsamp, endsamp; + t_cooled *x = (t_cooled *)(w[6]); + int lreadstart = x->x_readstart, lreadend = x->x_readend; + + if ( lreadstart <= lreadend ) + { + startsamp = (lreadstart*x->x_size)/100; + endsamp = (lreadend*x->x_size)/100; + } + else + { + startsamp = (lreadend*x->x_size)/100; + endsamp = (lreadstart*x->x_size)/100; + } + + while (n--) + { + // eventually records input + if ( x->x_record ) + { + *(x->x_ldata+x->x_writepos)=*(lin); + *(x->x_rdata+x->x_writepos)=*(rin); + x->x_writepos++; + if ( x->x_writepos >= x->x_size ) + { + x->x_record=0; + x->x_writepos=0; + if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 0); + outlet_bang(x->x_recend); + if ( x->x_empty ) x->x_empty = 0; + // post( "cooled~ : stopped recording" ); + } + } + // set outputs + *rout = 0.0; + *lout = 0.0; + if ( x->x_play) + { + is=0; + *lout = *(x->x_ldata+(int)x->x_readpos); + *rout = *(x->x_rdata+(int)x->x_readpos); + x->x_readpos+=x->x_readspeed; + // post( "xreadpos : %f (added %f) %d", x->x_readpos, x->x_readspeed, x->x_readend ); + if ( ( x->x_readspeed >= 0 ) && ( x->x_readpos >= endsamp ) ) + { + x->x_play=0; + x->x_readpos=(float)(startsamp); + // post( "cooled~ : stopped playing (readpos=%d)", x->x_readpos ); + outlet_bang(x->x_end); + } + if ( ( x->x_readspeed < 0 ) && ( x->x_readpos <= startsamp ) ) + { + x->x_play=0; + x->x_readpos = (float)(endsamp); + // post( "cooled~ : stopped playing (readpos=%d)", x->x_readpos ); + outlet_bang(x->x_end); + } + } + rout++; + lout++; + rin++; + lin++; + } + // post( "cooled~ : read : %f:%d : write: %d:%d", x->x_readpos, x->x_play, x->x_writepos, x->x_record ); + return (w+7); +} + +static void cooled_dsp(t_cooled *x, t_signal **sp) +{ + dsp_add(cooled_perform, 6, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n, x); +} + +/* record the cooled */ +static void cooled_record(t_cooled *x) +{ + if (x->x_allocate) + { + post( "cooled~ : error : cannot record while re-allocation" ); + return; + } + x->x_record=1; + x->x_writepos=0; + post( "cooled~ : recording on" ); +} + +/* map to stereo */ +static void cooled_stereo(t_cooled *x) +{ + int si; + + if (x->x_allocate) + { + post( "cooled~ : error : cannot map to stereo while re-allocation" ); + return; + } + for ( si=0; six_size; si++ ) + { + *(x->x_rdata+si) = *(x->x_ldata+si); + } + if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, !x->x_empty, !x->x_empty, 0); +} + +/* play the cooled */ +static void cooled_play(t_cooled *x) +{ + x->x_play=1; + // post( "cooled~ : playing on" ); +} + +/* sets the reading speed */ +static void cooled_readspeed(t_cooled *x, t_floatarg freadspeed) +{ + x->x_readspeed=freadspeed; +} + +/* resize cooled */ +static void cooled_resize(t_cooled *x, t_floatarg fnewsize ) +{ + if (fnewsize <= 0) + { + post( "cooled~ : error : wrong size" ); + return; + } + if (x->x_allocate) + { + post( "cooled~ : error : cannot resize while re-allocation" ); + return; + } +#ifndef _WIN32 + if (x->x_updatechild > 0) + { + post( "cooled~ : can't resize now, an update is pending." ); + return; + } +#endif + post( "cooled~ : reallocating tables" ); + x->x_allocate = 1; + x->x_play = 0; + x->x_record = 0; + cooled_readstart( x, 0); + cooled_readend( x, 100); + cooled_reallocate(x, x->x_size, fnewsize); + x->x_size = fnewsize; + x->x_empty = 1; + if ( x->x_readstart <= x->x_readend ) + { + x->x_readpos = (x->x_readstart*x->x_size)/100; + } + else + { + x->x_readpos = (x->x_readend*x->x_size)/100; + } + // erase all points, as data is zero no drawing is needed + if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, !x->x_empty, 1); + x->x_allocate = 0; +} + +/* set zoom factor */ +static void cooled_zoom(t_cooled *x, t_floatarg fzoom ) +{ + if (fzoom < 1) + { + post( "cooled~ : error : wrong zoom factor" ); + return; + } + if (x->x_allocate) + { + post( "cooled~ : error : cannot zoom while re-allocation" ); + return; + } + if ( x->x_gifdata != NULL ) + { + freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_gifdata = NULL; + } + if ( x->x_guicommand != NULL ) + { + freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + x->x_guicommand = NULL; + } + x->x_zoom = (int)fzoom; + if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return; + } + else + { + post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) + { + post( "cooled~ : error : could not allocate buffers" ); + return; + } + else + { + post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); + } + if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, !x->x_empty, !x->x_empty, 0); + canvas_fixlinesfor(x->x_glist, (t_text*)x ); +} + +/* modify the loop positions */ +static void cooled_loop(t_cooled *x, t_symbol *soperator ) +{ + char *operator = soperator->s_name; + int ci; + t_float fvalue, freadstart = x->x_readstart, freadend = x->x_readend; + + if ( (soperator->s_name[0] != '*') && + (soperator->s_name[0] != '/') && + (soperator->s_name[0] != '>') && + (soperator->s_name[0] != '<') ) + { + post( "cooled~ : error : wrong operator argument : should be *|/|>|<" ); + return; + } + for ( ci=1; ci<(int)strlen( soperator->s_name ); ci++ ) + { + if ( !(isdigit(soperator->s_name[ci])||(soperator->s_name[ci]=='.')) ) + { + post( "cooled~ : error : wrong operation value : %s : should be in a float format", soperator->s_name+1 ); + return; + } + } + if ( sscanf( soperator->s_name+1, "%f", &fvalue ) != 1 ) + { + post( "cooled~ : error : can't get operation value" ); + return; + } + switch( soperator->s_name[0] ) + { + case '*' : + freadend = x->x_readstart + fvalue*(x->x_readend-x->x_readstart); + break; + + case '/' : + if ( fvalue != 0 ) + { + freadend = x->x_readstart + (x->x_readend-x->x_readstart)/fvalue; + }; + break; + + case '>' : + freadstart = x->x_readstart + fvalue*(x->x_readend-x->x_readstart); + freadend = x->x_readend + fvalue*(x->x_readend-x->x_readstart); + break; + + case '<' : + freadstart = x->x_readstart - fvalue*(x->x_readend-x->x_readstart); + freadend = x->x_readend - fvalue*(x->x_readend-x->x_readstart); + break; + } + if ( freadstart < 0.0 ) freadstart = 0.0; + if ( freadend < 0.0 ) freadend = 0.0; + if ( freadstart > 100.0 ) freadstart = 100.0; + if ( freadend > 100.0 ) freadend = 100.0; + cooled_readstart( x, freadstart); + cooled_readend( x, freadend); +} + +/* refresh data */ +static void cooled_refresh(t_cooled *x) +{ + if (x->x_allocate) + { + post( "cooled~ : error : cannot refresh while re-allocation" ); + return; + } + if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 1); +} + +static void *cooled_new(t_symbol *s, int argc, t_atom *argv) +{ + t_cooled *x = (t_cooled *)pd_new(cooled_class); + outlet_new(&x->x_obj, &s_signal); + outlet_new(&x->x_obj, &s_signal); + x->x_recend = outlet_new(&x->x_obj, &s_bang ); + x->x_end = outlet_new(&x->x_obj, &s_bang ); + x->x_sampstart = outlet_new(&x->x_obj, &s_float ); + x->x_sampend = outlet_new(&x->x_obj, &s_float ); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("readstart")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("readend")); + + if ( argc != 0 ) + { + if ( argc < 3 ) + { + post( "audience~ : error in the number of arguments ( %d )", argc ); + return NULL; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT ) + { + post( "audience~ : wrong arguments" ); + return NULL; + } + x->x_size = (int)argv[0].a_w.w_float; + if ( x->x_size < 1 ) x->x_size = 1; + x->x_width = (int)argv[1].a_w.w_float; + if ( x->x_width < 10 ) x->x_width = 10; + x->x_height = (int)argv[2].a_w.w_float; + if ( x->x_height < 10 ) x->x_height = 10; + if ( argc == 3 ) + x->x_draw = 1; + else + x->x_draw = (int)argv[3].a_w.w_float; + } + else + { + x->x_size = COOLED_DEFAULT_SIZE; + x->x_width = COOLED_DEFAULT_WIDTH; + x->x_height = COOLED_DEFAULT_HEIGHT; + x->x_draw = 1; + } + + // activate graphical callbacks + class_setwidget(cooled_class, &cooled_widgetbehavior); + + x->x_play = 0; + x->x_readspeed = 1.; + x->x_record = 0; + x->x_allocate = 0; + x->x_readpos = 0.; + x->x_writepos = 0; + x->x_rdata = NULL; + x->x_ldata = NULL; + x->x_empty = 1; + x->x_xpos = -1; + x->x_ypos = -1; + /* graphic data */ + x->x_selected = 0; + x->x_zoom = 1; +#ifndef _WIN32 + x->x_updatechild = 0; +#endif + x->x_glist = (t_glist*)canvas_getcurrent(); + // post( "cooled~ : new : readend=%d", x->x_readend ); + cooled_readstart( x, 0); + cooled_readend( x, 100); + + if ( cooled_allocate(x) <0 ) + { + return NULL; + } + else + { + return(x); + } + +} + +void cooled_tilde_setup(void) +{ + logpost(NULL, 4, "%s", cooled_version); + cooled_class = class_new(gensym("cooled~"), (t_newmethod)cooled_new, (t_method)cooled_free, + sizeof(t_cooled), 0, A_GIMME, 0); + + + // set callbacks + cooled_widgetbehavior.w_getrectfn = cooled_getrect; + cooled_widgetbehavior.w_displacefn = cooled_displace; + cooled_widgetbehavior.w_selectfn = cooled_select; + cooled_widgetbehavior.w_activatefn = NULL; + cooled_widgetbehavior.w_deletefn = cooled_delete; + cooled_widgetbehavior.w_visfn = cooled_vis; + cooled_widgetbehavior.w_clickfn = cooled_click; + + class_setpropertiesfn(cooled_class, cooled_properties); + class_setsavefn(cooled_class, cooled_save); + + CLASS_MAINSIGNALIN( cooled_class, t_cooled, x_f ); + class_addmethod(cooled_class, (t_method)cooled_dsp, gensym("dsp"), A_CANT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_record, gensym("record"), A_NULL); + class_addmethod(cooled_class, (t_method)cooled_resize, gensym("resize"), A_FLOAT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_zoom, gensym("zoom"), A_FLOAT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_play, gensym("play"), A_NULL); + class_addmethod(cooled_class, (t_method)cooled_refresh, gensym("refresh"), A_NULL); + class_addmethod(cooled_class, (t_method)cooled_readstart, gensym("readstart"), A_FLOAT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_stereo, gensym("stereo"), A_NULL); + class_addmethod(cooled_class, (t_method)cooled_readend, gensym("readend"), A_FLOAT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_readspeed, gensym("readspeed"), A_FLOAT, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_loop, gensym("loop"), A_SYMBOL, A_NULL); + class_addmethod(cooled_class, (t_method)cooled_dialog, gensym("dialog"), A_GIMME, 0); + + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + cooled_class->c_externdir->s_name, cooled_class->c_name->s_name); +} diff --git a/externals/unauthorized/cooled~/cooled~.tk b/externals/unauthorized/cooled~.tcl similarity index 97% rename from externals/unauthorized/cooled~/cooled~.tk rename to externals/unauthorized/cooled~.tcl index db8cce8c70097cbadb72bc83b3c9902991f66226..59651645e8a28507af9be42108d9c7e74be898ed 100644 --- a/externals/unauthorized/cooled~/cooled~.tk +++ b/externals/unauthorized/cooled~.tcl @@ -17,13 +17,13 @@ proc cooled_apply {id} { [eval concat $$var_graph_draw] \ \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc cooled_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc cooled_ok {id} { @@ -44,7 +44,7 @@ proc pdtk_cooled_dialog {id width height draw} { set $var_graph_height $height set $var_graph_draw $draw - toplevel $id -class [winfo class .] + toplevel $id wm title $id {cooled} wm protocol $id WM_DELETE_WINDOW [concat cooled_cancel $id] diff --git a/externals/unauthorized/cooled~/INSTALL b/externals/unauthorized/cooled~/INSTALL deleted file mode 100644 index 411a1c39eed9849f8b6bbb0d60b8c5b8635e5afb..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/cooled~ - -make clean - -make - -make install - -open help-cooled~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/cooled~/Makefile b/externals/unauthorized/cooled~/Makefile deleted file mode 100644 index 28bc180b09d7721545ccae6caf7529c361205060..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -NAME=cooled~ -CSYM=cooled_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch -g #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk > $*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lpthread -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/cooled~/README b/externals/unauthorized/cooled~/README deleted file mode 100644 index d35d1b907aa23428fcb7c87d978033e55fc59108..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/README +++ /dev/null @@ -1,23 +0,0 @@ -***************************************************************************** -Version 0.1 -copyleft 2002 by Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -cooled : a micro sound editor - -This object displays a sound, lets you play a part of it -and do some cut and paste operations. - -To install cooled~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/cooled~/cooled~.c b/externals/unauthorized/cooled~/cooled~.c deleted file mode 100644 index 6dc15bbba81c27ee99fc72608b8ff351d7ebd5ec..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/cooled~.c +++ /dev/null @@ -1,1387 +0,0 @@ -/*------------------------ cooled~ -------------------------------------------- */ -/* */ -/* cooled~ : display sound, play parts and modify it with cut and paste */ -/* constructor : cooled~ | cooled~ */ -/* */ -/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* "I am the fly in the ointment" -- Wire + 154 */ -/* Komet -- Instrumentals */ -/* ---------------------------------------------------------------------------- */ - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef UNIX -#include -#endif -#ifdef NT -#define M_PI 3.14159265358979323846 -#endif -#include - -#include "m_pd.h" -#include "m_imp.h" -#include "g_canvas.h" - - -static int guidebug=0; -static int ignorevisible=1; // ignore visible test - // because this seems to lead to bad refresh - // wait for a fix - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g );\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h );\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i );\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -#define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j );\ - sys_vgui(a,b,c,d,e,f,g,h,i,j) - -#define SYS_VGUI11(a,b,c,d,e,f,g,h,i,j,k) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j,k );\ - sys_vgui(a,b,c,d,e,f,g,h,i,j,k) - -#define THREAD_SLEEP_TIME 10000 // 10000 us = 10 ms -#define COOLED_BGCOLOR "#000000" -#define COOLED_FGCOLOR "#34E112" -#define COOLED_FRCOLOR "#FFFFFF" - -#define COOLED_DEFAULT_SIZE 1024 -#define COOLED_DEFAULT_WIDTH 400 -#define COOLED_DEFAULT_HEIGHT 200 - -static char *cooled_version = "cooled~: version 0.13, written by Yves Degoyon (ydegoyon@free.fr)"; - -static t_class *cooled_class; -t_widgetbehavior cooled_widgetbehavior; - -typedef struct _cooled -{ - t_object x_obj; - - int x_size; /* size of the stored sound */ - t_float x_readpos; /* data's playing position */ - int x_writepos; /* data's recording position */ - t_float x_readstart; /* data's starting position for reading */ - t_float x_readend; /* data's ending position for reading */ - int x_play; /* playing on/off flag */ - t_float x_readspeed; /* speed increment */ - t_float x_record; /* flag to start recording process */ - t_float x_allocate; /* flag to indicate pending allocation */ - t_float x_empty; /* flag to indicate it's a brand new sound */ - t_float *x_rdata; /* table containing right channel samples */ - t_float *x_ldata; /* table containing leftt channel samples */ - t_outlet *x_end; /* outlet for end of restitution */ - t_outlet *x_recend; /* outlet for end of recording */ - t_outlet *x_sampstart; /* outlet for sample number [ start ] when selecting */ - t_outlet *x_sampend; /* outlet for sample number [ end ] when selecting */ - t_float *x_rsemp; /* temporary sample buffer ( right ) */ - t_float *x_lsemp; /* temporary sample buffer ( left ) */ - char* x_gifdata; /* buffer to store graphic data */ - char* x_guicommand; /* buffer to store gui command */ - int x_draw; /* drawing option */ - - /* graphical data block */ - int x_width; /* graphical width */ - int x_height; /* graphical height */ - int x_selected; /* flag to remember if we are seleted or not */ - int x_erase; /* flag used when an erase is needed */ - int x_redraw; /* flag used when drawing is needed */ - t_glist *x_glist; /* keep graphic context for various operations */ - int x_zoom; /* zoom factor */ - pthread_t x_updatechild; /* thread id for the update child */ - int x_updatestart; /* starting position for update */ - int x_updateend; /* ending position for update */ - int x_xpos; /* stuck x position */ - int x_ypos; /* stuck y position */ - int x_shifted; /* remember shift state from last click */ - int x_alted; /* remember alt state from last click */ - int x_xdraw; /* x drawing position */ - int x_edraw; /* end of drawing */ - - t_float x_f; /* float needed for signal input */ - -} t_cooled; - -/* ------------------------ drawing functions ---------------------------- */ - -static void cooled_update_block(t_cooled *x, t_glist *glist, int bnumber) -{ - int hi, i=0; - t_float fspectrum=0.0; - int phase=0; - char color[8]; - - memset( x->x_gifdata, 0x0, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - - // update cooled~ - for ( hi=x->x_height-1; hi>=0; hi-- ) - { - if ( ( hi == x->x_height/4) || ( hi == 3*x->x_height/4) ) - { - sprintf( color, "%s ", COOLED_FGCOLOR ); - } - else if ( hi == x->x_height/2) - { - sprintf( color, "%s ", COOLED_FRCOLOR ); - } - else - { - sprintf( color, "%s ", COOLED_BGCOLOR ); - } - for ( i=0; ix_zoom; i++ ) - { - strncpy( x->x_gifdata+(hi*x->x_zoom+i)*8, color, 8 ); - } - } - - // set all points - { - int fsamp = ( bnumber * x->x_size ) / x->x_width; - int lsamp = ( ( bnumber+1) * x->x_size ) / x->x_width; - int si; - - // post ( "cooled~ : updating samples [%d,%d]", fsamp, lsamp ); - - for ( si=fsamp;six_height/4 + ( *(x->x_rdata+si) * (x->x_height/4) ) - 1; - - if ( rind > x->x_height - 1 ) rind = x->x_height - 1; - if ( rind < x->x_height/2 ) rind = x->x_height/2; - - sprintf( color, "%s ", COOLED_FGCOLOR ); - for ( i=0; ix_zoom; i++ ) - { - strncpy( x->x_gifdata+(rind*x->x_zoom+i)*8, color, 8 ); - } - } - - // calculate left channel index - { - int lind = x->x_height/4 + ( *(x->x_ldata+si) * (x->x_height/4) ) - 1; - - if ( lind > x->x_height/2 - 1 ) lind = x->x_height/2 - 1; - if ( lind < 0 ) lind = 0; - - sprintf( color, "%s ", COOLED_FGCOLOR ); - for ( i=0; ix_zoom; i++ ) - { - strncpy( x->x_gifdata+(lind*x->x_zoom+i)*8, color, 8 ); - } - } - } - } - - for ( i=0; ix_zoom; i++ ) - { - sprintf( x->x_guicommand, "COOLEDIMAGE%x put {%s} -to %d 0\n", x, x->x_gifdata, (bnumber*x->x_zoom)+i ); - if ( glist_isvisible( x->x_glist ) ) - sys_gui( x->x_guicommand ); - } - -} - -static void cooled_erase_block(t_cooled *x, t_glist *glist, int sample ) -{ - t_canvas *canvas=glist_getcanvas(glist); - int hi; - t_float fspectrum=0.0; - char fillColor[ 16 ]; - - for ( hi=0; hix_height; hi++) - { - { - int i; - - for ( i=0; ix_zoom; i++ ) - { - strcpy( x->x_gifdata+i*sizeof("#FFFFFF "), strcat( COOLED_BGCOLOR, " ") ); - } - if ( glist_isvisible( x->x_glist ) ) - SYS_VGUI5("COOLEDIMAGE%x put {%s} -to %d %d\n", x, x->x_gifdata, - sample*x->x_zoom, (x->x_height-hi)*x->x_zoom ); - } - } -} - -static void *cooled_do_update_part(void *tdata) -{ - t_cooled *x = (t_cooled*) tdata; - t_canvas *canvas=glist_getcanvas(x->x_glist); - int si; - int nbpoints = 0; - t_float percentage = 0, opercentage = 0; - - // loose synchro - usleep( THREAD_SLEEP_TIME ); - - // check bounds - if ( x->x_updateend > x->x_size-1 ) x->x_updateend = x->x_size-1; - if ( x->x_updatestart < 0 ) x->x_updatestart = 0; - - post("cooled~ : ok, let's go [updating %d, %d]", x->x_updatestart, x->x_updateend ); - - if ( x->x_erase ) - { - for ( si=x->x_updatestart; si<=x->x_updateend; si++ ) - { - cooled_erase_block(x, x->x_glist, si); - nbpoints++; - percentage = (nbpoints*100/(x->x_updateend-x->x_updatestart+1)); - if ( (percentage == (int) percentage) && ((int)percentage%5 == 0) && ( percentage != opercentage ) ) - { - // post( "cooled~ : erase part : %d %% completed", (int)percentage ); - opercentage = percentage; - } - } - } - - percentage = opercentage = nbpoints = 0; - - if ( x->x_redraw ) - { - for ( si=x->x_updatestart; si<=x->x_updateend; si++ ) - { - cooled_update_block(x, x->x_glist, si); - nbpoints++; - percentage = (nbpoints*100/(x->x_updateend-x->x_updatestart+1)); - if ( (percentage == (int) percentage) && ((int)percentage%5 == 0) && ( percentage != opercentage ) ) - { - // post( "cooled~ : update part : %d %% completed", (int)percentage ); - opercentage = percentage; - } - } - } - - if ( glist_isvisible( x->x_glist ) ) - { - SYS_VGUI3( ".x%x.c delete rectangle %xCLIPZONE\n", - canvas, x); - if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) - { - SYS_VGUI7( ".x%x.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", - canvas, x->x_xpos+(int)(x->x_readstart*(x->x_width)/100 ), - x->x_ypos, x->x_xpos+(int)(x->x_readend*(x->x_width)/100 ), - x->x_ypos+x->x_height*x->x_zoom, x ); - } - // set borders in black - SYS_VGUI3(".x%x.c itemconfigure %xCOOLED -outline #000000\n", canvas, x); - } - - post("cooled~ : child thread %d ended", (int)x->x_updatechild ); - x->x_updatechild = 0; - return NULL; -} - -static void cooled_update_part(t_cooled *x, t_glist *glist, int bstart, int bend, - int erase, int redraw, int keepframe) -{ - pthread_attr_t update_child_attr; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if ( x->x_updatechild != 0 ) - { - // post( "cooled~ : error : no update is possible for now" ); - return; - } - x->x_updatestart = bstart; - x->x_updateend = bend; - if ( !keepframe ) - { - x->x_erase = 0; - } - else - { - x->x_erase = erase; - } - x->x_redraw = redraw; - // recreate the square if needed - if ( glist_isvisible( x->x_glist ) ) - { - if ( ( bstart == 0 ) && ( bend == x->x_width-1 ) && !keepframe ) - { - SYS_VGUI3(".x%x.c delete %xCOOLEDL\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xCOOLEDR\n", canvas, x ); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDR\n", - canvas, x->x_xpos, x->x_ypos, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height/2*x->x_zoom, - x); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDL\n", - canvas, x->x_xpos, - x->x_ypos + x->x_height/2*x->x_zoom, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height*x->x_zoom, - x); - SYS_VGUI2("image delete COOLEDIMAGE%x\n", x ); - SYS_VGUI3(".x%x.c delete ICOOLEDIMAGE%x\n", canvas, x ); - SYS_VGUI4("image create photo COOLEDIMAGE%x -format gif -width %d -height %d\n", - x, x->x_width*x->x_zoom, x->x_height*x->x_zoom ); - SYS_VGUI2("COOLEDIMAGE%x blank\n", x ); - SYS_VGUI6(".x%x.c create image %d %d -image COOLEDIMAGE%x -tags ICOOLEDIMAGE%x\n", - canvas, - x->x_xpos+(x->x_width*x->x_zoom)/2, - x->x_ypos+(x->x_height*x->x_zoom)/2, x, x ); - canvas_fixlinesfor( canvas, (t_text*)x ); - } - // set borders in red - SYS_VGUI3(".x%x.c itemconfigure %xCOOLED -outline #FF0000\n", canvas, x); - } - - // launch update thread - if ( pthread_attr_init( &update_child_attr ) < 0 ) { - post( "cooled~ : could not launch update thread" ); - perror( "pthread_attr_init" ); - return; - } - if ( pthread_attr_setdetachstate( &update_child_attr, PTHREAD_CREATE_DETACHED ) < 0 ) { - post( "cooled~ : could not launch update thread" ); - perror( "pthread_attr_setdetachstate" ); - return; - } - if ( pthread_create( &x->x_updatechild, &update_child_attr, cooled_do_update_part, x ) < 0 ) { - post( "cooled~ : could not launch update thread" ); - perror( "pthread_create" ); - return; - } - else - { - // post( "cooled~ : drawing thread %d launched", (int)x->x_updatechild ); - } -} - -static void cooled_draw_new(t_cooled *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - x->x_xpos=text_xpix(&x->x_obj, glist); - x->x_ypos=text_ypix(&x->x_obj, glist); - x->x_xdraw=text_xpix(&x->x_obj, glist); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDR\n", - canvas, x->x_xpos, x->x_ypos, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height/2*x->x_zoom, - x); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xCOOLEDL\n", - canvas, x->x_xpos, - x->x_ypos + x->x_height/2*x->x_zoom, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height*x->x_zoom, - x); - SYS_VGUI4("image create photo COOLEDIMAGE%x -format gif -width %d -height %d\n", - x, x->x_width*x->x_zoom, x->x_height*x->x_zoom ); - SYS_VGUI2("COOLEDIMAGE%x blank\n", x ); - SYS_VGUI6(".x%x.c create image %d %d -image COOLEDIMAGE%x -tags ICOOLEDIMAGE%x\n", - canvas, - x->x_xpos+(x->x_width*x->x_zoom)/2, - x->x_ypos+(x->x_height*x->x_zoom)/2, x, x ); - if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 0); - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void cooled_draw_delete(t_cooled *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if ( glist_isvisible( glist ) ) - { - SYS_VGUI3( ".x%x.c delete %xCAPTURE\n", canvas, x ); - if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) - { - SYS_VGUI3( ".x%x.c delete rectangle %xCLIPZONE\n", canvas, x); - } - SYS_VGUI3( ".x%x.c delete line %xINSERTHERE\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xCOOLEDR\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xCOOLEDL\n", canvas, x ); - SYS_VGUI3(".x%x.c delete ICOOLEDIMAGE%x\n", canvas, x ); - SYS_VGUI2("image delete COOLEDIMAGE%x\n", x ); - } -} - -static void cooled_draw_move(t_cooled *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if ( glist_isvisible( x->x_glist ) ) - { - SYS_VGUI7(".x%x.c coords %xCOOLEDR %d %d %d %d\n", - canvas, x, - x->x_xpos, x->x_ypos, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height/2*x->x_zoom); - SYS_VGUI7(".x%x.c coords %xCOOLEDL %d %d %d %d\n", - canvas, x, - x->x_xpos, - x->x_ypos + x->x_height/2*x->x_zoom, - x->x_xpos + x->x_width*x->x_zoom, - x->x_ypos + x->x_height*x->x_zoom ); - if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) - { - SYS_VGUI7(".x%x.c coords %xCLIPZONE %d %d %d %d\n", - canvas, x, - x->x_xpos+(int)(x->x_readstart*(x->x_width)/100*x->x_zoom ), - x->x_ypos, - x->x_xpos+(int)(x->x_readend*(x->x_width)/100*x->x_zoom ), - x->x_ypos+x->x_height*x->x_zoom ); - } - SYS_VGUI7(".x%x.c coords %xINSERTHERE %d %d %d %d\n", - canvas, x, - x->x_xdraw, - x->x_ypos, - x->x_xdraw, - x->x_ypos+x->x_height*x->x_zoom ); - SYS_VGUI5(".x%x.c coords ICOOLEDIMAGE%x %d %d\n", - canvas, x, - x->x_xpos+((x->x_width*x->x_zoom)/2), - (x->x_ypos+((x->x_height*x->x_zoom)/2)) ); - canvas_fixlinesfor( canvas, (t_text*)x ); - } -} - -static void cooled_draw_select(t_cooled* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if ( glist_isvisible( x->x_glist ) ) - { - if(x->x_selected) - { - /* sets the item in blue */ - SYS_VGUI3(".x%x.c itemconfigure %xCOOLEDR -outline #0000FF\n", canvas, x); - SYS_VGUI3(".x%x.c itemconfigure %xCOOLEDL -outline #0000FF\n", canvas, x); - } - else - { - SYS_VGUI3(".x%x.c itemconfigure %xCOOLEDR -outline #000000\n", canvas, x); - SYS_VGUI3(".x%x.c itemconfigure %xCOOLEDL -outline #000000\n", canvas, x); - } - } -} - -/* ------------------------ widget callbacks ----------------------------- */ - - - /* setting the starting point for reading ( in percent ) */ -static void cooled_readstart(t_cooled *x, t_floatarg fstart) -{ - t_float startpoint = fstart; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if (startpoint < 0) startpoint = 0; - if (startpoint > 100) startpoint = 100; - x->x_readstart = startpoint; - // set readspeed sign - if ( ( x->x_readstart > x->x_readend ) && ( x->x_readspeed > 0 ) ) x->x_readspeed = -x->x_readspeed; - if ( ( x->x_readstart < x->x_readend ) && ( x->x_readspeed < 0 ) ) x->x_readspeed = -x->x_readspeed; - if ( glist_isvisible( x->x_glist ) ) - { - SYS_VGUI3( ".x%x.c delete rectangle %xCLIPZONE\n", - canvas, x); - if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) - { - SYS_VGUI7( ".x%x.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", - canvas, x->x_xpos+(int)(x->x_readstart*x->x_width*x->x_zoom/100 ), - x->x_ypos, x->x_xpos+(int)(x->x_readend*x->x_width*x->x_zoom/100 ), - x->x_ypos+x->x_height*x->x_zoom, x ); - } - } - outlet_float( x->x_sampstart, (x->x_readstart*x->x_size)/100 ); -} - - /* setting the ending point for reading ( in percent ) */ -static void cooled_readend(t_cooled *x, t_floatarg fend) -{ - t_float endpoint = fend; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if (endpoint < 0) endpoint = 0; - if (endpoint > 100) endpoint = 100; - x->x_readend = endpoint; - // set readspeed sign - if ( ( x->x_readstart > x->x_readend ) && ( x->x_readspeed > 0 ) ) x->x_readspeed = -x->x_readspeed; - if ( ( x->x_readstart < x->x_readend ) && ( x->x_readspeed < 0 ) ) x->x_readspeed = -x->x_readspeed; - if ( glist_isvisible( x->x_glist ) ) - { - SYS_VGUI3( ".x%x.c delete rectangle %xCLIPZONE\n", - canvas, x); - if ( ( x->x_readstart != 0 ) || ( x->x_readend != 100 ) ) - { - SYS_VGUI7( ".x%x.c create rectangle %d %d %d %d -outline #FF0000 -tags %xCLIPZONE -width 2\n", - canvas, - x->x_xpos+(int)(x->x_readstart*x->x_width*x->x_zoom/100 ), - x->x_ypos, x->x_xpos+(int)(x->x_readend*x->x_width*x->x_zoom/100 ), - x->x_ypos+x->x_height*x->x_zoom, x ); - } - } - outlet_float( x->x_sampend, (x->x_readend*x->x_size)/100 ); -} - -static void cooled_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - t_cooled* x = (t_cooled*)z; - - *xp1 = x->x_xpos; - *yp1 = x->x_ypos; - *xp2 = x->x_xpos+x->x_width*x->x_zoom; - *yp2 = x->x_ypos+x->x_height*x->x_zoom+1; -} - -static void cooled_save(t_gobj *z, t_binbuf *b) -{ - t_cooled *x = (t_cooled *)z; - - binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"), - (int)x->x_obj.te_xpix, (int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_size, x->x_width, x->x_height, x->x_draw ); - binbuf_addv(b, ";"); -} - -static void cooled_select(t_gobj *z, t_glist *glist, int selected) -{ - t_cooled *x = (t_cooled *)z; - - x->x_selected = selected; - cooled_draw_select( x, glist ); -} - -static void cooled_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_cooled *x = (t_cooled *)z; - t_rtext *y; - - if (vis) - { - cooled_draw_new( x, glist ); - } - else - { - // erase all points - cooled_draw_delete( x, glist ); - } -} - -static void cooled_delete(t_gobj *z, t_glist *glist) -{ - canvas_deletelinesfor(glist, (t_text *)z); -} - -static void cooled_displace(t_gobj *z, t_glist *glist, int dx, int dy) -{ - t_cooled *x = (t_cooled *)z; - int xold = x->x_xpos; - int yold = x->x_ypos; - - x->x_xpos += dx; - x->x_ypos += dy; - - if ( ( x->x_xpos != xold ) || ( x->x_ypos != yold ) ) - { - cooled_draw_move( x, glist ); - } - -} - -static void cooled_motion(t_cooled *x, t_floatarg dx, t_floatarg dy) -{ - // post( "cooled_motion @ [%d,%d] dx=%f dy=%f alt=%d", x->x_xdraw, x->x_ydraw, dx, dy, x->x_alted ); - if ( dx != 0 ) - { - cooled_readstart( x, ((t_float)( x->x_xdraw - x->x_xpos ) * 100 )/ (t_float)( x->x_width * x->x_zoom ) ); - x->x_edraw += dx; - cooled_readend( x, ((t_float)( x->x_edraw - x->x_xpos ) * 100 )/ (t_float)( x->x_width * x->x_zoom ) ); - } -} - - /* erase data form readstart to readend */ -static void cooled_erase( t_cooled *x ) -{ - int startsamp, endsamp, si; - int lreadstart = x->x_readstart, lreadend = x->x_readend; - - if (x->x_allocate) { - post( "cooled~ : error : cannot erase while re-allocation" ); - return; - } - // post( "cooled~ : erase" ); - if ( lreadstart <= lreadend ) - { - startsamp = (lreadstart*x->x_size)/100; - endsamp = (lreadend*x->x_size)/100; - } - else - { - startsamp = (lreadend*x->x_size)/100; - endsamp = (lreadstart*x->x_size)/100; - } - - for ( si=startsamp; si<=endsamp; si++ ) - { - *(x->x_rdata+si) = 0.; - *(x->x_ldata+si) = 0.; - } - if ( x->x_draw ) cooled_update_part(x, x->x_glist, startsamp*x->x_width/x->x_size, endsamp*(x->x_width-1)/x->x_size, 0, 1, 1); -} - /* paste data form readstart to readend */ -static void cooled_paste( t_cooled *x ) -{ - int startsamp, endsamp, si, inssamp, hlimit, csize; - int lreadstart = x->x_readstart, lreadend = x->x_readend; - - if (x->x_allocate) { - post( "cooled~ : error : cannot paste while re-allocation" ); - return; - } - if ( lreadstart <= lreadend ) - { - startsamp = (lreadstart*x->x_size)/100; - endsamp = (lreadend*x->x_size)/100; - } - else - { - startsamp = (lreadend*x->x_size)/100; - endsamp = (lreadstart*x->x_size)/100; - } - - // insert data at insertion point - inssamp = ( x->x_xdraw - x->x_xpos) * x->x_size / ( x->x_width * x->x_zoom ); - // post( "cooled~ : replace [%d,%d] to %d", startsamp, endsamp, inssamp ); - csize=endsamp-startsamp; - for ( si=0; si<=csize; si++ ) - { - if ( ( si + inssamp >= x->x_size ) || ( startsamp + si >= x->x_size ) ) break; - *(x->x_rsemp+si) = *(x->x_rdata+startsamp+si); - *(x->x_lsemp+si) = *(x->x_ldata+startsamp+si); - } - hlimit = si; - for ( si=0 ; si<=hlimit; si++ ) - { - *(x->x_rdata+inssamp+si) += *(x->x_rsemp+si); - *(x->x_ldata+inssamp+si) += *(x->x_lsemp+si); - } - - // post( "cooled~ : updating [%d,%d]", inssamp*x->x_width/x->x_size, (inssamp+hlimit)*x->x_width/x->x_size ); - if ( x->x_draw ) cooled_update_part(x, x->x_glist, inssamp*x->x_width/x->x_size, (inssamp+hlimit)*(x->x_width-1)/x->x_size, 0, 1, 1); -} - /* replace data form readstart to readend */ -static void cooled_replace( t_cooled *x ) -{ - int startsamp, endsamp, si, inssamp, hlimit, csize; - int lreadstart = x->x_readstart, lreadend = x->x_readend; - - if (x->x_allocate) { - post( "cooled~ : error : cannot replace while re-allocation" ); - return; - } - if ( lreadstart <= lreadend ) - { - startsamp = (lreadstart*x->x_size)/100; - endsamp = (lreadend*x->x_size)/100; - } - else - { - startsamp = (lreadend*x->x_size)/100; - endsamp = (lreadstart*x->x_size)/100; - } - - // insert data at insertion point - inssamp = ( x->x_xdraw - x->x_xpos) * x->x_size / ( x->x_width * x->x_zoom ); - // post( "cooled~ : replace [%d,%d] to %d", startsamp, endsamp, inssamp ); - csize=endsamp-startsamp; - for ( si=0; si<=csize; si++ ) - { - if ( ( si + inssamp >= x->x_size ) || ( startsamp + si >= x->x_size ) ) break; - *(x->x_rsemp+si) = *(x->x_rdata+startsamp+si); - *(x->x_lsemp+si) = *(x->x_ldata+startsamp+si); - } - hlimit = si; - for ( si=0 ; si<=hlimit; si++ ) - { - *(x->x_rdata+inssamp+si) = *(x->x_rsemp+si); - *(x->x_ldata+inssamp+si) = *(x->x_lsemp+si); - } - - // post( "cooled~ : updating [%d,%d]", inssamp*x->x_width/x->x_size, (inssamp+hlimit)*x->x_width/x->x_size ); - if ( x->x_draw ) cooled_update_part(x, x->x_glist, inssamp*x->x_width/x->x_size, (inssamp+hlimit)*(x->x_width-1)/x->x_size, 0, 1, 1); - -} - - /* call editor's property dialog */ -static void cooled_properties(t_gobj *z, t_glist *owner) -{ - char buf[800]; - t_cooled *x=(t_cooled *)z; - - sprintf(buf, "pdtk_cooled_dialog %%s %d %d %d\n", - x->x_width, x->x_height, x->x_draw); - // post("cooled_properties : %s", buf ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); -} - - /* handle properties change */ -static void cooled_dialog(t_cooled *x, t_symbol *s, int argc, t_atom *argv) -{ - if ( !x ) { - post( "cooled~ : error :tried to set properties on an unexisting object" ); - } - if ( argc != 3 ) - { - post( "cooled~ : error in the number of arguments ( %d instead of 3 )", argc ); - return; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || argv[2].a_type != A_FLOAT ) { - post( "cooled~ : wrong arguments" ); - return; - } - cooled_draw_delete(x, x->x_glist); - if ( x->x_gifdata != NULL ) { - freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_gifdata = NULL; - } - if ( x->x_guicommand != NULL ) { - freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_guicommand = NULL; - } - x->x_width = (int)argv[0].a_w.w_float; - if ( x->x_width < 0 ) x->x_width = 100; - x->x_height = (int)argv[1].a_w.w_float; - if ( x->x_height < 0 ) x->x_height = 100; - x->x_draw = (int)argv[2].a_w.w_float; - if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return; - } else { - post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return; - } else { - post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - cooled_draw_new(x, x->x_glist); -} - - /* handle clicks */ -static int cooled_click(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) -{ - t_cooled* x = (t_cooled *)z; - int pipos; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - // post( "cooled_click : x=%d y=%d doit=%d alt=%d, shift=%d", xpix, ypix, doit, alt, shift ); - if ( doit ) - { - if ( shift && alt ) - { - cooled_paste(x); - } - else if ( shift ) - { - cooled_replace(x); - } - else if ( alt ) - { - cooled_erase(x); - } - else - { - x->x_xdraw = xpix; - x->x_edraw = xpix; - x->x_shifted = shift; - x->x_alted = alt; - // activate motion callback - glist_grab( glist, &x->x_obj.te_g, (t_glistmotionfn)cooled_motion, - 0, xpix, ypix ); - - // draw insertion line - if ( glist_isvisible( x->x_glist ) ) - { - SYS_VGUI3( ".x%x.c delete line %xINSERTHERE\n", - canvas, x); - SYS_VGUI7( ".x%x.c create line %d %d %d %d -fill #00FFFF -tags %xINSERTHERE -width 2\n", - canvas, x->x_xdraw, - x->x_ypos, x->x_xdraw, - x->x_ypos+x->x_height*x->x_zoom, x ); - } - - } - - } - else - { - // nothing - } - return (1); - -} - - /* clean up */ -static void cooled_free(t_cooled *x) -{ - if ( x->x_rdata != NULL ) { - freebytes(x->x_rdata, x->x_size*sizeof(float) ); - post( "Freed %d bytes", x->x_size*sizeof(float) ); - x->x_rdata = NULL; - } - if ( x->x_ldata != NULL ) { - freebytes(x->x_ldata, x->x_size*sizeof(float) ); - post( "Freed %d bytes", x->x_size*sizeof(float) ); - x->x_ldata = NULL; - } - if ( x->x_rsemp != NULL ) { - freebytes(x->x_rsemp, x->x_size*sizeof(float) ); - post( "Freed %d bytes", x->x_size*sizeof(float) ); - x->x_rsemp = NULL; - } - if ( x->x_lsemp != NULL ) { - freebytes(x->x_lsemp, x->x_size*sizeof(float) ); - post( "Freed %d bytes", x->x_size*sizeof(float) ); - x->x_lsemp = NULL; - } - if ( x->x_gifdata != NULL ) { - freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_gifdata = NULL; - } - if ( x->x_guicommand != NULL ) { - freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_guicommand = NULL; - } -} - - /* allocate tables for storing sound and temporary copy */ -static int cooled_allocate(t_cooled *x) -{ - int fi; - - if ( !(x->x_rdata = getbytes( x->x_size*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); - } - if ( !(x->x_ldata = getbytes( x->x_size*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); - } - if ( !(x->x_rsemp = getbytes( x->x_size*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); - } - if ( !(x->x_lsemp = getbytes( x->x_size*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", x->x_size*sizeof(float) ); - } - if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - - return 0; -} - - /* allocate tables for storing sound and temporary copy */ -static int cooled_reallocate(t_cooled *x, int ioldsize, int inewsize) -{ - int fi, csize; - t_float *prdata=x->x_rdata, *pldata=x->x_ldata, *prsemp=x->x_rsemp, *plsemp=x->x_lsemp; - - if ( !(x->x_rdata = getbytes( inewsize*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); - } - if ( !(x->x_ldata = getbytes( inewsize*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); - } - if ( !(x->x_rsemp = getbytes( inewsize*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); - } - if ( !(x->x_lsemp = getbytes( inewsize*sizeof(float) ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return -1; - } else { - post( "cooled~ : allocated %d bytes", inewsize*sizeof(float) ); - } - - if ( ioldsize <= inewsize ) - { - csize = ioldsize; - } - else - { - csize = inewsize; - } - memcpy( x->x_rdata, prdata, csize*sizeof(float) ); - memcpy( x->x_ldata, pldata, csize*sizeof(float) ); - memcpy( x->x_rsemp, prsemp, csize*sizeof(float) ); - memcpy( x->x_lsemp, plsemp, csize*sizeof(float) ); - - if ( prdata != NULL ) { - freebytes(prdata, ioldsize*sizeof(float) ); - post( "Freed %d bytes", ioldsize*sizeof(float) ); - } - if ( pldata != NULL ) { - freebytes(pldata, ioldsize*sizeof(float) ); - post( "Freed %d bytes", ioldsize*sizeof(float) ); - } - if ( prsemp != NULL ) { - freebytes(prsemp, ioldsize*sizeof(float) ); - post( "Freed %d bytes", ioldsize*sizeof(float) ); - } - if ( plsemp != NULL ) { - freebytes(plsemp, ioldsize*sizeof(float) ); - post( "Freed %d bytes", ioldsize*sizeof(float) ); - } - - return 0; -} - - /* records and playback the sound */ -static t_int *cooled_perform(t_int *w) -{ - t_float *lin = (t_float *)(w[1]); - t_float *rin = (t_float *)(w[2]); - t_float *rout = (t_float *)(w[3]); - t_float *lout = (t_float *)(w[4]); - int is; - int n = (int)(w[5]); /* number of samples */ - int startsamp, endsamp; - t_cooled *x = (t_cooled *)(w[6]); - int lreadstart = x->x_readstart, lreadend = x->x_readend; - - if ( lreadstart <= lreadend ) - { - startsamp = (lreadstart*x->x_size)/100; - endsamp = (lreadend*x->x_size)/100; - } - else - { - startsamp = (lreadend*x->x_size)/100; - endsamp = (lreadstart*x->x_size)/100; - } - - while (n--) - { - // eventually records input - if ( x->x_record ) { - *(x->x_ldata+x->x_writepos)=*(lin); - *(x->x_rdata+x->x_writepos)=*(rin); - x->x_writepos++; - if ( x->x_writepos >= x->x_size ) { - x->x_record=0; - x->x_writepos=0; - if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 0); - outlet_bang(x->x_recend); - if ( x->x_empty ) x->x_empty = 0; - // post( "cooled~ : stopped recording" ); - } - } - // set outputs - *rout = 0.0; - *lout = 0.0; - if ( x->x_play) { - is=0; - *lout = *(x->x_ldata+(int)x->x_readpos); - *rout = *(x->x_rdata+(int)x->x_readpos); - x->x_readpos+=x->x_readspeed; - // post( "xreadpos : %f (added %f) %d", x->x_readpos, x->x_readspeed, x->x_readend ); - if ( ( x->x_readspeed >= 0 ) && ( x->x_readpos >= endsamp ) ) { - x->x_play=0; - x->x_readpos=(float)(startsamp); - // post( "cooled~ : stopped playing (readpos=%d)", x->x_readpos ); - outlet_bang(x->x_end); - } - if ( ( x->x_readspeed < 0 ) && ( x->x_readpos <= startsamp ) ) { - x->x_play=0; - x->x_readpos = (float)(endsamp); - // post( "cooled~ : stopped playing (readpos=%d)", x->x_readpos ); - outlet_bang(x->x_end); - } - } - rout++;lout++; - rin++;lin++; - } - // post( "cooled~ : read : %f:%d : write: %d:%d", x->x_readpos, x->x_play, x->x_writepos, x->x_record ); - return (w+7); -} - -static void cooled_dsp(t_cooled *x, t_signal **sp) -{ - dsp_add(cooled_perform, 6, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n, x); -} - - /* record the cooled */ -static void cooled_record(t_cooled *x) -{ - if (x->x_allocate) { - post( "cooled~ : error : cannot record while re-allocation" ); - return; - } - x->x_record=1; - x->x_writepos=0; - post( "cooled~ : recording on" ); -} - - /* map to stereo */ -static void cooled_stereo(t_cooled *x) -{ - int si; - - if (x->x_allocate) { - post( "cooled~ : error : cannot map to stereo while re-allocation" ); - return; - } - for ( si=0; six_size; si++ ) - { - *(x->x_rdata+si) = *(x->x_ldata+si); - } - if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, !x->x_empty, !x->x_empty, 0); -} - - /* play the cooled */ -static void cooled_play(t_cooled *x) -{ - x->x_play=1; - // post( "cooled~ : playing on" ); -} - - /* sets the reading speed */ -static void cooled_readspeed(t_cooled *x, t_floatarg freadspeed) -{ - x->x_readspeed=freadspeed; -} - - /* resize cooled */ -static void cooled_resize(t_cooled *x, t_floatarg fnewsize ) -{ - if (fnewsize <= 0) { - post( "cooled~ : error : wrong size" ); - return; - } - if (x->x_allocate) { - post( "cooled~ : error : cannot resize while re-allocation" ); - return; - } - if (x->x_updatechild > 0) { - post( "cooled~ : can't resize now, an update is pending." ); - return; - } - post( "cooled~ : reallocating tables" ); - x->x_allocate = 1; - x->x_play = 0; - x->x_record = 0; - cooled_readstart( x, 0); - cooled_readend( x, 100); - cooled_reallocate(x, x->x_size, fnewsize); - x->x_size = fnewsize; - x->x_empty = 1; - if ( x->x_readstart <= x->x_readend ) - { - x->x_readpos = (x->x_readstart*x->x_size)/100; - } - else - { - x->x_readpos = (x->x_readend*x->x_size)/100; - } - // erase all points, as data is zero no drawing is needed - if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, !x->x_empty, 1); - x->x_allocate = 0; -} - - /* set zoom factor */ -static void cooled_zoom(t_cooled *x, t_floatarg fzoom ) -{ - if (fzoom < 1) { - post( "cooled~ : error : wrong zoom factor" ); - return; - } - if (x->x_allocate) { - post( "cooled~ : error : cannot zoom while re-allocation" ); - return; - } - if ( x->x_gifdata != NULL ) { - freebytes(x->x_gifdata, x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_gifdata = NULL; - } - if ( x->x_guicommand != NULL ) { - freebytes(x->x_guicommand, 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - post( "Freed %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - x->x_guicommand = NULL; - } - x->x_zoom = (int)fzoom; - if ( !(x->x_gifdata = ( char* ) getbytes( x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return; - } else { - post( "cooled~ : allocated %d bytes", x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - if ( !(x->x_guicommand = ( char* ) getbytes( 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ) ) ) { - post( "cooled~ : error : could not allocate buffers" ); - return; - } else { - post( "cooled~ : allocated %d bytes", 128+x->x_height*x->x_zoom*sizeof("#FFFFFF ") ); - } - if ( x->x_draw) cooled_update_part(x, x->x_glist, 0, x->x_width-1, !x->x_empty, !x->x_empty, 0); - canvas_fixlinesfor(x->x_glist, (t_text*)x ); -} - - /* modify the loop positions */ -static void cooled_loop(t_cooled *x, t_symbol *soperator ) -{ - char *operator = soperator->s_name; - int ci; - t_float fvalue, freadstart = x->x_readstart, freadend = x->x_readend; - - if ( (soperator->s_name[0] != '*') && - (soperator->s_name[0] != '/') && - (soperator->s_name[0] != '>') && - (soperator->s_name[0] != '<') ) { - post( "cooled~ : error : wrong operator argument : should be *|/|>|<" ); - return; - } - for ( ci=1; ci<(int)strlen( soperator->s_name ); ci++ ) - { - if ( !(isdigit(soperator->s_name[ci])||(soperator->s_name[ci]=='.')) ) { - post( "cooled~ : error : wrong operation value : %s : should be in a float format", soperator->s_name+1 ); - return; - } - } - if ( sscanf( soperator->s_name+1, "%f", &fvalue ) != 1 ) { - post( "cooled~ : error : can't get operation value" ); - return; - } - switch( soperator->s_name[0] ) - { - case '*' : - freadend = x->x_readstart + fvalue*(x->x_readend-x->x_readstart); - break; - - case '/' : - if ( fvalue != 0 ) { freadend = x->x_readstart + (x->x_readend-x->x_readstart)/fvalue; }; - break; - - case '>' : - freadstart = x->x_readstart + fvalue*(x->x_readend-x->x_readstart); - freadend = x->x_readend + fvalue*(x->x_readend-x->x_readstart); - break; - - case '<' : - freadstart = x->x_readstart - fvalue*(x->x_readend-x->x_readstart); - freadend = x->x_readend - fvalue*(x->x_readend-x->x_readstart); - break; - } - if ( freadstart < 0.0 ) freadstart = 0.0; - if ( freadend < 0.0 ) freadend = 0.0; - if ( freadstart > 100.0 ) freadstart = 100.0; - if ( freadend > 100.0 ) freadend = 100.0; - cooled_readstart( x, freadstart); - cooled_readend( x, freadend); -} - - /* refresh data */ -static void cooled_refresh(t_cooled *x) -{ - if (x->x_allocate) { - post( "cooled~ : error : cannot refresh while re-allocation" ); - return; - } - if ( x->x_draw ) cooled_update_part(x, x->x_glist, 0, x->x_width-1, 0, 1, 1); -} - -static void *cooled_new(t_symbol *s, int argc, t_atom *argv) -{ - t_cooled *x = (t_cooled *)pd_new(cooled_class); - outlet_new(&x->x_obj, &s_signal); - outlet_new(&x->x_obj, &s_signal); - x->x_recend = outlet_new(&x->x_obj, &s_bang ); - x->x_end = outlet_new(&x->x_obj, &s_bang ); - x->x_sampstart = outlet_new(&x->x_obj, &s_float ); - x->x_sampend = outlet_new(&x->x_obj, &s_float ); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("readstart")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("readend")); - - if ( argc != 0 ) - { - if ( argc < 3 ) - { - post( "audience~ : error in the number of arguments ( %d )", argc ); - return NULL; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT ) { - post( "audience~ : wrong arguments" ); - return NULL; - } - x->x_size = (int)argv[0].a_w.w_float; - if ( x->x_size < 1 ) x->x_size = 1; - x->x_width = (int)argv[1].a_w.w_float; - if ( x->x_width < 10 ) x->x_width = 10; - x->x_height = (int)argv[2].a_w.w_float; - if ( x->x_height < 10 ) x->x_height = 10; - if ( argc == 3 ) - x->x_draw = 1; - else - x->x_draw = (int)argv[3].a_w.w_float; - } - else - { - x->x_size = COOLED_DEFAULT_SIZE; - x->x_width = COOLED_DEFAULT_WIDTH; - x->x_height = COOLED_DEFAULT_HEIGHT; - x->x_draw = 1; - } - - // activate graphical callbacks - class_setwidget(cooled_class, &cooled_widgetbehavior); - - x->x_play = 0; - x->x_readspeed = 1.; - x->x_record = 0; - x->x_allocate = 0; - x->x_readpos = 0.; - x->x_writepos = 0; - x->x_rdata = NULL; - x->x_ldata = NULL; - x->x_empty = 1; - x->x_xpos = -1; - x->x_ypos = -1; - /* graphic data */ - x->x_selected = 0; - x->x_zoom = 1; - x->x_updatechild = 0; - x->x_glist = (t_glist*)canvas_getcurrent(); - // post( "cooled~ : new : readend=%d", x->x_readend ); - cooled_readstart( x, 0); - cooled_readend( x, 100); - - if ( cooled_allocate(x) <0 ) { - return NULL; - } else { - return(x); - } - -} - -void cooled_tilde_setup(void) -{ -#include "cooled~.tk2c" - post(cooled_version); - cooled_class = class_new(gensym("cooled~"), (t_newmethod)cooled_new, (t_method)cooled_free, - sizeof(t_cooled), 0, A_GIMME, 0); - - - // set callbacks - cooled_widgetbehavior.w_getrectfn = cooled_getrect; - cooled_widgetbehavior.w_displacefn = cooled_displace; - cooled_widgetbehavior.w_selectfn = cooled_select; - cooled_widgetbehavior.w_activatefn = NULL; - cooled_widgetbehavior.w_deletefn = cooled_delete; - cooled_widgetbehavior.w_visfn = cooled_vis; - cooled_widgetbehavior.w_clickfn = cooled_click; - - class_setpropertiesfn(cooled_class, cooled_properties); - class_setsavefn(cooled_class, cooled_save); - - CLASS_MAINSIGNALIN( cooled_class, t_cooled, x_f ); - class_addmethod(cooled_class, (t_method)cooled_dsp, gensym("dsp"), A_CANT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_record, gensym("record"), A_NULL); - class_addmethod(cooled_class, (t_method)cooled_resize, gensym("resize"), A_FLOAT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_zoom, gensym("zoom"), A_FLOAT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_play, gensym("play"), A_NULL); - class_addmethod(cooled_class, (t_method)cooled_refresh, gensym("refresh"), A_NULL); - class_addmethod(cooled_class, (t_method)cooled_readstart, gensym("readstart"), A_FLOAT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_stereo, gensym("stereo"), A_NULL); - class_addmethod(cooled_class, (t_method)cooled_readend, gensym("readend"), A_FLOAT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_readspeed, gensym("readspeed"), A_FLOAT, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_loop, gensym("loop"), A_SYMBOL, A_NULL); - class_addmethod(cooled_class, (t_method)cooled_dialog, gensym("dialog"), A_GIMME, 0); -} diff --git a/externals/unauthorized/cooled~/cooled~.tk2c b/externals/unauthorized/cooled~/cooled~.tk2c deleted file mode 100755 index 513c9760fa49fa50c26a8486e336b2eef05e199c..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/cooled~.tk2c +++ /dev/null @@ -1,65 +0,0 @@ -// ########### cooled procedures -- ydegoyon@free.fr ######### -sys_gui("proc cooled_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_draw [concat graph_draw_$vid]\n"); -sys_gui("global $var_graph_draw\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_draw] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc cooled_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc cooled_ok {id} {\n"); -sys_gui("cooled_apply $id\n"); -sys_gui("cooled_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_cooled_dialog {id width height draw} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_draw [concat graph_draw_$vid]\n"); -sys_gui("global $var_graph_draw\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_draw $draw\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {cooled}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat cooled_cancel $id]\n"); -sys_gui("label $id.label -text {EDITOR PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"cooled_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"cooled_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"cooled_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.1rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.1rangef.lwidth $id.1rangef.width -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.2rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.2rangef.lheight $id.2rangef.height -side left\n"); -sys_gui("checkbutton $id.draw -text {Draw Sample} -variable $var_graph_draw -anchor w\n"); -sys_gui("pack $id.draw -side top\n"); -sys_gui("bind $id.1rangef.width [concat cooled_ok $id]\n"); -sys_gui("bind $id.2rangef.height [concat cooled_ok $id]\n"); -sys_gui("focus $id.1rangef.width\n"); -sys_gui("}\n"); -// ########### cooled procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/cooled~/tk2c.bash b/externals/unauthorized/cooled~/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/cooled~/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/countund/countund-help.pd b/externals/unauthorized/countund-help.pd similarity index 100% rename from externals/unauthorized/countund/countund-help.pd rename to externals/unauthorized/countund-help.pd diff --git a/externals/unauthorized/countund/countund.c b/externals/unauthorized/countund.c similarity index 67% rename from externals/unauthorized/countund/countund.c rename to externals/unauthorized/countund.c index 47b1694db77dabfdb1ba27272cd564d569343d82..8b134eae57dbd2af43aa7c5448c0c5ef53f852e0 100644 --- a/externals/unauthorized/countund/countund.c +++ b/externals/unauthorized/countund.c @@ -54,62 +54,68 @@ typedef struct _countund t_int x_up; } t_countund; - /* clean up */ -static void countund_free(t_countund *x) +/* clean up */ +static void countund_free(t_countund *x) { } static void *countund_new(t_float flimit) { - t_countund *x = (t_countund *)pd_new(countund_class); - outlet_new(&x->x_obj, &s_float); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("limit")); - if ( flimit < 0 ) { - post( "countund~: wrong creation argument" ); - return NULL; - } - x->x_limit = (int) flimit; - x->x_value = 0; - x->x_up = 1; - return(x); + t_countund *x = (t_countund *)pd_new(countund_class); + outlet_new(&x->x_obj, &s_float); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("limit")); + if ( flimit < 0 ) + { + post( "countund~: wrong creation argument" ); + return NULL; + } + x->x_limit = (int) flimit; + x->x_value = 0; + x->x_up = 1; + return(x); } static void countund_limit(t_countund* x, t_float flimit) { - if ( flimit < 0 ) { - post( "countund~: wrong count limit" ); - return; - } else { - x->x_limit=(int)flimit; - } + if ( flimit < 0 ) + { + post( "countund~: wrong count limit" ); + } + else + { + x->x_limit=(int)flimit; + } } static void countund_bang(t_countund *x) { - - if ( x->x_up ) { - x->x_value+=1; - if (x->x_value>x->x_limit) { - x->x_value=x->x_limit-1; - x->x_up=0; - } - } else { - x->x_value-=1; - if (x->x_value<0) { - x->x_value=1; - x->x_up=1; - } - } - outlet_float( x->x_obj.ob_outlet, x->x_value ); - return; + if ( x->x_up ) + { + x->x_value+=1; + if (x->x_value>x->x_limit) + { + x->x_value=x->x_limit-1; + x->x_up=0; + } + } + else + { + x->x_value-=1; + if (x->x_value<0) + { + x->x_value=1; + x->x_up=1; + } + } + outlet_float( x->x_obj.ob_outlet, x->x_value ); } void countund_setup(void) { - post(countund_version); - countund_class = class_new(gensym("countund"), (t_newmethod)countund_new, - (t_method)countund_free, - sizeof(t_countund), 0, A_DEFFLOAT, 0); - class_addmethod( countund_class, (t_method)countund_bang, &s_bang, 0); - class_addmethod( countund_class, (t_method)countund_limit, gensym("limit"), A_FLOAT, 0); + logpost(NULL, 4, "%s", countund_version); + countund_class = class_new(gensym("countund"), (t_newmethod)countund_new, + (t_method)countund_free, + sizeof(t_countund), 0, A_DEFFLOAT, 0); + class_addmethod( countund_class, (t_method)countund_bang, &s_bang, 0); + class_addmethod( countund_class, (t_method)countund_limit, gensym("limit"), A_FLOAT, 0); } diff --git a/externals/unauthorized/countund/INSTALL b/externals/unauthorized/countund/INSTALL deleted file mode 100644 index f2488de650d26d707c13dbdc0200c0922127112e..0000000000000000000000000000000000000000 --- a/externals/unauthorized/countund/INSTALL +++ /dev/null @@ -1,7 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/extra/countund~ - -make - -you're set !! diff --git a/externals/unauthorized/countund/Makefile b/externals/unauthorized/countund/Makefile deleted file mode 100644 index 946a0aac39dadba2cc8599b11a5788efe7f1a868..0000000000000000000000000000000000000000 --- a/externals/unauthorized/countund/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=countund -CSYM=countund - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wshadow -Wstrict-prototypes\ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -clean: - rm -f *.o *.pd_* so_locations - -install: - cp help-* ../../doc/5.reference diff --git a/externals/unauthorized/disto~/rs-disto~.pd b/externals/unauthorized/disto~-help.pd similarity index 91% rename from externals/unauthorized/disto~/rs-disto~.pd rename to externals/unauthorized/disto~-help.pd index 981d2357292ab1327d836ef10a9a79f501cb6098..d2c8623c3f79ef8390b646471f92d71fee9da07d 100644 --- a/externals/unauthorized/disto~/rs-disto~.pd +++ b/externals/unauthorized/disto~-help.pd @@ -1,4 +1,7 @@ -#N canvas 97 16 837 658 10; +#N canvas 45 57 817 573 10; +#X text 389 525 comments & bugs @ ydegoyon.free.fr; +#X obj 125 503 dac~; +#N canvas 97 16 837 658 rs-disto~ 0; #X obj 87 469 outlet~; #X msg 149 9 preset 1; #X msg 149 31 preset 2; @@ -318,7 +321,7 @@ #X obj 517 379 hsl 128 15 0.1 1 0 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 0; #X text 477 327 High pass frequency [ 0 - 22500 ]; -#X text 133 543 Note : see file "distort3.txt" which explains parameters +#X text 133 543 Note : see file "examples/disto~.txt" which explains parameters ; #X text 375 212 Volume [ 0 - 5 ]; #X text 193 208 Drive [ 0 - 25 ]; @@ -347,3 +350,73 @@ #X connect 28 0 37 9; #X connect 37 0 0 0; #X connect 37 0 7 0; +#X restore 146 432 pd rs-disto~; +#X msg 94 62 bang; +#X obj 93 84 openpanel; +#X obj 93 104 t s b; +#X obj 150 106 float \$0; +#X text 101 39 Step 1 : Load a sound file; +#X obj 93 127 route float; +#X obj 94 219 soundfiler; +#X text 151 55 ( maybe \, a guitar sound ? ); +#X obj 582 374 table \$0-sample; +#X msg 94 197 read -resize \$1 \$2; +#X obj 95 176 pack s s; +#X msg 146 307 bang; +#X text 191 307 Step 2 : Start playing; +#X obj 59 288 adc~; +#X text 226 433 Step 3 : Modify parameters; +#X text 584 510 ( http://st.karelia.ru/~smlalx ); +#X text 391 496 a DOS guitar effects software that rocks; +#X obj 606 263 loadbang; +#X msg 608 293 \; pd dsp 1; +#X text 390 482 the algorithm is borrowed from Digital Effects \,; +#X text 35 266 Plug a guitar ??; +#X msg 228 330 stop; +#X obj 146 330 metro 250; +#X text 431 111 Disto~ : distortion with highpass and lowpass filters +; +#X obj 93 150 makefilename %d-sample; +#X obj 80 423 *~ 0; +#X obj 154 461 *~ 0; +#X msg 172 380 1; +#X msg 207 379 0; +#X text 287 382 Normal sound; +#X msg 242 380 bang; +#X msg 178 404 1; +#X msg 213 403 0; +#X msg 248 404 bang; +#X text 355 405 Distorted sound; +#X text 392 510 written by (c) Alexei Smoli; +#X obj 146 354 tabplay~ \$0-sample; +#X obj 287 404 loadbang; +#X connect 2 0 29 0; +#X connect 3 0 4 0; +#X connect 4 0 5 0; +#X connect 5 0 13 0; +#X connect 5 1 6 0; +#X connect 6 0 8 0; +#X connect 8 0 27 0; +#X connect 12 0 9 0; +#X connect 13 0 12 0; +#X connect 14 0 25 0; +#X connect 16 0 2 0; +#X connect 20 0 21 0; +#X connect 24 0 25 0; +#X connect 25 0 39 0; +#X connect 27 0 13 1; +#X connect 28 0 1 0; +#X connect 28 0 1 1; +#X connect 29 0 1 0; +#X connect 29 0 1 1; +#X connect 30 0 28 1; +#X connect 31 0 29 1; +#X connect 33 0 31 0; +#X connect 33 0 30 0; +#X connect 34 0 29 1; +#X connect 35 0 28 1; +#X connect 36 0 35 0; +#X connect 36 0 34 0; +#X connect 39 0 2 0; +#X connect 39 0 28 0; +#X connect 40 0 36 0; diff --git a/externals/unauthorized/disto~/disto~.c b/externals/unauthorized/disto~.c similarity index 69% rename from externals/unauthorized/disto~/disto~.c rename to externals/unauthorized/disto~.c index c397631d9df6cbf637d934cecdb040c5559888e0..b51640660fb53d9f7594581e52e9aae173aa4838 100644 --- a/externals/unauthorized/disto~/disto~.c +++ b/externals/unauthorized/disto~.c @@ -39,41 +39,43 @@ #include #include -#ifdef NT +#ifdef _MSC_VER #define M_PI 3.14159265358979323846 #endif #define BFSZ 4096 /* main delay buffer */ #define BLOCK_DELAY 10 /* number of blocks to delay */ #define NA 0.0 /* param not applicable */ -#define NBEXPS 129 +#define NBEXPS 129 static char *disto_version = "disto~: distortion, version 0.1 (ydegoyon@free.fr)"; -struct hipass { - /* few intermediate variables */ - double omega; - double sn,cs; - double alpha; - /* filter coefficients */ - double a0,a1,a2,b0,b1,b2; - double k0,k1,k2,k3,k4; - /* amplitudes */ - double x0,x1,x2; - double y0,y1,y2; +struct hipass +{ + /* few intermediate variables */ + double omega; + double sn,cs; + double alpha; + /* filter coefficients */ + double a0,a1,a2,b0,b1,b2; + double k0,k1,k2,k3,k4; + /* amplitudes */ + double x0,x1,x2; + double y0,y1,y2; } hipass; -struct lowpass { - /* few intermediate variables */ - double omega; - double sn,cs; - double alpha; - /* filter coefficients */ - double a0,a1,a2,b0,b1,b2; - double k0,k1,k2,k3,k4; - /* amplitudes */ - double x0,x1,x2; - double y0,y1,y2; +struct lowpass +{ + /* few intermediate variables */ + double omega; + double sn,cs; + double alpha; + /* filter coefficients */ + double a0,a1,a2,b0,b1,b2; + double k0,k1,k2,k3,k4; + /* amplitudes */ + double x0,x1,x2; + double y0,y1,y2; } lowpass; typedef struct _disto @@ -91,7 +93,7 @@ typedef struct _disto double x_hipassQ; /* the EE kinda definition for hi pass filter */ /* 0.1< <=1 */ double x_lowpassQ; /* the EE kinda definition for low pass filter */ /* 0.1< <=1 */ - /* audio processing data ( not setable ) */ + /* audio processing data ( not setable ) */ double data,pred; double outval,outvol; double exps[NBEXPS]; @@ -107,11 +109,11 @@ static t_class *disto_class; static void disto_init_filters (t_disto *x) { - t_int i; + t_int i; for (i=0; i<130; i++) { - x->exps[i]=exp((double)i*x->x_drive)*x->x_wetmix; + x->exps[i]=exp((double)i*x->x_drive)*x->x_wetmix; } x->HPF.omega = 2.0*M_PI*x->x_hipassfreq/(double)x->x_samplerate; @@ -151,11 +153,11 @@ static void disto_drive(t_disto *x, t_floatarg fdrive ) { if ( fdrive > 25.0 ) { - fdrive = 25.0; + fdrive = 25.0; } if ( fdrive < 0.0 ) { - fdrive = 0.0; + fdrive = 0.0; } x->x_drive = fdrive; // post( "disto~ : drive: %f", x->x_drive ); @@ -166,11 +168,11 @@ static void disto_drymix(t_disto *x, t_floatarg fdrymix ) { if ( fdrymix > 5.0 ) { - fdrymix = 5.0; + fdrymix = 5.0; } if ( fdrymix < -5.0 ) { - fdrymix = -5.0; + fdrymix = -5.0; } x->x_drymix = fdrymix; // post( "disto~ : drymix: %f", x->x_drymix ); @@ -181,11 +183,11 @@ static void disto_wetmix(t_disto *x, t_floatarg fwetmix ) { if ( fwetmix > 5.0 ) { - fwetmix = 5.0; + fwetmix = 5.0; } if ( fwetmix < -5.0 ) { - fwetmix = -5.0; + fwetmix = -5.0; } x->x_wetmix = fwetmix; // post( "disto~ : wetmix: %f", x->x_wetmix ); @@ -196,11 +198,11 @@ static void disto_feedback(t_disto *x, t_floatarg ffeedback ) { if ( ffeedback > 10.0 ) { - ffeedback = 10.0; + ffeedback = 10.0; } if ( ffeedback < -10.0 ) { - ffeedback = -10.0; + ffeedback = -10.0; } x->x_feedback = ffeedback; // post( "disto~ : feedback: %f", x->x_feedback ); @@ -211,11 +213,11 @@ static void disto_volume(t_disto *x, t_floatarg fvolume ) { if ( fvolume > 5.0 ) { - fvolume = 5.0; + fvolume = 5.0; } if ( fvolume < 0.0 ) { - fvolume = 0.0; + fvolume = 0.0; } x->x_volume = fvolume; // post( "disto~ : volume: %f", x->x_volume ); @@ -226,11 +228,11 @@ static void disto_hipassfreq(t_disto *x, t_floatarg fhipassfreq ) { if ( fhipassfreq > x->x_samplerate/2 ) { - fhipassfreq = x->x_samplerate/2; + fhipassfreq = x->x_samplerate/2; } if ( fhipassfreq < 0.0 ) { - fhipassfreq = 0.0; + fhipassfreq = 0.0; } x->x_hipassfreq = fhipassfreq; // post( "disto~ : hipassfreq: %f", x->x_hipassfreq ); @@ -241,11 +243,11 @@ static void disto_hipassQ(t_disto *x, t_floatarg fhipassQ ) { if ( fhipassQ > 1.0 ) { - fhipassQ = 1.0; + fhipassQ = 1.0; } if ( fhipassQ < 0.1 ) { - fhipassQ = 0.1; + fhipassQ = 0.1; } x->x_hipassQ = fhipassQ; // post( "disto~ : hipassQ: %f", x->x_hipassQ ); @@ -256,11 +258,11 @@ static void disto_lowpassfreq(t_disto *x, t_floatarg flowpassfreq ) { if ( flowpassfreq > x->x_samplerate/2 ) { - flowpassfreq = x->x_samplerate/2; + flowpassfreq = x->x_samplerate/2; } if ( flowpassfreq < 0.0 ) { - flowpassfreq = 0.0; + flowpassfreq = 0.0; } x->x_lowpassfreq = flowpassfreq; // post( "disto~ : lowpassfreq: %f", x->x_lowpassfreq ); @@ -271,11 +273,11 @@ static void disto_lowpassQ(t_disto *x, t_floatarg flowpassQ ) { if ( flowpassQ > 1.0 ) { - flowpassQ = 1.0; + flowpassQ = 1.0; } if ( flowpassQ < 0.1 ) { - flowpassQ = 0.1; + flowpassQ = 0.1; } x->x_lowpassQ = flowpassQ; // post( "disto~ : lowpassQ: %f", x->x_lowpassQ ); @@ -284,49 +286,48 @@ static void disto_lowpassQ(t_disto *x, t_floatarg flowpassQ ) static t_int *disto_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); - t_int n = (int)(w[3]); - t_disto *x = (t_disto*)(w[4]); - t_int i; + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_int n = (int)(w[3]); + t_disto *x = (t_disto*)(w[4]); + t_int i; for (i = 0; i < n; i++) { - x->HPF.x0 = *(in++); - x->HPF.y0 = (x->HPF.k0*x->HPF.x0+x->HPF.k1*x->HPF.x1+x->HPF.k2*x->HPF.x2-x->HPF.k3*x->HPF.y1-x->HPF.k4*x->HPF.y2); - x->HPF.y2 = x->HPF.y1; - x->HPF.y1 = x->HPF.y0; - x->HPF.x2 = x->HPF.x1; - x->HPF.x1 = x->HPF.x0; - x->data = (int)x->HPF.y0; - - if ((x->data-x->pred)>0) - x->outval += (x->data*x->x_drymix+ x->exps[abs(x->data)]); - else - if ((x->data-x->pred)<0) - x->outval += (x->data*x->x_drymix- x->exps[abs(x->data)]); - x->pred = x->data; - - x->LPF.x0 = *(out); - x->LPF.y0 = (x->LPF.k0*x->LPF.x0+x->LPF.k1*x->LPF.x1+x->LPF.k2*x->LPF.x2-x->LPF.k3*x->LPF.y1-x->LPF.k4*x->LPF.y2); - x->LPF.y2 = x->LPF.y1; - x->LPF.y1 = x->LPF.y0; - x->LPF.x2 = x->LPF.x1; - x->LPF.x1 = x->LPF.x0; - - x->outvol = x->LPF.y0*x->x_volume; - - if(x->outvol > 1.0) - x->data = 1.0; - else if(x->outvol < -1.0) - x->data = -1.0; + x->HPF.x0 = *(in++); + x->HPF.y0 = (x->HPF.k0*x->HPF.x0+x->HPF.k1*x->HPF.x1+x->HPF.k2*x->HPF.x2-x->HPF.k3*x->HPF.y1-x->HPF.k4*x->HPF.y2); + x->HPF.y2 = x->HPF.y1; + x->HPF.y1 = x->HPF.y0; + x->HPF.x2 = x->HPF.x1; + x->HPF.x1 = x->HPF.x0; + x->data = (int)x->HPF.y0; + + if ((x->data-x->pred)>0) + x->outval += (x->data*x->x_drymix+ x->exps[abs(x->data)]); + else if ((x->data-x->pred)<0) + x->outval += (x->data*x->x_drymix- x->exps[abs(x->data)]); + x->pred = x->data; + + x->LPF.x0 = *(out); + x->LPF.y0 = (x->LPF.k0*x->LPF.x0+x->LPF.k1*x->LPF.x1+x->LPF.k2*x->LPF.x2-x->LPF.k3*x->LPF.y1-x->LPF.k4*x->LPF.y2); + x->LPF.y2 = x->LPF.y1; + x->LPF.y1 = x->LPF.y0; + x->LPF.x2 = x->LPF.x1; + x->LPF.x1 = x->LPF.x0; + + x->outvol = x->LPF.y0*x->x_volume; + + if(x->outvol > 1.0) + x->data = 1.0; + else if(x->outvol < -1.0) + x->data = -1.0; else - x->data = x->outvol; + x->data = x->outvol; - *(out++) = x->data; + *(out++) = x->data; - x->outval *= x->x_feedback; + x->outval *= x->x_feedback; } @@ -337,88 +338,88 @@ static void disto_preset(t_disto *x, t_float pnumber) { switch ( (int)pnumber ) { - /* "Hard Distortion 100-10000Hz" */ - case 1: - x->x_drive = 1.5; - x->x_drymix = 1.0; - x->x_wetmix = 0.5; - x->x_feedback = 0.0; - x->x_volume = 1.0; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 0.5; - x->x_lowpassfreq = 10000.0; - x->x_lowpassQ = 0.5; - break; - - /* "Hard Distortion 100-6000Hz" */ - case 2: - x->x_drive = 1.5; - x->x_drymix = 1.0; - x->x_wetmix = 0.5; - x->x_feedback = 0.0; - x->x_volume = 1.0; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 0.5; - x->x_lowpassfreq = 2000.0; - x->x_lowpassQ = 0.5; - break; - - /* "Very Hard Distortion" */ - case 3: - x->x_drive = 2.0; - x->x_drymix = 0.0; - x->x_wetmix = 1.0; - x->x_feedback = 1.0; - x->x_volume = 5.0; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 0.5; - x->x_lowpassfreq = 6000.0; - x->x_lowpassQ = 0.5; - break; - - /* "Medium Distortion 0.2" */ - case 4: - x->x_drive = 0.2; - x->x_drymix = 1.0; - x->x_wetmix = 1.0; - x->x_feedback = 0.1; - x->x_volume = 1.0; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 0.5; - x->x_lowpassfreq = 6000.0; - x->x_lowpassQ = 0.5; - break; - - /* "Medium Distortion 0.8" */ - case 5: - x->x_drive = 0.8; - x->x_drymix = 1.0; - x->x_wetmix = 1.0; - x->x_feedback = 0.1; - x->x_volume = 1.0; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 1.0; - x->x_lowpassfreq = 6000.0; - x->x_lowpassQ = 0.5; - break; - - /* "Soft Distortion 0.8" */ - case 6: - x->x_drive = 0.8; - x->x_drymix = 0.4; - x->x_wetmix = 0.8; - x->x_feedback = 0.0; - x->x_volume = 0.5; - x->x_hipassfreq = 100.0; - x->x_hipassQ = 1.0; - x->x_lowpassfreq = 10000.0; - x->x_lowpassQ = 0.5; - break; - - default: - post( "disto~ : unknown preset requested : %d", pnumber ); - return; - break; + /* "Hard Distortion 100-10000Hz" */ + case 1: + x->x_drive = 1.5; + x->x_drymix = 1.0; + x->x_wetmix = 0.5; + x->x_feedback = 0.0; + x->x_volume = 1.0; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 0.5; + x->x_lowpassfreq = 10000.0; + x->x_lowpassQ = 0.5; + break; + + /* "Hard Distortion 100-6000Hz" */ + case 2: + x->x_drive = 1.5; + x->x_drymix = 1.0; + x->x_wetmix = 0.5; + x->x_feedback = 0.0; + x->x_volume = 1.0; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 0.5; + x->x_lowpassfreq = 2000.0; + x->x_lowpassQ = 0.5; + break; + + /* "Very Hard Distortion" */ + case 3: + x->x_drive = 2.0; + x->x_drymix = 0.0; + x->x_wetmix = 1.0; + x->x_feedback = 1.0; + x->x_volume = 5.0; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 0.5; + x->x_lowpassfreq = 6000.0; + x->x_lowpassQ = 0.5; + break; + + /* "Medium Distortion 0.2" */ + case 4: + x->x_drive = 0.2; + x->x_drymix = 1.0; + x->x_wetmix = 1.0; + x->x_feedback = 0.1; + x->x_volume = 1.0; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 0.5; + x->x_lowpassfreq = 6000.0; + x->x_lowpassQ = 0.5; + break; + + /* "Medium Distortion 0.8" */ + case 5: + x->x_drive = 0.8; + x->x_drymix = 1.0; + x->x_wetmix = 1.0; + x->x_feedback = 0.1; + x->x_volume = 1.0; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 1.0; + x->x_lowpassfreq = 6000.0; + x->x_lowpassQ = 0.5; + break; + + /* "Soft Distortion 0.8" */ + case 6: + x->x_drive = 0.8; + x->x_drymix = 0.4; + x->x_wetmix = 0.8; + x->x_feedback = 0.0; + x->x_volume = 0.5; + x->x_hipassfreq = 100.0; + x->x_hipassQ = 1.0; + x->x_lowpassfreq = 10000.0; + x->x_lowpassQ = 0.5; + break; + + default: + post( "disto~ : unknown preset requested : %d", pnumber ); + return; + break; } disto_init_filters( x ); } @@ -428,13 +429,14 @@ static void disto_dsp(t_disto *x, t_signal **sp) dsp_add(disto_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n, x ); } - /* clean up */ +/* clean up */ static void disto_free(t_disto *x) { - if ( x->x_buf != NULL ) { - freebytes(x->x_buf, BFSZ*sizeof( double ) ); - post( "Freed %d bytes", BFSZ*sizeof( double ) ); - x->x_buf = NULL; + if ( x->x_buf != NULL ) + { + freebytes(x->x_buf, BFSZ*sizeof( double ) ); + post( "Freed %d bytes", BFSZ*sizeof( double ) ); + x->x_buf = NULL; } } @@ -458,8 +460,8 @@ static void *disto_new(void) if ( !( x->x_buf = ( double* ) getbytes( BFSZ*sizeof( double ) ) ) ) { - post ("disto~ : could not allocate buffer" ); - return NULL; + post ("disto~ : could not allocate buffer" ); + return NULL; } // set default parameters @@ -471,9 +473,9 @@ static void *disto_new(void) void disto_tilde_setup(void) { - post( disto_version ); + logpost(NULL, 4, "%s", disto_version ); disto_class = class_new(gensym("disto~"), (t_newmethod)disto_new, (t_method)disto_free, - sizeof(t_disto), 0, 0); + sizeof(t_disto), 0, 0); CLASS_MAINSIGNALIN( disto_class, t_disto, x_f ); class_addmethod(disto_class, (t_method)disto_drive, gensym("drive"), A_FLOAT, 0); diff --git a/externals/unauthorized/disto~/COPYING b/externals/unauthorized/disto~/COPYING deleted file mode 100644 index 2128a66ea7d038eecac13febce1a26b3da3b7159..0000000000000000000000000000000000000000 --- a/externals/unauthorized/disto~/COPYING +++ /dev/null @@ -1,280 +0,0 @@ - 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 diff --git a/externals/unauthorized/disto~/INSTALL b/externals/unauthorized/disto~/INSTALL deleted file mode 100644 index 319f22a48d27900462d0d6b15e380ebdc5bc5772..0000000000000000000000000000000000000000 --- a/externals/unauthorized/disto~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/disto~ - -make clean - -make - -make install - -open help-disto~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/disto~/Makefile b/externals/unauthorized/disto~/Makefile deleted file mode 100644 index f578588a2540879458c52065ac23d959840d6ae8..0000000000000000000000000000000000000000 --- a/externals/unauthorized/disto~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=disto~ -CSYM=disto~ - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd rs-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/disto~/README b/externals/unauthorized/disto~/README deleted file mode 100644 index 68b1d93b3866c7f78e3653edb90783a7c3870667..0000000000000000000000000000000000000000 --- a/externals/unauthorized/disto~/README +++ /dev/null @@ -1,24 +0,0 @@ -Version 0.01 -copyleft 2002 by Yves Degoyon. - -tarballs and updates available @ http://ydegoyon.free.fr - -disto~ : a kind of effect used in pop music, use it elsewhere - -the algorithm was taken from Digital Effects (DISTORT3), -a guitar effects software for DOS which rocks, written by Alexey Smoli -( http://st.karelia.ru/~smlalx/ ) - -To install disto~, follow the steps from INSTALL - -This software is published under GPL terms, see COPYING -for rights restrictions. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - diff --git a/externals/unauthorized/disto~/disto~-help.pd b/externals/unauthorized/disto~/disto~-help.pd deleted file mode 100644 index 593702b7264b71bc499e7383b68852048dd90623..0000000000000000000000000000000000000000 --- a/externals/unauthorized/disto~/disto~-help.pd +++ /dev/null @@ -1,73 +0,0 @@ -#N canvas 45 57 817 573 10; -#X text 389 525 comments & bugs @ ydegoyon.free.fr; -#X obj 125 503 dac~; -#X obj 146 432 rs-disto~; -#X msg 94 62 bang; -#X obj 93 84 openpanel; -#X obj 93 104 t s b; -#X obj 150 106 float \$0; -#X text 101 39 Step 1 : Load a sound file; -#X obj 93 127 route float; -#X obj 94 219 soundfiler; -#X text 151 55 ( maybe \, a guitar sound ? ); -#X obj 582 374 table \$0-sample; -#X msg 94 197 read -resize \$1 \$2; -#X obj 95 176 pack s s; -#X msg 146 307 bang; -#X text 191 307 Step 2 : Start playing; -#X obj 59 288 adc~; -#X text 226 433 Step 3 : Modify parameters; -#X text 584 510 ( http://st.karelia.ru/~smlalx ); -#X text 391 496 a DOS guitar effects software that rocks; -#X obj 606 263 loadbang; -#X msg 608 293 \; pd dsp 1; -#X text 390 482 the algorithm is borrowed from Digital Effects \,; -#X text 35 266 Plug a guitar ??; -#X msg 228 330 stop; -#X obj 146 330 metro 250; -#X text 431 111 Disto~ : distortion with highpass and lowpass filters -; -#X obj 93 150 makefilename %d-sample; -#X obj 80 423 *~ 0; -#X obj 154 461 *~ 0; -#X msg 172 380 1; -#X msg 207 379 0; -#X text 287 382 Normal sound; -#X msg 242 380 bang; -#X msg 178 404 1; -#X msg 213 403 0; -#X msg 248 404 bang; -#X text 355 405 Distorted sound; -#X text 392 510 written by (c) Alexei Smoli; -#X obj 146 354 tabplay~ \$0-sample; -#X obj 287 404 loadbang; -#X connect 2 0 29 0; -#X connect 3 0 4 0; -#X connect 4 0 5 0; -#X connect 5 0 13 0; -#X connect 5 1 6 0; -#X connect 6 0 8 0; -#X connect 8 0 27 0; -#X connect 12 0 9 0; -#X connect 13 0 12 0; -#X connect 14 0 25 0; -#X connect 16 0 2 0; -#X connect 20 0 21 0; -#X connect 24 0 25 0; -#X connect 25 0 39 0; -#X connect 27 0 13 1; -#X connect 28 0 1 0; -#X connect 28 0 1 1; -#X connect 29 0 1 0; -#X connect 29 0 1 1; -#X connect 30 0 28 1; -#X connect 31 0 29 1; -#X connect 33 0 31 0; -#X connect 33 0 30 0; -#X connect 34 0 29 1; -#X connect 35 0 28 1; -#X connect 36 0 35 0; -#X connect 36 0 34 0; -#X connect 39 0 2 0; -#X connect 39 0 28 0; -#X connect 40 0 36 0; diff --git a/externals/unauthorized/filterbank~/analyze-100.pd b/externals/unauthorized/examples/analyze-100.pd similarity index 91% rename from externals/unauthorized/filterbank~/analyze-100.pd rename to externals/unauthorized/examples/analyze-100.pd index 132876b91377a144a599fe613c61caed18197ce8..4006b295ebd8f532a12ac029445f1362b55efa2d 100644 --- a/externals/unauthorized/filterbank~/analyze-100.pd +++ b/externals/unauthorized/examples/analyze-100.pd @@ -1,4 +1,5 @@ -#N canvas 112 -6 970 685 10; +#N canvas 112 22 970 685 10; +#X declare -lib unauthorized; #X obj 236 283 filterbank~ 0 2000 100; #X obj 31 62 t s b; #X obj 80 68 float \$0; @@ -19,6 +20,7 @@ #X msg 484 52 location /Samples; #X obj 484 25 loadbang; #X obj 391 369 dac~; +#X obj 728 13 import unauthorized; #X connect 0 8 19 0; #X connect 0 15 19 1; #X connect 0 28 19 1; diff --git a/externals/unauthorized/randomblock~/mrandtab.pd b/externals/unauthorized/examples/mrandtab.pd similarity index 61% rename from externals/unauthorized/randomblock~/mrandtab.pd rename to externals/unauthorized/examples/mrandtab.pd index 157111ca71fcf44fd5df33f0bc616e451c18b776..6532ff170c2c1e294a1017f3a0fd256cb6faa94d 100644 --- a/externals/unauthorized/randomblock~/mrandtab.pd +++ b/externals/unauthorized/examples/mrandtab.pd @@ -1,6 +1,7 @@ #N canvas 187 22 737 487 10; +#X obj 300 10 import unauthorized; #X obj 138 151 dac~; #X obj 136 114 randtab; #X text 174 86 Everything is in the subpatch; -#X connect 1 0 0 0; -#X connect 1 0 0 1; +#X connect 2 0 1 0; +#X connect 2 0 1 1; diff --git a/externals/unauthorized/randomblock~/randtab.pd b/externals/unauthorized/examples/randtab.pd similarity index 97% rename from externals/unauthorized/randomblock~/randtab.pd rename to externals/unauthorized/examples/randtab.pd index 089a86e86675a10c00822fe08cdbdde461b39470..36226b399d7cbc56c9dd3b291874b640b4615df1 100644 --- a/externals/unauthorized/randomblock~/randtab.pd +++ b/externals/unauthorized/examples/randtab.pd @@ -14,7 +14,7 @@ #X obj 110 303 tabread4~ \$0-music; #X obj 20 331 print~; #X msg 19 307 bang; -#X obj 138 29 opanel; +#X obj 138 29 openpanel; #X obj 109 330 /~ 100; #X obj 34 235 randomblock~ 1000; #X obj 241 325 print~; diff --git a/externals/unauthorized/filterbank~/resynth-64.pd b/externals/unauthorized/examples/resynth-64.pd similarity index 93% rename from externals/unauthorized/filterbank~/resynth-64.pd rename to externals/unauthorized/examples/resynth-64.pd index bb5a93d7d01e9f906419ce38142a5873faba6dee..7dfdc243149716b87d45ccbe5db56b842bb6afa9 100644 --- a/externals/unauthorized/filterbank~/resynth-64.pd +++ b/externals/unauthorized/examples/resynth-64.pd @@ -1,7 +1,8 @@ -#N canvas 36 14 971 657 10; +#N canvas 159 22 971 657 10; +#X declare -lib unauthorized; #X obj 56 522 *~ 1; #X obj 103 522 / 100; -#X floatatom 147 522 5 0 0; +#X floatatom 147 522 5 0 0 0 - - -; #X obj 272 280 filterbank~ 0 1920 64; #X obj 31 62 t s b; #X obj 80 68 float \$0; @@ -19,13 +20,13 @@ #X obj 486 42 playlist all 200 200; #X msg 359 35 location /Samples; #X obj 359 12 loadbang; -#X obj 374 569 volpan; +#X obj 374 569 output~; #X msg 518 250 randomize 0; #X obj 354 123 s fbstep; -#X floatatom 354 100 5 0 0; +#X floatatom 354 100 5 0 0 0 - - -; #X msg 306 91 30; #X obj 306 68 loadbang; -#X floatatom 229 42 5 0 0; +#X floatatom 229 42 5 0 0 0 - - -; #X obj 210 68 s firstfreq; #X msg 181 35 15; #X obj 181 12 loadbang; @@ -39,7 +40,7 @@ #X obj 108 476 setosc 7; #X obj 199 521 *~ 1; #X obj 246 521 / 100; -#X floatatom 290 521 5 0 0; +#X floatatom 290 521 5 0 0 0 - - -; #X obj 250 313 setosc 8; #X obj 250 336 setosc 9; #X obj 250 359 setosc 10; @@ -50,7 +51,7 @@ #X obj 251 475 setosc 15; #X obj 339 519 *~ 1; #X obj 386 519 / 100; -#X floatatom 430 519 5 0 0; +#X floatatom 430 519 5 0 0 0 - - -; #X obj 390 311 setosc 16; #X obj 390 334 setosc 17; #X obj 390 357 setosc 18; @@ -61,7 +62,7 @@ #X obj 391 473 setosc 23; #X obj 479 519 *~ 1; #X obj 526 519 / 100; -#X floatatom 570 519 5 0 0; +#X floatatom 570 519 5 0 0 0 - - -; #X obj 530 311 setosc 24; #X obj 530 334 setosc 25; #X obj 530 357 setosc 26; @@ -72,7 +73,7 @@ #X obj 531 473 setosc 31; #X obj 621 518 *~ 1; #X obj 668 518 / 100; -#X floatatom 712 518 5 0 0; +#X floatatom 712 518 5 0 0 0 - - -; #X obj 672 310 setosc 32; #X obj 672 333 setosc 33; #X obj 672 356 setosc 34; @@ -83,7 +84,7 @@ #X obj 673 472 setosc 39; #X obj 762 519 *~ 1; #X obj 809 519 / 100; -#X floatatom 853 519 5 0 0; +#X floatatom 853 519 5 0 0 0 - - -; #X obj 813 311 setosc 40; #X obj 813 334 setosc 41; #X obj 813 357 setosc 42; @@ -94,7 +95,7 @@ #X obj 814 473 setosc 47; #X obj 903 519 *~ 1; #X obj 950 519 / 100; -#X floatatom 994 519 5 0 0; +#X floatatom 994 519 5 0 0 0 - - -; #X obj 954 311 setosc 48; #X obj 954 334 setosc 49; #X obj 954 357 setosc 50; @@ -105,7 +106,7 @@ #X obj 955 473 setosc 55; #X obj 1041 518 *~ 1; #X obj 1088 518 / 100; -#X floatatom 1132 518 5 0 0; +#X floatatom 1132 518 5 0 0 0 - - -; #X obj 1092 310 setosc 56; #X obj 1092 333 setosc 57; #X obj 1092 356 setosc 58; @@ -114,6 +115,7 @@ #X obj 1092 425 setosc 61; #X obj 1092 448 setosc 62; #X obj 1093 472 setosc 63; +#X obj 682 9 import unauthorized; #X connect 0 0 20 0; #X connect 1 0 0 1; #X connect 2 0 1 0; diff --git a/externals/unauthorized/filterbank~/setosc.pd b/externals/unauthorized/examples/setosc.pd similarity index 100% rename from externals/unauthorized/filterbank~/setosc.pd rename to externals/unauthorized/examples/setosc.pd diff --git a/externals/unauthorized/audience~/speaker.gif b/externals/unauthorized/examples/speaker.gif similarity index 100% rename from externals/unauthorized/audience~/speaker.gif rename to externals/unauthorized/examples/speaker.gif diff --git a/externals/unauthorized/examples/test-streaming-mp3.pd b/externals/unauthorized/examples/test-streaming-mp3.pd new file mode 100644 index 0000000000000000000000000000000000000000..b097d7848403b74061873f4deb123564e91d43a3 --- /dev/null +++ b/externals/unauthorized/examples/test-streaming-mp3.pd @@ -0,0 +1,98 @@ +#N canvas 252 67 986 678 10; +#X declare -lib unauthorized; +#X msg 63 88 bang; +#X obj 63 108 openpanel; +#X obj 63 130 t s b; +#X obj 63 167 pack s s; +#X obj 99 130 float \$0; +#X text 51 69 Step 1 : Load a sound file; +#X obj 117 167 makefilename %d-sample; +#X msg 443 310 \; pd dsp 1; +#X msg 509 310 \; pd dsp 0; +#X obj 454 284 loadbang; +#X obj 62 247 mp3streamout~; +#X floatatom 63 270 5 0 0 0 - - -; +#X obj 62 211 readsf~; +#X msg 62 188 open \$1 \$2; +#X msg 33 178 1; +#X msg 265 215 disconnect; +#X obj 63 147 route float; +#X msg 569 77 bang; +#X obj 569 97 openpanel; +#X obj 569 119 t s b; +#X obj 569 156 pack s s; +#X obj 605 119 float \$0; +#X text 557 58 Step 1 : Load a sound file; +#X obj 623 156 makefilename %d-sample; +#X obj 568 236 mp3streamout~; +#X floatatom 569 259 5 0 0 0 - - -; +#X obj 568 200 readsf~; +#X msg 568 177 open \$1 \$2; +#X msg 539 167 1; +#X msg 784 207 disconnect; +#X obj 569 136 route float; +#X obj 364 492 dac~; +#X obj 361 468 *~; +#X floatatom 416 495 5 0 0 0 - - -; +#X symbolatom 459 467 15 0 0 0 - - -; +#X obj 407 470 / 100; +#X obj 122 500 dac~; +#X obj 119 476 *~; +#X floatatom 174 503 5 0 0 0 - - -; +#X symbolatom 217 475 10 0 0 0 - - -; +#X obj 165 478 / 100; +#X obj 96 449 mp3streamin~ 5001 1; +#X obj 345 440 mp3streamin~ 5000 1; +#X msg 777 179 connect yves 5001; +#X msg 246 258 mpeg 32 2 5; +#X msg 246 258 mpeg 32 2 5; +#X msg 246 294 mpeg 224 2 5; +#X msg 258 187 connect localhost 5000; +#X msg 263 155 connect dregs 5000; +#X obj 816 13 import unauthorized; +#X connect 0 0 1 0; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 2 1 4 0; +#X connect 3 0 13 0; +#X connect 4 0 16 0; +#X connect 6 0 3 1; +#X connect 9 0 7 0; +#X connect 10 0 11 0; +#X connect 12 0 10 0; +#X connect 12 0 10 1; +#X connect 13 0 12 0; +#X connect 14 0 12 0; +#X connect 15 0 10 0; +#X connect 16 0 6 0; +#X connect 17 0 18 0; +#X connect 18 0 19 0; +#X connect 19 0 20 0; +#X connect 19 1 21 0; +#X connect 20 0 27 0; +#X connect 21 0 30 0; +#X connect 23 0 20 1; +#X connect 24 0 25 0; +#X connect 26 0 24 0; +#X connect 26 0 24 1; +#X connect 27 0 26 0; +#X connect 28 0 26 0; +#X connect 29 0 24 0; +#X connect 30 0 23 0; +#X connect 32 0 31 0; +#X connect 32 0 31 1; +#X connect 33 0 35 0; +#X connect 35 0 32 1; +#X connect 37 0 36 0; +#X connect 37 0 36 1; +#X connect 38 0 40 0; +#X connect 40 0 37 1; +#X connect 41 0 37 0; +#X connect 41 2 39 0; +#X connect 42 0 32 0; +#X connect 42 2 34 0; +#X connect 43 0 24 0; +#X connect 44 0 10 0; +#X connect 46 0 10 0; +#X connect 47 0 10 0; +#X connect 48 0 10 0; diff --git a/externals/unauthorized/audience~/wanderer.gif b/externals/unauthorized/examples/wanderer.gif similarity index 100% rename from externals/unauthorized/audience~/wanderer.gif rename to externals/unauthorized/examples/wanderer.gif diff --git a/externals/unauthorized/examples/xmms.pd b/externals/unauthorized/examples/xmms.pd new file mode 100644 index 0000000000000000000000000000000000000000..fb37327f89378d85da75d2d7306a51f790c94563 --- /dev/null +++ b/externals/unauthorized/examples/xmms.pd @@ -0,0 +1,146 @@ +#N canvas 146 29 756 589 10; +#X declare -lib unauthorized; +#X obj 411 164 mp3fileout~; +#X floatatom 411 185 5 0 0 0 - - -; +#X floatatom 456 185 5 0 0 0 - - -; +#X msg 409 133 open \$1; +#X msg 466 133 start; +#X msg 511 134 stop; +#X text 534 174 Number of frames emitted; +#X text 396 204 Connection state; +#X symbolatom 127 306 80 0 0 0 - - -; +#X floatatom 520 83 5 0 0 0 - - -; +#X obj 20 77 playlist mp3 300 200; +#X msg 651 57 bang; +#X text 23 37 Step 1 : point to your MP3s directory; +#X obj 357 533 dac~; +#X symbolatom 131 458 10 0 0 0 - - -; +#X text 127 472 Incomer's address; +#X obj 349 490 *~ 1; +#X floatatom 461 533 5 0 0 0 - - -; +#X obj 427 533 / 100; +#X obj 390 490 *~ 1; +#X text 501 535 Volume; +#X msg 336 58 connect localhost 5672; +#X obj 95 361 mp3streamin~ 5672 1; +#X text 295 35 Step 2 : connect to the streamer; +#X text 65 305 Playing :; +#X msg 463 84 seek \$1; +#X text 566 31 Step 3 :start random play; +#X obj 657 430 loadbang; +#X msg 656 454 \; pd dsp 1; +#X msg 379 240 seek \$1; +#X obj 437 239 hsl 128 15 0 1e+07 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 0; +#X msg 547 134 disconnect; +#X obj 573 57 random 1000; +#X msg 620 93 seed \$1; +#X floatatom 673 93 5 0 0 0 - - -; +#X msg 634 240 bang; +#X text 575 284 Step 3 bis :start seq play; +#X obj 592 240 countn; +#X obj 578 262 - 1; +#X floatatom 531 263 5 0 0 0 - - -; +#X obj 551 207 spigot; +#X obj 599 206 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 +1; +#X msg 624 206 1; +#X obj 618 115 spigot; +#X obj 666 114 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 +1; +#X msg 691 114 1; +#X obj 362 461 ekwalizer --------------------------; +#X msg 544 335 100; +#X obj 385 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 7900 1; +#X obj 408 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 7900 1; +#X obj 432 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 7900 1; +#X obj 454 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 7900 1; +#X obj 477 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 498 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 516 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 534 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 552 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 573 363 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 +-1 -1 0 1; +#X obj 579 335 loadbang; +#X obj 494 559 loadbang; +#X msg 463 559 50; +#X obj 259 506 compressor~; +#X floatatom 279 454 5 0 0 0 - - -; +#X obj 241 529 env~; +#X obj 266 483 / 100; +#X obj 618 7 import unauthorized; +#X connect 0 0 1 0; +#X connect 0 1 2 0; +#X connect 0 2 40 0; +#X connect 0 2 43 0; +#X connect 3 0 0 0; +#X connect 4 0 0 0; +#X connect 5 0 0 0; +#X connect 10 0 8 0; +#X connect 10 0 3 0; +#X connect 11 0 32 0; +#X connect 11 0 45 0; +#X connect 16 0 61 0; +#X connect 17 0 18 0; +#X connect 18 0 16 1; +#X connect 18 0 19 1; +#X connect 19 0 61 0; +#X connect 21 0 0 0; +#X connect 21 0 4 0; +#X connect 22 0 46 0; +#X connect 22 1 46 0; +#X connect 22 2 14 0; +#X connect 25 0 10 0; +#X connect 27 0 28 0; +#X connect 29 0 0 0; +#X connect 30 0 29 0; +#X connect 31 0 0 0; +#X connect 32 0 9 0; +#X connect 32 0 25 0; +#X connect 33 0 32 0; +#X connect 34 0 33 0; +#X connect 35 0 37 0; +#X connect 35 0 42 0; +#X connect 37 0 38 0; +#X connect 38 0 25 0; +#X connect 38 0 39 0; +#X connect 40 0 37 0; +#X connect 41 0 40 1; +#X connect 42 0 41 0; +#X connect 43 0 32 0; +#X connect 44 0 43 1; +#X connect 45 0 44 0; +#X connect 46 0 19 0; +#X connect 46 0 16 0; +#X connect 47 0 48 0; +#X connect 47 0 49 0; +#X connect 47 0 50 0; +#X connect 47 0 51 0; +#X connect 48 0 46 1; +#X connect 49 0 46 2; +#X connect 50 0 46 3; +#X connect 51 0 46 4; +#X connect 52 0 46 5; +#X connect 53 0 46 6; +#X connect 54 0 46 7; +#X connect 55 0 46 8; +#X connect 56 0 46 9; +#X connect 57 0 46 10; +#X connect 58 0 47 0; +#X connect 59 0 60 0; +#X connect 60 0 17 0; +#X connect 61 0 13 0; +#X connect 61 0 13 1; +#X connect 61 0 63 0; +#X connect 62 0 64 0; +#X connect 64 0 61 1; diff --git a/externals/unauthorized/scrolllist/yesterday.txt b/externals/unauthorized/examples/yesterday.txt similarity index 100% rename from externals/unauthorized/scrolllist/yesterday.txt rename to externals/unauthorized/examples/yesterday.txt diff --git a/externals/unauthorized/exciter/exciter-help.pd b/externals/unauthorized/exciter-help.pd similarity index 100% rename from externals/unauthorized/exciter/exciter-help.pd rename to externals/unauthorized/exciter-help.pd diff --git a/externals/unauthorized/exciter.c b/externals/unauthorized/exciter.c new file mode 100644 index 0000000000000000000000000000000000000000..e4df7af500fce8736727ba436a4b3a7d4d399a8b --- /dev/null +++ b/externals/unauthorized/exciter.c @@ -0,0 +1,824 @@ +/* Copyright (c) 2002 Yves Degoyon. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ +/* */ +/* exciter : a graphical object which enables */ +/* to schedule bang events on a time scale */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* Made while listening to : */ +/* */ +/* "You're a maniac" */ +/* "To fullfill the emptyness" */ +/* Mecano ( no, not the spanish ones !!! ) - Escape The Human Myth */ +/* ---------------------------------------------------------------------------- */ + + +#include +#include +#include +#include +#include +#include +#include +#include "m_pd.h" +#include "m_imp.h" +#include "g_canvas.h" + +#include "exciter.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + +/* needed to create a exciter from PD's menu +void canvas_objtext(t_glist *gl, int xpos, int ypos, int selected, t_binbuf *b); +void canvas_startmotion(t_canvas *x); +*/ + +#define DEFAULT_EXCITER_WIDTH 200 +#define DEFAULT_EXCITER_HEIGHT 200 +#define DEFAULT_EXCITER_GRAIN 0.1 +#define DEFAULT_EXCITER_NBEVENTS 8 + +#define EXCITER_PIXEL_GRAIN 5 + +static char *exciter_version = "exciter: a bang-events sequencer, version 0.5 (ydegoyon@free.fr)"; + +t_widgetbehavior exciter_widgetbehavior; +static t_class *exciter_class; +static int excitercount=0; + +static int guidebug=0; +static int pointsize = 5; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ + post(a,b,c,d,e,f);\ + sys_vgui(a,b,c,d,e,f) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g);\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ + post(a,b,c,d,e,f,g,h);\ + sys_vgui(a,b,c,d,e,f,g,h) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i);\ + sys_vgui(a,b,c,d,e,f,g,h,i) + +#define SYS_VGUI13(a,b,c,d,e,f,g,h,i,j,k,l,m) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i,j,k,l,m);\ + sys_vgui(a,b,c,d,e,f,g,h,i,j,k,l,m) + +/* drawing functions */ + +/* draw an event */ +static void exciter_draw_gem(t_exciter *x, t_glist *glist, t_int ix, t_int iy) +{ + t_int polyray = ( x->x_height / x->x_nbevents) / 2; + t_canvas *canvas=glist_getcanvas(glist); + + SYS_VGUI13(".x%lx.c create polygon %d %d %d %d %d %d %d %d -outline #000000 -fill #FFFFFF -tags %xEVENT%.4d%.4d\n", + canvas, + text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN, + text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents + 2*polyray, + text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents + polyray, + text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + 2*polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents, + text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents - polyray, + x, ix, iy); +} + +/* delete an event */ +static void exciter_delete_gem(t_exciter *x, t_glist *glist, t_int ix, t_int iy) +{ + t_canvas *canvas=glist_getcanvas(glist); + + SYS_VGUI5(".x%lx.c delete %xEVENT%.4d%.4d\n", canvas, x, ix, iy ); +} + +static void exciter_draw_update(t_exciter *x, t_glist *glist) +{ + int ei, gi; + + t_canvas *canvas=glist_getcanvas(glist); + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) == 1 ) + { + exciter_draw_gem(x, glist, gi, ei ); + } + else + { + exciter_delete_gem(x, glist, gi, ei ); + } + } + } +} + +static void exciter_draw_new(t_exciter *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int ei; + + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #902181 -tags %xLINE\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height, + x); + SYS_VGUI5(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0 s\" -tags %xLOWERCAPTION\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height + 10, x ); + SYS_VGUI6(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%.2f s\" -tags %xHIGHERCAPTION\n", + canvas, text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height + 10, + x->x_width/EXCITER_PIXEL_GRAIN*x->x_timegrain , x); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN\n", + canvas, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) - 2, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) , + x); + if ( x->x_nbevents > 1 ) + { + for ( ei=0; eix_nbevents; ei++ ) + { + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", + canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2, + x, ei); + } + } + else + { + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", + canvas, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2, + x, 0); + } + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void exciter_draw_move(t_exciter *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int polyray = ( x->x_height / x->x_nbevents) / 2; + t_int ei, gi; + + SYS_VGUI7(".x%lx.c coords %xLINE %d %d %d %d \n", + canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height + ); + SYS_VGUI5(".x%lx.c coords %xLOWERCAPTION %d %d\n", + canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height + 10 ); + SYS_VGUI5(".x%lx.c coords %xHIGHERCAPTION %d %d\n", + canvas, x, text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height + 10); + SYS_VGUI7(".x%lx.c coords %xIN %d %d %d %d\n", + canvas, x, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) - 2, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) + ); + if ( x->x_nbevents > 1 ) + { + for ( ei=0; eix_nbevents; ei++ ) + { + SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n", + canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2 + ); + } + } + else + { + SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n", + canvas, x, 0, text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + 5, + text_ypix(&x->x_obj, glist) + x->x_height + 2 + ); + } + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + SYS_VGUI13(".x%lx.c coords %xEVENT%.4d%.4d %d %d %d %d %d %d %d %d\n", + canvas, x, gi, ei, + text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN, + text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents + 2*polyray, + text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents + polyray, + text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + 2*polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents, + text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + polyray, + text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents - polyray + ); + } + } + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void exciter_draw_erase(t_exciter* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + int i, ei, gi; + + SYS_VGUI3(".x%lx.c delete %xLINE\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xLOWERCAPTION\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xHIGHERCAPTION\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xIN\n", canvas, x ); + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) != 0 ) + { + exciter_delete_gem( x, glist, gi, ei ); + } + } + SYS_VGUI4(".x%lx.c delete %xOUT%d\n", canvas, x, ei ); + } +} + +static void exciter_draw_select(t_exciter* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if(x->x_selected) + { + /* sets the main item in blue */ + SYS_VGUI3(".x%lx.c itemconfigure %xLINE -outline #0000FF\n", canvas, x); + + } + else + { + /* sets the main item in black */ + SYS_VGUI3(".x%lx.c itemconfigure %xLINE -outline #000000\n", canvas, x); + } +} + +/* ------------------------ exciter widgetbehaviour----------------------------- */ + + +static void exciter_getrect(t_gobj *z, t_glist *owner, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_exciter* x = (t_exciter*)z; + + *xp1 = text_xpix(&x->x_obj, owner); + *yp1 = text_ypix(&x->x_obj, owner); + *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; + *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; +} + +static void exciter_save(t_gobj *z, t_binbuf *b) +{ + t_exciter *x = (t_exciter *)z; + int ei,gi; + + binbuf_addv(b, "ssiisiiifii", gensym("#X"),gensym("obj"), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, + atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), + x->x_width, x->x_height, + x->x_nbevents, x->x_timegrain, + x->x_loop, x->x_save + ); + if ( x->x_save ) + { + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) == 1 ) + { + // post( "exciter : saving ( %d, %d )", ei, gi ); + binbuf_addv(b, "ii", ei, gi ); + } + } + } + } + binbuf_addv(b, ";"); +} + +static void exciter_properties(t_gobj *z, t_glist *owner) +{ + char buf[800]; + t_exciter *x=(t_exciter *)z; + + sprintf(buf, "pdtk_exciter_dialog %%s %d %d %d %.2f %d %d\n", + (int)x->x_width, (int)x->x_height, (int)x->x_nbevents, x->x_timegrain, x->x_loop, x->x_save ); + // post("exciter_properties : %s", buf ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); +} + +static void exciter_select(t_gobj *z, t_glist *glist, int selected) +{ + t_exciter *x = (t_exciter *)z; + + x->x_selected = selected; + exciter_draw_select( x, glist ); +} + +static void exciter_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_exciter *x = (t_exciter *)z; + + post("exciter_vis : %d", vis ); + if (vis) + { + exciter_draw_new( x, glist ); + exciter_draw_update( x, glist ); + } + else + { + exciter_draw_erase( x, glist ); + } +} + +/* resuming the triggering of events */ +static void exciter_resume(t_exciter *x) +{ + x->x_started = 1; +} + +/* pausing the triggering of events */ +static void exciter_pause(t_exciter *x) +{ + x->x_started = 0; +} + +/* trigger events -- no dsp processing */ +static void exciter_dialog(t_exciter *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int onbevents, owidth, ei, gi, bi; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if ( !x ) + { + post( "exciter : error :tried to set properties on an unexisting object" ); + } + onbevents = x->x_nbevents; + owidth = x->x_width; + exciter_draw_erase(x, x->x_glist); + if ( argc < 6 ) + { + post( "exciter : error in the number of arguments ( %d )", argc ); + return; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) + { + post( "exciter : wrong arguments" ); + return; + } + + exciter_pause( x ); + x->x_width = argv[0].a_w.w_float; + if ( x->x_width <= 0 ) x->x_width = 100; + x->x_height = argv[1].a_w.w_float; + if ( x->x_height <= 0 ) x->x_height = 100; + x->x_nbevents = argv[2].a_w.w_float; + if ( x->x_nbevents < 1 ) x->x_nbevents = 1; + x->x_timegrain = argv[3].a_w.w_float; + if ( x->x_timegrain < 0.01 ) + { + post ("exciter : incorrect time grain : forced to 1 tick ( 10 ms )" ); + x->x_timegrain = 0.01; + } + x->x_loop = argv[4].a_w.w_float; + x->x_save = argv[5].a_w.w_float; + x->x_started = 0; + x->x_reltime = 0L; + x->x_plooptime = 0L; + x->x_gindex = -1; + x->x_looplength = x->x_timegrain * x->x_width * 1000 / EXCITER_PIXEL_GRAIN; + + // re-allocate arrays and keep old events + post( "exciter : re-allocate events" ); + if ( onbevents != x->x_nbevents || owidth != x->x_width ) + { + t_int mevents = ( onbevents > x->x_nbevents ) ? x->x_nbevents : onbevents; + t_int mwidth = ( owidth > x->x_width ) ? x->x_width : owidth; + t_int *newbangs; + + newbangs = (t_int*) getbytes( x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + memset( newbangs, 0x0, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + for ( ei=0; eix_width/EXCITER_PIXEL_GRAIN)+gi ) = + *(x->x_sbangs+ei*(owidth/EXCITER_PIXEL_GRAIN)+gi ); + } + } + if ( x->x_sbangs ) + freebytes( x->x_sbangs, onbevents*owidth/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + x->x_sbangs = newbangs; + } + + // re-allocate outlets + post( "exciter : re-allocate outlets" ); + if ( onbevents != x->x_nbevents ) + { + post( "exciter : cleaning up old outlets" ); + if ( x->x_bangs ) + { + for ( ei=0; eix_bangs[ei] ); + } + freebytes( x->x_bangs, onbevents*sizeof(t_outlet*) ); + } + post( "exciter : creating new ones" ); + x->x_bangs = (t_outlet **) getbytes( x->x_nbevents*sizeof(t_outlet **) ); + for ( bi=0; bix_nbevents; bi++ ) + { + x->x_bangs[bi] = outlet_new( &x->x_obj, &s_bang ); + } + } + canvas_fixlinesfor( canvas, (t_text*)x ); + exciter_draw_new(x, x->x_glist); + exciter_draw_update(x, x->x_glist); + exciter_resume( x ); +} + +static void exciter_delete(t_gobj *z, t_glist *glist) +{ + canvas_deletelinesfor(glist, (t_text *)z); +} + +static void exciter_displace(t_gobj *z, t_glist *glist, int dx, int dy) +{ + t_exciter *x = (t_exciter *)z; + t_int xold = text_xpix(&x->x_obj, glist); + t_int yold = text_ypix(&x->x_obj, glist); + + // post( "exciter_displace dx=%d dy=%d", dx, dy ); + + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; + if(xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist)) + { + exciter_draw_move(x, glist); + } +} + +static int exciter_click(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_exciter* x = (t_exciter *)z; + t_int nevent, npix; + + if ( doit) + { + nevent = ( 1 - ( ( ypix - ( (float)x->x_height / (float) x->x_nbevents / 2 ) + - text_ypix(&x->x_obj, glist)) / (float)x->x_height ) )*(x->x_nbevents-1); + npix = ( xpix - 1 - text_xpix(&x->x_obj, glist)) / EXCITER_PIXEL_GRAIN; + // post( "exciter : selected event (%d,%d)", nevent, npix ); + // set or unset event + { + if ( *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) == 1 ) + { + *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) = 0; + exciter_delete_gem( x, glist, npix, nevent ); + } + else + { + *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) = 1; + exciter_draw_gem( x, glist, npix, nevent ); + } + } + } + return (1); +} + +static t_exciter *exciter_new(t_symbol *s, int argc, t_atom *argv) +{ + int bi, i, ei, gi; + t_exciter *x; + t_pd *x2; + + // post( "exciter_new : create : %s argc =%d", s->s_name, argc ); + + x = (t_exciter *)pd_new(exciter_class); + x->x_glist = (t_glist *) canvas_getcurrent(); + // new exciter created from the gui + if ( argc != 0 ) + { + if ( argc < 6 ) + { + post( "exciter : error in the number of arguments ( %d )", argc ); + return NULL; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) + { + post( "exciter : wrong arguments" ); + return NULL; + } + + x->x_width = argv[0].a_w.w_float; + x->x_height = argv[1].a_w.w_float; + x->x_nbevents = argv[2].a_w.w_float; + if ( x->x_nbevents < 1 ) x->x_nbevents = 1; + x->x_timegrain = argv[3].a_w.w_float; + x->x_loop = argv[4].a_w.w_float; + x->x_save = argv[5].a_w.w_float; + } + else + { + x->x_width = DEFAULT_EXCITER_WIDTH; + x->x_height = DEFAULT_EXCITER_HEIGHT; + x->x_nbevents = DEFAULT_EXCITER_NBEVENTS; + x->x_timegrain = DEFAULT_EXCITER_GRAIN; + x->x_loop = 1; + x->x_save = 1; + + } + + // common fields for new and restored exciters + x->x_sbangs = (t_int*) getbytes( x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) = 0; + } + } + memset( x->x_sbangs, 0x0, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + x->x_selected = 0; + x->x_started = 0; + x->x_reltime = 0L; + x->x_plooptime = 0L; + x->x_gindex = -1; + x->x_looplength = x->x_timegrain * x->x_width * 1000 / EXCITER_PIXEL_GRAIN; + + x->x_bangs = (t_outlet **) getbytes( x->x_nbevents*sizeof(t_outlet **) ); + for ( bi=0; bix_nbevents; bi++ ) + { + x->x_bangs[bi] = outlet_new( &x->x_obj, &s_bang ); + } + + // post( "exciter : argc : %d", argc ); + if ( ( argc != 0 ) && ( x->x_save ) ) + { + int ai = 6; + int si = 0; + + while ( ai < argc - 1 ) + { + *(x->x_sbangs + +((int)argv[ai].a_w.w_float)*(x->x_width/EXCITER_PIXEL_GRAIN) + +(int)argv[ai+1].a_w.w_float) = 1; + ai += 2; + } + } + post( "exciter_new width: %d height : %d", x->x_width, x->x_height ); + + return (x); +} + +static void exciter_dump(t_exciter *x) +{ + t_int ei, gi; + + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) != 0 ) + { + post( "exciter : value ( %d, %d ) : %d", ei, gi, + *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) ); + } + } + } +} + +/* clearing all events */ +static void exciter_clear(t_exciter *x) +{ + t_int ei, gi; + + for ( ei=0; eix_nbevents; ei++ ) + { + for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) + { + *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) = 0; + } + } + exciter_draw_update( x, x->x_glist ); +} + + +/* starting the triggering of events */ +static void exciter_start(t_exciter *x) +{ + x->x_started = 1; + x->x_reltime = 0L; + x->x_plooptime = 0L; + x->x_gindex = -1; +} + +/* stop the triggering of events */ +static void exciter_stop(t_exciter *x) +{ + x->x_started = 0; +} + +/* reset the triggering of events */ +static void exciter_reset(t_exciter *x) +{ + x->x_reltime = 0L; + x->x_plooptime = 0L; + x->x_gindex = -1; +} + +static t_int *exciter_perform(t_int *w) +{ + t_int ei, gi; + t_int gstart, gend; + t_exciter* x = (t_exciter*)(w[1]); + struct timeval tv; + struct timezone tz; + long long looptime = 0L; + double preltime = x->x_reltime; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if ( x->x_started ) + { + // get current time in ms + gettimeofday( &tv, &tz ); + looptime = tv.tv_sec*1000 + tv.tv_usec/1000; + if ( x->x_plooptime == 0L ) + { + x->x_plooptime = looptime; + } + x->x_reltime += ( looptime - x->x_plooptime ); + if ( x->x_reltime > x->x_looplength ) + { + if ( x->x_loop ) + { + // post( "exciter : restarting loop" ); + x->x_reltime = 0; + preltime = 0; + x->x_gindex = -1; + } + else + { + // post( "exciter : end of the loop" ); + x->x_reltime = 0; + x->x_started = 0; + } + } + gstart = preltime/(x->x_timegrain*1000); + gend = x->x_reltime/(x->x_timegrain*1000); + + // prevent overflow due to long long precision + if ( gstart > x->x_width/EXCITER_PIXEL_GRAIN-1 ) gstart = x->x_width/EXCITER_PIXEL_GRAIN-1; + if ( gstart < 0 ) gstart = 0; + if ( gend > x->x_width/EXCITER_PIXEL_GRAIN-1 ) gend = x->x_width/EXCITER_PIXEL_GRAIN-1 ; + if ( gend < 0 ) gend = 0; + if ( gstart > x->x_gindex ) + { + // post( "exciter : focus slice : (%d,%d)", gstart, gend ); + for ( gi=x->x_gindex+1; gi<=gend; gi++ ) + { + for ( ei=0; eix_nbevents; ei++ ) + { + if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) == 1 ) + { + outlet_bang( x->x_bangs[ ei ] ); + SYS_VGUI5(".x%lx.c itemconfigure %xEVENT%.4d%.4d -fill #00FF00\n", + canvas, x, gi, ei); + } + } + } + // unfocus previous events + if ( gstart >= x->x_width/EXCITER_PIXEL_GRAIN - 1) + gstart = x->x_width/EXCITER_PIXEL_GRAIN; // not too proud of this one + // post( "exciter : unfocus slice : (%d,%d)", x->x_gindex, gstart-1 ); + for ( gi=x->x_gindex; gix_nbevents; ei++ ) + { + if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) == 1 ) + { + SYS_VGUI5(".x%lx.c itemconfigure %xEVENT%.4d%.4d -fill #FFFFFF\n", + canvas, x, gi, ei); + } + } + } + x->x_gindex = gend; + } + } + + x->x_plooptime = looptime; + return (w+2); +} + +static void exciter_dsp(t_exciter *x, t_signal **sp) +{ + dsp_add(exciter_perform, 1, x); +} + +static void exciter_free(t_exciter *x) +{ + t_int ei; + + // post( "exciter~: exciter_free" ); + if ( x->x_bangs ) + { + for ( ei=0; eix_nbevents; ei++ ) + { + outlet_free( x->x_bangs[ei] ); + } + freebytes( x->x_bangs, x->x_nbevents*sizeof(t_outlet*) ); + } + if ( x->x_sbangs ) + { + freebytes( x->x_sbangs, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); + } +} + +void exciter_setup(void) +{ + logpost(NULL, 4, "%s", exciter_version ); + exciter_class = class_new(gensym("exciter"), (t_newmethod)exciter_new, + (t_method)exciter_free, sizeof(t_exciter), 0, A_GIMME, 0); + class_addmethod(exciter_class, (t_method)exciter_dialog, gensym("dialog"), A_GIMME, 0); + class_addmethod(exciter_class, (t_method)exciter_dump, gensym("dump"), 0); + class_addmethod(exciter_class, (t_method)exciter_clear, gensym("clear"), 0); + class_addmethod(exciter_class, (t_method)exciter_start, gensym("start"), 0); + class_addmethod(exciter_class, (t_method)exciter_stop, gensym("stop"), 0); + class_addmethod(exciter_class, (t_method)exciter_reset, gensym("reset"), 0); + class_addmethod(exciter_class, (t_method)exciter_pause, gensym("pause"), 0); + class_addmethod(exciter_class, (t_method)exciter_resume, gensym("resume"), 0); + class_addmethod(exciter_class, (t_method)exciter_dsp, gensym("dsp"), A_CANT, A_NULL); + exciter_widgetbehavior.w_getrectfn = exciter_getrect; + exciter_widgetbehavior.w_displacefn = exciter_displace; + exciter_widgetbehavior.w_selectfn = exciter_select; + exciter_widgetbehavior.w_activatefn = NULL; + exciter_widgetbehavior.w_deletefn = exciter_delete; + exciter_widgetbehavior.w_visfn = exciter_vis; + exciter_widgetbehavior.w_clickfn = exciter_click; + +#if PD_MINOR_VERSION >= 37 + class_setpropertiesfn(exciter_class, exciter_properties); + class_setsavefn(exciter_class, exciter_save); +#else + exciter_widgetbehavior.w_propertiesfn = exciter_properties; + exciter_widgetbehavior.w_savefn = exciter_save; +#endif + + class_setwidget(exciter_class, &exciter_widgetbehavior); + + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + exciter_class->c_externdir->s_name, exciter_class->c_name->s_name); +} diff --git a/externals/unauthorized/exciter/exciter.h b/externals/unauthorized/exciter.h similarity index 100% rename from externals/unauthorized/exciter/exciter.h rename to externals/unauthorized/exciter.h diff --git a/externals/unauthorized/exciter/exciter.tk b/externals/unauthorized/exciter.tcl similarity index 98% rename from externals/unauthorized/exciter/exciter.tk rename to externals/unauthorized/exciter.tcl index ece532d92636e130feb43752f327001f3dd7b522..11b94e45407995e6416afa508fdf4cd2b493855a 100644 --- a/externals/unauthorized/exciter/exciter.tk +++ b/externals/unauthorized/exciter.tcl @@ -25,13 +25,13 @@ proc exciter_apply {id} { [eval concat $$var_graph_loop] \ [eval concat $$var_graph_save] \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc exciter_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc exciter_ok {id} { @@ -62,7 +62,7 @@ proc pdtk_exciter_dialog {id width height nbevents timegrain loop save } { set $var_graph_loop $loop set $var_graph_save $save - toplevel $id -class [winfo class .] + toplevel $id wm title $id {exciter} wm protocol $id WM_DELETE_WINDOW [concat exciter_cancel $id] diff --git a/externals/unauthorized/exciter/CHANGES.LOG b/externals/unauthorized/exciter/CHANGES.LOG old mode 100755 new mode 100644 diff --git a/externals/unauthorized/exciter/INSTALL b/externals/unauthorized/exciter/INSTALL deleted file mode 100644 index 55894c3de2508cb961478d87e826c0b1d92edb55..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/exciter - -make clean - -make - -make install - -open help-exciter.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/exciter/Makefile b/externals/unauthorized/exciter/Makefile deleted file mode 100644 index 22f0d81dc511f44710f6b3b7bd8cb1dbd6d8cc28..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -NAME=exciter -CSYM=exciter - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk >$*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/exciter/README b/externals/unauthorized/exciter/README deleted file mode 100644 index b57b6c91658c6da2ad6533b02ba8be670198cffe..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/README +++ /dev/null @@ -1,20 +0,0 @@ -Version 0.01 -copyright 2002 by Yves Degoyon. - -tarballs and updates available @ http://ydegoyon.free.fr - -exciter : a bang-events sequencer -the need for it sprung out of a talking with Nicolas Lhommet. - -To install exciter, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - diff --git a/externals/unauthorized/exciter/exciter.c b/externals/unauthorized/exciter/exciter.c deleted file mode 100644 index d026452d56c37385ce1d88f97d4872393fa3eae0..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/exciter.c +++ /dev/null @@ -1,822 +0,0 @@ -/* Copyright (c) 2002 Yves Degoyon. */ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ -/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -/* */ -/* exciter : a graphical object which enables */ -/* to schedule bang events on a time scale */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* Made while listening to : */ -/* */ -/* "You're a maniac" */ -/* "To fullfill the emptyness" */ -/* Mecano ( no, not the spanish ones !!! ) - Escape The Human Myth */ -/* ---------------------------------------------------------------------------- */ - - -#include -#include -#include -#include -#include -#include -#include -#include "m_pd.h" -#include "m_imp.h" -#include "g_canvas.h" - -#include "exciter.h" - -#ifdef NT -#include -#else -#include -#endif - -/* needed to create a exciter from PD's menu -void canvas_objtext(t_glist *gl, int xpos, int ypos, int selected, t_binbuf *b); -void canvas_startmotion(t_canvas *x); -*/ - -#define DEFAULT_EXCITER_WIDTH 200 -#define DEFAULT_EXCITER_HEIGHT 200 -#define DEFAULT_EXCITER_GRAIN 0.1 -#define DEFAULT_EXCITER_NBEVENTS 8 - -#define EXCITER_PIXEL_GRAIN 5 - -static char *exciter_version = "exciter: a bang-events sequencer, version 0.5 (ydegoyon@free.fr)"; - -t_widgetbehavior exciter_widgetbehavior; -static t_class *exciter_class; -static int excitercount=0; - -static int guidebug=0; -static int pointsize = 5; - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g);\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h);\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i);\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -#define SYS_VGUI13(a,b,c,d,e,f,g,h,i,j,k,l,m) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j,k,l,m);\ - sys_vgui(a,b,c,d,e,f,g,h,i,j,k,l,m) - -/* drawing functions */ - -/* draw an event */ -static void exciter_draw_gem(t_exciter *x, t_glist *glist, t_int ix, t_int iy) -{ - t_int polyray = ( x->x_height / x->x_nbevents) / 2; - t_canvas *canvas=glist_getcanvas(glist); - - SYS_VGUI13(".x%x.c create polygon %d %d %d %d %d %d %d %d -outline #000000 -fill #FFFFFF -tags %xEVENT%.4d%.4d\n", - canvas, - text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN, - text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents + 2*polyray, - text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents + polyray, - text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + 2*polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents, - text_xpix(&x->x_obj, glist) + ix*EXCITER_PIXEL_GRAIN + polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (iy+1)*x->x_height/x->x_nbevents - polyray, - x, ix, iy); -} - -/* delete an event */ -static void exciter_delete_gem(t_exciter *x, t_glist *glist, t_int ix, t_int iy) -{ - t_canvas *canvas=glist_getcanvas(glist); - - SYS_VGUI5(".x%x.c delete %xEVENT%.4d%.4d\n", canvas, x, ix, iy ); -} - -static void exciter_draw_update(t_exciter *x, t_glist *glist) -{ - int ei, gi; - - t_canvas *canvas=glist_getcanvas(glist); - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) == 1 ) - { - exciter_draw_gem(x, glist, gi, ei ); - } - else - { - exciter_delete_gem(x, glist, gi, ei ); - } - } - } -} - -static void exciter_draw_new(t_exciter *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int ei; - - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #902181 -tags %xLINE\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height, - x); - SYS_VGUI5(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0 s\" -tags %xLOWERCAPTION\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height + 10, x ); - SYS_VGUI6(".x%x.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%.2f s\" -tags %xHIGHERCAPTION\n", - canvas, text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height + 10, - x->x_width/EXCITER_PIXEL_GRAIN*x->x_timegrain , x); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN\n", - canvas, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) - 2, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) , - x); - if ( x->x_nbevents > 1 ) - { - for ( ei=0; eix_nbevents; ei++ ) - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", - canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2, - x, ei); - } - } - else - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n", - canvas, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2, - x, 0); - } - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void exciter_draw_move(t_exciter *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int polyray = ( x->x_height / x->x_nbevents) / 2; - t_int ei, gi; - - SYS_VGUI7(".x%x.c coords %xLINE %d %d %d %d \n", - canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height - ); - SYS_VGUI5(".x%x.c coords %xLOWERCAPTION %d %d\n", - canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height + 10 ); - SYS_VGUI5(".x%x.c coords %xHIGHERCAPTION %d %d\n", - canvas, x, text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height + 10); - SYS_VGUI7(".x%x.c coords %xIN %d %d %d %d\n", - canvas, x, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) - 2, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) - ); - if ( x->x_nbevents > 1 ) - { - for ( ei=0; eix_nbevents; ei++ ) - { - SYS_VGUI8(".x%x.c coords %xOUT%d %d %d %d %d\n", - canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbevents-1) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2 - ); - } - } - else - { - SYS_VGUI8(".x%x.c coords %xOUT%d %d %d %d %d\n", - canvas, x, 0, text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + 5, - text_ypix(&x->x_obj, glist) + x->x_height + 2 - ); - } - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - SYS_VGUI13(".x%x.c coords %xEVENT%.4d%.4d %d %d %d %d %d %d %d %d\n", - canvas, x, gi, ei, - text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN, - text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents + 2*polyray, - text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents + polyray, - text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + 2*polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents, - text_xpix(&x->x_obj, glist) + gi*EXCITER_PIXEL_GRAIN + polyray, - text_ypix(&x->x_obj, glist) + x->x_height - (ei+1)*x->x_height/x->x_nbevents - polyray - ); - } - } - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void exciter_draw_erase(t_exciter* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - int i, ei, gi; - - SYS_VGUI3(".x%x.c delete %xLINE\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xLOWERCAPTION\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xHIGHERCAPTION\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xIN\n", canvas, x ); - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) != 0 ) - { - exciter_delete_gem( x, glist, gi, ei ); - } - } - SYS_VGUI4(".x%x.c delete %xOUT%d\n", canvas, x, ei ); - } -} - -static void exciter_draw_select(t_exciter* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if(x->x_selected) - { - /* sets the main item in blue */ - SYS_VGUI3(".x%x.c itemconfigure %xLINE -outline #0000FF\n", canvas, x); - - } - else - { - /* sets the main item in black */ - SYS_VGUI3(".x%x.c itemconfigure %xLINE -outline #000000\n", canvas, x); - } -} - -/* ------------------------ exciter widgetbehaviour----------------------------- */ - - -static void exciter_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - t_exciter* x = (t_exciter*)z; - - *xp1 = text_xpix(&x->x_obj, owner); - *yp1 = text_ypix(&x->x_obj, owner); - *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; - *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; -} - -static void exciter_save(t_gobj *z, t_binbuf *b) -{ - t_exciter *x = (t_exciter *)z; - int ei,gi; - - binbuf_addv(b, "ssiisiiifii", gensym("#X"),gensym("obj"), - (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_width, x->x_height, - x->x_nbevents, x->x_timegrain, - x->x_loop, x->x_save - ); - if ( x->x_save ) - { - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - if( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) == 1 ) - { - // post( "exciter : saving ( %d, %d )", ei, gi ); - binbuf_addv(b, "ii", ei, gi ); - } - } - } - } - binbuf_addv(b, ";"); -} - -static void exciter_properties(t_gobj *z, t_glist *owner) -{ - char buf[800]; - t_exciter *x=(t_exciter *)z; - - sprintf(buf, "pdtk_exciter_dialog %%s %d %d %d %.2f %d %d\n", - x->x_width, x->x_height, x->x_nbevents, x->x_timegrain, x->x_loop, x->x_save ); - // post("exciter_properties : %s", buf ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); -} - -static void exciter_select(t_gobj *z, t_glist *glist, int selected) -{ - t_exciter *x = (t_exciter *)z; - - x->x_selected = selected; - exciter_draw_select( x, glist ); -} - -static void exciter_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_exciter *x = (t_exciter *)z; - - post("exciter_vis : %d", vis ); - if (vis) - { - exciter_draw_new( x, glist ); - exciter_draw_update( x, glist ); - } - else - { - exciter_draw_erase( x, glist ); - } -} - - /* resuming the triggering of events */ -static void exciter_resume(t_exciter *x) -{ - x->x_started = 1; -} - - /* pausing the triggering of events */ -static void exciter_pause(t_exciter *x) -{ - x->x_started = 0; -} - - /* trigger events -- no dsp processing */ -static void exciter_dialog(t_exciter *x, t_symbol *s, int argc, t_atom *argv) -{ - t_int onbevents, owidth, ei, gi, bi; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if ( !x ) { - post( "exciter : error :tried to set properties on an unexisting object" ); - } - onbevents = x->x_nbevents; - owidth = x->x_width; - exciter_draw_erase(x, x->x_glist); - if ( argc < 6 ) - { - post( "exciter : error in the number of arguments ( %d )", argc ); - return; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) - { - post( "exciter : wrong arguments" ); - return; - } - - exciter_pause( x ); - x->x_width = argv[0].a_w.w_float; - if ( x->x_width <= 0 ) x->x_width = 100; - x->x_height = argv[1].a_w.w_float; - if ( x->x_height <= 0 ) x->x_height = 100; - x->x_nbevents = argv[2].a_w.w_float; - if ( x->x_nbevents < 1 ) x->x_nbevents = 1; - x->x_timegrain = argv[3].a_w.w_float; - if ( x->x_timegrain < 0.01 ) - { - post ("exciter : incorrect time grain : forced to 1 tick ( 10 ms )" ); - x->x_timegrain = 0.01; - } - x->x_loop = argv[4].a_w.w_float; - x->x_save = argv[5].a_w.w_float; - x->x_started = 0; - x->x_reltime = 0L; - x->x_plooptime = 0L; - x->x_gindex = -1; - x->x_looplength = x->x_timegrain * x->x_width * 1000 / EXCITER_PIXEL_GRAIN; - - // re-allocate arrays and keep old events - post( "exciter : re-allocate events" ); - if ( onbevents != x->x_nbevents || owidth != x->x_width ) - { - t_int mevents = ( onbevents > x->x_nbevents ) ? x->x_nbevents : onbevents; - t_int mwidth = ( owidth > x->x_width ) ? x->x_width : owidth; - t_int *newbangs; - - newbangs = (t_int*) getbytes( x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - memset( newbangs, 0x0, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - for ( ei=0; eix_width/EXCITER_PIXEL_GRAIN)+gi ) = - *(x->x_sbangs+ei*(owidth/EXCITER_PIXEL_GRAIN)+gi ); - } - } - if ( x->x_sbangs ) - freebytes( x->x_sbangs, onbevents*owidth/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - x->x_sbangs = newbangs; - } - - // re-allocate outlets - post( "exciter : re-allocate outlets" ); - if ( onbevents != x->x_nbevents ) - { - post( "exciter : cleaning up old outlets" ); - if ( x->x_bangs ) - { - for ( ei=0; eix_bangs[ei] ); - } - freebytes( x->x_bangs, onbevents*sizeof(t_outlet*) ); - } - post( "exciter : creating new ones" ); - x->x_bangs = (t_outlet **) getbytes( x->x_nbevents*sizeof(t_outlet **) ); - for ( bi=0; bix_nbevents; bi++ ) - { - x->x_bangs[bi] = outlet_new( &x->x_obj, &s_bang ); - } - } - canvas_fixlinesfor( canvas, (t_text*)x ); - exciter_draw_new(x, x->x_glist); - exciter_draw_update(x, x->x_glist); - exciter_resume( x ); -} - -static void exciter_delete(t_gobj *z, t_glist *glist) -{ - canvas_deletelinesfor(glist, (t_text *)z); -} - -static void exciter_displace(t_gobj *z, t_glist *glist, int dx, int dy) -{ - t_exciter *x = (t_exciter *)z; - t_int xold = text_xpix(&x->x_obj, glist); - t_int yold = text_ypix(&x->x_obj, glist); - - // post( "exciter_displace dx=%d dy=%d", dx, dy ); - - x->x_obj.te_xpix += dx; - x->x_obj.te_ypix += dy; - if(xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist)) - { - exciter_draw_move(x, glist); - } -} - -static int exciter_click(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) -{ - t_exciter* x = (t_exciter *)z; - t_int nevent, npix; - - if ( doit) - { - nevent = ( 1 - ( ( ypix - ( (float)x->x_height / (float) x->x_nbevents / 2 ) - - text_ypix(&x->x_obj, glist)) / (float)x->x_height ) )*(x->x_nbevents-1); - npix = ( xpix - 1 - text_xpix(&x->x_obj, glist)) / EXCITER_PIXEL_GRAIN; - // post( "exciter : selected event (%d,%d)", nevent, npix ); - // set or unset event - { - if ( *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) == 1 ) - { - *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) = 0; - exciter_delete_gem( x, glist, npix, nevent ); - } - else - { - *(x->x_sbangs+nevent*(x->x_width/EXCITER_PIXEL_GRAIN)+npix ) = 1; - exciter_draw_gem( x, glist, npix, nevent ); - } - } - } - return (1); -} - -static t_exciter *exciter_new(t_symbol *s, int argc, t_atom *argv) -{ - int bi, i, ei, gi; - t_exciter *x; - t_pd *x2; - - // post( "exciter_new : create : %s argc =%d", s->s_name, argc ); - - x = (t_exciter *)pd_new(exciter_class); - x->x_glist = (t_glist *) canvas_getcurrent(); - // new exciter created from the gui - if ( argc != 0 ) - { - if ( argc < 6 ) - { - post( "exciter : error in the number of arguments ( %d )", argc ); - return NULL; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT ) - { - post( "exciter : wrong arguments" ); - return NULL; - } - - x->x_width = argv[0].a_w.w_float; - x->x_height = argv[1].a_w.w_float; - x->x_nbevents = argv[2].a_w.w_float; - if ( x->x_nbevents < 1 ) x->x_nbevents = 1; - x->x_timegrain = argv[3].a_w.w_float; - x->x_loop = argv[4].a_w.w_float; - x->x_save = argv[5].a_w.w_float; - } - else - { - x->x_width = DEFAULT_EXCITER_WIDTH; - x->x_height = DEFAULT_EXCITER_HEIGHT; - x->x_nbevents = DEFAULT_EXCITER_NBEVENTS; - x->x_timegrain = DEFAULT_EXCITER_GRAIN; - x->x_loop = 1; - x->x_save = 1; - - } - - // common fields for new and restored exciters - x->x_sbangs = (t_int*) getbytes( x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi) = 0; - } - } - memset( x->x_sbangs, 0x0, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - x->x_selected = 0; - x->x_started = 0; - x->x_reltime = 0L; - x->x_plooptime = 0L; - x->x_gindex = -1; - x->x_looplength = x->x_timegrain * x->x_width * 1000 / EXCITER_PIXEL_GRAIN; - - x->x_bangs = (t_outlet **) getbytes( x->x_nbevents*sizeof(t_outlet **) ); - for ( bi=0; bix_nbevents; bi++ ) - { - x->x_bangs[bi] = outlet_new( &x->x_obj, &s_bang ); - } - - // post( "exciter : argc : %d", argc ); - if ( ( argc != 0 ) && ( x->x_save ) ) - { - int ai = 6; - int si = 0; - - while ( ai < argc - 1 ) - { - *(x->x_sbangs - +((int)argv[ai].a_w.w_float)*(x->x_width/EXCITER_PIXEL_GRAIN) - +(int)argv[ai+1].a_w.w_float) = 1; - ai += 2; - } - } - post( "exciter_new width: %d height : %d", x->x_width, x->x_height ); - - return (x); -} - -static void exciter_dump(t_exciter *x) -{ - t_int ei, gi; - - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) != 0 ) - { - post( "exciter : value ( %d, %d ) : %d", ei, gi, - *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) ); - } - } - } -} - - /* clearing all events */ -static void exciter_clear(t_exciter *x) -{ - t_int ei, gi; - - for ( ei=0; eix_nbevents; ei++ ) - { - for ( gi=0; gi<(x->x_width/EXCITER_PIXEL_GRAIN); gi++ ) - { - *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) = 0; - } - } - exciter_draw_update( x, x->x_glist ); -} - - - /* starting the triggering of events */ -static void exciter_start(t_exciter *x) -{ - x->x_started = 1; - x->x_reltime = 0L; - x->x_plooptime = 0L; - x->x_gindex = -1; -} - - /* stop the triggering of events */ -static void exciter_stop(t_exciter *x) -{ - x->x_started = 0; -} - - /* reset the triggering of events */ -static void exciter_reset(t_exciter *x) -{ - x->x_reltime = 0L; - x->x_plooptime = 0L; - x->x_gindex = -1; -} - -static t_int *exciter_perform(t_int *w) -{ - t_int ei, gi; - t_int gstart, gend; - t_exciter* x = (t_exciter*)(w[1]); - struct timeval tv; - struct timezone tz; - long long looptime = 0L; - double preltime = x->x_reltime; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if ( x->x_started ) - { - // get current time in ms - gettimeofday( &tv, &tz ); - looptime = tv.tv_sec*1000 + tv.tv_usec/1000; - if ( x->x_plooptime == 0L ) - { - x->x_plooptime = looptime; - } - x->x_reltime += ( looptime - x->x_plooptime ); - if ( x->x_reltime > x->x_looplength ) - { - if ( x->x_loop ) - { - // post( "exciter : restarting loop" ); - x->x_reltime = 0; - preltime = 0; - x->x_gindex = -1; - } - else - { - // post( "exciter : end of the loop" ); - x->x_reltime = 0; - x->x_started = 0; - } - } - gstart = preltime/(x->x_timegrain*1000); - gend = x->x_reltime/(x->x_timegrain*1000); - - // prevent overflow due to long long precision - if ( gstart > x->x_width/EXCITER_PIXEL_GRAIN-1 ) gstart = x->x_width/EXCITER_PIXEL_GRAIN-1; - if ( gstart < 0 ) gstart = 0; - if ( gend > x->x_width/EXCITER_PIXEL_GRAIN-1 ) gend = x->x_width/EXCITER_PIXEL_GRAIN-1 ; - if ( gend < 0 ) gend = 0; - if ( gstart > x->x_gindex ) - { - // post( "exciter : focus slice : (%d,%d)", gstart, gend ); - for ( gi=x->x_gindex+1; gi<=gend; gi++ ) - { - for ( ei=0; eix_nbevents; ei++ ) - { - if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) == 1 ) - { - outlet_bang( x->x_bangs[ ei ] ); - SYS_VGUI5(".x%x.c itemconfigure %xEVENT%.4d%.4d -fill #00FF00\n", - canvas, x, gi, ei); - } - } - } - // unfocus previous events - if ( gstart >= x->x_width/EXCITER_PIXEL_GRAIN - 1) - gstart = x->x_width/EXCITER_PIXEL_GRAIN; // not too proud of this one - // post( "exciter : unfocus slice : (%d,%d)", x->x_gindex, gstart-1 ); - for ( gi=x->x_gindex; gix_nbevents; ei++ ) - { - if ( *(x->x_sbangs+ei*(x->x_width/EXCITER_PIXEL_GRAIN)+gi ) == 1 ) - { - SYS_VGUI5(".x%x.c itemconfigure %xEVENT%.4d%.4d -fill #FFFFFF\n", - canvas, x, gi, ei); - } - } - } - x->x_gindex = gend; - } - } - - x->x_plooptime = looptime; - return (w+2); -} - -static void exciter_dsp(t_exciter *x, t_signal **sp) -{ - dsp_add(exciter_perform, 1, x); -} - -static void exciter_free(t_exciter *x) -{ - t_int ei; - - // post( "exciter~: exciter_free" ); - if ( x->x_bangs ) - { - for ( ei=0; eix_nbevents; ei++ ) - { - outlet_free( x->x_bangs[ei] ); - } - freebytes( x->x_bangs, x->x_nbevents*sizeof(t_outlet*) ); - } - if ( x->x_sbangs ) - { - freebytes( x->x_sbangs, x->x_nbevents*x->x_width/EXCITER_PIXEL_GRAIN*sizeof(t_int) ); - } -} - -void exciter_setup(void) -{ - post( exciter_version ); -#include "exciter.tk2c" - exciter_class = class_new(gensym("exciter"), (t_newmethod)exciter_new, - (t_method)exciter_free, sizeof(t_exciter), 0, A_GIMME, 0); - class_addmethod(exciter_class, (t_method)exciter_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(exciter_class, (t_method)exciter_dump, gensym("dump"), 0); - class_addmethod(exciter_class, (t_method)exciter_clear, gensym("clear"), 0); - class_addmethod(exciter_class, (t_method)exciter_start, gensym("start"), 0); - class_addmethod(exciter_class, (t_method)exciter_stop, gensym("stop"), 0); - class_addmethod(exciter_class, (t_method)exciter_reset, gensym("reset"), 0); - class_addmethod(exciter_class, (t_method)exciter_pause, gensym("pause"), 0); - class_addmethod(exciter_class, (t_method)exciter_resume, gensym("resume"), 0); - class_addmethod(exciter_class, (t_method)exciter_dsp, gensym("dsp"), A_CANT, A_NULL); - exciter_widgetbehavior.w_getrectfn = exciter_getrect; - exciter_widgetbehavior.w_displacefn = exciter_displace; - exciter_widgetbehavior.w_selectfn = exciter_select; - exciter_widgetbehavior.w_activatefn = NULL; - exciter_widgetbehavior.w_deletefn = exciter_delete; - exciter_widgetbehavior.w_visfn = exciter_vis; - exciter_widgetbehavior.w_clickfn = exciter_click; - -#if PD_MINOR_VERSION >= 37 - class_setpropertiesfn(exciter_class, exciter_properties); - class_setsavefn(exciter_class, exciter_save); -#else - exciter_widgetbehavior.w_propertiesfn = exciter_properties; - exciter_widgetbehavior.w_savefn = exciter_save; -#endif - - class_setwidget(exciter_class, &exciter_widgetbehavior); - -} diff --git a/externals/unauthorized/exciter/exciter.tk2c b/externals/unauthorized/exciter/exciter.tk2c deleted file mode 100755 index a28572d12387c166efee45f5102c5612169db69b..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/exciter.tk2c +++ /dev/null @@ -1,94 +0,0 @@ -// ########### exciter procedures -- ydegoyon@free.fr ######### -sys_gui("proc exciter_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_nbevents [concat graph_nbevents_$vid]\n"); -sys_gui("global $var_graph_nbevents\n"); -sys_gui("set var_graph_timegrain [concat graph_timegrain_$vid]\n"); -sys_gui("global $var_graph_timegrain\n"); -sys_gui("set var_graph_loop [concat graph_loop_$vid]\n"); -sys_gui("global $var_graph_loop\n"); -sys_gui("set var_graph_save [concat graph_save_$vid]\n"); -sys_gui("global $var_graph_save\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_nbevents] [eval concat $$var_graph_timegrain] [eval concat $$var_graph_loop] [eval concat $$var_graph_save] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc exciter_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc exciter_ok {id} {\n"); -sys_gui("exciter_apply $id\n"); -sys_gui("exciter_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_exciter_dialog {id width height nbevents timegrain loop save } {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_nbevents [concat graph_nbevents_$vid]\n"); -sys_gui("global $var_graph_nbevents\n"); -sys_gui("set var_graph_timegrain [concat graph_timegrain_$vid]\n"); -sys_gui("global $var_graph_timegrain\n"); -sys_gui("set var_graph_loop [concat graph_loop_$vid]\n"); -sys_gui("global $var_graph_loop\n"); -sys_gui("set var_graph_save [concat graph_save_$vid]\n"); -sys_gui("global $var_graph_save\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_nbevents $nbevents\n"); -sys_gui("set $var_graph_timegrain $timegrain\n"); -sys_gui("set $var_graph_loop $loop\n"); -sys_gui("set $var_graph_save $save\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {exciter}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat exciter_cancel $id]\n"); -sys_gui("label $id.label -text {EXCITER PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"exciter_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"exciter_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"exciter_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.1rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.1rangef.lwidth $id.1rangef.width -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.2rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.2rangef.lheight $id.2rangef.height -side left\n"); -sys_gui("frame $id.3rangef\n"); -sys_gui("pack $id.3rangef -side top\n"); -sys_gui("label $id.3rangef.lnbevents -text \"Nb Events :\"\n"); -sys_gui("entry $id.3rangef.nbevents -textvariable $var_graph_nbevents -width 7\n"); -sys_gui("pack $id.3rangef.lnbevents $id.3rangef.nbevents -side left\n"); -sys_gui("frame $id.4rangef\n"); -sys_gui("pack $id.4rangef -side top\n"); -sys_gui("label $id.4rangef.ltimegrain -text \"Time Grain (seconds) :\"\n"); -sys_gui("entry $id.4rangef.timegrain -textvariable $var_graph_timegrain -width 7\n"); -sys_gui("pack $id.4rangef.ltimegrain $id.4rangef.timegrain -side left\n"); -sys_gui("checkbutton $id.loop -text {Loop} -variable $var_graph_loop -anchor w\n"); -sys_gui("pack $id.loop -side top\n"); -sys_gui("checkbutton $id.save -text {Save contents} -variable $var_graph_save -anchor w\n"); -sys_gui("pack $id.save -side top\n"); -sys_gui("bind $id.1rangef.width [concat exciter_ok $id]\n"); -sys_gui("bind $id.2rangef.height [concat exciter_ok $id]\n"); -sys_gui("bind $id.3rangef.nbevents [concat exciter_ok $id]\n"); -sys_gui("bind $id.4rangef.timegrain [concat exciter_ok $id]\n"); -sys_gui("focus $id.1rangef.width\n"); -sys_gui("}\n"); -// ########### exciter procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/exciter/tk2c.bash b/externals/unauthorized/exciter/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/exciter/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/filterbank~/filterbank~-help.pd b/externals/unauthorized/filterbank~-help.pd similarity index 100% rename from externals/unauthorized/filterbank~/filterbank~-help.pd rename to externals/unauthorized/filterbank~-help.pd diff --git a/externals/unauthorized/filterbank~/filterbank~.c b/externals/unauthorized/filterbank~.c similarity index 50% rename from externals/unauthorized/filterbank~/filterbank~.c rename to externals/unauthorized/filterbank~.c index 736101cf1e3aea28099abcb3c38f4436c23567ab..a25508426f5e36745e50d59fadc9c8df45fd147b 100644 --- a/externals/unauthorized/filterbank~/filterbank~.c +++ b/externals/unauthorized/filterbank~.c @@ -33,9 +33,12 @@ #include "filterbank~.h" -#ifdef NT -#include -#else +#ifdef _WIN32 +# include +# define random rand +#endif + +#ifndef _MSC_VER /* only MSVC doesn't have unistd.h */ #include #endif @@ -123,44 +126,44 @@ static void miller_sigbp_docoef(t_filterbank_tilde *x, t_int index, t_floatarg f static void filterbank_draw_new(t_filterbank_tilde *x, t_glist *glist) { - t_canvas *canvas=glist_getcanvas(glist); - int fi; - - // draw the square - { - - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xFILTERBANK\n", - canvas, - text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_width, - text_ypix(&x->x_obj, glist) + x->x_height, - x); - - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #000000 -tags %xSIN\n", - canvas, - text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist)-1, - text_xpix(&x->x_obj, glist)+7, - text_ypix(&x->x_obj, glist), - x); - - for ( fi=0; fix_nbfilters; fi++ ) - { - char color[8]; - - sprintf( color, "#%.2x%.2x%.2x", (int)random() % 256, (int)random() % 256, (int)random() % 256 ); - - SYS_VGUI11(".x%x.c create polygon %d %d %d %d %d %d -outline #000000 -fill %s -tags %xFILTER%d\n", - canvas, - text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters, - text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters + x->x_width/(2*x->x_nbfilters), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + (fi+1)*x->x_width/x->x_nbfilters, - text_ypix(&x->x_obj, glist), - color, x, fi); - } + t_canvas *canvas=glist_getcanvas(glist); + int fi; + + // draw the square + { + + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #FFFFFF -tags %xFILTERBANK\n", + canvas, + text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + x->x_width, + text_ypix(&x->x_obj, glist) + x->x_height, + x); + + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #000000 -tags %xSIN\n", + canvas, + text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist)-1, + text_xpix(&x->x_obj, glist)+7, + text_ypix(&x->x_obj, glist), + x); + + for ( fi=0; fix_nbfilters; fi++ ) + { + char color[8]; + + sprintf( color, "#%.2x%.2x%.2x", (int)random() % 256, (int)random() % 256, (int)random() % 256 ); + + SYS_VGUI11(".x%lx.c create polygon %d %d %d %d %d %d -outline #000000 -fill %s -tags %xFILTER%d\n", + canvas, + text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters, + text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters + x->x_width/(2*x->x_nbfilters), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + (fi+1)*x->x_width/x->x_nbfilters, + text_ypix(&x->x_obj, glist), + color, x, fi); + } } canvas_fixlinesfor( canvas, (t_text*)x ); @@ -171,33 +174,33 @@ static void filterbank_draw_move(t_filterbank_tilde *x, t_glist *glist) t_canvas *canvas=glist_getcanvas(glist); t_int fi; - SYS_VGUI7(".x%x.c coords %xFILTERBANK %d %d %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_width, - text_ypix(&x->x_obj, glist) + x->x_height + SYS_VGUI7(".x%lx.c coords %xFILTERBANK %d %d %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + x->x_width, + text_ypix(&x->x_obj, glist) + x->x_height ); - SYS_VGUI7(".x%x.c coords %xSIN %d %d %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist), - text_ypix(&x->x_obj, glist)-1, - text_xpix(&x->x_obj, glist)+7, - text_ypix(&x->x_obj, glist) + SYS_VGUI7(".x%lx.c coords %xSIN %d %d %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist), + text_ypix(&x->x_obj, glist)-1, + text_xpix(&x->x_obj, glist)+7, + text_ypix(&x->x_obj, glist) ); for ( fi=0; fix_nbfilters; fi++ ) { - SYS_VGUI10(".x%x.c coords %xFILTER%d %d %d %d %d %d %d\n", - canvas, x, fi, - text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters, - text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters + x->x_width/(2*x->x_nbfilters), - text_ypix(&x->x_obj, glist) + x->x_height, - text_xpix(&x->x_obj, glist) + (fi+1)*x->x_width/x->x_nbfilters, - text_ypix(&x->x_obj, glist) - ); + SYS_VGUI10(".x%lx.c coords %xFILTER%d %d %d %d %d %d %d\n", + canvas, x, fi, + text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters, + text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + fi*x->x_width/x->x_nbfilters + x->x_width/(2*x->x_nbfilters), + text_ypix(&x->x_obj, glist) + x->x_height, + text_xpix(&x->x_obj, glist) + (fi+1)*x->x_width/x->x_nbfilters, + text_ypix(&x->x_obj, glist) + ); } canvas_fixlinesfor( canvas, (t_text*)x ); @@ -205,14 +208,14 @@ static void filterbank_draw_move(t_filterbank_tilde *x, t_glist *glist) static void filterbank_draw_erase(t_filterbank_tilde* x,t_glist* glist) { - t_canvas *canvas=glist_getcanvas(glist); - int fi; - - SYS_VGUI3(".x%x.c delete %xFILTERBANK\n", canvas, x ); - SYS_VGUI3(".x%x.c delete %xSIN\n", canvas, x ); + t_canvas *canvas=glist_getcanvas(glist); + int fi; + + SYS_VGUI3(".x%lx.c delete %xFILTERBANK\n", canvas, x ); + SYS_VGUI3(".x%lx.c delete %xSIN\n", canvas, x ); for ( fi=0; fix_nbfilters; fi++ ) { - SYS_VGUI4(".x%x.c delete %xFILTER%d\n", canvas, x, fi ); + SYS_VGUI4(".x%lx.c delete %xFILTER%d\n", canvas, x, fi ); } } @@ -224,11 +227,11 @@ static void filterbank_draw_select(t_filterbank_tilde* x,t_glist* glist) if(x->x_selected) { /* sets the item in blue */ - SYS_VGUI3(".x%x.c itemconfigure %xFILTERBANK -outline #0000FF\n", canvas, x); + SYS_VGUI3(".x%lx.c itemconfigure %xFILTERBANK -outline #0000FF\n", canvas, x); } else { - SYS_VGUI3(".x%x.c itemconfigure %xFILTERBANK -outline #000000\n", canvas, x); + SYS_VGUI3(".x%lx.c itemconfigure %xFILTERBANK -outline #000000\n", canvas, x); } } @@ -236,152 +239,154 @@ static void filterbank_draw_select(t_filterbank_tilde* x,t_glist* glist) static void filterbank_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) + int *xp1, int *yp1, int *xp2, int *yp2) { - t_filterbank_tilde* x = (t_filterbank_tilde*)z; + t_filterbank_tilde* x = (t_filterbank_tilde*)z; - *xp1 = text_xpix(&x->x_obj, owner); - *yp1 = text_ypix(&x->x_obj, owner); - *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; - *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; + *xp1 = text_xpix(&x->x_obj, owner); + *yp1 = text_ypix(&x->x_obj, owner); + *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; + *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; } static void filterbank_save(t_gobj *z, t_binbuf *b) { - t_filterbank_tilde *x = (t_filterbank_tilde *)z; - t_int ii; + t_filterbank_tilde *x = (t_filterbank_tilde *)z; + t_int ii; - binbuf_addv(b, "ssiisiii", gensym("#X"),gensym("obj"), - (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_lowfreq, x->x_highfreq, + binbuf_addv(b, "ssiisiii", gensym("#X"),gensym("obj"), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, + atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), + x->x_lowfreq, x->x_highfreq, x->x_nbfilters ); - binbuf_addv(b, ";"); + binbuf_addv(b, ";"); } static void filterbank_properties(t_gobj *z, t_glist *owner) { - char buf[800]; - t_filterbank_tilde *x=(t_filterbank_tilde *)z; + char buf[800]; + t_filterbank_tilde *x=(t_filterbank_tilde *)z; - sprintf(buf, "pdtk_filterbank_dialog %%s %d %d\n", - x->x_lowfreq, x->x_highfreq ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); + sprintf(buf, "pdtk_filterbank_dialog %%s %d %d\n", + (int)x->x_lowfreq, (int)x->x_highfreq ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); } static void filterbank_select(t_gobj *z, t_glist *glist, int selected) { - t_filterbank_tilde *x = (t_filterbank_tilde *)z; + t_filterbank_tilde *x = (t_filterbank_tilde *)z; - x->x_selected = selected; - filterbank_draw_select( x, glist ); + x->x_selected = selected; + filterbank_draw_select( x, glist ); } static void filterbank_vis(t_gobj *z, t_glist *glist, int vis) { - t_filterbank_tilde *x = (t_filterbank_tilde *)z; - - // post( "filterbank~ : vis : %d", vis ); - if (vis) - { - filterbank_draw_new( x, glist ); - } - else - { - filterbank_draw_erase( x, glist ); - } + t_filterbank_tilde *x = (t_filterbank_tilde *)z; + + // post( "filterbank~ : vis : %d", vis ); + if (vis) + { + filterbank_draw_new( x, glist ); + } + else + { + filterbank_draw_erase( x, glist ); + } } static void filterbank_dialog(t_filterbank_tilde *x, t_symbol *s, int argc, t_atom *argv) { - t_int olowfreq = x->x_lowfreq; - t_int ohighfreq = x->x_highfreq; - t_int fi, ei; - t_int dspstate; - t_float Q; - t_float afreq, abandwidth; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - // !!paranoid - if ( !x ) { - post( "filterbank~ : error :tried to set properties on an unexisting object" ); - } - if ( argc != 2 ) - { - post( "filterbank : error in the number of arguments ( %d instead of 2 )", argc ); - return; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ) { - post( "filterbank~ : wrong arguments" ); - return; - } - - x->x_allocate = 1; - x->x_lowfreq = (int)argv[0].a_w.w_float; - if ( x->x_lowfreq < 0 ) x->x_lowfreq = 0; - x->x_highfreq = (int)argv[1].a_w.w_float; - if ( x->x_highfreq < x->x_lowfreq ) x->x_highfreq = x->x_lowfreq + 100; - - // recalculate filters if needed - if ( ( olowfreq != x->x_lowfreq ) || ( ohighfreq != x->x_highfreq ) ) - { - // free filters - if ( x->x_freq ) - { - freebytes( x->x_freq, x->x_nbfilters*sizeof(t_float) ); - } - if ( x->x_q ) - { - freebytes( x->x_q, x->x_nbfilters*sizeof(t_float) ); - } - if ( x->x_cspace ) - { - freebytes( x->x_cspace, x->x_nbfilters*sizeof(t_bpctl) ); - } - if ( x->x_ctl ) - { - freebytes( x->x_ctl, x->x_nbfilters*sizeof(t_bpctl*) ); - } - // create filters - x->x_freq = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); - x->x_q = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); - x->x_cspace = (t_bpctl *) getbytes( x->x_nbfilters*sizeof(t_bpctl) ); - x->x_ctl = (t_bpctl **) getbytes( x->x_nbfilters*sizeof(t_bpctl*) ); - if ( !x->x_freq || !x->x_q || !x->x_cspace || !x->x_ctl ) - { - post( "filterbank~ : could not allocate filters" ); - return; - } - abandwidth = ( x->x_highfreq - x->x_lowfreq ) / x->x_nbfilters; - afreq = x->x_lowfreq + ( abandwidth / 2 ); - for ( fi=0; fix_nbfilters; fi++ ) - { - x->x_ctl[fi] = &x->x_cspace[fi]; - x->x_cspace[fi].c_x1 = 0; - x->x_cspace[fi].c_x2 = 0; - Q = ( (t_float) afreq )/ ( (t_float) abandwidth ); - miller_sigbp_docoef( x, fi, afreq, Q ); - afreq += abandwidth; - } - } - - x->x_allocate = 0; + t_int olowfreq = x->x_lowfreq; + t_int ohighfreq = x->x_highfreq; + t_int fi, ei; + t_int dspstate; + t_float Q; + t_float afreq, abandwidth; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + // !!paranoid + if ( !x ) + { + post( "filterbank~ : error :tried to set properties on an unexisting object" ); + } + if ( argc != 2 ) + { + post( "filterbank : error in the number of arguments ( %d instead of 2 )", argc ); + return; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ) + { + post( "filterbank~ : wrong arguments" ); + return; + } + + x->x_allocate = 1; + x->x_lowfreq = (int)argv[0].a_w.w_float; + if ( x->x_lowfreq < 0 ) x->x_lowfreq = 0; + x->x_highfreq = (int)argv[1].a_w.w_float; + if ( x->x_highfreq < x->x_lowfreq ) x->x_highfreq = x->x_lowfreq + 100; + + // recalculate filters if needed + if ( ( olowfreq != x->x_lowfreq ) || ( ohighfreq != x->x_highfreq ) ) + { + // free filters + if ( x->x_freq ) + { + freebytes( x->x_freq, x->x_nbfilters*sizeof(t_float) ); + } + if ( x->x_q ) + { + freebytes( x->x_q, x->x_nbfilters*sizeof(t_float) ); + } + if ( x->x_cspace ) + { + freebytes( x->x_cspace, x->x_nbfilters*sizeof(t_bpctl) ); + } + if ( x->x_ctl ) + { + freebytes( x->x_ctl, x->x_nbfilters*sizeof(t_bpctl*) ); + } + // create filters + x->x_freq = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); + x->x_q = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); + x->x_cspace = (t_bpctl *) getbytes( x->x_nbfilters*sizeof(t_bpctl) ); + x->x_ctl = (t_bpctl **) getbytes( x->x_nbfilters*sizeof(t_bpctl*) ); + if ( !x->x_freq || !x->x_q || !x->x_cspace || !x->x_ctl ) + { + post( "filterbank~ : could not allocate filters" ); + return; + } + abandwidth = ( x->x_highfreq - x->x_lowfreq ) / x->x_nbfilters; + afreq = x->x_lowfreq + ( abandwidth / 2 ); + for ( fi=0; fix_nbfilters; fi++ ) + { + x->x_ctl[fi] = &x->x_cspace[fi]; + x->x_cspace[fi].c_x1 = 0; + x->x_cspace[fi].c_x2 = 0; + Q = ( (t_float) afreq )/ ( (t_float) abandwidth ); + miller_sigbp_docoef( x, fi, afreq, Q ); + afreq += abandwidth; + } + } + + x->x_allocate = 0; } static void filterbank_delete(t_gobj *z, t_glist *glist) { - t_filterbank_tilde *x = (t_filterbank_tilde *)z; + t_filterbank_tilde *x = (t_filterbank_tilde *)z; - // post( "filterbank~ : delete" ); - filterbank_draw_erase( x, glist ); - canvas_deletelinesfor(glist, (t_text *)z); + // post( "filterbank~ : delete" ); + filterbank_draw_erase( x, glist ); + canvas_deletelinesfor(glist, (t_text *)z); } static void filterbank_displace(t_gobj *z, t_glist *glist, int dx, int dy) { - t_filterbank_tilde *x = (t_filterbank_tilde *)z; - int xold = text_xpix(&x->x_obj, glist); - int yold = text_ypix(&x->x_obj, glist); + t_filterbank_tilde *x = (t_filterbank_tilde *)z; + int xold = text_xpix(&x->x_obj, glist); + int yold = text_ypix(&x->x_obj, glist); // post( "filterbank_displace dx=%d dy=%d", dx, dy ); @@ -389,31 +394,36 @@ static void filterbank_displace(t_gobj *z, t_glist *glist, int dx, int dy) x->x_obj.te_ypix += dy; if(xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist) ) { - filterbank_draw_move(x, x->x_glist); + filterbank_draw_move(x, x->x_glist); } } static void filterbank_randomize(t_filterbank_tilde *x, t_floatarg fflag ) { - t_int shind, tmpi, fi; - - if ( fflag != 0.0 && fflag != 1.0 ) { - post( "filterbank~ : wrong argument in randomize message : should be 0 or 1" ); - return; - } else if ( fflag == 1 ) { - for ( fi=0; fix_nbfilters; fi++ ) - { - shind = rand() % x->x_nbfilters; - tmpi = x->x_outmapping[ shind ]; - x->x_outmapping[ shind ] = x->x_outmapping[ fi ]; - x->x_outmapping[ fi ] = tmpi; - } - } else { - for ( fi=0; fix_nbfilters; fi++ ) - { - x->x_outmapping[ fi ] = fi; - } + t_int shind, tmpi, fi; + + if ( fflag != 0.0 && fflag != 1.0 ) + { + post( "filterbank~ : wrong argument in randomize message : should be 0 or 1" ); + return; + } + else if ( fflag == 1 ) + { + for ( fi=0; fix_nbfilters; fi++ ) + { + shind = rand() % x->x_nbfilters; + tmpi = x->x_outmapping[ shind ]; + x->x_outmapping[ shind ] = x->x_outmapping[ fi ]; + x->x_outmapping[ fi ] = tmpi; + } + } + else + { + for ( fi=0; fix_nbfilters; fi++ ) + { + x->x_outmapping[ fi ] = fi; + } } } @@ -424,38 +434,39 @@ static t_filterbank_tilde *filterbank_new(t_symbol *s, int argc, t_atom *argv) char *str; t_float Q; t_float afreq, abandwidth; - + x = (t_filterbank_tilde *)pd_new(filterbank_class_tilde); x->x_samplerate = (int)sys_getsr(); x->x_sr = 44100; - // new filterbank created from the gui + // new filterbank created from the gui if ( argc != 0 ) { - if ( argc != 3 ) - { - post( "filterbank~ : error in the number of arguments ( %d )", argc ); - return NULL; - } - if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT ) { - post( "filterbank~ : wrong arguments" ); - return NULL; - } + if ( argc != 3 ) + { + post( "filterbank~ : error in the number of arguments ( %d )", argc ); + return NULL; + } + if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT ) + { + post( "filterbank~ : wrong arguments" ); + return NULL; + } - x->x_lowfreq = (int)argv[0].a_w.w_float; - if ( x->x_lowfreq < 0 ) x->x_lowfreq = 0; - x->x_highfreq = (int)argv[1].a_w.w_float; - if ( x->x_highfreq < x->x_lowfreq ) x->x_highfreq = x->x_lowfreq + 100; - x->x_nbfilters = (int)argv[2].a_w.w_float; - if ( x->x_nbfilters < 1 ) x->x_nbfilters = 1; + x->x_lowfreq = (int)argv[0].a_w.w_float; + if ( x->x_lowfreq < 0 ) x->x_lowfreq = 0; + x->x_highfreq = (int)argv[1].a_w.w_float; + if ( x->x_highfreq < x->x_lowfreq ) x->x_highfreq = x->x_lowfreq + 100; + x->x_nbfilters = (int)argv[2].a_w.w_float; + if ( x->x_nbfilters < 1 ) x->x_nbfilters = 1; } else { - x->x_lowfreq = DEFAULT_FILTERBANK_LOWFREQ; - x->x_highfreq = DEFAULT_FILTERBANK_HIGHFREQ; - x->x_nbfilters = DEFAULT_FILTERBANK_NBFILTERS; + x->x_lowfreq = DEFAULT_FILTERBANK_LOWFREQ; + x->x_highfreq = DEFAULT_FILTERBANK_HIGHFREQ; + x->x_nbfilters = DEFAULT_FILTERBANK_NBFILTERS; } // post( "filterbank~ : new [ %d,%d ] with %d filters", x->x_lowfreq, x->x_highfreq, x->x_nbfilters ); @@ -464,34 +475,34 @@ static t_filterbank_tilde *filterbank_new(t_symbol *s, int argc, t_atom *argv) x->x_outputs = (t_outlet **) getbytes( x->x_nbfilters*sizeof(t_outlet *) ); if ( !x->x_outputs ) { - post( "filterbank~ : could not allocate outputs" ); - return NULL; + post( "filterbank~ : could not allocate outputs" ); + return NULL; } for ( fi=0; fix_nbfilters; fi++ ) { - x->x_outputs[fi] = outlet_new( &x->x_obj, &s_signal ); + x->x_outputs[fi] = outlet_new( &x->x_obj, &s_signal ); } - // create filters + // create filters x->x_freq = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); x->x_q = (t_float *) getbytes( x->x_nbfilters*sizeof(t_float) ); x->x_cspace = (t_bpctl *) getbytes( x->x_nbfilters*sizeof(t_bpctl) ); x->x_ctl = (t_bpctl **) getbytes( x->x_nbfilters*sizeof(t_bpctl*) ); if ( !x->x_freq || !x->x_q || !x->x_cspace || !x->x_ctl ) { - post( "filterbank~ : could not allocate filters" ); - return NULL; + post( "filterbank~ : could not allocate filters" ); + return NULL; } abandwidth = ( x->x_highfreq - x->x_lowfreq ) / x->x_nbfilters; afreq = x->x_lowfreq + ( abandwidth / 2 ); for ( fi=0; fix_nbfilters; fi++ ) { - x->x_ctl[fi] = &x->x_cspace[fi]; - x->x_cspace[fi].c_x1 = 0; - x->x_cspace[fi].c_x2 = 0; - Q = ( (t_float) afreq ) / ( (t_float) abandwidth ); - miller_sigbp_docoef( x, fi, afreq, Q ); - afreq += abandwidth; + x->x_ctl[fi] = &x->x_cspace[fi]; + x->x_cspace[fi].c_x1 = 0; + x->x_cspace[fi].c_x2 = 0; + Q = ( (t_float) afreq ) / ( (t_float) abandwidth ); + miller_sigbp_docoef( x, fi, afreq, Q ); + afreq += abandwidth; } x->x_width = x->x_nbfilters*FILTERBANK_OUTLET_WIDTH*2; @@ -503,48 +514,48 @@ static t_filterbank_tilde *filterbank_new(t_symbol *s, int argc, t_atom *argv) x->x_outmapping = (t_int*) getbytes( x->x_nbfilters*sizeof( t_int ) ); if ( !x->x_outmapping ) { - post( "filterbank~ : cannot allocate mapping array" ); - return NULL; // otherwise, pd schrieks + post( "filterbank~ : cannot allocate mapping array" ); + return NULL; // otherwise, pd schrieks } for ( fi=0; fix_nbfilters; fi++ ) { - x->x_outmapping[fi] = fi; + x->x_outmapping[fi] = fi; } return (x); } static void filterbank_free(t_filterbank_tilde *x) { - t_int ei, fi; - - if ( x->x_outputs ) - { - for ( ei=0; eix_nbfilters; ei++ ) - { - outlet_free( x->x_outputs[ei] ); - } - freebytes( x->x_outputs, x->x_nbfilters*sizeof(t_outlet*) ); - } - if ( x->x_freq ) - { - freebytes( x->x_freq, x->x_nbfilters*sizeof(t_float) ); - } - if ( x->x_q ) - { - freebytes( x->x_q, x->x_nbfilters*sizeof(t_float) ); - } - if ( x->x_cspace ) - { - freebytes( x->x_cspace, x->x_nbfilters*sizeof(t_bpctl) ); - } - if ( x->x_ctl ) - { - freebytes( x->x_ctl, x->x_nbfilters*sizeof(t_bpctl*) ); - } - if ( x->x_outmapping ) - { - freebytes( x->x_outmapping, x->x_nbfilters*sizeof(t_int) ); - } + t_int ei, fi; + + if ( x->x_outputs ) + { + for ( ei=0; eix_nbfilters; ei++ ) + { + outlet_free( x->x_outputs[ei] ); + } + freebytes( x->x_outputs, x->x_nbfilters*sizeof(t_outlet*) ); + } + if ( x->x_freq ) + { + freebytes( x->x_freq, x->x_nbfilters*sizeof(t_float) ); + } + if ( x->x_q ) + { + freebytes( x->x_q, x->x_nbfilters*sizeof(t_float) ); + } + if ( x->x_cspace ) + { + freebytes( x->x_cspace, x->x_nbfilters*sizeof(t_bpctl) ); + } + if ( x->x_ctl ) + { + freebytes( x->x_ctl, x->x_nbfilters*sizeof(t_bpctl*) ); + } + if ( x->x_outmapping ) + { + freebytes( x->x_outmapping, x->x_nbfilters*sizeof(t_int) ); + } } static t_int *filterbank_perform(t_int *w) @@ -555,8 +566,8 @@ static t_int *filterbank_perform(t_int *w) t_float *in, *out; int i; t_float last, prev, coef1, coef2, gain; - t_float *acopy; - t_int noneedtofilter = 1; + t_float *acopy; + t_int noneedtofilter = 1; in = (t_float*)w[3]; @@ -564,51 +575,53 @@ static t_int *filterbank_perform(t_int *w) acopy = (t_float*) getbytes( n*sizeof( t_float ) ); if ( !acopy ) { - post( "filterbank~ : cannot allocate audio copy block" ); - return 0; // otherwise, pd schrieks + post( "filterbank~ : cannot allocate audio copy block" ); + return 0; // otherwise, pd schrieks } memcpy( acopy, in, n*sizeof(t_float) ); for ( i=0; ix_nbfilters; fi++ ) - { - out = (t_float *)(w[x->x_outmapping[fi]+4]); - - last = x->x_ctl[fi]->c_x1; - prev = x->x_ctl[fi]->c_x2; - coef1 = x->x_ctl[fi]->c_coef1; - coef2 = x->x_ctl[fi]->c_coef2; - gain = x->x_ctl[fi]->c_gain; - for (i=0; i < n; i++) + for ( fi=0; fix_nbfilters; fi++ ) { - float output = *(acopy+i) + coef1 * last + coef2 * prev; - *out++ = gain * output; - prev = last; - last = output; - } + out = (t_float *)(w[x->x_outmapping[fi]+4]); + + last = x->x_ctl[fi]->c_x1; + prev = x->x_ctl[fi]->c_x2; + coef1 = x->x_ctl[fi]->c_coef1; + coef2 = x->x_ctl[fi]->c_coef2; + gain = x->x_ctl[fi]->c_gain; + for (i=0; i < n; i++) + { + float output = *(acopy+i) + coef1 * last + coef2 * prev; + *out++ = gain * output; + prev = last; + last = output; + } /* NAN protect */ - if (!((last <= 0) || (last >= 0))) - last = 0; - if (!((prev <= 0) || (prev >= 0))) - prev = 0; - x->x_ctl[fi]->c_x1 = last; - x->x_ctl[fi]->c_x2 = prev; - } - } else { - for ( fi=0; fix_nbfilters; fi++ ) - { - out = (t_float *)(w[x->x_outmapping[fi]+4]); - for (i=0; i < n; i++) + if (!((last <= 0) || (last >= 0))) + last = 0; + if (!((prev <= 0) || (prev >= 0))) + prev = 0; + x->x_ctl[fi]->c_x1 = last; + x->x_ctl[fi]->c_x2 = prev; + } + } + else + { + for ( fi=0; fix_nbfilters; fi++ ) { - *out++ = 0.0; + out = (t_float *)(w[x->x_outmapping[fi]+4]); + for (i=0; i < n; i++) + { + *out++ = 0.0; + } } - } } if ( acopy ) freebytes( acopy, n*sizeof(t_float) ); @@ -618,7 +631,7 @@ static t_int *filterbank_perform(t_int *w) static void filterbank_dsp(t_filterbank_tilde *x, t_signal **sp) { - t_int *dspargs, fi, nbargs; + t_int *dspargs, fi, nbargs; dspargs = (t_int*) getbytes( (x->x_nbfilters+3)*sizeof(t_int) ); @@ -629,10 +642,10 @@ static void filterbank_dsp(t_filterbank_tilde *x, t_signal **sp) nbargs = 3; for ( fi=0; fix_nbfilters; fi++ ) { - dspargs[3+fi] = (t_int)sp[fi+1]->s_vec; - nbargs++; + dspargs[3+fi] = (t_int)sp[fi+1]->s_vec; + nbargs++; } - + dsp_addv(filterbank_perform, nbargs, dspargs ); if ( dspargs ) freebytes( dspargs, (x->x_nbfilters+3)*sizeof(t_int) ); @@ -640,10 +653,9 @@ static void filterbank_dsp(t_filterbank_tilde *x, t_signal **sp) void filterbank_tilde_setup(void) { - post( filterbank_version ); -#include "filterbank~.tk2c" + logpost(NULL, 4, "%s", filterbank_version ); filterbank_class_tilde = class_new(gensym("filterbank~"), (t_newmethod)filterbank_new, - (t_method)filterbank_free, sizeof(t_filterbank_tilde), 0, A_GIMME, 0); + (t_method)filterbank_free, sizeof(t_filterbank_tilde), 0, A_GIMME, 0); CLASS_MAINSIGNALIN( filterbank_class_tilde, t_filterbank_tilde, x_f ); class_addmethod(filterbank_class_tilde, (t_method)filterbank_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(filterbank_class_tilde, (t_method)filterbank_dialog, gensym("dialog"), A_GIMME, 0); @@ -665,4 +677,7 @@ void filterbank_tilde_setup(void) #endif class_setwidget(filterbank_class_tilde, &filterbank_widgetbehavior); + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + filterbank_class_tilde->c_externdir->s_name, + filterbank_class_tilde->c_name->s_name); } diff --git a/externals/unauthorized/filterbank~/filterbank~.h b/externals/unauthorized/filterbank~.h similarity index 100% rename from externals/unauthorized/filterbank~/filterbank~.h rename to externals/unauthorized/filterbank~.h diff --git a/externals/unauthorized/filterbank~/filterbank~.tk b/externals/unauthorized/filterbank~.tcl similarity index 97% rename from externals/unauthorized/filterbank~/filterbank~.tk rename to externals/unauthorized/filterbank~.tcl index 84b3d87dc08e46f88920c277945f83fd94fe95b8..4e0e75ecc0e3c610579b79ba6d0e78357dffaa9a 100644 --- a/externals/unauthorized/filterbank~/filterbank~.tk +++ b/externals/unauthorized/filterbank~.tcl @@ -14,13 +14,13 @@ proc filterbank_apply {id} { [eval concat $$var_graph_highfreq] \ \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc filterbank_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc filterbank_ok {id} { @@ -38,7 +38,7 @@ proc pdtk_filterbank_dialog {id lowfreq highfreq} { set $var_graph_lowfreq $lowfreq set $var_graph_highfreq $highfreq - toplevel $id -class [winfo class .] + toplevel $id wm title $id {filterbank} wm protocol $id WM_DELETE_WINDOW [concat filterbank_cancel $id] diff --git a/externals/unauthorized/filterbank~/INSTALL b/externals/unauthorized/filterbank~/INSTALL deleted file mode 100644 index a8b614e1a4e306a69cba5255fbfe5041a6b9f9f0..0000000000000000000000000000000000000000 --- a/externals/unauthorized/filterbank~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/filterbank~ - -make clean - -make - -make install - -open help-filterbank~.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/filterbank~/Makefile b/externals/unauthorized/filterbank~/Makefile deleted file mode 100644 index 4930387ddb1f348b44492edccc375b377e211930..0000000000000000000000000000000000000000 --- a/externals/unauthorized/filterbank~/Makefile +++ /dev/null @@ -1,113 +0,0 @@ -NAME=filterbank~ -CSYM=filterbank~ - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.ont: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.oi5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.oi6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes -g \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.o: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - -.c.pd_linux: - ./tk2c.bash < $*.tk > $*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ----------------------- Mac OSX ----------------------- - -pd_darwin: $(NAME).pd_darwin - -.SUFFIXES: .pd_darwin - -DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch - -.c.osx: - cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - -.c.pd_darwin: - cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o - rm -f $*.o ../$*.pd_darwin - ln -s $*/$*.pd_darwin .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* *.tk2c core diff --git a/externals/unauthorized/filterbank~/README b/externals/unauthorized/filterbank~/README deleted file mode 100644 index e43ec357118372020dace8f31af318341c745d87..0000000000000000000000000000000000000000 --- a/externals/unauthorized/filterbank~/README +++ /dev/null @@ -1,20 +0,0 @@ -***************************************************************************** -Version 0.1 -copyleft 2002 Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -filterbank~ : filterbank outputs frequency response for a range of filters - -To install filterbank~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/filterbank~/filterbank~.tk2c b/externals/unauthorized/filterbank~/filterbank~.tk2c deleted file mode 100755 index 8a22d1b37c0cf9dcd632f0cfb059f5a0e68e2624..0000000000000000000000000000000000000000 --- a/externals/unauthorized/filterbank~/filterbank~.tk2c +++ /dev/null @@ -1,58 +0,0 @@ -// ########### filterbank procedures -- ydegoyon@free.fr ######### -sys_gui("proc filterbank_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_lowfreq [concat graph_lowfreq_$vid]\n"); -sys_gui("global $var_graph_lowfreq\n"); -sys_gui("set var_graph_highfreq [concat graph_highfreq_$vid]\n"); -sys_gui("global $var_graph_highfreq\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_lowfreq] [eval concat $$var_graph_highfreq] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc filterbank_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc filterbank_ok {id} {\n"); -sys_gui("filterbank_apply $id\n"); -sys_gui("filterbank_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_filterbank_dialog {id lowfreq highfreq} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_lowfreq [concat graph_lowfreq_$vid]\n"); -sys_gui("global $var_graph_lowfreq\n"); -sys_gui("set var_graph_highfreq [concat graph_highfreq_$vid]\n"); -sys_gui("global $var_graph_highfreq\n"); -sys_gui("set $var_graph_lowfreq $lowfreq\n"); -sys_gui("set $var_graph_highfreq $highfreq\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {filterbank}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat filterbank_cancel $id]\n"); -sys_gui("label $id.label -text {FILTERBANK PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"filterbank_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"filterbank_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"filterbank_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.llowfreq -text \"Lower Frequency :\"\n"); -sys_gui("entry $id.1rangef.lowfreq -textvariable $var_graph_lowfreq -width 7\n"); -sys_gui("pack $id.1rangef.llowfreq $id.1rangef.lowfreq -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lhighfreq -text \"Higher Frequency :\"\n"); -sys_gui("entry $id.2rangef.highfreq -textvariable $var_graph_highfreq -width 7\n"); -sys_gui("pack $id.2rangef.lhighfreq $id.2rangef.highfreq -side left\n"); -sys_gui("bind $id.1rangef.lowfreq [concat filterbank_ok $id]\n"); -sys_gui("bind $id.2rangef.highfreq [concat filterbank_ok $id]\n"); -sys_gui("focus $id.1rangef.lowfreq\n"); -sys_gui("}\n"); -// ########### filterbank procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/filterbank~/tk2c.bash b/externals/unauthorized/filterbank~/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/filterbank~/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/vocoder~/filters.c b/externals/unauthorized/filters.c similarity index 70% rename from externals/unauthorized/vocoder~/filters.c rename to externals/unauthorized/filters.c index 2bf9253c7b9d0adda676d591c6c9b43c03de6f65..64f079dee70b22041351a99ea61f76f49b0958e6 100644 --- a/externals/unauthorized/vocoder~/filters.c +++ b/externals/unauthorized/filters.c @@ -21,29 +21,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void lpc_filter(double *buf_ppf, double *lpc_coef, double *buf_sy, int n) { - int i,j; - double acc; - - for(i=0;i #endif #include -#ifdef UNIX -#include -#endif -#ifdef NT -#define M_PI 3.14159265358979323846 -#endif #include +#ifdef _MSC_VER +# define M_PI 3.14159265358979323846 +#else +# include +#endif #include /* standard pd stuff */ @@ -71,44 +70,51 @@ typedef struct _formant } t_formant; - /* clean up */ -static void formant_free(t_formant *x) +/* clean up */ +static void formant_free(t_formant *x) { - if ( x->x_data != NULL ) { - freebytes(x->x_data, x->x_size*sizeof(float) ); - x->x_data = NULL; + if ( x->x_data != NULL ) + { + freebytes(x->x_data, x->x_size*sizeof(float) ); + x->x_data = NULL; } } - /* generate sample data */ +/* generate sample data */ static t_int formant_gendata(t_formant *x) { t_float t, b, fs; - if ( x->x_size <= 0 || x->x_central_freq <= 0 || x->x_filter_width <= 0 || x->x_skirt_width <= 0 ) { - error( "formant~ : error generating data : negative or null parameter(s)" ); - return -1; + if ( x->x_size <= 0 || x->x_central_freq <= 0 || x->x_filter_width <= 0 || x->x_skirt_width <= 0 ) + { + error( "formant~ : error generating data : negative or null parameter(s)" ); + return -1; } - + x->x_gendata = 1; /* freeing data */ formant_free( x ); - if ( !( x->x_data = (float*) getbytes( x->x_size*sizeof(float) ) ) ) { - post( "formant~ : error generating data : cannot allocate table" ); - return -1; + if ( !( x->x_data = (float*) getbytes( x->x_size*sizeof(float) ) ) ) + { + post( "formant~ : error generating data : cannot allocate table" ); + return -1; } - + fs = 0; - while( fs < x->x_size-1 ) { - t = (fs/x->x_samplerate) * x->x_time_stretch; /* time taken from zero */ - b = M_PI / x->x_skirt_width ; - if ( t < b ) { - *(x->x_data+(int)fs) = 0.5*(1-cos(x->x_skirt_width*t))*exp(- x->x_filter_width*t )*sin( x->x_central_freq*t); - } else { - *(x->x_data+(int)fs) = exp(- x->x_filter_width*t )*sin( x->x_central_freq*t); - } - fs++; + while( fs < x->x_size-1 ) + { + t = (fs/x->x_samplerate) * x->x_time_stretch; /* time taken from zero */ + b = M_PI / x->x_skirt_width ; + if ( t < b ) + { + *(x->x_data+(int)fs) = 0.5*(1-cos(x->x_skirt_width*t))*exp(- x->x_filter_width*t )*sin( x->x_central_freq*t); + } + else + { + *(x->x_data+(int)fs) = exp(- x->x_filter_width*t )*sin( x->x_central_freq*t); + } + fs++; } /* everything went fine */ @@ -116,25 +122,30 @@ static t_int formant_gendata(t_formant *x) return 0; } - /* generates a formant */ +/* generates a formant */ static t_int *formant_perform(t_int *w) { t_formant *x = (t_formant *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); /* number of samples */ - while (n--) { - if ( !x->x_gendata && x->x_play) { - *out=*(x->x_data+x->x_readpos); - x->x_readpos = (x->x_readpos+1)%x->x_size; - if ( x->x_readpos == 0 ) { - x->x_play=0; - outlet_bang(x->x_end); - } - } else { - *out=0.0; - } - out++; + while (n--) + { + if ( !x->x_gendata && x->x_play) + { + *out=*(x->x_data+x->x_readpos); + x->x_readpos = (x->x_readpos+1)%x->x_size; + if ( x->x_readpos == 0 ) + { + x->x_play=0; + outlet_bang(x->x_end); + } + } + else + { + *out=0.0; + } + out++; } return (w+4); } @@ -144,63 +155,68 @@ static void formant_dsp(t_formant *x, t_signal **sp) dsp_add(formant_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } - /* replay the sample */ +/* replay the sample */ static void formant_bang(t_formant *x, t_floatarg fsize) { x->x_play=1; x->x_readpos=0; } - /* set size of the sample */ +/* set size of the sample */ static void formant_size(t_formant *x, t_floatarg fsize) { - if ( fsize <= 0 ) { - post( "formant~ : error : sample size should be >0" ); - return; + if ( fsize <= 0 ) + { + post( "formant~ : error : sample size should be >0" ); + return; } x->x_size = fsize; formant_gendata( x ); } - /* set central frequency of the formant */ +/* set central frequency of the formant */ static void formant_central_freq(t_formant *x, t_floatarg ffreq) { - if ( ffreq <= 0 ) { - post( "formant~ : error : filter central frequency should be >0" ); - return; + if ( ffreq <= 0 ) + { + post( "formant~ : error : filter central frequency should be >0" ); + return; } x->x_central_freq = ffreq; formant_gendata( x ); } - /* set filter width of the formant */ +/* set filter width of the formant */ static void formant_filter_width(t_formant *x, t_floatarg fwidth) { - if ( fwidth <= 0 ) { - post( "formant~ : error : filter width should be >0" ); - return; + if ( fwidth <= 0 ) + { + post( "formant~ : error : filter width should be >0" ); + return; } x->x_filter_width = fwidth; formant_gendata( x ); } - /* set skirt width of the formant */ +/* set skirt width of the formant */ static void formant_skirt_width(t_formant *x, t_floatarg swidth) { - if ( swidth <= 0 ) { - post( "formant~ : error : skirt width should be >0" ); - return; + if ( swidth <= 0 ) + { + post( "formant~ : error : skirt width should be >0" ); + return; } x->x_skirt_width = swidth; formant_gendata( x ); } - /* set time stretch factor */ +/* set time stretch factor */ static void formant_time_stretch(t_formant *x, t_floatarg fstretch) { - if ( fstretch <= 0 ) { - post( "formant~ : error : time stretch should be >0" ); - return; + if ( fstretch <= 0 ) + { + post( "formant~ : error : time stretch should be >0" ); + return; } x->x_time_stretch = fstretch; formant_gendata( x ); @@ -210,12 +226,13 @@ static void *formant_new(t_floatarg fsize, t_floatarg ffreq, t_floatarg ffwidth, { t_formant *x = (t_formant *)pd_new(formant_class); outlet_new(&x->x_obj, &s_signal); - - if ( fsize <= 0 || ffreq <= 0 || ffwidth <= 0 || fswidth <= 0 ) { - error( "formant~ : missing or negative creation arguments" ); - return NULL; + + if ( fsize <= 0 || ffreq <= 0 || ffwidth <= 0 || fswidth <= 0 ) + { + error( "formant~ : missing or negative creation arguments" ); + return NULL; } - + x->x_size = fsize; x->x_central_freq = ffreq; x->x_filter_width = ffwidth; @@ -230,19 +247,22 @@ static void *formant_new(t_floatarg fsize, t_floatarg ffreq, t_floatarg ffwidth, inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("swidth")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("stretch")); x->x_end = outlet_new( &x->x_obj, &s_bang ); - if ( formant_gendata( x ) ) { + if ( formant_gendata( x ) ) + { post( "formant~ : error generating data" ); return NULL; - } else { + } + else + { return(x); } } void formant_tilde_setup(void) { - post(formant_version); + logpost(NULL, 4, "%s", formant_version); formant_class = class_new(gensym("formant~"), (t_newmethod)formant_new, (t_method)formant_free, - sizeof(t_formant), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + sizeof(t_formant), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(formant_class, (t_method)formant_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(formant_class, (t_method)formant_size, gensym("size"), A_FLOAT, 0); class_addmethod(formant_class, (t_method)formant_bang, gensym("bang"), 0); diff --git a/externals/unauthorized/formant~/INSTALL b/externals/unauthorized/formant~/INSTALL deleted file mode 100644 index bcbc08b0ee5d79b673954ddf9d1da3b24850a83d..0000000000000000000000000000000000000000 --- a/externals/unauthorized/formant~/INSTALL +++ /dev/null @@ -1,9 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/formant~ - -make - -make install - -you're set !! diff --git a/externals/unauthorized/formant~/Makefile b/externals/unauthorized/formant~/Makefile deleted file mode 100644 index 3f0c97f2279cc7265a205d50aaa4e4d05ba2439f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/formant~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=formant~ -CSYM=formant_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/formant~/README b/externals/unauthorized/formant~/README deleted file mode 100644 index 41526cbf9d9c086ea40cc0093b2bd2e5a97ba0bb..0000000000000000000000000000000000000000 --- a/externals/unauthorized/formant~/README +++ /dev/null @@ -1,21 +0,0 @@ -Version 0.01 -copyleft 2001 by Yves Degoyon - -formant~.dll is a formant synthesis generator external for pd (by Miller -Puckette). - -To install formant~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - -thruth is here. -trust is in another world. - diff --git a/externals/unauthorized/grid/g_grid.h b/externals/unauthorized/g_grid.h similarity index 100% rename from externals/unauthorized/grid/g_grid.h rename to externals/unauthorized/g_grid.h diff --git a/externals/unauthorized/grid/grid-help.pd b/externals/unauthorized/grid-help.pd similarity index 100% rename from externals/unauthorized/grid/grid-help.pd rename to externals/unauthorized/grid-help.pd diff --git a/externals/unauthorized/grid/grid.c b/externals/unauthorized/grid.c similarity index 94% rename from externals/unauthorized/grid/grid.c rename to externals/unauthorized/grid.c index 237ab674e41755e1850050fbca49b642f0a20eb8..da3c56ab1ea165cef34ecd6829ef457ef494156e 100644 --- a/externals/unauthorized/grid/grid.c +++ b/externals/unauthorized/grid.c @@ -38,7 +38,7 @@ static int gridcount=0; static int guidebug=0; static int pointsize = 5; -static char *grid_version = "grid: version 0.8.1, written by Yves Degoyon (ydegoyon@free.fr)"; +static char *grid_version = "grid: version 0.9, written by Yves Degoyon (ydegoyon@free.fr)"; #define GRID_SYS_VGUI2(a,b) if (guidebug) \ post(a,b);\ @@ -396,12 +396,13 @@ static void grid_dialog(t_grid *x, t_symbol *s, int argc, t_atom *argv) { if (!x) { - post( "grid : error :tried to set properties on an unexisting object" ); + error("grid : error :tried to set properties on an unexisting object"); } if (argc != 12) { - post( "grid : error in the number of arguments ( %d instead of 12 )", - argc ); + pd_error(x, + "grid : error in the number of arguments ( %d instead of 12 )", + argc ); return; } if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || @@ -410,7 +411,7 @@ static void grid_dialog(t_grid *x, t_symbol *s, int argc, t_atom *argv) argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT || argv[8].a_type != A_FLOAT || argv[9].a_type != A_FLOAT || argv[10].a_type != A_FLOAT || argv[11].a_type != A_FLOAT ) { - post( "grid : wrong arguments" ); + pd_error(x, "grid : wrong arguments" ); return; } x->x_name = argv[0].a_w.w_symbol; @@ -537,15 +538,15 @@ static void grid_new_color(t_grid *x, t_floatarg color1, if ((color1 < 0) || (color1 > 255)) { - post("wrong color component : %d", (int)color1); + pd_error(x, "wrong color component : %d", (int)color1); } if ((color2 < 0) || (color2 > 255)) { - post("wrong color component : %d", (int)color2); + pd_error(x, "wrong color component : %d", (int)color2); } if ((color3 < 0) || (color3 > 255)) { - post("wrong color component : %d", (int)color3); + pd_error(x, "wrong color component : %d", (int)color3); } if (color1 < 17) @@ -577,12 +578,14 @@ static void grid_values(t_grid* x, t_floatarg xvalue, t_floatarg yvalue) if (xvalue < x->x_min ) xvalue = x->x_min; if (xvalue > x->x_max ) xvalue = x->x_max; - x->x_current = text_xpix(&x->x_obj, x->x_glist) + ((xvalue - x->x_min) / x->x_max) * x->x_width; + x->x_current = text_xpix(&x->x_obj, x->x_glist) + + abs(((xvalue - x->x_min) / (x->x_max - x->x_min)) * x->x_width); if (yvalue < x->y_min ) yvalue = x->y_min; if (yvalue > x->y_max ) yvalue = x->y_max; - x->y_current = text_ypix(&x->x_obj, x->x_glist) + (1 - ((yvalue - x->y_min) / x->y_max)) * x->x_height; + x->y_current = text_ypix(&x->x_obj, x->x_glist) + + abs((1 - (yvalue - x->y_min) / (x->y_max - x->y_min)) * x->x_height); if (xold != x->x_current || yold != x->y_current) { @@ -599,12 +602,14 @@ static void grid_xvalues(t_grid* x, t_floatarg xvalue, t_floatarg yvalue) if (xvalue < x->x_min ) xvalue = x->x_min; if (xvalue > x->x_max ) xvalue = x->x_max; - x->x_current = text_xpix(&x->x_obj, x->x_glist) + ((xvalue - x->x_min) / x->x_max) * x->x_width; + x->x_current = text_xpix(&x->x_obj, x->x_glist) + + abs(((xvalue - x->x_min) / (x->x_max - x->x_min)) * x->x_width); if (yvalue < x->y_min ) yvalue = x->y_min; if (yvalue > x->y_max ) yvalue = x->y_max; - x->y_current = text_ypix(&x->x_obj, x->x_glist) + (1 - ((yvalue - x->y_min) / x->y_max)) * x->x_height; + x->y_current = text_ypix(&x->x_obj, x->x_glist) + + abs((1 - (yvalue - x->y_min) / (x->y_max - x->y_min)) * x->x_height); if (xold != x->x_current || yold != x->y_current) { @@ -632,14 +637,17 @@ static void grid_valuemotion(t_grid* x, t_floatarg dx, t_floatarg dy) if (xvalue < x->x_min ) xvalue = x->x_min; if (xvalue > x->x_max ) xvalue = x->x_max; - x->x_current = text_xpix(&x->x_obj, x->x_glist) + ((xvalue - x->x_min) / x->x_max) * x->x_width; + x->x_current = text_xpix(&x->x_obj, x->x_glist) + + abs(((xvalue - x->x_min) / (x->x_max - x->x_min)) * x->x_width); if (yvalue < x->y_min ) yvalue = x->y_min; if (yvalue > x->y_max ) yvalue = x->y_max; x->y_current = text_ypix(&x->x_obj, x->x_glist) + (1 - ((yvalue - x->y_min) / x->y_max)) * x->x_height; - if (xold != x->x_current || yold != x->y_current) + + + if (xold != x->x_current || yold != x->y_current) { grid_output_current(x); grid_draw_update(x, x->x_glist); @@ -666,12 +674,14 @@ static void grid_xvaluemotion(t_grid* x, t_floatarg dx, t_floatarg dy) if (xvalue < x->x_min) xvalue = x->x_min; if (xvalue > x->x_max) xvalue = x->x_max; - x->x_current = text_xpix(&x->x_obj, x->x_glist) + ((xvalue - x->x_min) / x->x_max) * x->x_width; + x->x_current = text_xpix(&x->x_obj, x->x_glist) + + abs(((xvalue - x->x_min) / (x->x_max - x->x_min)) * x->x_width); if (yvalue < x->y_min) yvalue = x->y_min; if (yvalue > x->y_max) yvalue = x->y_max; - x->y_current = text_ypix(&x->x_obj, x->x_glist) + (1 - ((yvalue - x->y_min) / x->y_max)) * x->x_height; + x->y_current = text_ypix(&x->x_obj, x->x_glist) + + abs((1 - (yvalue - x->y_min) / (x->y_max - x->y_min)) * x->x_height); if (xold != x->x_current || yold != x->y_current) { @@ -753,8 +763,8 @@ static t_grid *grid_new(t_symbol *s, int argc, t_atom *argv) { if ( argc != 14 ) { - post( "grid : error in the number of arguments " - "( %d instead of 14 )", + pd_error(x, "grid : error in the number of arguments " + "( %d instead of 14 )", argc ); return NULL; } @@ -766,7 +776,7 @@ static t_grid *grid_new(t_symbol *s, int argc, t_atom *argv) argv[10].a_type != A_FLOAT || argv[11].a_type != A_FLOAT || argv[12].a_type != A_FLOAT || argv[13].a_type != A_FLOAT ) { - post( "grid : wrong arguments" ); + pd_error(x, "grid : wrong arguments" ); return NULL; } diff --git a/externals/unauthorized/grid/grid.tk b/externals/unauthorized/grid.tcl similarity index 99% rename from externals/unauthorized/grid/grid.tk rename to externals/unauthorized/grid.tcl index 21c7a4091e9adc60826a492d5c03feac455460eb..6a739e55aff5d5212aabceb761ae3f739e8100eb 100644 --- a/externals/unauthorized/grid/grid.tk +++ b/externals/unauthorized/grid.tcl @@ -44,13 +44,13 @@ proc grid_apply {id} { [eval concat $$var_graph_ylines] \ \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc grid_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc grid_ok {id} { @@ -98,7 +98,7 @@ proc pdtk_grid_dialog {id name width xmin xmax height ymin ymax grid xstep ystep set $var_graph_xlines $xlines set $var_graph_ylines $ylines - toplevel $id -class [winfo class .] + toplevel $id wm title $id {grid} wm protocol $id WM_DELETE_WINDOW [concat grid_cancel $id] diff --git a/externals/unauthorized/grid/INSTALL b/externals/unauthorized/grid/INSTALL deleted file mode 100644 index 22c4df68e8b525a795efea3d29fed8014466ccc0..0000000000000000000000000000000000000000 --- a/externals/unauthorized/grid/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/grid - -make clean - -make - -make install - -open help-grid.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/grid/Makefile b/externals/unauthorized/grid/Makefile deleted file mode 100644 index 775ff3b8ef163b84fcb5655f4afedd4dd674f92e..0000000000000000000000000000000000000000 --- a/externals/unauthorized/grid/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -NAME=grid -CSYM=grid - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk > $*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/grid/README b/externals/unauthorized/grid/README deleted file mode 100644 index fa0f1b759e4333e358c6fa34f1ba41ee5feea3c1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/grid/README +++ /dev/null @@ -1,19 +0,0 @@ -Version 0.01 -copyleft 2001 by Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -grid : 2-dimensional control object, ala "kaospad" - -To install grid, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/grid/grid.tk2c b/externals/unauthorized/grid/grid.tk2c deleted file mode 100644 index dd57bbc677c728d3e6256b1a1f30d682cdd9dbf4..0000000000000000000000000000000000000000 --- a/externals/unauthorized/grid/grid.tk2c +++ /dev/null @@ -1,164 +0,0 @@ -// ########### grid procedures -- ydegoyon@free.fr ######### -sys_gui("proc grid_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_name [concat graph_name_$vid]\n"); -sys_gui("global $var_graph_name\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_xmin [concat graph_xmin_$vid]\n"); -sys_gui("global $var_graph_xmin\n"); -sys_gui("set var_graph_xmax [concat graph_xmax_$vid]\n"); -sys_gui("global $var_graph_xmax\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_ymin [concat graph_ymin_$vid]\n"); -sys_gui("global $var_graph_ymin\n"); -sys_gui("set var_graph_ymax [concat graph_ymax_$vid]\n"); -sys_gui("global $var_graph_ymax\n"); -sys_gui("set var_graph_grid [concat graph_grid_$vid]\n"); -sys_gui("global $var_graph_grid\n"); -sys_gui("set var_graph_xstep [concat graph_xstep_$vid]\n"); -sys_gui("global $var_graph_xstep\n"); -sys_gui("set var_graph_ystep [concat graph_ystep_$vid]\n"); -sys_gui("global $var_graph_ystep\n"); -sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); -sys_gui("global $var_graph_xlines\n"); -sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); -sys_gui("global $var_graph_ylines\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_name] [eval concat $$var_graph_width] [eval concat $$var_graph_xmin] [eval concat $$var_graph_xmax] [eval concat $$var_graph_height] [eval concat $$var_graph_ymin] [eval concat $$var_graph_ymax] [eval concat $$var_graph_grid] [eval concat $$var_graph_xstep] [eval concat $$var_graph_ystep] [eval concat $$var_graph_xlines] [eval concat $$var_graph_ylines] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc grid_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc grid_ok {id} {\n"); -sys_gui("grid_apply $id\n"); -sys_gui("grid_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_grid_dialog {id name width xmin xmax height ymin ymax grid xstep ystep xlines ylines} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_name [concat graph_name_$vid]\n"); -sys_gui("global $var_graph_name\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_xmin [concat graph_xmin_$vid]\n"); -sys_gui("global $var_graph_xmin\n"); -sys_gui("set var_graph_xmax [concat graph_xmax_$vid]\n"); -sys_gui("global $var_graph_xmax\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_ymin [concat graph_ymin_$vid]\n"); -sys_gui("global $var_graph_ymin\n"); -sys_gui("set var_graph_ymax [concat graph_ymax_$vid]\n"); -sys_gui("global $var_graph_ymax\n"); -sys_gui("set var_graph_grid [concat graph_grid_$vid]\n"); -sys_gui("global $var_graph_grid\n"); -sys_gui("set var_graph_xstep [concat graph_xstep_$vid]\n"); -sys_gui("global $var_graph_xstep\n"); -sys_gui("set var_graph_ystep [concat graph_ystep_$vid]\n"); -sys_gui("global $var_graph_ystep\n"); -sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); -sys_gui("global $var_graph_xlines\n"); -sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); -sys_gui("global $var_graph_ylines\n"); -sys_gui("set $var_graph_name $name\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_xmin $xmin\n"); -sys_gui("set $var_graph_xmax $xmax\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_ymin $ymin\n"); -sys_gui("set $var_graph_ymax $ymax\n"); -sys_gui("set $var_graph_grid $grid\n"); -sys_gui("set $var_graph_xstep $xstep\n"); -sys_gui("set $var_graph_ystep $ystep\n"); -sys_gui("set $var_graph_xlines $xlines\n"); -sys_gui("set $var_graph_ylines $ylines\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {grid}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat grid_cancel $id]\n"); -sys_gui("label $id.label -text {GRID PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"grid_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"grid_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"grid_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lname -text \"Name :\"\n"); -sys_gui("entry $id.1rangef.name -textvariable $var_graph_name -width 7\n"); -sys_gui("pack $id.1rangef.lname $id.1rangef.name -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.2rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.2rangef.lwidth $id.2rangef.width -side left\n"); -sys_gui("frame $id.3rangef\n"); -sys_gui("pack $id.3rangef -side top\n"); -sys_gui("label $id.3rangef.lxmin -text \"X min :\"\n"); -sys_gui("entry $id.3rangef.xmin -textvariable $var_graph_xmin -width 7\n"); -sys_gui("pack $id.3rangef.lxmin $id.3rangef.xmin -side left\n"); -sys_gui("frame $id.4rangef\n"); -sys_gui("pack $id.4rangef -side top\n"); -sys_gui("label $id.4rangef.lxmax -text \"X max :\"\n"); -sys_gui("entry $id.4rangef.xmax -textvariable $var_graph_xmax -width 7\n"); -sys_gui("pack $id.4rangef.lxmax $id.4rangef.xmax -side left\n"); -sys_gui("frame $id.41rangef\n"); -sys_gui("pack $id.41rangef -side top\n"); -sys_gui("label $id.41rangef.lxstep -text \"X step :\"\n"); -sys_gui("entry $id.41rangef.xstep -textvariable $var_graph_xstep -width 7\n"); -sys_gui("pack $id.41rangef.lxstep $id.41rangef.xstep -side left\n"); -sys_gui("frame $id.42rangef\n"); -sys_gui("pack $id.42rangef -side top\n"); -sys_gui("label $id.42rangef.lxlines -text \"X sections :\"\n"); -sys_gui("entry $id.42rangef.xlines -textvariable $var_graph_xlines -width 7\n"); -sys_gui("pack $id.42rangef.lxlines $id.42rangef.xlines -side left\n"); -sys_gui("frame $id.5rangef\n"); -sys_gui("pack $id.5rangef -side top\n"); -sys_gui("label $id.5rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.5rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.5rangef.lheight $id.5rangef.height -side left\n"); -sys_gui("frame $id.6rangef\n"); -sys_gui("pack $id.6rangef -side top\n"); -sys_gui("label $id.6rangef.lymin -text \"Y min :\"\n"); -sys_gui("entry $id.6rangef.ymin -textvariable $var_graph_ymin -width 7\n"); -sys_gui("pack $id.6rangef.lymin $id.6rangef.ymin -side left\n"); -sys_gui("frame $id.7rangef\n"); -sys_gui("pack $id.7rangef -side top\n"); -sys_gui("label $id.7rangef.lymax -text \"Y max :\"\n"); -sys_gui("entry $id.7rangef.ymax -textvariable $var_graph_ymax -width 7\n"); -sys_gui("pack $id.7rangef.lymax $id.7rangef.ymax -side left\n"); -sys_gui("frame $id.71rangef\n"); -sys_gui("pack $id.71rangef -side top\n"); -sys_gui("label $id.71rangef.lystep -text \"Y step :\"\n"); -sys_gui("entry $id.71rangef.ystep -textvariable $var_graph_ystep -width 7\n"); -sys_gui("pack $id.71rangef.lystep $id.71rangef.ystep -side left\n"); -sys_gui("frame $id.72rangef\n"); -sys_gui("pack $id.72rangef -side top\n"); -sys_gui("label $id.72rangef.lylines -text \"Y sections :\"\n"); -sys_gui("entry $id.72rangef.ylines -textvariable $var_graph_ylines -width 7\n"); -sys_gui("pack $id.72rangef.lylines $id.72rangef.ylines -side left\n"); -sys_gui("checkbutton $id.showgrid -text {Show Grid} -variable $var_graph_grid -anchor w\n"); -sys_gui("pack $id.showgrid -side top\n"); -sys_gui("bind $id.1rangef.name [concat grid_ok $id]\n"); -sys_gui("bind $id.2rangef.width [concat grid_ok $id]\n"); -sys_gui("bind $id.3rangef.xmin [concat grid_ok $id]\n"); -sys_gui("bind $id.4rangef.xmax [concat grid_ok $id]\n"); -sys_gui("bind $id.41rangef.xstep [concat grid_ok $id]\n"); -sys_gui("bind $id.42rangef.xlines [concat grid_ok $id]\n"); -sys_gui("bind $id.5rangef.height [concat grid_ok $id]\n"); -sys_gui("bind $id.6rangef.ymin [concat grid_ok $id]\n"); -sys_gui("bind $id.7rangef.ymax [concat grid_ok $id]\n"); -sys_gui("bind $id.71rangef.ystep [concat grid_ok $id]\n"); -sys_gui("bind $id.72rangef.ylines [concat grid_ok $id]\n"); -sys_gui("focus $id.1rangef.name\n"); -sys_gui("}\n"); -// ########### grid procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/grid/tk2c.bash b/externals/unauthorized/grid/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/grid/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/mp3amp~/interface.h b/externals/unauthorized/interface.h similarity index 100% rename from externals/unauthorized/mp3amp~/interface.h rename to externals/unauthorized/interface.h diff --git a/externals/unauthorized/lpc.c b/externals/unauthorized/lpc.c new file mode 100644 index 0000000000000000000000000000000000000000..e68058864b03741f28fb0cc05eb83d562a3d565a --- /dev/null +++ b/externals/unauthorized/lpc.c @@ -0,0 +1,254 @@ +/* +vox - a musical real-time vocoder. version 1.0 +Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "tables.h" +#include "lpc.h" +#define THRES 0.06 +#define Dmin 10.81e-3 + +/* Levinson Durbin algorithm for computing LPC coefficients using +autocorrelation fonction */ +void lev_durb(double *corr,double *lpc_coef) +{ + double k[11],tab[11]; + double err,acc; + int i,j; + double *a=tab; + double *prev_a=lpc_coef; + double *exch; + + + /*init vectors*/ + for (i=0; i<11; i++) + { + prev_a[i]=0; + a[i]=0; + }; + err=corr[0]; + for(i=1; i<11; i++) + { + prev_a[0]=1; + acc=0; + for(j=0; jTHRES) + { + for(i=0; i<3*n; i++) + { + buffer[i]=buf_x[i-n]*HammingWindowTable[i]; + }; + /* autocorrelation computation*/ + for(i=0; i<11; i++) + { + acc=0; + for(j=i; j0; k--) + { + b[k]=2*x*b[k+1]-b[k+2]+fonc[5-k]; + }; + res=x*b[1]-b[2]+fonc[5]/2; + return(res); +} + + + +/* converts LPC vector into LSP frequency vector */ +/* all LSP frenquencies are in [0;PI] but are normalized to be in [0;1] */ +void lpc2lsp(double lpc_coef[],double *f1,double *f2,double lsp_coef[]) +{ + + int i,k=1; + double *fonc,*prev_f,*f_exch; + double prev_sign1,sign,prev_sign2; + double *s, *prev_s,*s_exch; + double lpc_exp[11]; + + /* first computes an additional bandwidth expansion on LPC coeffs*/ + for(i=1; i<11; i++) + { + lpc_exp[i]=lpc_coef[i]*BandExpTable[i]; + }; + /* computes the F1 and F2 coeffs*/ + f1[0]=f2[0]=1; + for(i=0; i<5; i++) + { + f1[i+1]=lpc_exp[i+1]+lpc_exp[10-i]-f1[i]; + f2[i+1]=lpc_exp[i+1]-lpc_exp[10-i]+f2[i]; + }; + + /*find the roots of C(x) alternatively for F1 and F2*/ + fonc=f1; + prev_f=f2; + prev_sign1=evalc(1.0,f1); + prev_sign2=evalc(1.0,f2); + s=&prev_sign1; + prev_s=&prev_sign2; + for(i=1; i<256; i++) + { + sign=evalc(CosineTable[i],fonc); + if ((sign)*(*s)<0) + { + /* interpolate to find root*/ + lsp_coef[k]=((double)i-(*s)/(sign-(*s)))/256.0; + k++; + /* chek if all roots are found */ + if (k==11) i=257; + (*s)=sign; + /* pointers exchange */ + s_exch=s; + s=prev_s; + prev_s=s_exch; + f_exch=fonc; + fonc=prev_f; + prev_f=f_exch; + } + else (*s)=sign; + } + /* if here all roots are not found , use lspDC vector */ + if (k!=11) + { + for(i=1; i<11; i++) + { + lsp_coef[i]=LspDcTable[i]; + }; + }; +} + + +/* converts lsp frequencies to lpc coeffs */ + +void lsp2lpc(double *lsp_coef,double *lpc_coef) +{ + int i,j=0,index,ok=1; + double lspcos[11],delta,tmp,p_avg; + double F1[12],F2[12]; /* begin at indice two*/ + + F1[0]=0; + F1[1]=1; + F2[0]=0; + F2[1]=1; + /* stability check */ + while(ok && (j<11)) + { + ok=0; + for(i=1; i<10; i++) + { + if( (lsp_coef[i+1]-lsp_coef[i]) < Dmin) + { + ok=1; + p_avg=(lsp_coef[i]+lsp_coef[i+1])/2.0; + lsp_coef[i]=p_avg-Dmin/2.0; + lsp_coef[i+1]=p_avg+Dmin/2.0; + }; + }; + j++; + } + + /* first converts lsp frequencies to lsp coefficients */ + for (i=1; i<11; i++) + { + /* interpolation */ + tmp=lsp_coef[i]*255.0; + index=(int)tmp; + delta=CosineTable[index+1]-CosineTable[index]; + lspcos[i]=CosineTable[index]+delta*(tmp-index); + }; + + for(i=2; i<7; i++) + { + F1[i]=-2*lspcos[2*i-3]*F1[i-1]+2*F1[i-2]; + F2[i]=-2*lspcos[2*i-2]*F2[i-1]+2*F2[i-2]; + for(j=i-1; j>1; j--) + { + F1[j]=F1[j]-2*lspcos[2*i-3]*F1[j-1]+F1[j-2]; + F2[j]=F2[j]-2*lspcos[2*i-2]*F2[j-1]+F2[j-2]; + }; + }; + for(i=6; i>1; i--) + { + F1[i]=F1[i]+F1[i-1]; + F2[i]=F2[i]-F2[i-1]; + }; + for(i=2; i<7; i++) + { + lpc_coef[i-1]=(F1[i]+F2[i])*0.5; + lpc_coef[i+4]=(F1[8-i]-F2[8-i])*0.5; + }; + lpc_coef[0]=1; +} + diff --git a/externals/unauthorized/disto~/distort3.txt b/externals/unauthorized/manual/disto~.txt similarity index 96% rename from externals/unauthorized/disto~/distort3.txt rename to externals/unauthorized/manual/disto~.txt index e25d857ff8631754b66e8ececff7c1c57591dfb4..820268a191abdc680c37a6e182da79cdd1926876 100644 --- a/externals/unauthorized/disto~/distort3.txt +++ b/externals/unauthorized/manual/disto~.txt @@ -1,5 +1,5 @@ Distortion (algorithm 3) -þþþþþþþþþþþþþþþþþþþþþþþþ +------------------------ Similar to Distortion (algorithm 1) but uses Hi & Low Pass Filters from Filters. Algorithm is HPF -> Distortion -> LPF. There are parameters for diff --git a/externals/unauthorized/mp3amp~/mp3amp~-help.pd b/externals/unauthorized/mp3amp~-help.pd similarity index 100% rename from externals/unauthorized/mp3amp~/mp3amp~-help.pd rename to externals/unauthorized/mp3amp~-help.pd diff --git a/externals/unauthorized/mp3amp~.c b/externals/unauthorized/mp3amp~.c new file mode 100644 index 0000000000000000000000000000000000000000..f3aeebed35095b5fa77826294a64f88c7bc61131 --- /dev/null +++ b/externals/unauthorized/mp3amp~.c @@ -0,0 +1,1266 @@ +/* ------------------------- mp3amp~ ------------------------------------------ */ +/* */ +/* Tilde object to receive an mp3-stream from a shoutcast/icecast server. */ +/* Written by Yves Degoyon (ydegoyon@free.fr). */ +/* Get source at http://ydegoyon.free.fr */ +/* */ +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2 of the License, or (at your option) any later version. */ +/* */ +/* This library 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 */ +/* Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the */ +/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ +/* Boston, MA 02111-1307, USA. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* Uses the LAME MPEG 1 Layer 3 encoding library which can be found at */ +/* http://www.mp3dev.org */ +/* */ +/* ---------------------------------------------------------------------------- */ + +#include +#include "m_imp.h" +#include "g_canvas.h" +#include "s_stuff.h" +#include "pthread.h" + +#include +#include +#include +#include +#include +#include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ +#include "mpglib.h" /* mpglib decoding library from lame 3.92 */ +#include "interface.h" /* mpglib decoding library from lame 3.92 */ +#ifdef _WIN32 +#if !defined(__OBJC__) && !defined(__GNU_LIBOBJC__) && !defined(__objc_INCLUDE_GNU) +#define BOOL WINBOOL +#endif +#include +#include +#include +#define strdup _strdup +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define SOCKET_ERROR -1 +#endif /* _WIN32 */ + +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#if defined(__APPLE__) || defined(WIN32) +#define MSG_NOSIGNAL 0 +#endif + +#define LAME_AUDIO_CHUNK_SIZE 1152 +#define MIN_AUDIO_INPUT 2*LAME_AUDIO_CHUNK_SIZE /* we must have at least n chunks to play a steady sound */ +#define INPUT_BUFFER_SIZE 131072 /* data received on the socket : 128k */ +#define OUTPUT_BUFFER_SIZE 131072 /* audio output buffer : 128k */ +#define DECODE_PACKET_SIZE 131072 /* size of the data returned by mpglib : 128k */ +#define STRBUF_SIZE 4096 /* char received from server on startup */ +#define MAX_DECODERS 50 +#define BARHEIGHT 10 + +static int guidebug=0; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ + post(a,b,c,d,e,f);\ + sys_vgui(a,b,c,d,e,f) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g );\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ + post(a,b,c,d,e,f,g,h );\ + sys_vgui(a,b,c,d,e,f,g,h) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i );\ + sys_vgui(a,b,c,d,e,f,g,h,i) + + +/* useful debugging functions from mpglib */ +extern int decode_header( struct frame* fr, unsigned long newhead ); +extern void print_header_compact( struct frame* fr ); +extern int head_check( unsigned long head, int check_layer ); + +static char *mp3amp_version = "mp3amp~: mp3 streaming client v0.12, written by Yves Degoyon"; + +/* ------------------------ mp3amp~ ----------------------------- */ + +static t_class *mp3amp_class; + +/* too bad, this needs to be static, + handling an array to enable several decoders in pd */ +static MPSTR mps[MAX_DECODERS]; /* decoder buffer */ +static int nbinstances = 0; + +extern const long freqs[9]; + +/* time-out used for select() call */ +static struct timeval ztout; + +typedef struct _mp3amp +{ + t_object x_obj; + t_int x_instance; /* instance of the object */ + t_outlet *x_connection; + t_int x_fd; /* the socket number */ + t_int x_inframes; /* number of waiting frames */ + t_int x_dframes; /* displayed frames in status bar */ + t_int x_packetsize; /* size of the packets */ + t_int x_pblocks; /* processed blocks */ + t_int x_graphic; /* indicates if we show a graphic bar */ + t_canvas *x_canvas; /* remember canvas */ + t_int x_nbwaitloops; /* number of loops to wait */ + t_int x_nbloops; /* number of loops processed */ + t_int x_blocksize; /* size of a dsp block */ + t_int x_resample; /* resampling factor (pd's sr / stream sr) */ + t_int x_dsp; /* number of dsp calls, used to measure time */ + t_int x_standby; /* flag to freeze decoding */ + t_int x_nooutput; /* flag to avoid output of connection state */ + +#ifdef _WIN32 + char *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ +#else + unsigned char *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ +#endif + + t_int x_inwriteposition; + t_int x_inbuffersize; + t_int x_offset; /* offset used for start of decoding */ + + t_float *x_outbuffer; /* buffer to store audio decoded data */ + t_int x_outwriteposition; + t_int x_outreadposition; + t_int x_outunread; + t_int x_outbuffersize; + char x_out[DECODE_PACKET_SIZE]; + + /* mp3 stuff */ + t_int x_samplerate; + t_int x_bitrate; /* bitrate of mp3 stream read at connection time */ + t_int x_bitrateindex; /* bitrate index for each frame, might change dynamically */ + t_int x_mp3mode; /* mode (mono, joint stereo, stereo, dual mono) */ + char* x_bcname; /* name of broadcast */ + char* x_bcurl; /* url of broadcast */ + char* x_bcgenre; /* genre of broadcast */ + char* x_bcaim; /* aim of broadcast */ + char* x_mountpoint; /* mountpoint for IceCast server */ + char* x_hostname; /* hostname to connect to */ + t_int x_port; /* port number to connect to */ + + t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */ +} t_mp3amp; + +static void mp3amp_recv(t_mp3amp *x); +static void mp3amp_disconnect(t_mp3amp *x); +static void mp3amp_connect_url(t_mp3amp *x, t_symbol *url); + +static int strip_shout_header(char *head, int n) +{ + int i; + for (i = 0; i < (n - 2); i++) + { + if (head[i] == 10 && head[i + 1] == 13) + break; + if (head[i] == '\n' && head[i + 1] == '\n') + break; + } + head[i + 1] = '\0'; + return n - (i + 1); +} + +static int strip_ice_header(char *head, int n) +{ + int i; + for (i = 0; i < (n - 2); i++) + { + if ((head[i] == '\n') && (head[i + 1] == '\n')) + break; + } + head[i + 1] = '\0'; + return n - (i + 1); +} + +static void mp3amp_tilde_mpglib_init(t_mp3amp *x) +{ + int ret; + + InitMP3(&mps[x->x_instance]); +} + +static int mp3amp_decode_input(t_mp3amp *x) +{ + t_int i; + t_int alength = 0; + float resample = 0; + struct frame hframe; + unsigned int a,b,c,d; + unsigned long cheader; + signed short int *p = (signed short int *) x->x_out; + t_int pbytes; + t_int ret, totlength=0; + t_int pframes = 0; + + x->x_offset=0; + // search for an header to check dynamic bitrate + while ( x->x_offset < x->x_inwriteposition ) + { + /* decode first 4 bytes as the header */ + a = *((unsigned char*)x->x_inbuffer+x->x_offset); + b = *((unsigned char*)x->x_inbuffer+x->x_offset+1); + c = *((unsigned char*)x->x_inbuffer+x->x_offset+2); + d = *((unsigned char*)x->x_inbuffer+x->x_offset+3); + + cheader = 0; + cheader = a; + cheader <<= 8; + cheader |= b; + cheader <<= 8; + cheader |= c; + cheader <<= 8; + cheader |= d; + if ( head_check( cheader, 0 ) ) + { + decode_header( &hframe, cheader ); + if ( hframe.framesize == 0 ) + { + post( "mp3amp~: weird header ( frame size = 0 ) .... ignored" ); + x->x_offset++; + continue; + } + x->x_packetsize = hframe.framesize; + // print_header_compact( &hframe ); + // when the bitrate change, reinit decoder + if ( x->x_bitrateindex != hframe.bitrate_index ) + { + post( "mp3amp~: bitrate has changed, reinitialize decoder" ); + ExitMP3(&mps[x->x_instance]); + InitMP3(&mps[x->x_instance]); + x->x_bitrateindex = hframe.bitrate_index; + } + break; + } + x->x_offset++; + } + + if ( x->x_inframes > 0 ) + { + + ret = decodeMP3(&mps[x->x_instance], (unsigned char*)(x->x_inbuffer+x->x_offset), + hframe.framesize+sizeof( unsigned long), (char *) p, sizeof(x->x_out), &pbytes); + + switch (ret) + { + case MP3_OK: + switch (mps[x->x_instance].fr.stereo) + { + case 1: + case 2: + alength = ((mps[x->x_instance].fr.stereo==1)?pbytes >> 1 : pbytes >> 2); + // post( "mp3amp~: stereo : %d", mps[x->x_instance].fr.stereo ); + // update outbuffer contents + for ( i=0; ix_outunread >= x->x_outbuffersize-2 ) + { + // post( "mp3amp~: decode : too much input ... ignored" ); + continue; + } + *(x->x_outbuffer+x->x_outwriteposition) = ((t_float)(*p++))/32767.0; + x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; + *(x->x_outbuffer+x->x_outwriteposition) = + ((mps[x->x_instance].fr.stereo==2)?((t_float)(*p++))/32767.0 : 0.0); + x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; + x->x_outunread+=2; + + if ( x->x_outunread >= MIN_AUDIO_INPUT && !x->x_stream ) + { + post("mp3amp~: stream connected" ); + x->x_resample = x->x_samplerate / freqs[hframe.sampling_frequency]; + if ( x->x_resample == 0 ) x->x_resample=1; + post("mp3amp~: resampling stream from %d to %d Hz (r=%d)", + freqs[hframe.sampling_frequency], x->x_samplerate, x->x_resample ); + x->x_stream = 1; + } + } + break; + default: + alength = -1; + break; + } + // roll buffer + if ( x->x_inwriteposition > hframe.framesize+ (int) sizeof( unsigned long ) + x->x_offset ) + // ^----- maybe the frame is not complete + { + x->x_inwriteposition -= hframe.framesize+sizeof( unsigned long )+x->x_offset; + memcpy( (void *)(x->x_inbuffer), + (void *)(x->x_inbuffer+x->x_offset+hframe.framesize+sizeof( unsigned long )), + x->x_inwriteposition); + x->x_offset = 0; + // post ( "mp3amp~: decoded frame %d", x->x_inframes ); + x->x_inframes--; + pframes++; + } + else // sorry, it will be ignored + { + // error( "mp3amp~: incomplete frame...ignored"); + // x->x_offset = 0; + // x->x_inwriteposition = 0; + // x->x_inframes = 0; + } + + totlength += alength; + break; + + case MP3_NEED_MORE: + if ( mps[x->x_instance].framesize == 0 && mps[x->x_instance].fsizeold != 0 ) + { + post( "mp3amp~: decoding done (totlength=%d).", totlength ); + } + else + { + post( "mp3amp~: retry lame decoding (more data needed)." ); + return -1; + } + break; + + case MP3_ERR: + post( "mp3amp~: lame decoding failed." ); + return ret; + break; + + } + + } + + if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) + { + /* update graphical read status */ + if ( x->x_inframes != x->x_dframes ) + { + char color[32]; + t_int width; + + width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); + SYS_VGUI3(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x ); + if ( x->x_inframes < (MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE) ) + { + strcpy( color, "red" ); + } + else + { + strcpy( color, "lightgreen" ); + } + SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n", + x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, + x->x_obj.te_xpix+(x->x_inwriteposition*width)/INPUT_BUFFER_SIZE, + x->x_obj.te_ypix - 1, color, x ); + x->x_dframes = x->x_inframes; + } + } + return totlength; +} + +static void mp3amp_recv(t_mp3amp *x) +{ + int ret, i; + float resample = 0; + struct frame hframe; + unsigned int a,b,c,d; + unsigned long cheader; + +#ifdef _WIN32 + if(( ret = recv(x->x_fd, (char*)x->x_inbuffer + x->x_inwriteposition, + (x->x_inbuffersize-x->x_inwriteposition), 0)) < 0) +#else + if ( ( ret = recv(x->x_fd, (void*) (x->x_inbuffer + x->x_inwriteposition), + (size_t)((x->x_inbuffersize-x->x_inwriteposition)), + MSG_NOSIGNAL) ) < 0 ) +#endif + { + post( "mp3amp~: receive error" ); +#ifndef _MSC_VER + perror( "recv" ); +#endif + mp3amp_disconnect(x); + return; + } + else + { + + // post( "mp3amp~: received %d bytes at %d on %d ( up to %d)", + // ret, x->x_inwriteposition, x->x_fd, + // x->x_inbuffersize-x->x_inwriteposition ); + + if ( ret == 0 && ( x->x_inbuffersize-x->x_inwriteposition != 0 ) ) + { + error("mp3amp~: stream lost..."); + mp3amp_disconnect(x); + } + else + { + // check if we should decode those packets + if ( x->x_standby ) + { + return; + } + // check we don't overflow input buffer + if ( ( x->x_inwriteposition + ret ) > x->x_inbuffersize*0.9 ) + { + post( "mp3streamin~ : too much input...resetting" ); + x->x_inwriteposition=0; + x->x_offset = 0; + x->x_inframes = 0; + return; + } + x->x_inwriteposition += ret; + x->x_offset = 0; + // check some parameters in the stream + while ( x->x_offset < x->x_inwriteposition ) + { + /* decode first 4 bytes as the header */ + a = *((unsigned char*)x->x_inbuffer+x->x_offset); + b = *((unsigned char*)x->x_inbuffer+x->x_offset+1); + c = *((unsigned char*)x->x_inbuffer+x->x_offset+2); + d = *((unsigned char*)x->x_inbuffer+x->x_offset+3); + + cheader = 0; + cheader = a; + cheader <<= 8; + cheader |= b; + cheader <<= 8; + cheader |= c; + cheader <<= 8; + cheader |= d; + if ( head_check( cheader, 0 ) ) + { + decode_header( &hframe, cheader ); + // print_header_compact( &hframe ); + x->x_packetsize = hframe.framesize; + if ( hframe.framesize == 0 ) + { + post( "mp3amp~: weird header ( frame size = 0 ) .... ignored" ); + x->x_inwriteposition -= ret; + return; + } + x->x_inframes += ret/x->x_packetsize; + // post( "mp3amp~: nb frames %d", x->x_inframes ); + break; + } + x->x_offset++; + } + } + } +} + +static t_int *mp3amp_perform(t_int *w) +{ + t_mp3amp *x = (t_mp3amp*) (w[1]); + t_float *out1 = (t_float *)(w[2]); + t_float *out2 = (t_float *)(w[3]); + int n = (int)(w[4]); + int ret; + int i = 0; + + x->x_blocksize = n; + x->x_nbwaitloops = LAME_AUDIO_CHUNK_SIZE/x->x_blocksize; + // post( "mp3mp3amp~ : will wait %d loops", x->x_nbwaitloops ); + x->x_dsp++; + + while( n-- ) + { + if(x->x_stream && !x->x_standby ) // check that the stream provides enough data + { + if(x->x_resample == 1) /* don't need to resample */ + { + *out1++=*(x->x_outbuffer+x->x_outreadposition); + x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; + *out2++=*(x->x_outbuffer+x->x_outreadposition); + x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; + x->x_outunread-=2; + } + else + { + /* we just use the same sample x->x_resample times */ + *out1++=*(x->x_outbuffer+x->x_outreadposition); + *out2++=*(x->x_outbuffer+((x->x_outreadposition + 1)%x->x_outbuffersize)); + if((n%x->x_resample)== 0) + { + x->x_outreadposition = (x->x_outreadposition + 2)%x->x_outbuffersize; + x->x_outunread-=2; + } + } + if ( n == 1 ) x->x_pblocks++; + } + else + { + *out1++=0.0; + *out2++=0.0; + } + } + + if ( x->x_pblocks == LAME_AUDIO_CHUNK_SIZE/x->x_blocksize ) + { + x->x_pblocks = 0; + } + + /* check for readability, then fill the input buffer */ + if(( x->x_fd > 0 )&&(x->x_dsp >= 16)) /* determine how often we try to read */ + { + fd_set readset; + fd_set exceptset; + + FD_ZERO(&readset); + FD_ZERO(&exceptset); + FD_SET(x->x_fd, &readset ); + FD_SET(x->x_fd, &exceptset ); + + x->x_dsp = 0; + + if ( select( x->x_fd+1, &readset, NULL, &exceptset, &ztout ) >0 ) + { + if ( FD_ISSET( x->x_fd, &readset) || FD_ISSET( x->x_fd, &exceptset ) ) + { + /* receive data or error */ + mp3amp_recv(x); + } + } + } + + // check new incoming data + if ( x->x_fd > 0 && ( x->x_nbloops == 0 ) && ( x->x_inframes > 0 ) && ( !x->x_standby ) ) + { + mp3amp_decode_input(x); + } + if ( x->x_nbwaitloops != 0 ) + { + x->x_nbloops = (x->x_nbloops+1 ) % x->x_nbwaitloops; + } + return (w+5); +} + +static void mp3amp_dsp(t_mp3amp *x, t_signal **sp) +{ + dsp_add(mp3amp_perform, 4, x, sp[1]->s_vec, sp[2]->s_vec, sp[1]->s_n); +} + + +/* freeze decoding */ +static void mp3amp_standby(t_mp3amp *x, t_floatarg fstandby ) +{ + if ( fstandby == 0. ) + { + x->x_standby = 0; + } + else + { + x->x_standby = 1; + } +} + +/* connection main procedure executed by a thread */ +static void *mp3amp_do_connect(void *tdata ) +{ + t_mp3amp *x = (t_mp3amp*) tdata; + struct sockaddr_in server; + struct hostent *hp; + t_int portno = x->x_port; /* get port from message box */ + + /* variables used for communication with server */ + char *sptr = NULL; + char request[STRBUF_SIZE]; /* string to be send to server */ + char *url; /* used for relocation */ + fd_set fdset; + struct timeval tv; + t_int sockfd; /* socket to server */ + t_int relocate, numrelocs = 0; + t_int i, ret, rest, nanswers=0; + char *cpoint = NULL; + t_int offset = 0, endofheaders = 0; + + if (x->x_fd >= 0) + { + error("mp3amp~: already connected"); + return NULL; + } + + sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sockfd < 0) + { + error("mp3amp~: internal error while attempting to open socket"); + return NULL; + } + + /* connect socket using hostname provided in command line */ + server.sin_family = AF_INET; + hp = gethostbyname(x->x_hostname); + if (hp == 0) + { + post("mp3amp~: bad host?"); + sys_closesocket(sockfd); + return NULL; + } + memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); + + /* assign client port number */ + server.sin_port = htons((unsigned short)portno); + + /* try to connect. */ + post("mp3amp~: connecting to http:/%s:%d/%s", x->x_hostname, x->x_port, x->x_mountpoint ); + if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0) + { + error("mp3amp~: connection failed!\n"); + sys_closesocket(sockfd); + return NULL; + } + post("mp3amp~: connected : socket opened" ); + + /* sheck if we can read/write from/to the socket */ + FD_ZERO( &fdset); + FD_SET( sockfd, &fdset); + tv.tv_sec = 0; /* seconds */ + tv.tv_usec = 500; /* microseconds */ + + ret = select(sockfd + 1, &fdset, NULL, NULL, &tv); + if(ret != 0) + { + error("mp3amp~: can not read from socket"); + sys_closesocket(sockfd); + return NULL; + } + post("mp3amp~: select done" ); + + /* check mountpoint */ + if( strstr(x->x_mountpoint, "listen.pls") ) + { + /* SHOUTcast playlist -> get / */ + x->x_mountpoint = ""; + } + + /* build up stuff we need to send to server */ + sprintf(request, "GET /%s HTTP/1.0 \r\nHost: %s\r\nUser-Agent: mp3amp~ 0.11\r\nAccept: */*\r\n\r\n", + x->x_mountpoint, x->x_hostname); + + if ( send(sockfd, request, strlen(request), 0) < 0 ) /* say hello to server */ + { + post( "mp3amp~: could not contact server... " ); +#ifndef _MSC_VER + perror( "send" ); +#endif + return NULL; + } + post("mp3amp~: send done" ); + + relocate = FALSE; + memset( request, 0x00, STRBUF_SIZE ); + + // read all the answer + endofheaders=0; + while ( !endofheaders ) + { + if( ( ret = recv(sockfd, request+offset, STRBUF_SIZE, MSG_NOSIGNAL) ) <0) + { + error("mp3amp~: no response from server"); +#ifndef _MSC_VER + perror( "recv" ); +#endif + return NULL; + } + post ( "mp3amp~ : received %d bytes at %d", ret, offset ); + for ( i=offset; ix_nooutput = 1; + mp3amp_connect_url(x, gensym(url)); + x->x_nooutput = 0; + return NULL; + // relocate = TRUE; + } + if( !(sptr = strstr(request, "200")) && !relocate ) + { + error("mp3amp~: cannot connect to the (default) stream"); + return NULL; + } + + post("mp3amp~: IceCast server detected"); + + // post("mp3amp~: server's header : %s", request ); + + // check what we got + if( cpoint = strstr(request, "x-audiocast-mount:")) + { + x->x_mountpoint = strdup(cpoint + 18); + for ( i=0; i<(int)strlen(x->x_mountpoint); i++ ) + { + if ( x->x_mountpoint[i] == '\n' ) + { + x->x_mountpoint[i] = '\0'; + break; + } + } + post(" mountpoint: %s", x->x_mountpoint); + } + if( cpoint = strstr(request, "x-audiocast-server-url:")) + { + sptr = strdup( cpoint + 24); + for ( i=0; i<(int)strlen(sptr); i++ ) + { + if ( sptr[i] == '\n' ) + { + sptr[i] = '\0'; + break; + } + } + post(" server-url: %s", sptr); + } + if( cpoint = strstr(request, "x-audiocast-location:")) + { + sptr = strdup( cpoint + 22); + for ( i=0; i<(int)strlen(sptr); i++ ) + { + if ( sptr[i] == '\n' ) + { + sptr[i] = '\0'; + break; + } + } + post(" location: %s", sptr); + } + if( cpoint = strstr(request, "x-audiocast-admin:")) + { + sptr = strdup( cpoint + 19); + for ( i=0; i<(int)strlen(sptr); i++ ) + { + if ( sptr[i] == '\n' ) + { + sptr[i] = '\0'; + break; + } + } + post(" admin: %s", sptr); + } + if( cpoint = strstr(request, "x-audiocast-name:")) + { + x->x_bcname = strdup( cpoint + 17); + for ( i=0; i<(int)strlen(x->x_bcname); i++ ) + { + if ( x->x_bcname[i] == '\n' ) + { + x->x_bcname[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if( cpoint = strstr(request, "x-audiocast-genre:")) + { + x->x_bcgenre = strdup( cpoint + 18); + for ( i=0; i<(int)strlen(x->x_bcgenre); i++ ) + { + if ( x->x_bcgenre[i] == '\n' ) + { + x->x_bcgenre[i] = '\0'; + break; + } + } + post(" genre: %s", x->x_bcgenre); + } + if( cpoint = strstr(request, "x-audiocast-url:")) + { + x->x_bcurl = strdup( cpoint + 16); + for ( i=0; i<(int)strlen(x->x_bcurl); i++ ) + { + if ( x->x_bcurl[i] == '\n' ) + { + x->x_bcurl[i] = '\0'; + break; + } + } + post(" url: %s", x->x_bcurl); + } + if( cpoint = strstr(request, "x-audiocast-public:1")) + { + post(" broadcast is public"); + } + else if( cpoint = strstr(request, "x-audiocast-public:0")) + { + post(" broadcast is NOT public"); + } + if( cpoint = strstr(request, "x-audiocast-bitrate:")) + { + sptr = strdup( cpoint + 20); + for ( i=0; i<(int)strlen(sptr); i++ ) + { + if ( sptr[i] == '\n' ) + { + sptr[i] = '\0'; + break; + } + } + if(!strncmp(sptr, "320", 3))x->x_bitrate = 320; + else if(!strncmp(sptr, "256", 3))x->x_bitrate = 256; + else if(!strncmp(sptr, "224", 3))x->x_bitrate = 224; + else if(!strncmp(sptr, "192", 3))x->x_bitrate = 192; + else if(!strncmp(sptr, "160", 3))x->x_bitrate = 160; + else if(!strncmp(sptr, "144", 3))x->x_bitrate = 144; + else if(!strncmp(sptr, "128", 3))x->x_bitrate = 128; + else if(!strncmp(sptr, "112", 3))x->x_bitrate = 112; + else if(!strncmp(sptr, "96", 2))x->x_bitrate = 96; + else if(!strncmp(sptr, "80", 2))x->x_bitrate = 80; + else if(!strncmp(sptr, "64", 2))x->x_bitrate = 64; + else if(!strncmp(sptr, "56", 2))x->x_bitrate = 56; + else if(!strncmp(sptr, "48", 2))x->x_bitrate = 48; + else if(!strncmp(sptr, "40", 2))x->x_bitrate = 40; + else if(!strncmp(sptr, "32", 2))x->x_bitrate = 32; + else if(!strncmp(sptr, "24", 2))x->x_bitrate = 24; + else if(!strncmp(sptr, "16", 2))x->x_bitrate = 16; + else if(!strncmp(sptr, "8", 1))x->x_bitrate = 8; + else + { + post("mp3amp~: unsupported bitrate! : %s", sptr); + return NULL; + } + post(" bitrate: %d", x->x_bitrate); + } + if( cpoint = strstr(request, "x-audiocast-udpport:")) + { + post("mp3amp~: sorry, server wants UDP connection!"); + return NULL; + } + } + else /* it is a SHOUTcast server */ + { + strip_shout_header (request, STRBUF_SIZE); + post("mp3amp~: SHOUTcast server detected"); + if(strstr(request, "ICY 401") != 0) + { + post("mp3amp~: ICY 401 Service Unavailable"); + return NULL; + } + if (strstr(request, "ICY 200 OK")) + { + /* recv and decode info about broadcast line by line */ + post("mp3amp~: connecting to stream..."); + i = ret; + /* check what we got */ + + if( cpoint = strstr(request, "icy-name:")) + { + x->x_bcname = strdup( cpoint + 10); + for ( i=0; i<(int)strlen(x->x_bcname); i++ ) + { + if ( x->x_bcname[i] == '\n' ) + { + x->x_bcname[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if( cpoint = strstr(request, "x-audiocast-name:")) + { + x->x_bcname = strdup( cpoint + 18); + for ( i=0; i<(int)strlen(x->x_bcname); i++ ) + { + if ( x->x_bcname[i] == '\n' ) + { + x->x_bcname[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if( cpoint = strstr(request, "icy-genre:")) + { + x->x_bcgenre = strdup( cpoint + 10); + for ( i=0; i<(int)strlen(x->x_bcgenre); i++ ) + { + if ( x->x_bcgenre[i] == '\n' ) + { + x->x_bcgenre[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if( cpoint = strstr(request, "icy-aim:")) + { + x->x_bcaim = strdup( cpoint + 8); + for ( i=0; i<(int)strlen(x->x_bcaim); i++ ) + { + if ( x->x_bcaim[i] == '\n' ) + { + x->x_bcaim[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if( cpoint = strstr(request, "icy-url:")) + { + x->x_bcurl = strdup( cpoint + 8); + for ( i=0; i<(int)strlen(x->x_bcurl); i++ ) + { + if ( x->x_bcurl[i] == '\n' ) + { + x->x_bcurl[i] = '\0'; + break; + } + } + post(" name: %s", x->x_bcname); + } + if(strstr(request, "icy-pub:1")) + { + post(" broadcast is public"); + } + else if(strstr(request, "icy-pub:0")) + { + post(" broadcast is NOT public"); + } + if( cpoint = strstr(request, "icy-br:")) + { + sptr = strdup( cpoint + 7); + if(!strncmp(sptr, "320", 3))x->x_bitrate = 320; + else if(!strncmp(sptr, "256", 3))x->x_bitrate = 256; + else if(!strncmp(sptr, "224", 3))x->x_bitrate = 224; + else if(!strncmp(sptr, "192", 3))x->x_bitrate = 192; + else if(!strncmp(sptr, "160", 3))x->x_bitrate = 160; + else if(!strncmp(sptr, "144", 3))x->x_bitrate = 144; + else if(!strncmp(sptr, "128", 3))x->x_bitrate = 128; + else if(!strncmp(sptr, "112", 3))x->x_bitrate = 112; + else if(!strncmp(sptr, "96", 2))x->x_bitrate = 96; + else if(!strncmp(sptr, "80", 2))x->x_bitrate = 80; + else if(!strncmp(sptr, "64", 2))x->x_bitrate = 64; + else if(!strncmp(sptr, "56", 2))x->x_bitrate = 56; + else if(!strncmp(sptr, "48", 2))x->x_bitrate = 48; + else if(!strncmp(sptr, "40", 2))x->x_bitrate = 40; + else if(!strncmp(sptr, "32", 2))x->x_bitrate = 32; + else if(!strncmp(sptr, "24", 2))x->x_bitrate = 24; + else if(!strncmp(sptr, "16", 2))x->x_bitrate = 16; + else if(!strncmp(sptr, "8", 2))x->x_bitrate = 8; + else + { + post("mp3amp~: unsupported bitrate! (%s)", sptr); + return NULL; + } + post(" bitrate: %d", x->x_bitrate); + } + if(strstr(request, "x-audiocast-udpport:")) + { + post("mp3amp~: sorry, server wants UDP connection!"); + return NULL; + } + } + else + { + post("mp3amp~: unknown response from server"); + return NULL; + } + relocate = FALSE; + } + if (relocate) + { + error("mp3amp~: too many HTTP relocations"); + return NULL; + } + post("mp3amp~: connected to http://%s:%d/%s", hp->h_name, portno, x->x_mountpoint); + x->x_fd = sockfd; + if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) + { + t_int width; + + width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); + SYS_VGUI3(".x%lx.c delete rectangle %xPBAR\n", x->x_canvas, x ); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n", + x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, + x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x ); + } + + return NULL; +} + +/* launch the connection thread */ +static void mp3amp_connect(t_mp3amp *x, t_symbol *hostname, t_symbol *mountpoint, t_floatarg fportno ) +{ + pthread_attr_t update_child_attr; + pthread_t connectchild; + + // store data + x->x_hostname = (char*) getbytes( strlen( hostname->s_name ) + 1 ); // there's a memory leak here + strcpy( x->x_hostname, hostname->s_name ); + + x->x_mountpoint = (char*) getbytes( strlen( mountpoint->s_name ) + 1 ); // there's a memory leak here + strcpy( x->x_mountpoint, mountpoint->s_name ); + + x->x_port = fportno; + + // launch connection thread + if ( pthread_attr_init( &update_child_attr ) < 0 ) + { + post( "mp3amp~ : could not launch connection thread" ); + perror( "pthread_attr_init" ); + return; + } + if ( pthread_attr_setdetachstate( &update_child_attr, PTHREAD_CREATE_DETACHED ) < 0 ) + { + post( "mp3amp~ : could not launch connection thread" ); + perror( "pthread_attr_setdetachstate" ); + return; + } + if ( pthread_create( &connectchild, &update_child_attr, mp3amp_do_connect, x ) < 0 ) + { + post( "mp3amp~ : could not launch connection thread" ); + perror( "pthread_create" ); + return; + } + else + { + // post( "cooled~ : drawing thread %d launched", (int)x->x_updatechild ); + } + + if ( !x->x_nooutput ) outlet_float(x->x_connection, 1); +} + +/* connect using url like "http://localhost:8000/mountpoint" */ +static void mp3amp_connect_url(t_mp3amp *x, t_symbol *url) +{ + char *hostptr = NULL, *p, *endhost = NULL, *hostname = NULL; + char *pathptr = NULL; + t_int portno = 8000; + + post( "mp3amp~ : connect url : %s", url->s_name ); + + /* strip http:// or ftp:// */ + p = url->s_name; + if (strncmp(p, "http://", 7) == 0) + p += 7; + + if (strncmp(p, "ftp://", 6) == 0) + p += 6; + + hostptr = p; + while (*p && *p != '/' && *p != ':') /* look for end of hostname: */ + p++; + + endhost = p; + switch ( *p ) + { + case ':' : + portno = atoi( p+1 ); + while (*p && *p != '/') p++; + pathptr = p+1; + break; + case '/' : + portno = 8000; + pathptr = p+1; + break; + default : + if ( ( p - url->s_name ) != (int)strlen( url->s_name ) ) + { + post( "mp3amp~ : wrong url : %s", hostptr ); + return; + } + pathptr = ""; + break; + } + + hostname=(char*)getbytes( (int)(endhost - hostptr) + 1); + strncpy( hostname, hostptr, (int)(endhost - hostptr) ); + hostname[ endhost - hostptr ] = '\0'; + + post ("mp3amp~ : connecting to host=%s port=%d path=%s", hostname, portno, pathptr ); + + /* call the 'normal' connection routine */ + mp3amp_connect(x, gensym(hostname), gensym(pathptr), portno); +} + +/* close connection to SHOUTcast server */ +static void mp3amp_disconnect(t_mp3amp *x) +{ + x->x_stream = 0; + x->x_inframes = 0; + x->x_dframes = 0; + x->x_inwriteposition = 0; + x->x_offset = 0; + if(x->x_fd >= 0) /* close socket */ + { + sys_closesocket(x->x_fd); + x->x_fd = -1; + } + ExitMP3(&mps[x->x_instance]); + InitMP3(&mps[x->x_instance]); + if ( x->x_graphic ) + { + SYS_VGUI3(".x%lx.c delete rectangle %xPBAR\n", x->x_canvas, x ); + SYS_VGUI3(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x ); + } + post("mp3amp~: connection closed"); + outlet_float(x->x_connection, 0); +} + +static void mp3amp_free(t_mp3amp *x) +{ + if (x->x_fd > 0) + { + post( "mp3amp~: closing socket" ); + sys_closesocket(x->x_fd); + x->x_fd = -1; + } + freebytes(x->x_inbuffer, INPUT_BUFFER_SIZE); + freebytes(x->x_outbuffer, OUTPUT_BUFFER_SIZE*sizeof(t_float)); +} + +static void *mp3amp_new(t_floatarg fdographics) +{ + t_mp3amp *x = NULL; + + if ( ((int)fdographics != 0) && ((int)fdographics != 1.) ) + { + post( "mp3amp~: error : constructor : mp3amp~ [graphic flag = 0 | 1 ] ( got = %f)", fdographics ); + return NULL; + } + + x = (t_mp3amp *)pd_new(mp3amp_class); + outlet_new(&x->x_obj, gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + x->x_connection = outlet_new(&x->x_obj, gensym("float")); + + if ( nbinstances < MAX_DECODERS ) + { + x->x_instance = nbinstances++; + } + else + { + post( "mp3amp~: cannot create more decoders (memory issues), sorry" ); + return NULL; + } + + x->x_fd = -1; + x->x_stream = 0; + x->x_inframes = 0; + x->x_samplerate = sys_getsr(); + x->x_nbwaitloops = 1; + x->x_nbloops = 0; + x->x_dsp = 0; + + x->x_inbuffersize = INPUT_BUFFER_SIZE; + x->x_outbuffersize = OUTPUT_BUFFER_SIZE; + x->x_inbuffer = (unsigned char*) getbytes(INPUT_BUFFER_SIZE); + x->x_offset = 0; + x->x_outbuffer = (t_float*) getbytes(OUTPUT_BUFFER_SIZE*sizeof(t_float)); + + if ( !x->x_inbuffer || !x->x_outbuffer ) + { + post( "mp3amp~: could not allocate buffers" ); + return NULL; + } + memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE ); + memset( x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE ); + + x->x_inwriteposition = 0; + x->x_outreadposition = 0; + x->x_outwriteposition = 0; + x->x_outunread = 0; + x->x_standby = 0; + x->x_resample = -1; + x->x_nooutput = 0; + + ztout.tv_sec = 0; + ztout.tv_usec = 0; + + x->x_graphic = (int)fdographics; + post( "mp3amp~: getting canvas" ); + x->x_canvas = canvas_getcurrent(); + + post( "mp3amp~: initializing decoder..." ); + /* init mpg123 decoder */ + mp3amp_tilde_mpglib_init(x); + + logpost(NULL, 4, "%s", mp3amp_version); + + return (x); +} + + +void mp3amp_tilde_setup(void) +{ + mp3amp_class = class_new(gensym("mp3amp~"), + (t_newmethod) mp3amp_new, (t_method) mp3amp_free, + sizeof(t_mp3amp), 0, A_DEFFLOAT, A_NULL); + + class_addmethod(mp3amp_class, nullfn, gensym("signal"), 0); + class_addmethod(mp3amp_class, (t_method)mp3amp_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(mp3amp_class, (t_method)mp3amp_connect, gensym("connect"), A_SYMBOL, A_SYMBOL, A_FLOAT, 0); + class_addmethod(mp3amp_class, (t_method)mp3amp_connect_url, gensym("connecturl"), A_SYMBOL, 0); + class_addmethod(mp3amp_class, (t_method)mp3amp_standby, gensym("standby"), A_DEFFLOAT, 0); + class_addmethod(mp3amp_class, (t_method)mp3amp_disconnect, gensym("disconnect"), 0); +} diff --git a/externals/unauthorized/mp3amp~/INSTALL b/externals/unauthorized/mp3amp~/INSTALL deleted file mode 100644 index 8260a98d34f50e75a1cbda6ca6750344acda2e6f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/INSTALL +++ /dev/null @@ -1,19 +0,0 @@ -You need to get lame > v3.90 installed first. -libmp3lame.so is searched in /usr/local/lib -( no time to write configure scripts ). -if it's installed elsewhere, change the Makefile, -you won't die from that. - -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/mp3amp~ - -make clean - -make - -make install - -thanks for getting here. - -Yves/ diff --git a/externals/unauthorized/mp3amp~/Makefile b/externals/unauthorized/mp3amp~/Makefile deleted file mode 100644 index 05ec33f87352ec2d0b48306e69bd5b062687e84f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=mp3amp~ -CSYM=mp3amp_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch -g - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib -lmp3lame - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/mp3amp~/README b/externals/unauthorized/mp3amp~/README deleted file mode 100644 index 4ab73ee2dec8c64a804a8eeaca0bafa28f636777..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/README +++ /dev/null @@ -1,45 +0,0 @@ -Version 0.01 -copyright (c) 2001 by Olaf Matthes & Yves Degoyon - -mp3amp~ is a MPEG I Layer III (mp3) icecast/shoutcast client for Pure Data - -To install mp3amp~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - -mp3amp~ has been compiled for Linux using LAME 3.92. -The newest version of LAME can be found at sourceforge.net - -COPYING: you may use this source under GPL terms! - -PLEASE NOTE: This software may contain patented alogrithm (at least - patented in some countries). It may be not allowed to sell/use products - based on this source code in these countries. Check this out first! - -COPYRIGHT of MP3 music: - Please note, that the duplicating of copyrighted music without explicit - permission violates the rights of the owner. - -***************************************************************************** - - using mp3amp~ external for Pure Data - -Open the help-mp3amp~.pd to understand how it works. -Open the help-graphic-mp3amp~.pd if you want to see the status of the incoming stream. - -BUGS : - -a/ certainly, not all bitrates will work, -that's too tedious to test, 128, 256, 320 are ok. - -b/ cannot instantiate more than 10 decoders, if needed change MAX_DECODERS in the code - -c/ this is beta, be patient !!! bugs report welcome !!! diff --git a/externals/unauthorized/mp3amp~/graphic-mp3amp~-help.pd b/externals/unauthorized/mp3amp~/graphic-mp3amp~-help.pd deleted file mode 100644 index 241a6070e02921e3abd1e95e9d259d151044533b..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/graphic-mp3amp~-help.pd +++ /dev/null @@ -1,52 +0,0 @@ -#N canvas 171 33 789 555 10; -#X obj 115 265 dac~; -#X floatatom 164 265 5 0 0; -#X msg 29 150 disconnect; -#X text 208 267 connection status; -#X obj 458 48 loadbang; -#X msg 458 71 \; pd dsp 1; -#X msg 99 76 connect yves puredata 8000; -#X text 96 55 connect ; -#X text 38 18 constructor : mp3amp~ ; -#X text 151 127 connect to SHOUTcast server; -#X msg 157 145 connect localhost listen.pls 8000; -#X msg 176 165 connect localhost content/scpromo.mp3 8000; -#X text 399 141 <-- play livestream; -#X text 479 165 <-- play file; -#X msg 121 99 connect localhost kas 8000; -#X text 97 44 connect to ICEcast server; -#X text 38 7 mp3amp~ : an icecast/shoucast client for PD; -#X text 226 186 Another way of connecting; -#X msg 226 205 connecturl http://localhost:8000/kas; -#X msg 31 374 standby 0; -#X text 114 380 for CPU load reasons \,; -#X text 115 392 ability to freeze decoding; -#X text 114 405 ( packets are read and ignored ); -#X msg 31 399 standby 1; -#X obj 115 196 mp3amp~ 1; -#X msg 353 230 connecturl http://216.235.81.7:20690/play?session=panjabiradio:0&\;lid=-1-fra&\;SaneID=212.198.0.97-1030988754258 -; -#X msg 352 280 connecturl http://213.197.144.44:8000/; -#X msg 352 334 connecturl http://24.207.26.60:8000/; -#X msg 354 307 connecturl http://64.113.197.158:8000/; -#X msg 352 361 connecturl http://liveice.agria.hu:8000/radioeger-hq -; -#X text 406 511 Authors : Yves Degoyon ( ydegoyon@free.fr ); -#X connect 2 0 24 0; -#X connect 4 0 5 0; -#X connect 6 0 24 0; -#X connect 10 0 24 0; -#X connect 11 0 24 0; -#X connect 14 0 24 0; -#X connect 18 0 24 0; -#X connect 19 0 24 0; -#X connect 23 0 24 0; -#X connect 24 0 0 0; -#X connect 24 0 0 1; -#X connect 24 1 0 1; -#X connect 24 2 1 0; -#X connect 25 0 24 0; -#X connect 26 0 24 0; -#X connect 27 0 24 0; -#X connect 28 0 24 0; -#X connect 29 0 24 0; diff --git a/externals/unauthorized/mp3amp~/mp3amp~.c b/externals/unauthorized/mp3amp~/mp3amp~.c deleted file mode 100644 index 226cfc63158e35e20e95c3ee7a9385d9bc87265b..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/mp3amp~.c +++ /dev/null @@ -1,1262 +0,0 @@ -/* ------------------------- mp3amp~ ------------------------------------------ */ -/* */ -/* Tilde object to receive an mp3-stream from a shoutcast/icecast server. */ -/* Written by Yves Degoyon (ydegoyon@free.fr). */ -/* Get source at http://ydegoyon.free.fr */ -/* */ -/* This library is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public */ -/* License as published by the Free Software Foundation; either */ -/* version 2 of the License, or (at your option) any later version. */ -/* */ -/* This library 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 */ -/* Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public */ -/* License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* Uses the LAME MPEG 1 Layer 3 encoding library which can be found at */ -/* http://www.mp3dev.org */ -/* */ -/* ---------------------------------------------------------------------------- */ - -#include -#include "m_imp.h" -#include "g_canvas.h" -#include "s_stuff.h" -#include "pthread.h" - -#include -#include -#include -#include -#include -#include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ -#include "mpglib.h" /* mpglib decoding library from lame 3.92 */ -#include "interface.h" /* mpglib decoding library from lame 3.92 */ -#ifdef _WIN32 -#include -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define SOCKET_ERROR -1 -#endif /* _WIN32 */ - -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -#if defined(__APPLE__) || defined(WIN32) -#define MSG_NOSIGNAL 0 -#endif -#ifdef UNIX -#define STRDUP strdup -#endif -#ifdef WIN32 -#define STRDUP _strdup -#define sys_closesocket closesocket -#endif - - -#define LAME_AUDIO_CHUNK_SIZE 1152 -#define MIN_AUDIO_INPUT 2*LAME_AUDIO_CHUNK_SIZE /* we must have at least n chunks to play a steady sound */ -#define INPUT_BUFFER_SIZE 131072 /* data received on the socket : 128k */ -#define OUTPUT_BUFFER_SIZE 131072 /* audio output buffer : 128k */ -#define DECODE_PACKET_SIZE 131072 /* size of the data returned by mpglib : 128k */ -#define STRBUF_SIZE 4096 /* char received from server on startup */ -#define MAX_DECODERS 50 -#define BARHEIGHT 10 - -static int guidebug=0; - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g );\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h );\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i );\ - sys_vgui(a,b,c,d,e,f,g,h,i) - - - /* useful debugging functions from mpglib */ -extern int decode_header( struct frame* fr, unsigned long newhead ); -extern void print_header_compact( struct frame* fr ); -extern int head_check( unsigned long head, int check_layer ); - -static char *mp3amp_version = "mp3amp~: mp3 streaming client v0.12, written by Yves Degoyon"; - -/* ------------------------ mp3amp~ ----------------------------- */ - -static t_class *mp3amp_class; - -/* too bad, this needs to be static, - handling an array to enable several decoders in pd */ -static MPSTR mps[MAX_DECODERS]; /* decoder buffer */ -static int nbinstances = 0; - -extern const long freqs[9]; - -/* time-out used for select() call */ -static struct timeval ztout; - -typedef struct _mp3amp -{ - t_object x_obj; - t_int x_instance; /* instance of the object */ - t_outlet *x_connection; - t_int x_fd; /* the socket number */ - t_int x_inframes; /* number of waiting frames */ - t_int x_dframes; /* displayed frames in status bar */ - t_int x_packetsize; /* size of the packets */ - t_int x_pblocks; /* processed blocks */ - t_int x_graphic; /* indicates if we show a graphic bar */ - t_canvas *x_canvas; /* remember canvas */ - t_int x_nbwaitloops; /* number of loops to wait */ - t_int x_nbloops; /* number of loops processed */ - t_int x_blocksize; /* size of a dsp block */ - t_int x_resample; /* resampling factor (pd's sr / stream sr) */ - t_int x_dsp; /* number of dsp calls, used to measure time */ - t_int x_standby; /* flag to freeze decoding */ - t_int x_nooutput; /* flag to avoid output of connection state */ - -#ifdef UNIX - unsigned char *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ -#else - char *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ -#endif - - t_int x_inwriteposition; - t_int x_inbuffersize; - t_int x_offset; /* offset used for start of decoding */ - - t_float *x_outbuffer; /* buffer to store audio decoded data */ - t_int x_outwriteposition; - t_int x_outreadposition; - t_int x_outunread; - t_int x_outbuffersize; - char x_out[DECODE_PACKET_SIZE]; - - /* mp3 stuff */ - t_int x_samplerate; - t_int x_bitrate; /* bitrate of mp3 stream read at connection time */ - t_int x_bitrateindex; /* bitrate index for each frame, might change dynamically */ - t_int x_mp3mode; /* mode (mono, joint stereo, stereo, dual mono) */ - char* x_bcname; /* name of broadcast */ - char* x_bcurl; /* url of broadcast */ - char* x_bcgenre; /* genre of broadcast */ - char* x_bcaim; /* aim of broadcast */ - char* x_mountpoint; /* mountpoint for IceCast server */ - char* x_hostname; /* hostname to connect to */ - t_int x_port; /* port number to connect to */ - - t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */ -} t_mp3amp; - -static void mp3amp_recv(t_mp3amp *x); -static void mp3amp_disconnect(t_mp3amp *x); -static void mp3amp_connect_url(t_mp3amp *x, t_symbol *url); - -static int strip_shout_header(char *head, int n) -{ - int i; - for (i = 0; i < (n - 2); i++) - { - if (head[i] == 10 && head[i + 1] == 13) - break; - if (head[i] == '\n' && head[i + 1] == '\n') - break; - } - head[i + 1] = '\0'; - return n - (i + 1); -} - -static int strip_ice_header(char *head, int n) -{ - int i; - for (i = 0; i < (n - 2); i++) - { - if ((head[i] == '\n') && (head[i + 1] == '\n')) - break; - } - head[i + 1] = '\0'; - return n - (i + 1); -} - -static void mp3amp_tilde_mpglib_init(t_mp3amp *x) -{ - int ret; - - InitMP3(&mps[x->x_instance]); -} - -static int mp3amp_decode_input(t_mp3amp *x) -{ - t_int i; - t_int alength = 0; - float resample = 0; - struct frame hframe; - unsigned int a,b,c,d; - unsigned long cheader; - signed short int *p = (signed short int *) x->x_out; - t_int pbytes; - t_int ret, totlength=0; - t_int pframes = 0; - - x->x_offset=0; - // search for an header to check dynamic bitrate - while ( x->x_offset < x->x_inwriteposition ) - { - /* decode first 4 bytes as the header */ - a = *((unsigned char*)x->x_inbuffer+x->x_offset); - b = *((unsigned char*)x->x_inbuffer+x->x_offset+1); - c = *((unsigned char*)x->x_inbuffer+x->x_offset+2); - d = *((unsigned char*)x->x_inbuffer+x->x_offset+3); - - cheader = 0; - cheader = a; - cheader <<= 8; - cheader |= b; - cheader <<= 8; - cheader |= c; - cheader <<= 8; - cheader |= d; - if ( head_check( cheader, 0 ) ) - { - decode_header( &hframe, cheader ); - if ( hframe.framesize == 0 ) - { - post( "mp3amp~: weird header ( frame size = 0 ) .... ignored" ); - x->x_offset++; - continue; - } - x->x_packetsize = hframe.framesize; - // print_header_compact( &hframe ); - // when the bitrate change, reinit decoder - if ( x->x_bitrateindex != hframe.bitrate_index ) - { - post( "mp3amp~: bitrate has changed, reinitialize decoder" ); - ExitMP3(&mps[x->x_instance]); - InitMP3(&mps[x->x_instance]); - x->x_bitrateindex = hframe.bitrate_index; - } - break; - } - x->x_offset++; - } - - if ( x->x_inframes > 0 ) - { - - ret = decodeMP3(&mps[x->x_instance], (unsigned char*)(x->x_inbuffer+x->x_offset), - hframe.framesize+sizeof( unsigned long), (char *) p, sizeof(x->x_out), &pbytes); - - switch (ret) - { - case MP3_OK: - switch (mps[x->x_instance].fr.stereo) { - case 1: - case 2: - alength = ((mps[x->x_instance].fr.stereo==1)?pbytes >> 1 : pbytes >> 2); - // post( "mp3amp~: stereo : %d", mps[x->x_instance].fr.stereo ); - // update outbuffer contents - for ( i=0; ix_outunread >= x->x_outbuffersize-2 ) - { - // post( "mp3amp~: decode : too much input ... ignored" ); - continue; - } - *(x->x_outbuffer+x->x_outwriteposition) = ((t_float)(*p++))/32767.0; - x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; - *(x->x_outbuffer+x->x_outwriteposition) = - ((mps[x->x_instance].fr.stereo==2)?((t_float)(*p++))/32767.0 : 0.0); - x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; - x->x_outunread+=2; - - if ( x->x_outunread >= MIN_AUDIO_INPUT && !x->x_stream ) - { - post("mp3amp~: stream connected" ); - x->x_resample = x->x_samplerate / freqs[hframe.sampling_frequency]; - if ( x->x_resample == 0 ) x->x_resample=1; - post("mp3amp~: resampling stream from %d to %d Hz (r=%d)", - freqs[hframe.sampling_frequency], x->x_samplerate, x->x_resample ); - x->x_stream = 1; - } - } - break; - default: - alength = -1; - break; - } - // roll buffer - if ( x->x_inwriteposition > hframe.framesize+ (int) sizeof( unsigned long ) + x->x_offset ) - // ^----- maybe the frame is not complete - { - x->x_inwriteposition -= hframe.framesize+sizeof( unsigned long )+x->x_offset; - memcpy( (void *)(x->x_inbuffer), - (void *)(x->x_inbuffer+x->x_offset+hframe.framesize+sizeof( unsigned long )), - x->x_inwriteposition); - x->x_offset = 0; - // post ( "mp3amp~: decoded frame %d", x->x_inframes ); - x->x_inframes--; - pframes++; - } - else // sorry, it will be ignored - { - // error( "mp3amp~: incomplete frame...ignored"); - // x->x_offset = 0; - // x->x_inwriteposition = 0; - // x->x_inframes = 0; - } - - totlength += alength; - break; - - case MP3_NEED_MORE: - if ( mps[x->x_instance].framesize == 0 && mps[x->x_instance].fsizeold != 0 ) - { - post( "mp3amp~: decoding done (totlength=%d).", totlength ); - } - else - { - post( "mp3amp~: retry lame decoding (more data needed)." ); - return -1; - } - break; - - case MP3_ERR: - post( "mp3amp~: lame decoding failed." ); - return ret; - break; - - } - - } - - if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) - { - /* update graphical read status */ - if ( x->x_inframes != x->x_dframes ) - { - char color[32]; - t_int width; - - width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); - SYS_VGUI3(".x%x.c delete rectangle %xSTATUS\n", x->x_canvas, x ); - if ( x->x_inframes < (MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE) ) - { - strcpy( color, "red" ); - } - else - { - strcpy( color, "lightgreen" ); - } - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n", - x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, - x->x_obj.te_xpix+(x->x_inwriteposition*width)/INPUT_BUFFER_SIZE, - x->x_obj.te_ypix - 1, color, x ); - x->x_dframes = x->x_inframes; - } - } - return totlength; -} - -static void mp3amp_recv(t_mp3amp *x) -{ - int ret, i; - float resample = 0; - struct frame hframe; - unsigned int a,b,c,d; - unsigned long cheader; - -#ifdef UNIX - if ( ( ret = recv(x->x_fd, (void*) (x->x_inbuffer + x->x_inwriteposition), - (size_t)((x->x_inbuffersize-x->x_inwriteposition)), - MSG_NOSIGNAL) ) < 0 ) -#else - if(( ret = recv(x->x_fd, (char*)x->x_inbuffer + x->x_inwriteposition, - (x->x_inbuffersize-x->x_inwriteposition), 0)) < 0) -#endif - { - post( "mp3amp~: receive error" ); -#ifdef UNIX - perror( "recv" ); -#endif - mp3amp_disconnect(x); - return; - } - else - { - - // post( "mp3amp~: received %d bytes at %d on %d ( up to %d)", - // ret, x->x_inwriteposition, x->x_fd, - // x->x_inbuffersize-x->x_inwriteposition ); - - if ( ret == 0 && ( x->x_inbuffersize-x->x_inwriteposition != 0 ) ) - { - error("mp3amp~: stream lost..."); - mp3amp_disconnect(x); - } - else - { - // check if we should decode those packets - if ( x->x_standby ) - { - return; - } - // check we don't overflow input buffer - if ( ( x->x_inwriteposition + ret ) > x->x_inbuffersize*0.9 ) - { - post( "mp3streamin~ : too much input...resetting" ); - x->x_inwriteposition=0; - x->x_offset = 0; - x->x_inframes = 0; - return; - } - x->x_inwriteposition += ret; - x->x_offset = 0; - // check some parameters in the stream - while ( x->x_offset < x->x_inwriteposition ) - { - /* decode first 4 bytes as the header */ - a = *((unsigned char*)x->x_inbuffer+x->x_offset); - b = *((unsigned char*)x->x_inbuffer+x->x_offset+1); - c = *((unsigned char*)x->x_inbuffer+x->x_offset+2); - d = *((unsigned char*)x->x_inbuffer+x->x_offset+3); - - cheader = 0; - cheader = a; - cheader <<= 8; - cheader |= b; - cheader <<= 8; - cheader |= c; - cheader <<= 8; - cheader |= d; - if ( head_check( cheader, 0 ) ) - { - decode_header( &hframe, cheader ); - // print_header_compact( &hframe ); - x->x_packetsize = hframe.framesize; - if ( hframe.framesize == 0 ) - { - post( "mp3amp~: weird header ( frame size = 0 ) .... ignored" ); - x->x_inwriteposition -= ret; - return; - } - x->x_inframes += ret/x->x_packetsize; - // post( "mp3amp~: nb frames %d", x->x_inframes ); - break; - } - x->x_offset++; - } - } - } -} - -static t_int *mp3amp_perform(t_int *w) -{ - t_mp3amp *x = (t_mp3amp*) (w[1]); - t_float *out1 = (t_float *)(w[2]); - t_float *out2 = (t_float *)(w[3]); - int n = (int)(w[4]); - int ret; - int i = 0; - - x->x_blocksize = n; - x->x_nbwaitloops = LAME_AUDIO_CHUNK_SIZE/x->x_blocksize; - // post( "mp3mp3amp~ : will wait %d loops", x->x_nbwaitloops ); - x->x_dsp++; - - while( n-- ) - { - if(x->x_stream && !x->x_standby ) // check that the stream provides enough data - { - if(x->x_resample == 1) /* don't need to resample */ - { - *out1++=*(x->x_outbuffer+x->x_outreadposition); - x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; - *out2++=*(x->x_outbuffer+x->x_outreadposition); - x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; - x->x_outunread-=2; - } - else - { /* we just use the same sample x->x_resample times */ - *out1++=*(x->x_outbuffer+x->x_outreadposition); - *out2++=*(x->x_outbuffer+((x->x_outreadposition + 1)%x->x_outbuffersize)); - if((n%x->x_resample)== 0) - { - x->x_outreadposition = (x->x_outreadposition + 2)%x->x_outbuffersize; - x->x_outunread-=2; - } - } - if ( n == 1 ) x->x_pblocks++; - } - else - { - *out1++=0.0; - *out2++=0.0; - } - } - - if ( x->x_pblocks == LAME_AUDIO_CHUNK_SIZE/x->x_blocksize ) - { - x->x_pblocks = 0; - } - - /* check for readability, then fill the input buffer */ - if(( x->x_fd > 0 )&&(x->x_dsp >= 16)) /* determine how often we try to read */ - { - fd_set readset; - fd_set exceptset; - - FD_ZERO(&readset); - FD_ZERO(&exceptset); - FD_SET(x->x_fd, &readset ); - FD_SET(x->x_fd, &exceptset ); - - x->x_dsp = 0; - - if ( select( x->x_fd+1, &readset, NULL, &exceptset, &ztout ) >0 ) - { - if ( FD_ISSET( x->x_fd, &readset) || FD_ISSET( x->x_fd, &exceptset ) ) - { - /* receive data or error */ - mp3amp_recv(x); - } - } - } - - // check new incoming data - if ( x->x_fd > 0 && ( x->x_nbloops == 0 ) && ( x->x_inframes > 0 ) && ( !x->x_standby ) ) - { - mp3amp_decode_input(x); - } - if ( x->x_nbwaitloops != 0 ) - { - x->x_nbloops = (x->x_nbloops+1 ) % x->x_nbwaitloops; - } - return (w+5); -} - -static void mp3amp_dsp(t_mp3amp *x, t_signal **sp) -{ - dsp_add(mp3amp_perform, 4, x, sp[1]->s_vec, sp[2]->s_vec, sp[1]->s_n); -} - - - /* freeze decoding */ -static void mp3amp_standby(t_mp3amp *x, t_floatarg fstandby ) -{ - if ( fstandby == 0. ) - { - x->x_standby = 0; - } - else - { - x->x_standby = 1; - } -} - - /* connection main procedure executed by a thread */ -static void *mp3amp_do_connect(void *tdata ) -{ - t_mp3amp *x = (t_mp3amp*) tdata; - struct sockaddr_in server; - struct hostent *hp; - t_int portno = x->x_port; /* get port from message box */ - - /* variables used for communication with server */ - char *sptr = NULL; - char request[STRBUF_SIZE]; /* string to be send to server */ - char *url; /* used for relocation */ - fd_set fdset; - struct timeval tv; - t_int sockfd; /* socket to server */ - t_int relocate, numrelocs = 0; - t_int i, ret, rest, nanswers=0; - char *cpoint = NULL; - t_int offset = 0, endofheaders = 0; - - if (x->x_fd >= 0) - { - error("mp3amp~: already connected"); - return NULL; - } - - sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sockfd < 0) - { - error("mp3amp~: internal error while attempting to open socket"); - return NULL; - } - - /* connect socket using hostname provided in command line */ - server.sin_family = AF_INET; - hp = gethostbyname(x->x_hostname); - if (hp == 0) - { - post("mp3amp~: bad host?"); - sys_closesocket(sockfd); - return NULL; - } - memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); - - /* assign client port number */ - server.sin_port = htons((unsigned short)portno); - - /* try to connect. */ - post("mp3amp~: connecting to http:/%s:%d/%s", x->x_hostname, x->x_port, x->x_mountpoint ); - if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0) - { - error("mp3amp~: connection failed!\n"); - sys_closesocket(sockfd); - return NULL; - } - post("mp3amp~: connected : socket opened" ); - - /* sheck if we can read/write from/to the socket */ - FD_ZERO( &fdset); - FD_SET( sockfd, &fdset); - tv.tv_sec = 0; /* seconds */ - tv.tv_usec = 500; /* microseconds */ - - ret = select(sockfd + 1, &fdset, NULL, NULL, &tv); - if(ret != 0) - { - error("mp3amp~: can not read from socket"); - sys_closesocket(sockfd); - return NULL; - } - post("mp3amp~: select done" ); - - /* check mountpoint */ - if( strstr(x->x_mountpoint, "listen.pls") ) - { /* SHOUTcast playlist -> get / */ - x->x_mountpoint = ""; - } - - /* build up stuff we need to send to server */ - sprintf(request, "GET /%s HTTP/1.0 \r\nHost: %s\r\nUser-Agent: mp3amp~ 0.11\r\nAccept: */*\r\n\r\n", - x->x_mountpoint, x->x_hostname); - - if ( send(sockfd, request, strlen(request), 0) < 0 ) /* say hello to server */ - { - post( "mp3amp~: could not contact server... " ); -#ifdef UNIX - perror( "send" ); -#endif - return NULL; - } - post("mp3amp~: send done" ); - - relocate = FALSE; - memset( request, 0x00, STRBUF_SIZE ); - - // read all the answer - endofheaders=0; - while ( !endofheaders ) - { - if( ( ret = recv(sockfd, request+offset, STRBUF_SIZE, MSG_NOSIGNAL) ) <0) - { - error("mp3amp~: no response from server"); -#ifdef UNIX - perror( "recv" ); -#endif - return NULL; - } - post ( "mp3amp~ : received %d bytes at %d", ret, offset ); - for ( i=offset; ix_nooutput = 1; - mp3amp_connect_url(x, gensym(url)); - x->x_nooutput = 0; - return NULL; - // relocate = TRUE; - } - if( !(sptr = strstr(request, "200")) && !relocate ) - { - error("mp3amp~: cannot connect to the (default) stream"); - return NULL; - } - - post("mp3amp~: IceCast server detected"); - - // post("mp3amp~: server's header : %s", request ); - - // check what we got - if( cpoint = strstr(request, "x-audiocast-mount:")) - { - x->x_mountpoint = STRDUP(cpoint + 18); - for ( i=0; i<(int)strlen(x->x_mountpoint); i++ ) - { - if ( x->x_mountpoint[i] == '\n' ) - { - x->x_mountpoint[i] = '\0'; - break; - } - } - post(" mountpoint: %s", x->x_mountpoint); - } - if( cpoint = strstr(request, "x-audiocast-server-url:")) - { - sptr = STRDUP( cpoint + 24); - for ( i=0; i<(int)strlen(sptr); i++ ) - { - if ( sptr[i] == '\n' ) - { - sptr[i] = '\0'; - break; - } - } - post(" server-url: %s", sptr); - } - if( cpoint = strstr(request, "x-audiocast-location:")) - { - sptr = STRDUP( cpoint + 22); - for ( i=0; i<(int)strlen(sptr); i++ ) - { - if ( sptr[i] == '\n' ) - { - sptr[i] = '\0'; - break; - } - } - post(" location: %s", sptr); - } - if( cpoint = strstr(request, "x-audiocast-admin:")) - { - sptr = STRDUP( cpoint + 19); - for ( i=0; i<(int)strlen(sptr); i++ ) - { - if ( sptr[i] == '\n' ) - { - sptr[i] = '\0'; - break; - } - } - post(" admin: %s", sptr); - } - if( cpoint = strstr(request, "x-audiocast-name:")) - { - x->x_bcname = STRDUP( cpoint + 17); - for ( i=0; i<(int)strlen(x->x_bcname); i++ ) - { - if ( x->x_bcname[i] == '\n' ) - { - x->x_bcname[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if( cpoint = strstr(request, "x-audiocast-genre:")) - { - x->x_bcgenre = STRDUP( cpoint + 18); - for ( i=0; i<(int)strlen(x->x_bcgenre); i++ ) - { - if ( x->x_bcgenre[i] == '\n' ) - { - x->x_bcgenre[i] = '\0'; - break; - } - } - post(" genre: %s", x->x_bcgenre); - } - if( cpoint = strstr(request, "x-audiocast-url:")) - { - x->x_bcurl = STRDUP( cpoint + 16); - for ( i=0; i<(int)strlen(x->x_bcurl); i++ ) - { - if ( x->x_bcurl[i] == '\n' ) - { - x->x_bcurl[i] = '\0'; - break; - } - } - post(" url: %s", x->x_bcurl); - } - if( cpoint = strstr(request, "x-audiocast-public:1")) - { - post(" broadcast is public"); - } - else if( cpoint = strstr(request, "x-audiocast-public:0")) - { - post(" broadcast is NOT public"); - } - if( cpoint = strstr(request, "x-audiocast-bitrate:")) - { - sptr = STRDUP( cpoint + 20); - for ( i=0; i<(int)strlen(sptr); i++ ) - { - if ( sptr[i] == '\n' ) - { - sptr[i] = '\0'; - break; - } - } - if(!strncmp(sptr, "320", 3))x->x_bitrate = 320; - else if(!strncmp(sptr, "256", 3))x->x_bitrate = 256; - else if(!strncmp(sptr, "224", 3))x->x_bitrate = 224; - else if(!strncmp(sptr, "192", 3))x->x_bitrate = 192; - else if(!strncmp(sptr, "160", 3))x->x_bitrate = 160; - else if(!strncmp(sptr, "144", 3))x->x_bitrate = 144; - else if(!strncmp(sptr, "128", 3))x->x_bitrate = 128; - else if(!strncmp(sptr, "112", 3))x->x_bitrate = 112; - else if(!strncmp(sptr, "96", 2))x->x_bitrate = 96; - else if(!strncmp(sptr, "80", 2))x->x_bitrate = 80; - else if(!strncmp(sptr, "64", 2))x->x_bitrate = 64; - else if(!strncmp(sptr, "56", 2))x->x_bitrate = 56; - else if(!strncmp(sptr, "48", 2))x->x_bitrate = 48; - else if(!strncmp(sptr, "40", 2))x->x_bitrate = 40; - else if(!strncmp(sptr, "32", 2))x->x_bitrate = 32; - else if(!strncmp(sptr, "24", 2))x->x_bitrate = 24; - else if(!strncmp(sptr, "16", 2))x->x_bitrate = 16; - else if(!strncmp(sptr, "8", 1))x->x_bitrate = 8; - else - { - post("mp3amp~: unsupported bitrate! : %s", sptr); - return NULL; - } - post(" bitrate: %d", x->x_bitrate); - } - if( cpoint = strstr(request, "x-audiocast-udpport:")) - { - post("mp3amp~: sorry, server wants UDP connection!"); - return NULL; - } - } - else /* it is a SHOUTcast server */ - { - strip_shout_header (request, STRBUF_SIZE); - post("mp3amp~: SHOUTcast server detected"); - if(strstr(request, "ICY 401") != 0) - { - post("mp3amp~: ICY 401 Service Unavailable"); - return NULL; - } - if (strstr(request, "ICY 200 OK")) - { - /* recv and decode info about broadcast line by line */ - post("mp3amp~: connecting to stream..."); - i = ret; - /* check what we got */ - - if( cpoint = strstr(request, "icy-name:")) - { - x->x_bcname = STRDUP( cpoint + 10); - for ( i=0; i<(int)strlen(x->x_bcname); i++ ) - { - if ( x->x_bcname[i] == '\n' ) - { - x->x_bcname[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if( cpoint = strstr(request, "x-audiocast-name:")) - { - x->x_bcname = STRDUP( cpoint + 18); - for ( i=0; i<(int)strlen(x->x_bcname); i++ ) - { - if ( x->x_bcname[i] == '\n' ) - { - x->x_bcname[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if( cpoint = strstr(request, "icy-genre:")) - { - x->x_bcgenre = STRDUP( cpoint + 10); - for ( i=0; i<(int)strlen(x->x_bcgenre); i++ ) - { - if ( x->x_bcgenre[i] == '\n' ) - { - x->x_bcgenre[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if( cpoint = strstr(request, "icy-aim:")) - { - x->x_bcaim = STRDUP( cpoint + 8); - for ( i=0; i<(int)strlen(x->x_bcaim); i++ ) - { - if ( x->x_bcaim[i] == '\n' ) - { - x->x_bcaim[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if( cpoint = strstr(request, "icy-url:")) - { - x->x_bcurl = STRDUP( cpoint + 8); - for ( i=0; i<(int)strlen(x->x_bcurl); i++ ) - { - if ( x->x_bcurl[i] == '\n' ) - { - x->x_bcurl[i] = '\0'; - break; - } - } - post(" name: %s", x->x_bcname); - } - if(strstr(request, "icy-pub:1")) - { - post(" broadcast is public"); - } - else if(strstr(request, "icy-pub:0")) - { - post(" broadcast is NOT public"); - } - if( cpoint = strstr(request, "icy-br:")) - { - sptr = STRDUP( cpoint + 7); - if(!strncmp(sptr, "320", 3))x->x_bitrate = 320; - else if(!strncmp(sptr, "256", 3))x->x_bitrate = 256; - else if(!strncmp(sptr, "224", 3))x->x_bitrate = 224; - else if(!strncmp(sptr, "192", 3))x->x_bitrate = 192; - else if(!strncmp(sptr, "160", 3))x->x_bitrate = 160; - else if(!strncmp(sptr, "144", 3))x->x_bitrate = 144; - else if(!strncmp(sptr, "128", 3))x->x_bitrate = 128; - else if(!strncmp(sptr, "112", 3))x->x_bitrate = 112; - else if(!strncmp(sptr, "96", 2))x->x_bitrate = 96; - else if(!strncmp(sptr, "80", 2))x->x_bitrate = 80; - else if(!strncmp(sptr, "64", 2))x->x_bitrate = 64; - else if(!strncmp(sptr, "56", 2))x->x_bitrate = 56; - else if(!strncmp(sptr, "48", 2))x->x_bitrate = 48; - else if(!strncmp(sptr, "40", 2))x->x_bitrate = 40; - else if(!strncmp(sptr, "32", 2))x->x_bitrate = 32; - else if(!strncmp(sptr, "24", 2))x->x_bitrate = 24; - else if(!strncmp(sptr, "16", 2))x->x_bitrate = 16; - else if(!strncmp(sptr, "8", 2))x->x_bitrate = 8; - else - { - post("mp3amp~: unsupported bitrate! (%s)", sptr); - return NULL; - } - post(" bitrate: %d", x->x_bitrate); - } - if(strstr(request, "x-audiocast-udpport:")) - { - post("mp3amp~: sorry, server wants UDP connection!"); - return NULL; - } - } - else - { - post("mp3amp~: unknown response from server"); - return NULL; - } - relocate = FALSE; - } - if (relocate) { - error("mp3amp~: too many HTTP relocations"); - return NULL; - } - post("mp3amp~: connected to http://%s:%d/%s", hp->h_name, portno, x->x_mountpoint); - x->x_fd = sockfd; - if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) - { - t_int width; - - width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); - SYS_VGUI3(".x%x.c delete rectangle %xPBAR\n", x->x_canvas, x ); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n", - x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, - x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x ); - } - - return NULL; -} - - /* launch the connection thread */ -static void mp3amp_connect(t_mp3amp *x, t_symbol *hostname, t_symbol *mountpoint, t_floatarg fportno ) -{ - pthread_attr_t update_child_attr; - pthread_t connectchild; - - // store data - x->x_hostname = (char*) getbytes( strlen( hostname->s_name ) + 1 ); // there's a memory leak here - strcpy( x->x_hostname, hostname->s_name ); - - x->x_mountpoint = (char*) getbytes( strlen( mountpoint->s_name ) + 1 ); // there's a memory leak here - strcpy( x->x_mountpoint, mountpoint->s_name ); - - x->x_port = fportno; - - // launch connection thread - if ( pthread_attr_init( &update_child_attr ) < 0 ) { - post( "mp3amp~ : could not launch connection thread" ); - perror( "pthread_attr_init" ); - return; - } - if ( pthread_attr_setdetachstate( &update_child_attr, PTHREAD_CREATE_DETACHED ) < 0 ) { - post( "mp3amp~ : could not launch connection thread" ); - perror( "pthread_attr_setdetachstate" ); - return; - } - if ( pthread_create( &connectchild, &update_child_attr, mp3amp_do_connect, x ) < 0 ) { - post( "mp3amp~ : could not launch connection thread" ); - perror( "pthread_create" ); - return; - } - else - { - // post( "cooled~ : drawing thread %d launched", (int)x->x_updatechild ); - } - - if ( !x->x_nooutput ) outlet_float(x->x_connection, 1); -} - - /* connect using url like "http://localhost:8000/mountpoint" */ -static void mp3amp_connect_url(t_mp3amp *x, t_symbol *url) -{ - char *hostptr = NULL, *p, *endhost = NULL, *hostname = NULL; - char *pathptr = NULL; - t_int portno = 8000; - - post( "mp3amp~ : connect url : %s", url->s_name ); - - /* strip http:// or ftp:// */ - p = url->s_name; - if (strncmp(p, "http://", 7) == 0) - p += 7; - - if (strncmp(p, "ftp://", 6) == 0) - p += 6; - - hostptr = p; - while (*p && *p != '/' && *p != ':') /* look for end of hostname: */ - p++; - - endhost = p; - switch ( *p ) - { - case ':' : - portno = atoi( p+1 ); - while (*p && *p != '/') p++; - pathptr = p+1; - break; - case '/' : - portno = 8000; - pathptr = p+1; - break; - default : - if ( ( p - url->s_name ) != (int)strlen( url->s_name ) ) - { - post( "mp3amp~ : wrong url : %s", hostptr ); - return; - } - pathptr = ""; - break; - } - - hostname=(char*)getbytes( (int)(endhost - hostptr) + 1); - strncpy( hostname, hostptr, (int)(endhost - hostptr) ); - hostname[ endhost - hostptr ] = '\0'; - - post ("mp3amp~ : connecting to host=%s port=%d path=%s", hostname, portno, pathptr ); - - /* call the 'normal' connection routine */ - mp3amp_connect(x, gensym(hostname), gensym(pathptr), portno); -} - - /* close connection to SHOUTcast server */ -static void mp3amp_disconnect(t_mp3amp *x) -{ - x->x_stream = 0; - x->x_inframes = 0; - x->x_dframes = 0; - x->x_inwriteposition = 0; - x->x_offset = 0; - if(x->x_fd >= 0) /* close socket */ - { - sys_closesocket(x->x_fd); - x->x_fd = -1; - } - ExitMP3(&mps[x->x_instance]); - InitMP3(&mps[x->x_instance]); - if ( x->x_graphic ) - { - SYS_VGUI3(".x%x.c delete rectangle %xPBAR\n", x->x_canvas, x ); - SYS_VGUI3(".x%x.c delete rectangle %xSTATUS\n", x->x_canvas, x ); - } - post("mp3amp~: connection closed"); - outlet_float(x->x_connection, 0); -} - -static void mp3amp_free(t_mp3amp *x) -{ - if (x->x_fd > 0) { - post( "mp3amp~: closing socket" ); - sys_closesocket(x->x_fd); - x->x_fd = -1; - } - freebytes(x->x_inbuffer, INPUT_BUFFER_SIZE); - freebytes(x->x_outbuffer, OUTPUT_BUFFER_SIZE*sizeof(t_float)); -} - -static void *mp3amp_new(t_floatarg fdographics) -{ - t_mp3amp *x = NULL; - - if ( ((int)fdographics != 0) && ((int)fdographics != 1.) ) - { - post( "mp3amp~: error : constructor : mp3amp~ [graphic flag = 0 | 1 ] ( got = %f)", fdographics ); - return NULL; - } - - x = (t_mp3amp *)pd_new(mp3amp_class); - outlet_new(&x->x_obj, gensym("signal")); - outlet_new(&x->x_obj, gensym("signal")); - x->x_connection = outlet_new(&x->x_obj, gensym("float")); - - if ( nbinstances < MAX_DECODERS ) - { - x->x_instance = nbinstances++; - } - else - { - post( "mp3amp~: cannot create more decoders (memory issues), sorry" ); - return NULL; - } - - x->x_fd = -1; - x->x_stream = 0; - x->x_inframes = 0; - x->x_samplerate = sys_getsr(); - x->x_nbwaitloops = 1; - x->x_nbloops = 0; - x->x_dsp = 0; - - x->x_inbuffersize = INPUT_BUFFER_SIZE; - x->x_outbuffersize = OUTPUT_BUFFER_SIZE; - x->x_inbuffer = (unsigned char*) getbytes(INPUT_BUFFER_SIZE); - x->x_offset = 0; - x->x_outbuffer = (t_float*) getbytes(OUTPUT_BUFFER_SIZE*sizeof(t_float)); - - if ( !x->x_inbuffer || !x->x_outbuffer ) - { - post( "mp3amp~: could not allocate buffers" ); - return NULL; - } - memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE ); - memset( x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE ); - - x->x_inwriteposition = 0; - x->x_outreadposition = 0; - x->x_outwriteposition = 0; - x->x_outunread = 0; - x->x_standby = 0; - x->x_resample = -1; - x->x_nooutput = 0; - - ztout.tv_sec = 0; - ztout.tv_usec = 0; - - x->x_graphic = (int)fdographics; - post( "mp3amp~: getting canvas" ); - x->x_canvas = canvas_getcurrent(); - - post( "mp3amp~: initializing decoder..." ); - /* init mpg123 decoder */ - mp3amp_tilde_mpglib_init(x); - - post(mp3amp_version); - - return (x); -} - - -void mp3amp_tilde_setup(void) -{ - mp3amp_class = class_new(gensym("mp3amp~"), - (t_newmethod) mp3amp_new, (t_method) mp3amp_free, - sizeof(t_mp3amp), 0, A_DEFFLOAT, A_NULL); - - class_addmethod(mp3amp_class, nullfn, gensym("signal"), 0); - class_addmethod(mp3amp_class, (t_method)mp3amp_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(mp3amp_class, (t_method)mp3amp_connect, gensym("connect"), A_SYMBOL, A_SYMBOL, A_FLOAT, 0); - class_addmethod(mp3amp_class, (t_method)mp3amp_connect_url, gensym("connecturl"), A_SYMBOL, 0); - class_addmethod(mp3amp_class, (t_method)mp3amp_standby, gensym("standby"), A_DEFFLOAT, 0); - class_addmethod(mp3amp_class, (t_method)mp3amp_disconnect, gensym("disconnect"), 0); -} diff --git a/externals/unauthorized/mp3amp~/mp3amp~.libs b/externals/unauthorized/mp3amp~/mp3amp~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3amp~/mp3amp~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3cast~/mp3cast~-help.pd b/externals/unauthorized/mp3cast~-help.pd similarity index 100% rename from externals/unauthorized/mp3cast~/mp3cast~-help.pd rename to externals/unauthorized/mp3cast~-help.pd diff --git a/externals/unauthorized/mp3cast~/mp3cast~.c b/externals/unauthorized/mp3cast~.c similarity index 76% rename from externals/unauthorized/mp3cast~/mp3cast~.c rename to externals/unauthorized/mp3cast~.c index 882d3c5ff9f9cc291b7576f66aba45110d61060a..a5bc66a4eec3ffeb3f018735e8a84ed513b4c12c 100644 --- a/externals/unauthorized/mp3cast~/mp3cast~.c +++ b/externals/unauthorized/mp3cast~.c @@ -25,9 +25,9 @@ /* be found at http://www.cdex.n3.net. */ /* */ /* ---------------------------------------------------------------------------- */ - - - + + + #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) @@ -53,7 +53,7 @@ #include #include #include -#else +#else #include #include #include @@ -64,19 +64,20 @@ #endif #include /* lame encoder stuff */ -#include "mpg123.h" +#include "mpg123.h" #define MY_MP3_MALLOC_IN_SIZE 65536 - /* max size taken from lame readme */ -#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 +/* max size taken from lame readme */ +#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 #define MAXDATARATE 320 /* maximum mp3 data rate is 320kbit/s */ #define STRBUF_SIZE 1024 static char *mp3cast_version = "mp3cast~: mp3 streamer version 0.5, written by Yves Degoyon"; -static char base64table[65] = { +static char base64table[65] = +{ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', @@ -89,12 +90,12 @@ typedef struct _mp3cast { t_object x_obj; - /* LAME stuff */ + /* LAME stuff */ int x_lame; /* info about encoder status */ int x_lamechunk; /* chunk size for LAME encoder */ int x_mp3size; /* number of returned mp3 samples */ - /* buffer stuff */ + /* buffer stuff */ unsigned short x_inp; /* in position for buffer */ unsigned short x_outp; /* out position for buffer*/ short *x_mp3inbuf; /* data to be sent to LAME */ @@ -103,17 +104,17 @@ typedef struct _mp3cast int x_bytesbuffered; /* number of unprocessed bytes in buffer */ int x_start; - /* mp3 format stuff */ + /* mp3 format stuff */ int x_samplerate; int x_bitrate; /* bitrate of mp3 stream */ int x_mp3mode; /* mode (mono, joint stereo, stereo, dual mono) */ int x_mp3quality; /* quality of encoding */ - /* SHOUTcast server stuff */ + /* SHOUTcast server stuff */ int x_fd; /* info about connection status */ char* x_passwd; /* password for server */ int x_icecast; /* tells if we use a IceCast server or SHOUTcast */ - /* special IceCast server stuff */ + /* special IceCast server stuff */ char* x_mountpoint; char* x_name; char* x_url; @@ -128,28 +129,28 @@ typedef struct _mp3cast } t_mp3cast; - /* encode PCM data to mp3 stream */ +/* encode PCM data to mp3 stream */ static void mp3cast_encode(t_mp3cast *x) { unsigned short i, wp; int err = -1; int n = x->x_lamechunk; -#ifdef UNIX - if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) -#else +#ifdef _WIN32 if(x->x_lamechunk < sizeof(x->x_mp3inbuf)) +#else + if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) #endif { error("not enough memory!"); return; } - /* on start/reconnect set outpoint that it not interferes with inpoint */ + /* on start/reconnect set outpoint that it not interferes with inpoint */ if(x->x_start == -1) { post("mp3cast~: initialising buffers"); - /* we try to keep 2.5 times the data the encoder needs in the buffer */ + /* we try to keep 2.5 times the data the encoder needs in the buffer */ if(x->x_inp > (2 * x->x_lamechunk)) { x->x_outp = (short) x->x_inp - (2.5 * x->x_lamechunk); @@ -164,10 +165,10 @@ static void mp3cast_encode(t_mp3cast *x) i = MY_MP3_MALLOC_IN_SIZE - x->x_outp; - /* read from buffer */ - if(x->x_lamechunk <= i) + /* read from buffer */ + if(x->x_lamechunk <= i) { - /* enough data until end of buffer */ + /* enough data until end of buffer */ for(n = 0; n < x->x_lamechunk; n++) /* fill encode buffer */ { x->x_mp3inbuf[n] = x->x_buffer[n + x->x_outp]; @@ -188,13 +189,13 @@ static void mp3cast_encode(t_mp3cast *x) x->x_outp = x->x_lamechunk - i; } - /* encode mp3 data */ - x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, - x->x_lamechunk/lame_get_num_channels(x->lgfp), + /* encode mp3 data */ + x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, + x->x_lamechunk/lame_get_num_channels(x->lgfp), x->x_mp3outbuf, MY_MP3_MALLOC_OUT_SIZE); // post( "mp3cast~ : encoding returned %d frames", x->x_mp3size ); - /* check result */ + /* check result */ if(x->x_mp3size<0) { lame_close( x->lgfp ); @@ -204,7 +205,7 @@ static void mp3cast_encode(t_mp3cast *x) } - /* stream mp3 to SHOUTcast server */ +/* stream mp3 to SHOUTcast server */ static void mp3cast_stream(t_mp3cast *x) { int err = -1, i; /* error return code */ @@ -223,12 +224,12 @@ static void mp3cast_stream(t_mp3cast *x) #endif /* _WIN32 */ x->x_fd = -1; outlet_float(x->x_obj.ob_outlet, 0); - } + } if((err > 0)&&(err != x->x_mp3size))error("mp3cast~: %d bytes skipped", x->x_mp3size - err); } - - /* buffer data as channel interleaved PCM */ + +/* buffer data as channel interleaved PCM */ static t_int *mp3cast_perform(t_int *w) { t_float *in1 = (t_float *)(w[1]); /* left audio inlet */ @@ -238,76 +239,94 @@ static t_int *mp3cast_perform(t_int *w) unsigned short i,wp; float in; - /* copy the data into the buffer */ + /* copy the data into the buffer */ i = MY_MP3_MALLOC_IN_SIZE - x->x_inp; /* space left at the end of buffer */ - + n *= 2; /* two channels go into one buffer */ - if( n <= i ) + if( n <= i ) { /* the place between inp and MY_MP3_MALLOC_IN_SIZE */ /* is big enough to hold the data */ - for(wp = 0; wp < n; wp++) + for(wp = 0; wp < n; wp++) + { + if(wp%2) + { + in = *(in2++); /* right channel / inlet */ + } + else + { + in = *(in1++); /* left channel / inlet */ + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) { - if(wp%2) - { - in = *(in2++); /* right channel / inlet */ - } - else - { - in = *(in1++); /* left channel / inlet */ - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = -1.0; } - x->x_inp += n; /* n more samples written to buffer */ - } - else + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + x->x_inp += n; /* n more samples written to buffer */ + } + else { - /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ - /* big enough to hold the data */ - /* writing will take place in two turns, one from */ - /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ + /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ + /* big enough to hold the data */ + /* writing will take place in two turns, one from */ + /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ - for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + { + if(wp%2) + { + in = *(in2++); + } + else + { + in = *(in1++); + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + { + if(wp%2) { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = *(in2++); } - for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + else { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp - i] = (short) (32767.0 * in); + in = *(in1++); } - x->x_inp = n - i; /* new writeposition in buffer */ + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp - i] = (short) (32767.0 * in); + } + x->x_inp = n - i; /* new writeposition in buffer */ } if((x->x_fd >= 0)&&(x->x_lame >= 0)) - { - /* count buffered samples when things are running */ + { + /* count buffered samples when things are running */ x->x_bytesbuffered += n; - /* encode and send to server */ + /* encode and send to server */ if(x->x_bytesbuffered > x->x_lamechunk) { mp3cast_encode(x); /* encode to mp3 */ @@ -327,7 +346,7 @@ static void mp3cast_dsp(t_mp3cast *x, t_signal **sp) dsp_add(mp3cast_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); } - /* initialize the lame library */ +/* initialize the lame library */ static void mp3cast_tilde_lame_init(t_mp3cast *x) { int ret; @@ -335,8 +354,8 @@ static void mp3cast_tilde_lame_init(t_mp3cast *x) #ifdef _WIN32 /* load lame_enc.dll library */ - HINSTANCE dll; - dll=LoadLibrary("lame_enc.dll"); + HINSTANCE dll; + dll=LoadLibrary("lame_enc.dll"); if(!dll) { error("mp3cast~: error loading lame_enc.dll"); @@ -348,12 +367,14 @@ static void mp3cast_tilde_lame_init(t_mp3cast *x) } #endif /* _WIN32 */ { - const char *lameVersion = get_lame_version(); - post( "mp3cast~ : using lame version : %s", lameVersion ); + const char *lameVersion = get_lame_version(); + char logbuf[MAXPDSTRING]; + sprintf(logbuf, "mp3cast~ : using lame version : %s", lameVersion); + logpost(NULL, 4, "%s", logbuf ); } - /* setting lame parameters */ + /* setting lame parameters */ lame_set_num_channels( x->lgfp, 2); lame_set_in_samplerate( x->lgfp, sys_getsr() ); lame_set_out_samplerate( x->lgfp, x->x_samplerate ); @@ -364,62 +385,67 @@ static void mp3cast_tilde_lame_init(t_mp3cast *x) lame_set_original( x->lgfp, 1 ); lame_set_copyright( x->lgfp, 1 ); /* viva free music societies !!! */ lame_set_disable_reservoir( x->lgfp, 0 ); - lame_set_padding_type( x->lgfp, PAD_NO ); + //lame_set_padding_type( x->lgfp, PAD_NO ); /* deprecated function */ ret = lame_init_params( x->lgfp ); - if ( ret<0 ) { - post( "mp3cast~ : error : lame params initialization returned : %d", ret ); - } else { - x->x_lame=1; - /* magic formula copied from windows dll for MPEG-I */ - x->x_lamechunk = 2*1152; + if ( ret<0 ) + { + post( "mp3cast~ : error : lame params initialization returned : %d", ret ); + } + else + { + x->x_lame=1; + /* magic formula copied from windows dll for MPEG-I */ + x->x_lamechunk = 2*1152; - post( "mp3cast~ : lame initialization done. (%d)", x->x_lame ); + post( "mp3cast~ : lame initialization done. (%d)", x->x_lame ); } lame_init_bitstream( x->lgfp ); } char *mp3cast_base64_encode(char *data) { - int len = strlen(data); - char *out = t_getbytes(len*4/3 + 4); - char *result = out; - int chunk; - - while(len > 0) { - chunk = (len >3)?3:len; - *out++ = base64table[(*data & 0xFC)>>2]; - *out++ = base64table[((*data & 0x03)<<4) | ((*(data+1) & 0xF0) >> 4)]; - - switch(chunk) { - case 3: - *out++ = base64table[((*(data+1) & 0x0F)<<2) | ((*(data+2) & 0xC0)>>6)]; - *out++ = base64table[(*(data+2)) & 0x3F]; - break; - case 2: - *out++ = base64table[((*(data+1) & 0x0F)<<2)]; - *out++ = '='; - break; - case 1: - *out++ = '='; - *out++ = '='; - break; - } - data += chunk; - len -= chunk; - } - *out = 0; + int len = strlen(data); + char *out = t_getbytes(len*4/3 + 4); + char *result = out; + int chunk; + + while(len > 0) + { + chunk = (len >3)?3:len; + *out++ = base64table[(*data & 0xFC)>>2]; + *out++ = base64table[((*data & 0x03)<<4) | ((*(data+1) & 0xF0) >> 4)]; + + switch(chunk) + { + case 3: + *out++ = base64table[((*(data+1) & 0x0F)<<2) | ((*(data+2) & 0xC0)>>6)]; + *out++ = base64table[(*(data+2)) & 0x3F]; + break; + case 2: + *out++ = base64table[((*(data+1) & 0x0F)<<2)]; + *out++ = '='; + break; + case 1: + *out++ = '='; + *out++ = '='; + break; + } + data += chunk; + len -= chunk; + } + *out = 0; - return result; + return result; } - /* connect to server */ +/* connect to server */ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno) { struct sockaddr_in server; struct hostent *hp; int portno = fportno; /* get port from message box */ - /* information about this broadcast to be send to the server */ + /* information about this broadcast to be send to the server */ const char *name = x->x_name; /* name of broadcast */ const char *url = x->x_url; /* url of broadcast */ const char *genre = x->x_genre; /* genre of broadcast */ @@ -430,7 +456,7 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno const char *mountpoint = x->x_mountpoint; /* mountpoint for IceCast server */ int isPublic = x->x_isPublic; /* don't publish broadcast on www.shoutcast.com */ - /* variables used for communication with server */ + /* variables used for communication with server */ const char * buf = 0; char resp[STRBUF_SIZE]; unsigned int len; @@ -454,7 +480,7 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno return; } - /* connect socket using hostname provided in command line */ + /* connect socket using hostname provided in command line */ server.sin_family = AF_INET; hp = gethostbyname(hostname->s_name); if (hp == 0) @@ -465,10 +491,10 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno } memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); - /* assign client port number */ + /* assign client port number */ server.sin_port = htons((unsigned short)portno); - /* try to connect. */ + /* try to connect. */ post("mp3cast~: connecting to port %d", portno); if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0) { @@ -481,7 +507,7 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno return; } - /* sheck if we can read/write from/to the socket */ + /* sheck if we can read/write from/to the socket */ FD_ZERO( &fdset); FD_SET( sockfd, &fdset); tv.tv_sec = 0; /* seconds */ @@ -510,16 +536,16 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno if(x->x_icecast == 0) /* SHOUTCAST */ { - /* now try to log in at SHOUTcast server */ + /* now try to log in at SHOUTcast server */ post("mp3cast~: logging in to SHOUTcast server..."); - /* first line is the passwd */ + /* first line is the passwd */ buf = x->x_passwd; send(sockfd, buf, strlen(buf), 0); buf = "\n"; send(sockfd, buf, strlen(buf), 0); - /* header for SHOUTcast server */ + /* header for SHOUTcast server */ buf = "icy-name:"; /* name of broadcast */ send(sockfd, buf, strlen(buf), 0); buf = name; @@ -528,18 +554,18 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno send(sockfd, buf, strlen(buf), 0); buf = url; send(sockfd, buf, strlen(buf), 0); - - buf = "\nicy-genre:"; /* genre of broadcast */ + + buf = "\nicy-genre:"; /* genre of broadcast */ send(sockfd, buf, strlen(buf), 0); buf = genre; send(sockfd, buf, strlen(buf), 0); - - buf = "\nicy-description:"; /* description of broadcast */ + + buf = "\nicy-description:"; /* description of broadcast */ send(sockfd, buf, strlen(buf), 0); buf = description; send(sockfd, buf, strlen(buf), 0); - - buf = "\nicy-irc:"; + + buf = "\nicy-irc:"; send(sockfd, buf, strlen(buf), 0); buf = irc; send(sockfd, buf, strlen(buf), 0); @@ -574,11 +600,11 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno } else if ( x->x_icecast == 1 ) /* IceCast */ { - /* now try to log in at IceCast server */ + /* now try to log in at IceCast server */ post("mp3cast~: logging in to IceCast server..."); - /* send the request, a string like: - * "SOURCE /\n" */ + /* send the request, a string like: + * "SOURCE /\n" */ buf = "SOURCE "; send(sockfd, buf, strlen(buf), 0); buf = x->x_passwd; @@ -631,51 +657,51 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno buf = "\n\n"; send(sockfd, buf, strlen(buf), 0); - /* end login for IceCast */ + /* end login for IceCast */ } else if ( x->x_icecast == 2 ) /* Icecast 2 */ { char *base64; /* buffer to hold 64bit encoded strings */ - /* send the request, a string like: "SOURCE / HTTP/1.0\r\n" */ + /* send the request, a string like: "SOURCE / HTTP/1.0\r\n" */ buf = "SOURCE /"; send(sockfd, buf, strlen(buf), 0); buf = x->x_mountpoint; send(sockfd, buf, strlen(buf), 0); buf = " HTTP/1.0\r\n"; send(sockfd, buf, strlen(buf), 0); - /* send basic authorization as base64 encoded string */ + /* send basic authorization as base64 encoded string */ sprintf(resp, "source:%s", x->x_passwd); len = strlen(resp); base64 = mp3cast_base64_encode(resp); sprintf(resp, "Authorization: Basic %s\r\n", base64); send(sockfd, resp, strlen(resp), 0); t_freebytes(base64, len*4/3 + 4); - /* send application name */ + /* send application name */ buf = "User-Agent: mp3cast~"; send(sockfd, buf, strlen(buf), 0); - /* send content type: mpeg */ + /* send content type: mpeg */ buf = "\r\nContent-Type: audio/mpeg"; send(sockfd, buf, strlen(buf), 0); - /* send the ice headers */ - /* name */ + /* send the ice headers */ + /* name */ buf = "\r\nice-name: "; send(sockfd, buf, strlen(buf), 0); buf = x->x_name; send(sockfd, buf, strlen(buf), 0); - /* url */ + /* url */ buf = "\r\nice-url: "; send(sockfd, buf, strlen(buf), 0); buf = x->x_url; send(sockfd, buf, strlen(buf), 0); - /* genre */ + /* genre */ buf = "\r\nice-genre: "; send(sockfd, buf, strlen(buf), 0); buf = genre; send(sockfd, buf, strlen(buf), 0); - /* public */ + /* public */ buf = "\r\nice-public: "; send(sockfd, buf, strlen(buf), 0); - if(isPublic==0) + if(isPublic==0) { buf = "0"; } @@ -684,25 +710,25 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno buf = "1"; } send(sockfd, buf, strlen(buf), 0); - /* bitrate */ + /* bitrate */ if(sprintf(resp, "\r\nice-audio-info: bitrate=%d", x->x_bitrate) == -1) { error("shoutcast~: could not create audio-info"); } send(sockfd, resp, strlen(resp), 0); - /* description */ + /* description */ buf = "\r\nice-description: "; send(sockfd, buf, strlen(buf), 0); buf = description; send(sockfd, buf, strlen(buf), 0); - /* end of header: write an empty line */ + /* end of header: write an empty line */ buf = "\r\n\r\n"; send(sockfd, buf, strlen(buf), 0); } - /* read the anticipated response: "OK" */ + /* read the anticipated response: "OK" */ len = recv(sockfd, resp, STRBUF_SIZE, 0); - if ( strstr( resp, "OK" ) == NULL ) + if ( strstr( resp, "OK" ) == NULL ) { post("mp3cast~: login failed!"); if ( len>0 ) post("mp3cast~: server answered : %s", resp); @@ -714,8 +740,8 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno return; } - /* suck anything that the other side has to say */ - // while (len = recv(sockfd, resp, STRBUF_SIZE,0)) + /* suck anything that the other side has to say */ + // while (len = recv(sockfd, resp, STRBUF_SIZE,0)) // { // post("mp3cast~: server answered : %s", resp); // } @@ -728,14 +754,15 @@ static void mp3cast_connect(t_mp3cast *x, t_symbol *hostname, t_floatarg fportno } - /* close connection to SHOUTcast server */ +/* close connection to SHOUTcast server */ static void mp3cast_disconnect(t_mp3cast *x) { int err = -1; if(x->x_lame >= 0) { - /* ignore remaining bytes */ - if ( x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, 0) < 0 ) { + /* ignore remaining bytes */ + if ( x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, 0) < 0 ) + { post( "mp3cast~ : warning : remaining encoded bytes" ); } lame_close( x->lgfp ); @@ -757,16 +784,16 @@ static void mp3cast_disconnect(t_mp3cast *x) } } - /* set password for SHOUTcast server */ +/* set password for SHOUTcast server */ static void mp3cast_password(t_mp3cast *x, t_symbol *password) { post("mp3cast~ : setting password to %s", password->s_name ); x->x_passwd = password->s_name; } - /* settings for mp3 encoding */ +/* settings for mp3 encoding */ static void mp3cast_mpeg(t_mp3cast *x, t_floatarg fsamplerate, t_floatarg fbitrate, - t_floatarg fmode, t_floatarg fquality) + t_floatarg fmode, t_floatarg fquality) { x->x_samplerate = fsamplerate; if(fbitrate > MAXDATARATE) @@ -777,32 +804,32 @@ static void mp3cast_mpeg(t_mp3cast *x, t_floatarg fsamplerate, t_floatarg fbitra x->x_mp3mode = fmode; x->x_mp3quality = fquality; post("mp3cast~: setting mp3 stream to %dHz, %dkbit/s, mode %d, quality %d", - x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); + x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); if(x->x_fd>=0)post("mp3cast~ : reconnect to make changes take effect! "); } - /* print settings */ +/* print settings */ static void mp3cast_print(t_mp3cast *x) { const char * buf = 0; - post(mp3cast_version); + logpost(NULL, 4, "%s", mp3cast_version); post(" LAME mp3 settings:\n" " output sample rate: %d Hz\n" " bitrate: %d kbit/s", x->x_samplerate, x->x_bitrate); switch(x->x_mp3mode) { - case 0 : - buf = "stereo"; - break; - case 1 : - buf = "joint stereo"; - break; - case 2 : - buf = "dual channel"; - break; - case 3 : - buf = "mono"; - break; + case 0 : + buf = "stereo"; + break; + case 1 : + buf = "joint stereo"; + break; + case 2 : + buf = "dual channel"; + break; + case 3 : + buf = "mono"; + break; } post(" mode: %s\n" " quality: %d", buf, x->x_mp3quality); @@ -844,40 +871,40 @@ static void mp3cast_shoutcast(t_mp3cast *x) post("mp3cast~: set server type to SHOUTcast"); } - /* set mountpoint for IceCast server */ +/* set mountpoint for IceCast server */ static void mp3cast_mountpoint(t_mp3cast *x, t_symbol *mount) { x->x_mountpoint = mount->s_name; post("mp3cast~: mountpoint set to %s", x->x_mountpoint); } - /* set namle for IceCast server */ +/* set namle for IceCast server */ static void mp3cast_name(t_mp3cast *x, t_symbol *name) { x->x_name = name->s_name; post("mp3cast~: name set to %s", x->x_name); } - /* set url for IceCast server */ +/* set url for IceCast server */ static void mp3cast_url(t_mp3cast *x, t_symbol *url) { x->x_url = url->s_name; post("mp3cast~: url set to %s", x->x_url); } - /* set genre for IceCast server */ +/* set genre for IceCast server */ static void mp3cast_genre(t_mp3cast *x, t_symbol *genre) { x->x_genre = genre->s_name; post("mp3cast~: genre set to %s", x->x_genre); } - /* set isPublic for IceCast server */ +/* set isPublic for IceCast server */ static void mp3cast_isPublic(t_mp3cast *x, t_floatarg isPublic) { x->x_isPublic = isPublic; char* isPublicStr; - if(isPublic==0) + if(isPublic==0) { isPublicStr = "no"; } @@ -888,15 +915,15 @@ static void mp3cast_isPublic(t_mp3cast *x, t_floatarg isPublic) post("mp3cast~: isPublic set to %s", isPublicStr); } - /* set description for IceCast server */ +/* set description for IceCast server */ static void mp3cast_description(t_mp3cast *x, t_symbol *description) { x->x_description = description->s_name; post("mp3cast~: description set to %s", x->x_description); } - /* clean up */ -static void mp3cast_free(t_mp3cast *x) +/* clean up */ +static void mp3cast_free(t_mp3cast *x) { if(x->x_lame >= 0) lame_close( x->lgfp ); @@ -947,9 +974,9 @@ static void *mp3cast_new(void) void mp3cast_tilde_setup(void) { - post(mp3cast_version); + logpost(NULL, 4, "%s", mp3cast_version); mp3cast_class = class_new(gensym("mp3cast~"), (t_newmethod)mp3cast_new, (t_method)mp3cast_free, - sizeof(t_mp3cast), 0, 0); + sizeof(t_mp3cast), 0, 0); CLASS_MAINSIGNALIN(mp3cast_class, t_mp3cast, x_f ); class_addmethod(mp3cast_class, (t_method)mp3cast_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(mp3cast_class, (t_method)mp3cast_connect, gensym("connect"), A_SYMBOL, A_FLOAT, 0); diff --git a/externals/unauthorized/mp3cast~/INSTALL b/externals/unauthorized/mp3cast~/INSTALL deleted file mode 100644 index 769e78eca3f89e2eb8fb255116dc1bc7c1bd37ad..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -You need to get lame > v3.90 installed first. -libmp3lame.so is searched in /usr/local/lib -( no time to write configure scripts ). -if it's installed elsewhere, change the Makefile, -you won't die from that. - -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/mp3cast~ - -make -f Makefile.linux - -make -f Makefile.linux install - -you're set !! diff --git a/externals/unauthorized/mp3cast~/Makefile b/externals/unauthorized/mp3cast~/Makefile deleted file mode 100644 index 923edb284359355a55628d82e0727dc8d0629eed..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/Makefile +++ /dev/null @@ -1,90 +0,0 @@ -NAME=mp3cast~ -CSYM=mp3cast_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch - -LBITS := $(shell getconf LONG_BIT) -ifeq ($(LBITS),64) - # do 64 bit stuff here, like set some CFLAGS -ARCHFLAGS= -fPIC -else -ARCHFLAGS= -endif - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(ARCHFLAGS) $(LINUXINCLUDE) -DHAVE_STRCHR -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib -lmp3lame - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/mp3cast~/README b/externals/unauthorized/mp3cast~/README deleted file mode 100644 index 7247f818cf24ac758d0594710579e7a4595f3a08..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/README +++ /dev/null @@ -1,108 +0,0 @@ -Version 0.01 -copyright (c) 2001 by Olaf Matthes -ported to Linux by Yves Degoyon - -mp3cast~.dll is a MPEG I Layer III (mp3) streaming external for pd (by Miller -Puckette) that connects to a SHOUTcast or IceCast server. - -To install mp3cast~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - -mp3cast~ has been compiled for Linux using LAME 3.92. -The newest version of LAME can be found at sourceforge.net - -COPYING: you may use this source under GPL terms! - -PLEASE NOTE: This software may contain patented alogrithm (at least - patented in some countries). It may be not allowed to sell/use products - based on this source code in these countries. Check this out first! - -COPYRIGHT of MP3 music: - Please note, that the duplicating of copyrighted music without explicit - permission violates the rights of the owner. - -***************************************************************************** - - using mp3cast~ external for Pure Data - -Open the help-mp3cast~.pd to understand how it works. -In this patch, you must send the messages to mp3cast~ -in the following order : - -1/ password ***** -2/ icecast | mp3cast -3/ connect host port -4/ pd dsp 1 - -Parameters sent to mp3cast~ object : - - Sampling Rate (Hz): -Possible values are 48000, 44100 and 32000. If Pd runs at a different sampling -rate, LAME will resample the signal. Default value for mp3 sampling rate is Pd's -sampling rate. - - Bitrate (kbit/s): -Possible values are 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 -and 320. Default is 224. - - Mode: -Possible values are 0 (stereo), 1 (joint stereo, the default), 2 (dual channel) -and 3 (mono). - - Password: -The default is 'pd', can be changed with a message "passwd yourpassword". - - Server: -Use message "connect name_of_your_server.com port" to connect (same as with -Pd's netsend). 'port' is the number specified in the server's config file. -Attention (for SHOUTcast users): The actual port number used is one higher! -Standard would be 8000 resulting in a socket at port 8001!!! Bare this in mind -when configuring proxys or using mp3cast~ in connection with netsend / -netreceive. For IceCast, the port number used is the same as specified. - - Outlet: -The outlet outputs an int, 1 if connected to SHOUTcast server, 0 if not. This could -be used to build an automatic reconnect mechanism. - - Other things: -mp3cast~ prints the current status (connection, login, LAME status) to the pd -window. To see the current settings, send it a message "print" and mp3 settings -will be displayed. -Note that changing any mp3 settings will require to disconnect and reconnect again! -This has to be done manually. - - Known problems: -If you turn off audio processing when you are connected with the server, no data will -be sent to it. This will make the server disconnect after a certain time ('no data' -error in server log). mp3cast~ does not recongnise this and attempts to keep on -streaming. To avoid this set 'AutoDumpSourceTime' in the servers config file to a -fairly high value preventing the server from closing the socket to fast. - -ALLOWED QUALITY FACTOR : - - -q = 0...9. Default -q 5 - -q 0: Highest quality, very slow - -q 9: Poor quality, but fast - -h Same as -q 2. Recommended. - -f Same as -q 7. Fast, ok quality - -ALLOWED SAMPLERATE/BITRATES - -MPEG-1 layer III sample frequencies (kHz): 32 48 44.1 -bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 - -MPEG-2 layer III sample frequencies (kHz): 16 24 22.05 -bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 - -MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025 -bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 - diff --git a/externals/unauthorized/mp3cast~/interface.h b/externals/unauthorized/mp3cast~/interface.h deleted file mode 100644 index de3136a0c88b10e1d0e7a7bac704afc5ac835e86..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/interface.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Copyright (C) 2000 Albert L. Faber -** -** 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. -*/ - -#ifndef INTERFACE_H_INCLUDED -#define INTERFACE_H_INCLUDED - -// #include "common.h" -#include "interface.h" - -BOOL InitMP3(PMPSTR mp); -int decodeMP3(PMPSTR mp,unsigned char *inmemory,int inmemsize,char *outmemory,int outmemsize,int *done); -void ExitMP3(PMPSTR mp); - -/* added remove_buf to support mpglib seeking */ -void remove_buf(PMPSTR mp); - -#endif diff --git a/externals/unauthorized/mp3cast~/mp3cast~.libs b/externals/unauthorized/mp3cast~/mp3cast~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/mp3cast~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3cast~/mpg123.h b/externals/unauthorized/mp3cast~/mpg123.h deleted file mode 100644 index 1c530d384d4ec30b38f2648b08e91ea76b618b22..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/mpg123.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef MPG123_H_INCLUDED -#define MPG123_H_INCLUDED - -#include - -#define STDC_HEADERS - -#ifdef STDC_HEADERS -# include -#else -# ifndef HAVE_STRCHR -# define strchr index -# define strrchr rindex -# endif -char *strchr (), *strrchr (); -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy ((s), (d), (n)) -# define memmove(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif - -#include - - -#if defined(__riscos__) && defined(FPA10) -#include "ymath.h" -#else -#include -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -#ifdef REAL_IS_FLOAT -# define real float -#elif defined(REAL_IS_LONG_DOUBLE) -# define real long double -#else -# define real double -#endif - -#define FALSE 0 -#define TRUE 1 - -#define SBLIMIT 32 -#define SSLIMIT 18 - -#define MPG_MD_STEREO 0 -#define MPG_MD_JOINT_STEREO 1 -#define MPG_MD_DUAL_CHANNEL 2 -#define MPG_MD_MONO 3 - -#define MAXFRAMESIZE 1792 - -/* AF: ADDED FOR LAYER1/LAYER2 */ -#define SCALE_BLOCK 12 - - -/* Pre Shift fo 16 to 8 bit converter table */ -#define AUSHIFT (3) - -struct frame { - int stereo; - int jsbound; - int single; - int lsf; - int mpeg25; - int header_change; - int lay; - int error_protection; - int bitrate_index; - int sampling_frequency; - int padding; - int extension; - int mode; - int mode_ext; - int copyright; - int original; - int emphasis; - int framesize; /* computed framesize */ - - /* AF: ADDED FOR LAYER1/LAYER2 */ -#if defined(USE_LAYER_2) || defined(USE_LAYER_1) - int II_sblimit; - struct al_table2 *alloc; - int down_sample_sblimit; - int down_sample; - -#endif - -}; - -struct gr_info_s { - int scfsi; - unsigned part2_3_length; - unsigned big_values; - unsigned scalefac_compress; - unsigned block_type; - unsigned mixed_block_flag; - unsigned table_select[3]; - unsigned subblock_gain[3]; - unsigned maxband[3]; - unsigned maxbandl; - unsigned maxb; - unsigned region1start; - unsigned region2start; - unsigned preflag; - unsigned scalefac_scale; - unsigned count1table_select; - real *full_gain[3]; - real *pow2gain; -}; - -struct III_sideinfo -{ - unsigned main_data_begin; - unsigned private_bits; - struct { - struct gr_info_s gr[2]; - } ch[2]; -}; - - -#endif diff --git a/externals/unauthorized/mp3cast~/mpglib.h b/externals/unauthorized/mp3cast~/mpglib.h deleted file mode 100644 index 1f4ef9aa829a1dd76e0fdf7dec0f953be0136114..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3cast~/mpglib.h +++ /dev/null @@ -1,65 +0,0 @@ -// #include "lame-analysis.h" - -#define NOANALYSIS - -#ifndef NOANALYSIS -extern plotting_data *mpg123_pinfo; -#endif - -struct buf { - unsigned char *pnt; - long size; - long pos; - struct buf *next; - struct buf *prev; -}; - -struct framebuf { - struct buf *buf; - long pos; - struct frame *next; - struct frame *prev; -}; - -typedef struct mpstr_tag { - struct buf *head,*tail; - int vbr_header; /* 1 if valid Xing vbr header detected */ - int num_frames; /* set if vbr header present */ - int enc_delay; /* set if vbr header present */ - int enc_padding; /* set if vbr header present */ - int header_parsed; - int side_parsed; - int data_parsed; - int free_format; /* 1 = free format frame */ - int old_free_format; /* 1 = last frame was free format */ - int bsize; - int framesize; - int ssize; - int dsize; - int fsizeold; - int fsizeold_nopadding; - struct frame fr; - unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ - real hybrid_block[2][2][SBLIMIT*SSLIMIT]; - int hybrid_blc[2]; - unsigned long header; - int bsnum; - real synth_buffs[2][2][0x110]; - int synth_bo; - int sync_bitstream; - -} MPSTR, *PMPSTR; - - -#if ( defined(_MSC_VER) || defined(__BORLANDC__) ) - typedef int BOOL; /* windef.h contains the same definition */ -#else - #define BOOL int -#endif - -#define MP3_ERR -1 -#define MP3_OK 0 -#define MP3_NEED_MORE 1 - - - diff --git a/externals/unauthorized/mp3live~/mp3live~-help.pd b/externals/unauthorized/mp3fileout~-help.pd similarity index 100% rename from externals/unauthorized/mp3live~/mp3live~-help.pd rename to externals/unauthorized/mp3fileout~-help.pd diff --git a/externals/unauthorized/mp3live~/mp3fileout~.c b/externals/unauthorized/mp3fileout~.c similarity index 52% rename from externals/unauthorized/mp3live~/mp3fileout~.c rename to externals/unauthorized/mp3fileout~.c index 97d0d493dda8fb8a9195d32efa1a516fa841e8bc..c331d0f990458c886e7bce2d347c537eef6dc073 100644 --- a/externals/unauthorized/mp3live~/mp3fileout~.c +++ b/externals/unauthorized/mp3fileout~.c @@ -28,10 +28,11 @@ /* "And all the one who tried hard to succeed" */ /* You know who, don't you ??? */ /* ---------------------------------------------------------------------------- */ - + #include #include +#include #include #include @@ -58,6 +59,12 @@ #define MSG_NOSIGNAL 0 #endif +/* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_fopen fopen +#define sys_fclose fclose +#define sys_close close +#endif #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ #include "mpglib.h" /* mpglib decoding library from lame 3.92 */ @@ -81,17 +88,17 @@ extern void sys_sockerror(char *s); void mp3fileout_closesocket(int fd) { -#ifdef UNIX +#ifndef _MSC_VER if ( close(fd) < 0 ) { - perror( "close" ); + perror( "close" ); } else { - post( "mp3fileout~ : closed socket : %d", fd ); + post( "mp3fileout~ : closed socket : %d", fd ); } #endif -#ifdef NT +#ifdef _WIN32 closesocket(fd); #else sys_rmpollfn(fd); @@ -104,223 +111,224 @@ static t_class *mp3fileout_class; typedef struct _mp3fileout { - t_object x_obj; - t_int x_socket; - t_int x_fd; /* file descriptor for the mp3 file */ - t_int x_eof; /* end of file is reached */ - t_int x_emit; /* indicates the ability to emit */ - t_int x_nbwaitloops;/* synchronization cycles count */ - t_int x_blocksize; /* actual blocksize */ - - void *x_inbuffer; /* accumulation buffer for read mp3 frames */ - t_int x_inwriteposition; - t_int x_inbuffersize; - t_int x_framesize; - t_int x_offset; /* offset used for decoding */ - t_int x_nbloops; /* number of perform loops */ - - void *x_outbuffer; /* buffer to be emitted */ - t_int x_outframes; /* number of frames emitted */ - t_int x_outbuffersize; - t_int x_outavable; /* number of available bytes to emit */ - - t_canvas *x_canvas; - - t_outlet *x_connected; /* indicates state of the connection */ - t_outlet *x_endreached;/* indicates the end of file */ - t_outlet *x_frames; /* indicates the number of frames emitted */ + t_object x_obj; + t_int x_socket; + t_int x_fd; /* file descriptor for the mp3 file */ + t_int x_eof; /* end of file is reached */ + t_int x_emit; /* indicates the ability to emit */ + t_int x_nbwaitloops;/* synchronization cycles count */ + t_int x_blocksize; /* actual blocksize */ + + void *x_inbuffer; /* accumulation buffer for read mp3 frames */ + t_int x_inwriteposition; + t_int x_inbuffersize; + t_int x_framesize; + t_int x_offset; /* offset used for decoding */ + t_int x_nbloops; /* number of perform loops */ + + void *x_outbuffer; /* buffer to be emitted */ + t_int x_outframes; /* number of frames emitted */ + t_int x_outbuffersize; + t_int x_outavable; /* number of available bytes to emit */ + + t_canvas *x_canvas; + + t_outlet *x_connected; /* indicates state of the connection */ + t_outlet *x_endreached;/* indicates the end of file */ + t_outlet *x_frames; /* indicates the number of frames emitted */ } t_mp3fileout; static int mp3fileout_search_header(t_mp3fileout *x) { - t_int i; - t_int length = 0; - struct frame hframe; - unsigned long cheader; - t_int ret = sizeof( unsigned long); - t_int foffset = 0; - unsigned int a,b,c,d; - unsigned char buf[sizeof(unsigned long)]; - t_float nbsamplesframe = 0; - - while( ret>0 ) - { - ret = read( x->x_fd, (void *)buf, sizeof( unsigned long ) ); - - foffset+=ret; - - if ( ret>0 ) + t_int i; + t_int length = 0; + struct frame hframe; + unsigned long cheader; + t_int ret = sizeof( unsigned long); + t_int foffset = 0; + unsigned int a,b,c,d; + unsigned char buf[sizeof(unsigned long)]; + t_float nbsamplesframe = 0; + + while( ret>0 ) { - /* check for a valid header */ - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - cheader = 0; - cheader = a; - cheader <<= 8; - cheader |= b; - cheader <<= 8; - cheader |= c; - cheader <<= 8; - cheader |= d; - if ( head_check( cheader, 0 ) ) - { - decode_header( &hframe, cheader ); - // print_header_compact( &hframe ); - x->x_framesize = hframe.framesize; - nbsamplesframe = ( hframe.mpeg25 ? 576 : 1152 ); - x->x_nbwaitloops = (int)(nbsamplesframe/x->x_blocksize); - if ( x->x_nbwaitloops == 0 ) x->x_nbwaitloops = 1; - // post ( "mp3fileout~ : will wait %d loops", x->x_nbwaitloops ); - - // rewind file to the start of the frame - if ( lseek( x->x_fd, -sizeof(unsigned long), SEEK_CUR ) < 0 ) + ret = read( x->x_fd, (void *)buf, sizeof( unsigned long ) ); + + foffset+=ret; + + if ( ret>0 ) { - post( "mp3fileout~ : could not rewind file." ); + /* check for a valid header */ + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + cheader = 0; + cheader = a; + cheader <<= 8; + cheader |= b; + cheader <<= 8; + cheader |= c; + cheader <<= 8; + cheader |= d; + if ( head_check( cheader, 0 ) ) + { + decode_header( &hframe, cheader ); + // print_header_compact( &hframe ); + x->x_framesize = hframe.framesize; + nbsamplesframe = ( hframe.mpeg25 ? 576 : 1152 ); + x->x_nbwaitloops = (int)(nbsamplesframe/x->x_blocksize); + if ( x->x_nbwaitloops == 0 ) x->x_nbwaitloops = 1; + // post ( "mp3fileout~ : will wait %d loops", x->x_nbwaitloops ); + + // rewind file to the start of the frame + if ( lseek( x->x_fd, -sizeof(unsigned long), SEEK_CUR ) < 0 ) + { + post( "mp3fileout~ : could not rewind file." ); + } + if ( x->x_outframes == 0 ) + { + post( "mp3fileout~ : found firstframe @ %d", foffset ); + } + break; + } + // post( "mp3fileout~ : read %d bytes.", ret ); } - if ( x->x_outframes == 0 ) + else { - post( "mp3fileout~ : found firstframe @ %d", foffset ); + if ( ret < 0 ) + { + post( "mp3fileout~ : error encountered ( ret=%d )...file reading done.", ret ); + perror( "read" ); + x->x_eof = 1; + } + else + { + post( "mp3fileout~ : file reading done.", ret ); + x->x_eof = 1; + outlet_bang( x->x_endreached ); + } + return -1; } - break; - } - // post( "mp3fileout~ : read %d bytes.", ret ); - } - else - { - if ( ret < 0 ) - { - post( "mp3fileout~ : error encountered ( ret=%d )...file reading done.", ret ); - perror( "read" ); - x->x_eof = 1; - } - else - { - post( "mp3fileout~ : file reading done.", ret ); - x->x_eof = 1; - outlet_bang( x->x_endreached ); - } - return -1; - } - } + } - return x->x_framesize; + return x->x_framesize; } static int mp3fileout_read_frame(t_mp3fileout *x) { - int size, ret; - - if ( x->x_fd > 0 && !x->x_eof) - { - if ( ( size = mp3fileout_search_header( x ) ) > 0 ) - { - if ( size+sizeof(unsigned long) > INPUT_BUFFER_SIZE ) - { - post( "mp3fileout~ : cannot read frame : size too big : %d", size ); - return -1; - } - // post( "mp3fileout~ : reading a frame : size : %d", size ); - ret = read( x->x_fd, x->x_inbuffer, size+sizeof(unsigned long) ); - - if ( ret>0 ) - { - memcpy( x->x_outbuffer, x->x_inbuffer, ret ); - x->x_outavable += ret; - return ret; - } - else - { + int size, ret; + + if ( x->x_fd > 0 && !x->x_eof) + { + if ( ( size = mp3fileout_search_header( x ) ) > 0 ) + { + if ( size+sizeof(unsigned long) > INPUT_BUFFER_SIZE ) + { + post( "mp3fileout~ : cannot read frame : size too big : %d", size ); + return -1; + } + // post( "mp3fileout~ : reading a frame : size : %d", size ); + ret = read( x->x_fd, x->x_inbuffer, size+sizeof(unsigned long) ); + + if ( ret>0 ) + { + memcpy( x->x_outbuffer, x->x_inbuffer, ret ); + x->x_outavable += ret; + return ret; + } + else + { + return -1; + } + } + else + { return -1; - } - } - else - { - return -1; - } - } - else - { - return -1; - } + } + } + else + { + return -1; + } } static int mp3fileout_send_frame(t_mp3fileout *x) { - int ret=0; + int ret=0; if ( x->x_socket > 0 && x->x_emit ) { - if ( ( ret = send( x->x_socket, x->x_outbuffer, x->x_outavable, MSG_NOSIGNAL ) ) < 0 ) - { - post( "mp3fileout~ : connection lost." ); - perror( "send" ); - x->x_socket = -1; - x->x_emit = 0; - return -1; - } - else - { - memcpy( x->x_outbuffer, x->x_outbuffer+ret, x->x_outbuffersize-ret ); - x->x_outavable -= ret; - x->x_outframes++; - outlet_float( x->x_frames, x->x_outframes ); - // post( "mp3fileout~ : sent %d bytes, x->x_outavable : %d", ret, x->x_outavable ); - } - - } + if ( ( ret = send( x->x_socket, x->x_outbuffer, x->x_outavable, MSG_NOSIGNAL ) ) < 0 ) + { + post( "mp3fileout~ : connection lost." ); + perror( "send" ); + x->x_socket = -1; + x->x_emit = 0; + return -1; + } + else + { + memcpy( x->x_outbuffer, x->x_outbuffer+ret, x->x_outbuffersize-ret ); + x->x_outavable -= ret; + x->x_outframes++; + outlet_float( x->x_frames, x->x_outframes ); + // post( "mp3fileout~ : sent %d bytes, x->x_outavable : %d", ret, x->x_outavable ); + } + + } else { - // artificially empty buffer - x->x_outavable = 0; + // artificially empty buffer + x->x_outavable = 0; } return ret; } static void mp3fileout_free(t_mp3fileout *x) { - if (x->x_socket > 0) { + if (x->x_socket > 0) + { post( "mp3fileout~ : closing socket" ); mp3fileout_closesocket(x->x_socket); x->x_socket = -1; - } - if ( x->x_fd > 0 ) - { - if ( close( x->x_fd ) < 0 ) - { - post( "mp3fileout~ : could not close file." ); - perror( "close" ); - } - } - if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize ); + } + if ( x->x_fd > 0 ) + { + if ( close( x->x_fd ) < 0 ) + { + post( "mp3fileout~ : could not close file." ); + perror( "close" ); + } + } + if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize ); } static t_int *mp3fileout_perform(t_int *w) { - t_mp3fileout *x = (t_mp3fileout*) (w[1]); - int ret; - int i = 0; - - x->x_blocksize = (t_int)(w[2]); - // check new incoming data - if ( x->x_socket > 0 ) - { + t_mp3fileout *x = (t_mp3fileout*) (w[1]); + int ret; + int i = 0; + + x->x_blocksize = (t_int)(w[2]); + // check new incoming data + if ( x->x_socket > 0 ) + { if ( x->x_nbloops % x->x_nbwaitloops == 0 ) { - /* read a frame in the file */ - if ( mp3fileout_read_frame(x) > 0 ) - { - /* send the frame to the peer */ - mp3fileout_send_frame(x); - } + /* read a frame in the file */ + if ( mp3fileout_read_frame(x) > 0 ) + { + /* send the frame to the peer */ + mp3fileout_send_frame(x); + } } x->x_nbloops = ( x->x_nbloops+1 ) % x->x_nbwaitloops; - } - return (w+3); + } + return (w+3); } static void mp3fileout_dsp(t_mp3fileout *x, t_signal **sp) @@ -328,123 +336,123 @@ static void mp3fileout_dsp(t_mp3fileout *x, t_signal **sp) dsp_add(mp3fileout_perform, 2, x, sp[0]->s_n); } - /* start streaming */ +/* start streaming */ static void mp3fileout_start(t_mp3fileout *x) { x->x_emit = 1; if ( x->x_fd > 0 ) { - // reset file pointer - if ( lseek( x->x_fd, 0, SEEK_SET ) < 0 ) - { - post ( "mp3fileout~ : could not reset file pointer."); - x->x_eof = 1; - return; - } - x->x_eof = 0; - x->x_outframes = 0; - outlet_float( x->x_frames, x->x_outframes ); + // reset file pointer + if ( lseek( x->x_fd, 0, SEEK_SET ) < 0 ) + { + post ( "mp3fileout~ : could not reset file pointer."); + x->x_eof = 1; + return; + } + x->x_eof = 0; + x->x_outframes = 0; + outlet_float( x->x_frames, x->x_outframes ); } } - /* resume file reading */ +/* resume file reading */ static void mp3fileout_resume(t_mp3fileout *x) { x->x_emit = 1; } - /* seek in file */ +/* seek in file */ static void mp3fileout_seek(t_mp3fileout *x, t_floatarg foffset) { if ( foffset < 0 ) { - post( "mp3fileout~ : wrong offset."); - return; + post( "mp3fileout~ : wrong offset."); + return; } if ( x->x_fd > 0 ) { - // reset file pointer - if ( lseek( x->x_fd, (int)foffset, SEEK_SET ) < 0 ) - { - post ( "mp3fileout~ : could not reset file pointer."); - x->x_eof = 1; - return; - } - x->x_eof = 0; + // reset file pointer + if ( lseek( x->x_fd, (int)foffset, SEEK_SET ) < 0 ) + { + post ( "mp3fileout~ : could not reset file pointer."); + x->x_eof = 1; + return; + } + x->x_eof = 0; } } - /* stop streaming */ +/* stop streaming */ static void mp3fileout_stop(t_mp3fileout *x) { x->x_emit = 0; } - /* open mp3 file */ +/* open mp3 file */ static void mp3fileout_open(t_mp3fileout *x, t_symbol *filename) { - // first close previous file + // first close previous file if ( x->x_fd > 0 ) { - if ( close( x->x_fd ) < 0 ) - { - post( "mp3fileout~ : could not close file." ); - perror( "close" ); - } - x->x_outframes = 0; - outlet_float( x->x_frames, x->x_outframes ); + if ( close( x->x_fd ) < 0 ) + { + post( "mp3fileout~ : could not close file." ); + perror( "close" ); + } + x->x_outframes = 0; + outlet_float( x->x_frames, x->x_outframes ); } - if ( ( x->x_fd = open( filename->s_name, O_RDONLY ) ) < 0 ) + if ( ( x->x_fd = sys_open( filename->s_name, O_RDONLY ) ) < 0 ) { - post( "mp3fileout~ : could not open file : %s", filename->s_name ); - perror( "open" ); - x->x_eof = 1; + post( "mp3fileout~ : could not open file : %s", filename->s_name ); + perror( "open" ); + x->x_eof = 1; } else { - x->x_eof = 0; - post( "mp3fileout~ : opened file : %s ( fd = %d )", filename->s_name, x->x_fd ); + x->x_eof = 0; + post( "mp3fileout~ : opened file : %s ( fd = %d )", filename->s_name, x->x_fd ); } } - /* connect to the peer */ +/* connect to the peer */ static void mp3fileout_connect(t_mp3fileout *x, t_symbol *hostname, t_floatarg fportno) { struct sockaddr_in csocket; struct hostent *hp; int portno = fportno; /* get port from message box */ - - /* variables used for communication with the peer */ + + /* variables used for communication with the peer */ unsigned int len; int sockfd; - -#ifndef UNIX + +#ifdef _WIN32 unsigned int ret; #else int ret; #endif - + if (x->x_socket >= 0) { error("mp3fileout~: already connected"); return; } - + sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sockfd < 0) { error("mp3fileout~: internal error while attempting to open socket"); return; } - - /* connect socket using hostname provided in command line */ + + /* connect socket using hostname provided in command line */ csocket.sin_family = AF_INET; hp = gethostbyname(hostname->s_name); if (hp == 0) { post("mp3fileout~: bad host?"); -#ifndef UNIX +#ifdef _WIN32 closesocket(sockfd); #else close(sockfd); @@ -452,39 +460,39 @@ static void mp3fileout_connect(t_mp3fileout *x, t_symbol *hostname, t_floatarg f return; } memcpy((char *)&csocket.sin_addr, (char *)hp->h_addr, hp->h_length); - - /* assign client port number */ + + /* assign client port number */ csocket.sin_port = htons((unsigned short)portno); - - /* try to connect. */ + + /* try to connect. */ post("mp3fileout~: connecting to port %d", portno); if (connect(sockfd, (struct sockaddr *) &csocket, sizeof (csocket)) < 0) { error("mp3fileout~: connection failed!\n"); -#ifndef UNIX +#ifdef _WIN32 closesocket(sockfd); #else close(sockfd); #endif return; } - + x->x_socket = sockfd; x->x_outframes = 0; outlet_float( x->x_frames, x->x_outframes ); - outlet_float( x->x_connected, 1 ); + outlet_float( x->x_connected, 1 ); post( "mp3fileout~ : connected to peer" ); - -} - /* close connection to the peer */ +} + +/* close connection to the peer */ static void mp3fileout_disconnect(t_mp3fileout *x) { - + int err = -1; if(x->x_socket >= 0) /* close socket */ { -#ifndef UNIX +#ifdef _WIN32 closesocket(x->x_socket); #else close(x->x_socket); @@ -501,12 +509,12 @@ static void *mp3fileout_new(void) { t_mp3fileout *x; int i; - + x = (t_mp3fileout *)pd_new(mp3fileout_class); - x->x_connected = outlet_new( &x->x_obj, &s_float ); - x->x_frames = outlet_new( &x->x_obj, &s_float ); - x->x_endreached = outlet_new( &x->x_obj, &s_bang ); - + x->x_connected = outlet_new( &x->x_obj, &s_float ); + x->x_frames = outlet_new( &x->x_obj, &s_float ); + x->x_endreached = outlet_new( &x->x_obj, &s_bang ); + x->x_socket = -1; x->x_fd = -1; x->x_eof = 0; @@ -517,8 +525,8 @@ static void *mp3fileout_new(void) x->x_inbuffer = (char*) getbytes( x->x_inbuffersize ); if ( !x->x_inbuffer ) { - post( "mp3fileout~ : could not allocate buffers." ); - return NULL; + post( "mp3fileout~ : could not allocate buffers." ); + return NULL; } memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE ); @@ -526,8 +534,8 @@ static void *mp3fileout_new(void) x->x_outbuffer = (char*) getbytes( x->x_outbuffersize ); if ( !x->x_outbuffer ) { - post( "mp3fileout~ : could not allocate buffers." ); - return NULL; + post( "mp3fileout~ : could not allocate buffers." ); + return NULL; } memset( x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE ); x->x_outavable = 0; @@ -541,10 +549,10 @@ static void *mp3fileout_new(void) void mp3fileout_tilde_setup(void) { - post( mp3fileout_version ); - mp3fileout_class = class_new(gensym("mp3fileout~"), - (t_newmethod) mp3fileout_new, (t_method) mp3fileout_free, - sizeof(t_mp3fileout), 0, A_NULL); + logpost(NULL, 4, "%s", mp3fileout_version ); + mp3fileout_class = class_new(gensym("mp3fileout~"), + (t_newmethod) mp3fileout_new, (t_method) mp3fileout_free, + sizeof(t_mp3fileout), 0, A_NULL); class_addmethod(mp3fileout_class, nullfn, gensym("signal"), 0); class_addmethod(mp3fileout_class, (t_method) mp3fileout_dsp, gensym("dsp"), A_CANT, 0); diff --git a/externals/unauthorized/mp3live~/INSTALL b/externals/unauthorized/mp3live~/INSTALL deleted file mode 100644 index 63db4c7788faeb5e65fe5a91fb21b4a003eb33a6..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/INSTALL +++ /dev/null @@ -1,21 +0,0 @@ -You need to get lame > v3.90 installed first. -libmp3lame.so is searched in /usr/local/lib -( no time to write configure scripts ). -if it's installed elsewhere, change the Makefile, -you won't die from that. - -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/mp3live~ - -make clean - -make - -make install - -open help-mp3live~.pd - -Thanx for getting here. - -Yves/ diff --git a/externals/unauthorized/mp3live~/Makefile b/externals/unauthorized/mp3live~/Makefile deleted file mode 100644 index 536bb252c69fc91ed71d7f6affc90f31dd4f5d95..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -NAME=mp3streamout~ -CSYM=mp3streamout_tilde -NAMEB=mp3streamin~ -CSYMB=mp3streamin_tilde -NAMEC=mp3fileout~ -CSYMC=mp3fileout_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll $(NAMEB).dll $(NAMEC).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 $(NAMEB).pd_irix5 $(NAMEC).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 $(NAMEB).pd_irix6 $(NAMEC).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux $(NAMEB).pd_linux $(NAMEC).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -g -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib -lmp3lame - #strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s mp3live~/$*.pd_linux .. - - - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/mp3live~/README b/externals/unauthorized/mp3live~/README deleted file mode 100644 index 3af0dbb0f205e714b9397d0e6d34d95d4d4f2530..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/README +++ /dev/null @@ -1,65 +0,0 @@ -Version 0.01 -copyleft (c) 2001 by Yves Degoyon - -mp3live~ is a peer-to-peer mp3 streamer package -consisting of three objects : mp3streamout~, mp3fileout~ and mp3streamin~. - -To install mp3live~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - -mp3live~ has been compiled for Linux using LAME 3.92. -The newest version of LAME can be found at sourceforge.net - -COPYING: you may use this source under GPL terms! - -PLEASE NOTE: This software may contain patented alogrithm (at least - patented in some countries). It may be not allowed to sell/use products - based on this source code in these countries. Check this out first! - -COPYRIGHT of MP3 music: - Please note, that the duplicating of copyrighted music without explicit - permission violates the rights of the owner. - And remember, copyrighted music sucks [ as well as corporate ] - -***************************************************************************** - - using mp3live~ external for Pure Data - -Open the help-mp3live~.pd to understand how it works. - -A note about MPEG encoding : - -ALLOWED QUALITY FACTOR : - - -q = 0...9. Default -q 5 - -q 0: Highest quality, very slow - -q 9: Poor quality, but fast - -h Same as -q 2. Recommended. - -f Same as -q 7. Fast, ok quality - -ALLOWED BITRATES : - -bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 - -BUGS : - -1. -You cannot create more than MAX_DECODERS mp3streamin~ objects. The actual value is 100. - -2. -Current version of lame ( 3.92 ) produces a lot of errors for quality < 5. Blame it on lame !!!! - -3. -Mono is not supported. Some additional code should be added for mp3streamin~. Blame it on me !!! - -4. -Resampling is not supported. Blame it on me !!! diff --git a/externals/unauthorized/mp3live~/interface.h b/externals/unauthorized/mp3live~/interface.h deleted file mode 100644 index de3136a0c88b10e1d0e7a7bac704afc5ac835e86..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/interface.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Copyright (C) 2000 Albert L. Faber -** -** 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. -*/ - -#ifndef INTERFACE_H_INCLUDED -#define INTERFACE_H_INCLUDED - -// #include "common.h" -#include "interface.h" - -BOOL InitMP3(PMPSTR mp); -int decodeMP3(PMPSTR mp,unsigned char *inmemory,int inmemsize,char *outmemory,int outmemsize,int *done); -void ExitMP3(PMPSTR mp); - -/* added remove_buf to support mpglib seeking */ -void remove_buf(PMPSTR mp); - -#endif diff --git a/externals/unauthorized/mp3live~/mp3fileout~.libs b/externals/unauthorized/mp3live~/mp3fileout~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mp3fileout~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3live~/mp3streamin~.c b/externals/unauthorized/mp3live~/mp3streamin~.c deleted file mode 100644 index eff40684ee084276202c3fd2756150c660601ab7..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mp3streamin~.c +++ /dev/null @@ -1,671 +0,0 @@ -/* ------------------------ mp3streamin~ -------------------------------------- */ -/* */ -/* Tilde object to receive an mp3-stream sent by a peer using mp3streamout~. */ -/* Written by Yves Degoyon (ydegoyon@free.fr). */ -/* Tarballs and updates @ http://ydegoyon.free.fr */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* Uses the LAME MPEG 1 Layer 3 encoding library (lame_enc.dll) which can */ -/* be found at http://www.cdex.n3.net. */ -/* */ -/* "Repackage sex, your interests." */ -/* "Somehow, maintain the interest." */ -/* Gang Of Four -- Natural's Not In It */ -/* ---------------------------------------------------------------------------- */ - - -#include -#include -#include - -#if PD_MINOR_VERSION >=37 -#include "s_stuff.h" -#endif - -#include -#include -#ifdef _WIN32 -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define SOCKET_ERROR -1 -#endif /* _WIN32 */ - -#if defined(__APPLE__) || defined(_WIN32) -#define MSG_NOSIGNAL 0 -#define SOL_TCP IPPROTO_TCP -#endif - -#include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ -#include "mpglib.h" /* mpglib decoding library from lame 3.92 */ -#include "interface.h" /* mpglib decoding library from lame 3.92 */ - -#define MIN_AUDIO_INPUT 8064 // we must a least have 8 chunks to play a correct sound -#define INPUT_BUFFER_SIZE MIN_AUDIO_INPUT -#define OUTPUT_BUFFER_SIZE 131072 /* 128k*/ -#define LAME_AUDIO_CHUNK_SIZE 1152 -#define BARHEIGHT 10 -#define MAX_DECODERS 10 - -/* useful debugging functions from mpglib */ -extern int decode_header( struct frame* fr, unsigned long newhead ); -extern void print_header_compact( struct frame* fr ); -extern int head_check( unsigned long head, int check_layer ); - -/* time-out used for select() call */ -static struct timeval ztout; - -static char *mp3streamin_version = "mp3streamin~: mp3 peer-to-peer streamer version 0.3, written by ydegoyon@free.fr"; - -extern void sys_sockerror(char *s); - -void mp3streamin_closesocket(int fd) -{ -#ifdef UNIX - if ( close(fd) < 0 ) - { - perror( "close" ); - } - else - { - post( "mp3streamin~ : closed socket : %d", fd ); - } -#endif -#ifdef NT - closesocket(fd); -#endif - sys_rmpollfn(fd); -} - -int setsocketoptions(int sockfd) -{ - int sockopt = 1; - if (setsockopt(sockfd, SOL_TCP, TCP_NODELAY, (const char*) &sockopt, sizeof(int)) < 0) - { - post("mp3streamin~ : setsockopt TCP_NODELAY failed"); - perror( "setsockopt" ); - return -1; - } - else - { - post("mp3streamin~ : TCP_NODELAY set"); - } - -#ifdef UNIX - sockopt = 1; - if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(int)) < 0) - { - post("mp3streamin~ : setsockopt SO_REUSEADDR failed"); - perror( "setsockopt" ); - return -1; - } - else - { - post("mp3streamin~ : setsockopt SO_REUSEADDR done."); - } -#endif - return 0; -} - - -/* ------------------------ mp3streamin~ ----------------------------- */ - -static t_class *mp3streamin_class; - -typedef struct _mp3streamin -{ - t_object x_obj; - t_int x_instance; - t_int x_socket; - t_int x_shutdown; - t_outlet *x_connectionip; - t_int x_serversocket; - t_int x_inpackets; /* number of packets received */ - t_int x_dpacket; /* displayed packet in status bar */ - t_int x_packetsize; /* size of the packets */ - t_int x_pblocks; /* processed blocks */ - t_int x_graphic; /* indicates if we show a graphic bar */ - - void *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ - t_int x_inwriteposition; - t_int x_inbuffersize; - - t_float *x_outbuffer; /* buffer to store audio decoded data */ - t_int x_outwriteposition; - t_int x_outreadposition; - t_int x_outunread; - t_int x_outbuffersize; - - t_canvas *x_canvas; - - t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */ - t_int x_newstream; /* at first, the stream must provide enough data to start */ - t_int x_bitrateindex; /* remember the bitrate index */ - -} t_mp3streamin; - -/* too bad, this needs to be static, - handling an array to enable several decoders in pd */ -static MPSTR mp[MAX_DECODERS]; /* decoder buffer */ -int nbinstances = 0; - -void mp3streamin_tilde_mpglib_init(t_mp3streamin *x) -{ - int ret; - - InitMP3(&mp[x->x_instance]); -} - -static int mp3streamin_decode_input(t_mp3streamin *x) -{ - int i; - int alength = 0; - struct frame hframe; - unsigned int a,b,c,d; - unsigned long cheader; - static char out[8192]; - signed short int *p = (signed short int *) out; - int pbytes; - int ret; - - if ( !x->x_shutdown ) - { - /* decode first 4 bytes as the header */ - a = *((unsigned char*)x->x_inbuffer); - b = *((unsigned char*)x->x_inbuffer+1); - c = *((unsigned char*)x->x_inbuffer+2); - d = *((unsigned char*)x->x_inbuffer+3); - - cheader = 0; - cheader = a; - cheader <<= 8; - cheader |= b; - cheader <<= 8; - cheader |= c; - cheader <<= 8; - cheader |= d; - if ( head_check( cheader, 0 ) ) - { - // post( "mp3streamin~ : valid header ( packet=%d)", x->x_inpackets ); - decode_header( &hframe, cheader ); - // print_header_compact( &hframe ); - // when the bitrate change, reinit decoder - if ( x->x_bitrateindex != hframe.bitrate_index ) - { - ExitMP3(&mp[x->x_instance]); - InitMP3(&mp[x->x_instance]); - x->x_bitrateindex = hframe.bitrate_index; - } - } - else - { - post( "mp3streamin~ : error : mp3 packet received without header" ); - // ignore data - x->x_inwriteposition = 0; - x->x_inpackets--; - return( -1 ); - } - - // post( "mp3streamin~ : decoding %d bytes framesize=%d", x->x_inwriteposition, hframe.framesize ); - ret = - decodeMP3(&mp[x->x_instance], (unsigned char*)x->x_inbuffer, - x->x_inwriteposition, (char *) p, sizeof(out), &pbytes); - - switch (ret) { - case MP3_OK: - switch (mp[x->x_instance].fr.stereo) { - case 1: - case 2: - alength = ((mp[x->x_instance].fr.stereo==1)?pbytes >> 1 : pbytes >> 2); - // post( "mp3streamin~ : processed %d samples", alength ); - // update outbuffer contents - for ( i=0; ix_outunread >= x->x_outbuffersize-2 ) - { - post( "mp3streamin~ : too much input ... ignored" ); - continue; - } - *(x->x_outbuffer+x->x_outwriteposition) = ((t_float)(*p++))/32767.0; - x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; - *(x->x_outbuffer+x->x_outwriteposition) = - ((mp[x->x_instance].fr.stereo==2)?((t_float)(*p++))/32767.0 : 0.0); - x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; - x->x_outunread+=2; - - if ( x->x_outunread > MIN_AUDIO_INPUT && !x->x_stream ) - { - post( "mp3streamin~ : stream connected." ); - x->x_stream = 1; - } - } - - break; - default: - alength = -1; - break; - } - break; - - case MP3_NEED_MORE: - post( "mp3streamin~ : retry lame decoding (more data needed)." ); - alength = 0; - break; - - case MP3_ERR: - post( "mp3streamin~ : lame decoding failed." ); - alength = -1; - break; - - } - - x->x_inwriteposition = 0; - } - else - { - if ( x->x_outunread == 0 ) - { - post( "mp3streamin~ : connection closed" ); - mp3streamin_closesocket(x->x_socket); - x->x_stream = 0; - x->x_newstream = 0; - x->x_inpackets = 0; - x->x_inwriteposition = 0; - x->x_bitrateindex = -1; - x->x_socket=-1; - outlet_symbol( x->x_connectionip, gensym("") ); - } - } - - if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) - { - /* update graphical read status */ - if ( x->x_inpackets != x->x_dpacket ) - { - char color[32]; - int minpackets = ( MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE )-2; // audio loop has eaten some already - - - sys_vgui(".x%x.c delete rectangle %xSTATUS\n", x->x_canvas, x ); - sys_vgui(".x%x.c delete line %xTHRESHOLD\n", x->x_canvas, x ); - if ( x->x_outunread > 0 ) - { - t_int width; - - if ( x->x_inpackets < (MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE)/2 ) - { - strcpy( color, "red" ); - } - else - { - strcpy( color, "lightgreen" ); - } - width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); - sys_vgui(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n", - x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, - x->x_obj.te_xpix+(x->x_inpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, - x->x_obj.te_ypix - 1, color, x ); - sys_vgui(".x%x.c create line %d %d %d %d -fill red -tags %xTHRESHOLD\n", - x->x_canvas, x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, - x->x_obj.te_ypix-BARHEIGHT-1, - x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, - x->x_obj.te_ypix-1, x ); - x->x_dpacket = x->x_inpackets; - } - else - { - if ( x->x_shutdown ) - { - x->x_shutdown=0; - sys_vgui(".x%x.c delete rectangle %xPBAR\n", x->x_canvas, x ); - sys_vgui(".x%x.c delete line %xTHRESHOLD\n", x->x_canvas, x ); - } - } - } - } - return alength; -} - -static void mp3streamin_recv(t_mp3streamin *x) -{ - int ret; - - if ( ( ret = recv(x->x_socket, (void*) (x->x_inbuffer + x->x_inwriteposition), - (size_t)((x->x_inbuffersize-x->x_inwriteposition)), - MSG_NOSIGNAL) ) < 0 ) - { - post( "mp3_streamin~ : receive error" ); - perror( "recv" ); - return; - } - else - { - // post( "streamin~ : received %d bytes at %d on %d ( up to %d)", - // ret, x->x_inwriteposition, x->x_socket, - // x->x_inbuffersize-x->x_inwriteposition*sizeof( unsigned long) ); - - if ( ret == 0 ) - { - /* initiate the shutdown phase */ - x->x_shutdown=1; - } - else - { - // check we don't overflow input buffer - if ( (x->x_inpackets+1)*x->x_packetsize > x->x_inbuffersize ) - { - post( "mp3streamin~ : too much input...resetting" ); - x->x_inpackets=0; - x->x_inwriteposition=0; - return; - } - x->x_inpackets++; - x->x_packetsize=ret; - if ( x->x_inpackets % 100 == 0 ) - { - // post( "mp3streamin~ : received %d packets", x->x_inpackets ); - } - x->x_inwriteposition += ret; - } - - mp3streamin_decode_input(x); - } -} - -static void mp3streamin_acceptconnection(t_mp3streamin *x) -{ - struct sockaddr_in incomer_address; - int sockaddrl = (int) sizeof( struct sockaddr ); - - int fd = accept(x->x_serversocket, (struct sockaddr*)&incomer_address, &sockaddrl ); - - if (fd < 0) { - post("mp3streamin~: accept failed"); - return; - } - - if (x->x_socket > 0) { - sys_addpollfn(fd, (t_fdpollfn)mp3streamin_recv, x); - if ( x->x_outunread != 0 ) - { - post("mp3streamin~: still have some data to decode, retry later you %s.", - inet_ntoa( incomer_address.sin_addr )); - mp3streamin_closesocket( fd ); - return; - } - post("mp3streamin~: the source has changed to %s.", - inet_ntoa( incomer_address.sin_addr )); - mp3streamin_closesocket(x->x_socket); - } - - x->x_socket = fd; - sys_addpollfn(x->x_socket, (t_fdpollfn)mp3streamin_recv, x); - outlet_symbol( x->x_connectionip, gensym( inet_ntoa( incomer_address.sin_addr) ) ); - - if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) - { - t_int width; - - width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); - sys_vgui(".x%x.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n", - x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, - x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x ); - } - x->x_stream = 0; - x->x_newstream = 1; - -} - - -static int mp3streamin_startservice(t_mp3streamin* x, int portno) -{ - struct sockaddr_in server; - int sockfd; - - /* create a socket */ - sockfd = socket(AF_INET, SOCK_STREAM, 0); - - if (sockfd < 0) - { - sys_sockerror("socket"); - return (0); - } - server.sin_family = AF_INET; - server.sin_addr.s_addr = INADDR_ANY; - - /* assign server port number */ - server.sin_port = htons((u_short)portno); - post("listening to port number %d", portno); - - setsocketoptions(sockfd); - - /* name the socket */ - if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) { - sys_sockerror("bind"); - mp3streamin_closesocket(sockfd); - return (0); - } - - if (listen(sockfd, 5) < 0) { - sys_sockerror("listen"); - mp3streamin_closesocket(sockfd); - } - else - { - x->x_serversocket = sockfd; - sys_addpollfn(x->x_serversocket, (t_fdpollfn)mp3streamin_acceptconnection, x); - } - - return 1; -} - -static void mp3streamin_free(t_mp3streamin *x) -{ - post( "mp3streamin~ : free %x", x ); - if (x->x_serversocket > 0) { - post( "mp3streamin~ : closing server socket" ); - mp3streamin_closesocket(x->x_serversocket); - x->x_serversocket = -1; - } - if (x->x_socket > 0) { - post( "mp3streamin~ : closing socket" ); - mp3streamin_closesocket(x->x_socket); - x->x_socket = -1; - } - if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize ); - if ( x->x_outbuffer ) freebytes( x->x_outbuffer, x->x_outbuffersize*sizeof(t_float) ); - if ( x->x_instance == nbinstances-1 ) - { - nbinstances--; - } -} - -static t_int *mp3streamin_perform(t_int *w) -{ - t_mp3streamin *x = (t_mp3streamin*) (w[1]); - t_float *out1 = (t_float *)(w[2]); - t_float *out2 = (t_float *)(w[3]); - int n = (int)(w[4]); - int bsize = n; - int ret; - int i = 0; - - while( n-- ) - { - if ( ( ( x->x_outunread > MIN_AUDIO_INPUT ) && x->x_newstream ) || // wait the buffer to load - ( ( x->x_shutdown ) && ( x->x_outunread >= 2 ) ) || // clean disconnection - ( x->x_stream ) // check that the stream provides enough data - ) - { - if ( x->x_newstream && !x->x_shutdown ) - { - x->x_newstream = 0; - x->x_stream = 1; - } - *out1++=*(x->x_outbuffer+x->x_outreadposition); - x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; - *out2++=*(x->x_outbuffer+x->x_outreadposition); - x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; - x->x_outunread-=2; - if ( n == 1 ) x->x_pblocks++; - } - else - { - *out1++=0.0; - *out2++=0.0; - } - } - - if ( ( x->x_outunread <= MIN_AUDIO_INPUT/10 ) && ( x->x_stream ) ) - { - post( "mp3streamin~ : stream lost (too little input)" ); - x->x_stream = 0; - x->x_newstream = 1; // waiting for a new stream - } - - if ( x->x_pblocks == LAME_AUDIO_CHUNK_SIZE/bsize ) - { - x->x_inpackets--; - x->x_pblocks = 0; - } - -#ifdef DO_MY_OWN_SELECT - // check new incoming data - if ( x->x_socket > 0 ) - { - fd_set readset; - fd_set exceptset; - - FD_ZERO(&readset); - FD_ZERO(&exceptset); - FD_SET(x->x_socket, &readset ); - FD_SET(x->x_socket, &exceptset ); - - if ( select( maxfd+1, &readset, NULL, &exceptset, &ztout ) >0 ) - { - if ( FD_ISSET( x->x_socket, &readset) || FD_ISSET( x->x_socket, &exceptset ) ) - { - /* receive data or error and decode it */ - mp3streamin_recv(x); - } - } - } -#endif - return (w+5); -} - -static void mp3streamin_dsp(t_mp3streamin *x, t_signal **sp) -{ - dsp_add(mp3streamin_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - - -static void *mp3streamin_new(t_floatarg fportno, t_floatarg fdographics) -{ - t_mp3streamin *x; - int i; - - if ( fportno < 0 || fportno > 65535 ) - { - post( "mp3streamin~ : error : wrong portnumber : %d", (int)fportno ); - return NULL; - } - if ( ((int)fdographics != 0) && ((int)fdographics != 1.) ) - { - post( "mp3streamin~ : error : constructor : mp3streamin~ [graphic flag = 0 | 1 ] ( got = %f)", fdographics ); - return NULL; - } - - x = (t_mp3streamin *)pd_new(mp3streamin_class); - post( "mp3streamin~ : new %x (instance = %d) %d", x, nbinstances, sizeof( MPSTR ) ); - outlet_new(&x->x_obj, &s_signal); - outlet_new(&x->x_obj, &s_signal); - x->x_connectionip = outlet_new(&x->x_obj, &s_symbol); - - x->x_serversocket = -1; - x->x_socket = -1; - x->x_shutdown = 0; - x->x_inpackets = 0; - x->x_dpacket = -1; - - x->x_canvas = canvas_getcurrent(); - - x->x_inbuffersize = INPUT_BUFFER_SIZE; - x->x_outbuffersize = OUTPUT_BUFFER_SIZE; - x->x_inbuffer = (char*) getbytes( x->x_inbuffersize ); - memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE ); - x->x_outbuffer = (t_float*) getbytes( x->x_outbuffersize*sizeof(t_float) ); - memset( x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE ); - - if ( !x->x_inbuffer || !x->x_outbuffer ) - { - post( "mp3streamin~ : could not allocate buffers." ); - return NULL; - } - - if ( nbinstances < MAX_DECODERS ) - { - x->x_instance = nbinstances++; - } - else - { - post( "mp3streamin~ : cannot create more decoders (memory issues), sorry" ); - return NULL; - } - - x->x_inwriteposition = 0; - x->x_outreadposition = 0; - x->x_outwriteposition = 0; - x->x_outunread = 0; - - ztout.tv_sec = 0; - ztout.tv_usec = 0; - - x->x_graphic = (int)fdographics; - - post( "mp3streamin~ : starting service on port %d", (int)fportno ); - mp3streamin_startservice(x, (int)fportno); - - // init lame decoder - mp3streamin_tilde_mpglib_init(x); - - return (x); -} - - -void mp3streamin_tilde_setup(void) -{ - post( mp3streamin_version ); - mp3streamin_class = class_new(gensym("mp3streamin~"), - (t_newmethod) mp3streamin_new, (t_method) mp3streamin_free, - sizeof(t_mp3streamin), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, A_NULL); - - class_addmethod(mp3streamin_class, nullfn, gensym("signal"), 0); - class_addmethod(mp3streamin_class, (t_method) mp3streamin_dsp, gensym("dsp"), A_CANT, 0); -} diff --git a/externals/unauthorized/mp3live~/mp3streamin~.libs b/externals/unauthorized/mp3live~/mp3streamin~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mp3streamin~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3live~/mp3streamout~.libs b/externals/unauthorized/mp3live~/mp3streamout~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mp3streamout~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3live~/mpg123.h b/externals/unauthorized/mp3live~/mpg123.h deleted file mode 100644 index 1c530d384d4ec30b38f2648b08e91ea76b618b22..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mpg123.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef MPG123_H_INCLUDED -#define MPG123_H_INCLUDED - -#include - -#define STDC_HEADERS - -#ifdef STDC_HEADERS -# include -#else -# ifndef HAVE_STRCHR -# define strchr index -# define strrchr rindex -# endif -char *strchr (), *strrchr (); -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy ((s), (d), (n)) -# define memmove(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif - -#include - - -#if defined(__riscos__) && defined(FPA10) -#include "ymath.h" -#else -#include -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -#ifdef REAL_IS_FLOAT -# define real float -#elif defined(REAL_IS_LONG_DOUBLE) -# define real long double -#else -# define real double -#endif - -#define FALSE 0 -#define TRUE 1 - -#define SBLIMIT 32 -#define SSLIMIT 18 - -#define MPG_MD_STEREO 0 -#define MPG_MD_JOINT_STEREO 1 -#define MPG_MD_DUAL_CHANNEL 2 -#define MPG_MD_MONO 3 - -#define MAXFRAMESIZE 1792 - -/* AF: ADDED FOR LAYER1/LAYER2 */ -#define SCALE_BLOCK 12 - - -/* Pre Shift fo 16 to 8 bit converter table */ -#define AUSHIFT (3) - -struct frame { - int stereo; - int jsbound; - int single; - int lsf; - int mpeg25; - int header_change; - int lay; - int error_protection; - int bitrate_index; - int sampling_frequency; - int padding; - int extension; - int mode; - int mode_ext; - int copyright; - int original; - int emphasis; - int framesize; /* computed framesize */ - - /* AF: ADDED FOR LAYER1/LAYER2 */ -#if defined(USE_LAYER_2) || defined(USE_LAYER_1) - int II_sblimit; - struct al_table2 *alloc; - int down_sample_sblimit; - int down_sample; - -#endif - -}; - -struct gr_info_s { - int scfsi; - unsigned part2_3_length; - unsigned big_values; - unsigned scalefac_compress; - unsigned block_type; - unsigned mixed_block_flag; - unsigned table_select[3]; - unsigned subblock_gain[3]; - unsigned maxband[3]; - unsigned maxbandl; - unsigned maxb; - unsigned region1start; - unsigned region2start; - unsigned preflag; - unsigned scalefac_scale; - unsigned count1table_select; - real *full_gain[3]; - real *pow2gain; -}; - -struct III_sideinfo -{ - unsigned main_data_begin; - unsigned private_bits; - struct { - struct gr_info_s gr[2]; - } ch[2]; -}; - - -#endif diff --git a/externals/unauthorized/mp3live~/mpglib.h b/externals/unauthorized/mp3live~/mpglib.h deleted file mode 100644 index 1f4ef9aa829a1dd76e0fdf7dec0f953be0136114..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/mpglib.h +++ /dev/null @@ -1,65 +0,0 @@ -// #include "lame-analysis.h" - -#define NOANALYSIS - -#ifndef NOANALYSIS -extern plotting_data *mpg123_pinfo; -#endif - -struct buf { - unsigned char *pnt; - long size; - long pos; - struct buf *next; - struct buf *prev; -}; - -struct framebuf { - struct buf *buf; - long pos; - struct frame *next; - struct frame *prev; -}; - -typedef struct mpstr_tag { - struct buf *head,*tail; - int vbr_header; /* 1 if valid Xing vbr header detected */ - int num_frames; /* set if vbr header present */ - int enc_delay; /* set if vbr header present */ - int enc_padding; /* set if vbr header present */ - int header_parsed; - int side_parsed; - int data_parsed; - int free_format; /* 1 = free format frame */ - int old_free_format; /* 1 = last frame was free format */ - int bsize; - int framesize; - int ssize; - int dsize; - int fsizeold; - int fsizeold_nopadding; - struct frame fr; - unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ - real hybrid_block[2][2][SBLIMIT*SSLIMIT]; - int hybrid_blc[2]; - unsigned long header; - int bsnum; - real synth_buffs[2][2][0x110]; - int synth_bo; - int sync_bitstream; - -} MPSTR, *PMPSTR; - - -#if ( defined(_MSC_VER) || defined(__BORLANDC__) ) - typedef int BOOL; /* windef.h contains the same definition */ -#else - #define BOOL int -#endif - -#define MP3_ERR -1 -#define MP3_OK 0 -#define MP3_NEED_MORE 1 - - - diff --git a/externals/unauthorized/mp3live~/test-streaming-mp3.pd b/externals/unauthorized/mp3live~/test-streaming-mp3.pd deleted file mode 100644 index e9e6b2e2cb16807d0f21d6b41d794ea77e6fbd2b..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3live~/test-streaming-mp3.pd +++ /dev/null @@ -1,96 +0,0 @@ -#N canvas 15 9 986 678 10; -#X msg 63 58 bang; -#X obj 63 78 openpanel; -#X obj 63 100 t s b; -#X obj 63 137 pack s s; -#X obj 99 100 float \$0; -#X text 51 39 Step 1 : Load a sound file; -#X obj 117 137 makefilename %d-sample; -#X msg 443 280 \; pd dsp 1; -#X msg 509 280 \; pd dsp 0; -#X obj 454 254 loadbang; -#X obj 62 217 mp3streamout~; -#X floatatom 63 240 5 0 0; -#X obj 62 181 readsf~; -#X msg 62 158 open \$1 \$2; -#X msg 33 148 1; -#X msg 265 185 disconnect; -#X obj 63 117 route float; -#X msg 569 47 bang; -#X obj 569 67 openpanel; -#X obj 569 89 t s b; -#X obj 569 126 pack s s; -#X obj 605 89 float \$0; -#X text 557 28 Step 1 : Load a sound file; -#X obj 623 126 makefilename %d-sample; -#X obj 568 206 mp3streamout~; -#X floatatom 569 229 5 0 0; -#X obj 568 170 readsf~; -#X msg 568 147 open \$1 \$2; -#X msg 539 137 1; -#X msg 784 177 disconnect; -#X obj 569 106 route float; -#X obj 364 462 dac~; -#X obj 361 438 *~; -#X floatatom 416 465 5 0 0; -#X symbolatom 459 437 15 0 0; -#X obj 407 440 / 100; -#X obj 122 470 dac~; -#X obj 119 446 *~; -#X floatatom 174 473 5 0 0; -#X symbolatom 217 445 10 0 0; -#X obj 165 448 / 100; -#X obj 96 419 mp3streamin~ 5001 1; -#X obj 345 410 mp3streamin~ 5000 1; -#X msg 777 149 connect yves 5001; -#X msg 246 228 mpeg 32 2 5; -#X msg 246 228 mpeg 32 2 5; -#X msg 246 264 mpeg 224 2 5; -#X msg 258 157 connect localhost 5000; -#X msg 263 125 connect dregs 5000; -#X connect 0 0 1 0; -#X connect 1 0 2 0; -#X connect 2 0 3 0; -#X connect 2 1 4 0; -#X connect 3 0 13 0; -#X connect 4 0 16 0; -#X connect 6 0 3 1; -#X connect 9 0 7 0; -#X connect 10 0 11 0; -#X connect 12 0 10 0; -#X connect 12 0 10 1; -#X connect 13 0 12 0; -#X connect 14 0 12 0; -#X connect 15 0 10 0; -#X connect 16 0 6 0; -#X connect 17 0 18 0; -#X connect 18 0 19 0; -#X connect 19 0 20 0; -#X connect 19 1 21 0; -#X connect 20 0 27 0; -#X connect 21 0 30 0; -#X connect 23 0 20 1; -#X connect 24 0 25 0; -#X connect 26 0 24 0; -#X connect 26 0 24 1; -#X connect 27 0 26 0; -#X connect 28 0 26 0; -#X connect 29 0 24 0; -#X connect 30 0 23 0; -#X connect 32 0 31 0; -#X connect 32 0 31 1; -#X connect 33 0 35 0; -#X connect 35 0 32 1; -#X connect 37 0 36 0; -#X connect 37 0 36 1; -#X connect 38 0 40 0; -#X connect 40 0 37 1; -#X connect 41 0 37 0; -#X connect 41 2 39 0; -#X connect 42 0 32 0; -#X connect 42 2 34 0; -#X connect 43 0 24 0; -#X connect 44 0 10 0; -#X connect 46 0 10 0; -#X connect 47 0 10 0; -#X connect 48 0 10 0; diff --git a/externals/unauthorized/mp3streamin~-help.pd b/externals/unauthorized/mp3streamin~-help.pd new file mode 100644 index 0000000000000000000000000000000000000000..ac68464c919518bfc2a0bd270de042327903a86f --- /dev/null +++ b/externals/unauthorized/mp3streamin~-help.pd @@ -0,0 +1,118 @@ +#N canvas 11 -3 941 684 10; +#X msg 35 594 \; pd dsp 1; +#X text 432 123 <-- settings for mp3 stream; +#X text 492 177 1 = joint stereo (default); +#X text 456 165 mode: 0 = stereo; +#X text 492 189 2 = dual channel; +#X msg 101 594 \; pd dsp 0; +#X obj 551 317 dac~; +#X msg 368 80 disconnect; +#X floatatom 221 227 5 0 0; +#X obj 221 199 mp3streamout~; +#X msg 367 54 connect localhost 5000; +#X msg 767 69 bang; +#X obj 767 89 openpanel; +#X obj 766 186 soundfiler; +#X floatatom 767 210 10 0 0; +#X obj 767 111 t s b; +#X obj 767 148 pack s s; +#X msg 766 169 read -resize \$1 \$2; +#X obj 803 111 float \$0; +#X text 755 50 Step 1 : Load a sound file; +#X obj 767 128 route float; +#X obj 123 149 tabplay~ \$0-sample; +#X msg 123 120 bang; +#X obj 114 627 table \$0-sample; +#X obj 821 148 makefilename %d-sample; +#X text 371 34 Step 2 : connect the streamer; +#X text 8 100 Step 3 : emit a sound through the streamer; +#X obj 234 276 env~; +#X obj 67 310 timer; +#X obj 207 276 > 0; +#X obj 159 276 route 1; +#X obj 122 276 t b f; +#X floatatom 121 340 5 0 0; +#X obj 80 276 spigot; +#X msg 102 256 0; +#X msg 130 256 1; +#X text 453 135 (bitrate \, mode \, quality); +#X text 453 227 Note : resampling is not supported for now; +#X text 454 238 Note : see the README for allowed bitrate; +#X text 30 9 mp3live~ : mp3streamout~ / mp3streamin~; +#X text 30 20 peer-to-peer mp3 streaming \, written by ydegoyon@free.fr +; +#X msg 342 147 mpeg 32 2 9; +#X text 492 202 3 = mono ( not supported ); +#X text 455 153 bitrate: bitrate of stream \, def. 128kbit/s; +#X text 452 215 quality: 5 = high \, 9 = low; +#X text 85 360 streamer latency (ms); +#X obj 35 573 loadbang; +#X msg 343 123 mpeg 128 0 5; +#X obj 536 270 mp3streamin~ 5000 1; +#X symbolatom 639 300 10 0 0; +#X text 622 316 Incomer's address; +#X floatatom 229 496 5 0 0; +#X floatatom 327 498 5 0 0; +#X text 282 366 Step 3 bis : emit a file through the streamer; +#X msg 298 386 bang; +#X msg 299 423 open \$1; +#X msg 393 410 disconnect; +#X msg 393 391 connect localhost 5000; +#X msg 393 429 start; +#X msg 438 430 stop; +#X obj 298 406 openpanel; +#X text 292 522 Number of frames emitted; +#X text 160 515 Connection state; +#X text 31 36 Warning : mp3fileout~ will not read ANY mp3 file \,; +#X text 30 46 but \, at least \, those produced with mp3write~.; +#X msg 474 430 resume; +#X msg 524 429 seek 10000; +#X text 391 503 A bang is emitted at the end of the file; +#X obj 301 454 mp3fileout~; +#X obj 389 485 print thisistheend; +#X connect 7 0 9 0; +#X connect 9 0 8 0; +#X connect 10 0 9 0; +#X connect 11 0 12 0; +#X connect 12 0 15 0; +#X connect 13 0 14 0; +#X connect 15 0 16 0; +#X connect 15 1 18 0; +#X connect 16 0 17 0; +#X connect 17 0 13 0; +#X connect 18 0 20 0; +#X connect 20 0 24 0; +#X connect 21 0 9 0; +#X connect 21 0 9 1; +#X connect 22 0 21 0; +#X connect 22 0 28 0; +#X connect 22 0 35 0; +#X connect 24 0 16 1; +#X connect 27 0 29 0; +#X connect 28 0 32 0; +#X connect 29 0 30 0; +#X connect 30 0 31 0; +#X connect 31 0 33 0; +#X connect 32 0 34 0; +#X connect 33 0 28 1; +#X connect 34 0 33 1; +#X connect 35 0 33 1; +#X connect 41 0 9 0; +#X connect 46 0 0 0; +#X connect 47 0 9 0; +#X connect 48 0 6 0; +#X connect 48 0 27 0; +#X connect 48 1 6 1; +#X connect 48 2 49 0; +#X connect 54 0 60 0; +#X connect 55 0 68 0; +#X connect 56 0 68 0; +#X connect 57 0 68 0; +#X connect 58 0 68 0; +#X connect 59 0 68 0; +#X connect 60 0 55 0; +#X connect 65 0 68 0; +#X connect 66 0 68 0; +#X connect 68 0 51 0; +#X connect 68 1 52 0; +#X connect 68 2 69 0; diff --git a/externals/unauthorized/mp3streamin~.c b/externals/unauthorized/mp3streamin~.c new file mode 100644 index 0000000000000000000000000000000000000000..60bb3929c53570b1214f492aecb92eaa87c9cb5d --- /dev/null +++ b/externals/unauthorized/mp3streamin~.c @@ -0,0 +1,679 @@ +/* ------------------------ mp3streamin~ -------------------------------------- */ +/* */ +/* Tilde object to receive an mp3-stream sent by a peer using mp3streamout~. */ +/* Written by Yves Degoyon (ydegoyon@free.fr). */ +/* Tarballs and updates @ http://ydegoyon.free.fr */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* Uses the LAME MPEG 1 Layer 3 encoding library (lame_enc.dll) which can */ +/* be found at http://www.cdex.n3.net. */ +/* */ +/* "Repackage sex, your interests." */ +/* "Somehow, maintain the interest." */ +/* Gang Of Four -- Natural's Not In It */ +/* ---------------------------------------------------------------------------- */ + + +#include +#include +#include + +#if PD_MINOR_VERSION >=37 +#include "s_stuff.h" +#endif + +#include +#include +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define SOCKET_ERROR -1 +#endif /* _WIN32 */ + +#if defined(__APPLE__) || defined(_WIN32) +#define MSG_NOSIGNAL 0 +#define SOL_TCP IPPROTO_TCP +#endif + +#include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ +#include "mpglib.h" /* mpglib decoding library from lame 3.92 */ +#include "interface.h" /* mpglib decoding library from lame 3.92 */ + +#define MIN_AUDIO_INPUT 8064 // we must a least have 8 chunks to play a correct sound +#define INPUT_BUFFER_SIZE MIN_AUDIO_INPUT +#define OUTPUT_BUFFER_SIZE 131072 /* 128k*/ +#define LAME_AUDIO_CHUNK_SIZE 1152 +#define BARHEIGHT 10 +#define MAX_DECODERS 10 + +/* useful debugging functions from mpglib */ +extern int decode_header( struct frame* fr, unsigned long newhead ); +extern void print_header_compact( struct frame* fr ); +extern int head_check( unsigned long head, int check_layer ); + +/* time-out used for select() call */ +static struct timeval ztout; + +static char *mp3streamin_version = "mp3streamin~: mp3 peer-to-peer streamer version 0.3, written by ydegoyon@free.fr"; + +extern void sys_sockerror(char *s); + +void mp3streamin_closesocket(int fd) +{ +#ifndef _MSC_VER + if ( close(fd) < 0 ) + { + perror( "close" ); + } + else + { + post( "mp3streamin~ : closed socket : %d", fd ); + } +#endif +#ifdef _WIN32 + closesocket(fd); +#endif + sys_rmpollfn(fd); +} + +int setsocketoptions(int sockfd) +{ + int sockopt = 1; + if (setsockopt(sockfd, SOL_TCP, TCP_NODELAY, (const char*) &sockopt, sizeof(int)) < 0) + { + post("mp3streamin~ : setsockopt TCP_NODELAY failed"); + perror( "setsockopt" ); + return -1; + } + else + { + post("mp3streamin~ : TCP_NODELAY set"); + } + +#ifndef _MSC_VER + sockopt = 1; + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(int)) < 0) + { + post("mp3streamin~ : setsockopt SO_REUSEADDR failed"); + perror( "setsockopt" ); + return -1; + } + else + { + post("mp3streamin~ : setsockopt SO_REUSEADDR done."); + } +#endif + return 0; +} + + +/* ------------------------ mp3streamin~ ----------------------------- */ + +static t_class *mp3streamin_class; + +typedef struct _mp3streamin +{ + t_object x_obj; + t_int x_instance; + t_int x_socket; + t_int x_shutdown; + t_outlet *x_connectionip; + t_int x_serversocket; + t_int x_inpackets; /* number of packets received */ + t_int x_dpacket; /* displayed packet in status bar */ + t_int x_packetsize; /* size of the packets */ + t_int x_pblocks; /* processed blocks */ + t_int x_graphic; /* indicates if we show a graphic bar */ + + void *x_inbuffer; /* accumulation buffer for incoming mp3 frames */ + t_int x_inwriteposition; + t_int x_inbuffersize; + + t_float *x_outbuffer; /* buffer to store audio decoded data */ + t_int x_outwriteposition; + t_int x_outreadposition; + t_int x_outunread; + t_int x_outbuffersize; + + t_canvas *x_canvas; + + t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */ + t_int x_newstream; /* at first, the stream must provide enough data to start */ + t_int x_bitrateindex; /* remember the bitrate index */ + +} t_mp3streamin; + +/* too bad, this needs to be static, + handling an array to enable several decoders in pd */ +static MPSTR mp[MAX_DECODERS]; /* decoder buffer */ +int nbinstances = 0; + +void mp3streamin_tilde_mpglib_init(t_mp3streamin *x) +{ + int ret; + + InitMP3(&mp[x->x_instance]); +} + +static int mp3streamin_decode_input(t_mp3streamin *x) +{ + int i; + int alength = 0; + struct frame hframe; + unsigned int a,b,c,d; + unsigned long cheader; + static char out[8192]; + signed short int *p = (signed short int *) out; + int pbytes; + int ret; + + if ( !x->x_shutdown ) + { + /* decode first 4 bytes as the header */ + a = *((unsigned char*)x->x_inbuffer); + b = *((unsigned char*)x->x_inbuffer+1); + c = *((unsigned char*)x->x_inbuffer+2); + d = *((unsigned char*)x->x_inbuffer+3); + + cheader = 0; + cheader = a; + cheader <<= 8; + cheader |= b; + cheader <<= 8; + cheader |= c; + cheader <<= 8; + cheader |= d; + if ( head_check( cheader, 0 ) ) + { + // post( "mp3streamin~ : valid header ( packet=%d)", x->x_inpackets ); + decode_header( &hframe, cheader ); + // print_header_compact( &hframe ); + // when the bitrate change, reinit decoder + if ( x->x_bitrateindex != hframe.bitrate_index ) + { + ExitMP3(&mp[x->x_instance]); + InitMP3(&mp[x->x_instance]); + x->x_bitrateindex = hframe.bitrate_index; + } + } + else + { + post( "mp3streamin~ : error : mp3 packet received without header" ); + // ignore data + x->x_inwriteposition = 0; + x->x_inpackets--; + return( -1 ); + } + + // post( "mp3streamin~ : decoding %d bytes framesize=%d", x->x_inwriteposition, hframe.framesize ); + ret = + decodeMP3(&mp[x->x_instance], (unsigned char*)x->x_inbuffer, + x->x_inwriteposition, (char *) p, sizeof(out), &pbytes); + + switch (ret) + { + case MP3_OK: + switch (mp[x->x_instance].fr.stereo) + { + case 1: + case 2: + alength = ((mp[x->x_instance].fr.stereo==1)?pbytes >> 1 : pbytes >> 2); + // post( "mp3streamin~ : processed %d samples", alength ); + // update outbuffer contents + for ( i=0; ix_outunread >= x->x_outbuffersize-2 ) + { + post( "mp3streamin~ : too much input ... ignored" ); + continue; + } + *(x->x_outbuffer+x->x_outwriteposition) = ((t_float)(*p++))/32767.0; + x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; + *(x->x_outbuffer+x->x_outwriteposition) = + ((mp[x->x_instance].fr.stereo==2)?((t_float)(*p++))/32767.0 : 0.0); + x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; + x->x_outunread+=2; + + if ( x->x_outunread > MIN_AUDIO_INPUT && !x->x_stream ) + { + post( "mp3streamin~ : stream connected." ); + x->x_stream = 1; + } + } + + break; + default: + alength = -1; + break; + } + break; + + case MP3_NEED_MORE: + post( "mp3streamin~ : retry lame decoding (more data needed)." ); + alength = 0; + break; + + case MP3_ERR: + post( "mp3streamin~ : lame decoding failed." ); + alength = -1; + break; + + } + + x->x_inwriteposition = 0; + } + else + { + if ( x->x_outunread == 0 ) + { + post( "mp3streamin~ : connection closed" ); + mp3streamin_closesocket(x->x_socket); + x->x_stream = 0; + x->x_newstream = 0; + x->x_inpackets = 0; + x->x_inwriteposition = 0; + x->x_bitrateindex = -1; + x->x_socket=-1; + outlet_symbol( x->x_connectionip, gensym("") ); + } + } + + if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) + { + /* update graphical read status */ + if ( x->x_inpackets != x->x_dpacket ) + { + char color[32]; + int minpackets = ( MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE )-2; // audio loop has eaten some already + + + sys_vgui(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x ); + sys_vgui(".x%lx.c delete line %xTHRESHOLD\n", x->x_canvas, x ); + if ( x->x_outunread > 0 ) + { + t_int width; + + if ( x->x_inpackets < (MIN_AUDIO_INPUT/LAME_AUDIO_CHUNK_SIZE)/2 ) + { + strcpy( color, "red" ); + } + else + { + strcpy( color, "lightgreen" ); + } + width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n", + x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, + x->x_obj.te_xpix+(x->x_inpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, + x->x_obj.te_ypix - 1, color, x ); + sys_vgui(".x%lx.c create line %d %d %d %d -fill red -tags %xTHRESHOLD\n", + x->x_canvas, x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, + x->x_obj.te_ypix-BARHEIGHT-1, + x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE, + x->x_obj.te_ypix-1, x ); + x->x_dpacket = x->x_inpackets; + } + else + { + if ( x->x_shutdown ) + { + x->x_shutdown=0; + sys_vgui(".x%lx.c delete rectangle %xPBAR\n", x->x_canvas, x ); + sys_vgui(".x%lx.c delete line %xTHRESHOLD\n", x->x_canvas, x ); + } + } + } + } + return alength; +} + +static void mp3streamin_recv(t_mp3streamin *x) +{ + int ret; + + if ( ( ret = recv(x->x_socket, (void*) (x->x_inbuffer + x->x_inwriteposition), + (size_t)((x->x_inbuffersize-x->x_inwriteposition)), + MSG_NOSIGNAL) ) < 0 ) + { + post( "mp3_streamin~ : receive error" ); + perror( "recv" ); + return; + } + else + { + // post( "streamin~ : received %d bytes at %d on %d ( up to %d)", + // ret, x->x_inwriteposition, x->x_socket, + // x->x_inbuffersize-x->x_inwriteposition*sizeof( unsigned long) ); + + if ( ret == 0 ) + { + /* initiate the shutdown phase */ + x->x_shutdown=1; + } + else + { + // check we don't overflow input buffer + if ( (x->x_inpackets+1)*x->x_packetsize > x->x_inbuffersize ) + { + post( "mp3streamin~ : too much input...resetting" ); + x->x_inpackets=0; + x->x_inwriteposition=0; + return; + } + x->x_inpackets++; + x->x_packetsize=ret; + if ( x->x_inpackets % 100 == 0 ) + { + // post( "mp3streamin~ : received %d packets", x->x_inpackets ); + } + x->x_inwriteposition += ret; + } + + mp3streamin_decode_input(x); + } +} + +static void mp3streamin_acceptconnection(t_mp3streamin *x) +{ + struct sockaddr_in incomer_address; + int sockaddrl = (int) sizeof( struct sockaddr ); + + int fd = accept(x->x_serversocket, (struct sockaddr*)&incomer_address, &sockaddrl ); + + if (fd < 0) + { + post("mp3streamin~: accept failed"); + return; + } + + if (x->x_socket > 0) + { + sys_addpollfn(fd, (t_fdpollfn)mp3streamin_recv, x); + if ( x->x_outunread != 0 ) + { + post("mp3streamin~: still have some data to decode, retry later you %s.", + inet_ntoa( incomer_address.sin_addr )); + mp3streamin_closesocket( fd ); + return; + } + post("mp3streamin~: the source has changed to %s.", + inet_ntoa( incomer_address.sin_addr )); + mp3streamin_closesocket(x->x_socket); + } + + x->x_socket = fd; + sys_addpollfn(x->x_socket, (t_fdpollfn)mp3streamin_recv, x); + outlet_symbol( x->x_connectionip, gensym( inet_ntoa( incomer_address.sin_addr) ) ); + + if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) + { + t_int width; + + width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) ); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n", + x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1, + x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x ); + } + x->x_stream = 0; + x->x_newstream = 1; + +} + + +static int mp3streamin_startservice(t_mp3streamin* x, int portno) +{ + struct sockaddr_in server; + int sockfd; + + /* create a socket */ + sockfd = socket(AF_INET, SOCK_STREAM, 0); + + if (sockfd < 0) + { + sys_sockerror("socket"); + return (0); + } + server.sin_family = AF_INET; + server.sin_addr.s_addr = INADDR_ANY; + + /* assign server port number */ + server.sin_port = htons((u_short)portno); + post("listening to port number %d", portno); + + setsocketoptions(sockfd); + + /* name the socket */ + if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) + { + sys_sockerror("bind"); + mp3streamin_closesocket(sockfd); + return (0); + } + + if (listen(sockfd, 5) < 0) + { + sys_sockerror("listen"); + mp3streamin_closesocket(sockfd); + } + else + { + x->x_serversocket = sockfd; + sys_addpollfn(x->x_serversocket, (t_fdpollfn)mp3streamin_acceptconnection, x); + } + + return 1; +} + +static void mp3streamin_free(t_mp3streamin *x) +{ + post( "mp3streamin~ : free %x", x ); + if (x->x_serversocket > 0) + { + post( "mp3streamin~ : closing server socket" ); + mp3streamin_closesocket(x->x_serversocket); + x->x_serversocket = -1; + } + if (x->x_socket > 0) + { + post( "mp3streamin~ : closing socket" ); + mp3streamin_closesocket(x->x_socket); + x->x_socket = -1; + } + if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize ); + if ( x->x_outbuffer ) freebytes( x->x_outbuffer, x->x_outbuffersize*sizeof(t_float) ); + if ( x->x_instance == nbinstances-1 ) + { + nbinstances--; + } +} + +static t_int *mp3streamin_perform(t_int *w) +{ + t_mp3streamin *x = (t_mp3streamin*) (w[1]); + t_float *out1 = (t_float *)(w[2]); + t_float *out2 = (t_float *)(w[3]); + int n = (int)(w[4]); + int bsize = n; + int ret; + int i = 0; + + while( n-- ) + { + if ( ( ( x->x_outunread > MIN_AUDIO_INPUT ) && x->x_newstream ) || // wait the buffer to load + ( ( x->x_shutdown ) && ( x->x_outunread >= 2 ) ) || // clean disconnection + ( x->x_stream ) // check that the stream provides enough data + ) + { + if ( x->x_newstream && !x->x_shutdown ) + { + x->x_newstream = 0; + x->x_stream = 1; + } + *out1++=*(x->x_outbuffer+x->x_outreadposition); + x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; + *out2++=*(x->x_outbuffer+x->x_outreadposition); + x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize; + x->x_outunread-=2; + if ( n == 1 ) x->x_pblocks++; + } + else + { + *out1++=0.0; + *out2++=0.0; + } + } + + if ( ( x->x_outunread <= MIN_AUDIO_INPUT/10 ) && ( x->x_stream ) ) + { + post( "mp3streamin~ : stream lost (too little input)" ); + x->x_stream = 0; + x->x_newstream = 1; // waiting for a new stream + } + + if ( x->x_pblocks == LAME_AUDIO_CHUNK_SIZE/bsize ) + { + x->x_inpackets--; + x->x_pblocks = 0; + } + +#ifdef DO_MY_OWN_SELECT + // check new incoming data + if ( x->x_socket > 0 ) + { + fd_set readset; + fd_set exceptset; + + FD_ZERO(&readset); + FD_ZERO(&exceptset); + FD_SET(x->x_socket, &readset ); + FD_SET(x->x_socket, &exceptset ); + + if ( select( maxfd+1, &readset, NULL, &exceptset, &ztout ) >0 ) + { + if ( FD_ISSET( x->x_socket, &readset) || FD_ISSET( x->x_socket, &exceptset ) ) + { + /* receive data or error and decode it */ + mp3streamin_recv(x); + } + } + } +#endif + return (w+5); +} + +static void mp3streamin_dsp(t_mp3streamin *x, t_signal **sp) +{ + dsp_add(mp3streamin_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + + +static void *mp3streamin_new(t_floatarg fportno, t_floatarg fdographics) +{ + t_mp3streamin *x; + int i; + + if ( fportno < 0 || fportno > 65535 ) + { + post( "mp3streamin~ : error : wrong portnumber : %d", (int)fportno ); + return NULL; + } + if ( ((int)fdographics != 0) && ((int)fdographics != 1.) ) + { + post( "mp3streamin~ : error : constructor : mp3streamin~ [graphic flag = 0 | 1 ] ( got = %f)", fdographics ); + return NULL; + } + + x = (t_mp3streamin *)pd_new(mp3streamin_class); + post( "mp3streamin~ : new %x (instance = %d) %d", x, nbinstances, sizeof( MPSTR ) ); + outlet_new(&x->x_obj, &s_signal); + outlet_new(&x->x_obj, &s_signal); + x->x_connectionip = outlet_new(&x->x_obj, &s_symbol); + + x->x_serversocket = -1; + x->x_socket = -1; + x->x_shutdown = 0; + x->x_inpackets = 0; + x->x_dpacket = -1; + + x->x_canvas = canvas_getcurrent(); + + x->x_inbuffersize = INPUT_BUFFER_SIZE; + x->x_outbuffersize = OUTPUT_BUFFER_SIZE; + x->x_inbuffer = (char*) getbytes( x->x_inbuffersize ); + memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE ); + x->x_outbuffer = (t_float*) getbytes( x->x_outbuffersize*sizeof(t_float) ); + memset( x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE ); + + if ( !x->x_inbuffer || !x->x_outbuffer ) + { + post( "mp3streamin~ : could not allocate buffers." ); + return NULL; + } + + if ( nbinstances < MAX_DECODERS ) + { + x->x_instance = nbinstances++; + } + else + { + post( "mp3streamin~ : cannot create more decoders (memory issues), sorry" ); + return NULL; + } + + x->x_inwriteposition = 0; + x->x_outreadposition = 0; + x->x_outwriteposition = 0; + x->x_outunread = 0; + + ztout.tv_sec = 0; + ztout.tv_usec = 0; + + x->x_graphic = (int)fdographics; + + post( "mp3streamin~ : starting service on port %d", (int)fportno ); + mp3streamin_startservice(x, (int)fportno); + + // init lame decoder + mp3streamin_tilde_mpglib_init(x); + + return (x); +} + + +void mp3streamin_tilde_setup(void) +{ + logpost(NULL, 4, "%s", mp3streamin_version ); + mp3streamin_class = class_new(gensym("mp3streamin~"), + (t_newmethod) mp3streamin_new, (t_method) mp3streamin_free, + sizeof(t_mp3streamin), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, A_NULL); + + class_addmethod(mp3streamin_class, nullfn, gensym("signal"), 0); + class_addmethod(mp3streamin_class, (t_method) mp3streamin_dsp, gensym("dsp"), A_CANT, 0); +} diff --git a/externals/unauthorized/mp3streamout~-help.pd b/externals/unauthorized/mp3streamout~-help.pd new file mode 100644 index 0000000000000000000000000000000000000000..ac68464c919518bfc2a0bd270de042327903a86f --- /dev/null +++ b/externals/unauthorized/mp3streamout~-help.pd @@ -0,0 +1,118 @@ +#N canvas 11 -3 941 684 10; +#X msg 35 594 \; pd dsp 1; +#X text 432 123 <-- settings for mp3 stream; +#X text 492 177 1 = joint stereo (default); +#X text 456 165 mode: 0 = stereo; +#X text 492 189 2 = dual channel; +#X msg 101 594 \; pd dsp 0; +#X obj 551 317 dac~; +#X msg 368 80 disconnect; +#X floatatom 221 227 5 0 0; +#X obj 221 199 mp3streamout~; +#X msg 367 54 connect localhost 5000; +#X msg 767 69 bang; +#X obj 767 89 openpanel; +#X obj 766 186 soundfiler; +#X floatatom 767 210 10 0 0; +#X obj 767 111 t s b; +#X obj 767 148 pack s s; +#X msg 766 169 read -resize \$1 \$2; +#X obj 803 111 float \$0; +#X text 755 50 Step 1 : Load a sound file; +#X obj 767 128 route float; +#X obj 123 149 tabplay~ \$0-sample; +#X msg 123 120 bang; +#X obj 114 627 table \$0-sample; +#X obj 821 148 makefilename %d-sample; +#X text 371 34 Step 2 : connect the streamer; +#X text 8 100 Step 3 : emit a sound through the streamer; +#X obj 234 276 env~; +#X obj 67 310 timer; +#X obj 207 276 > 0; +#X obj 159 276 route 1; +#X obj 122 276 t b f; +#X floatatom 121 340 5 0 0; +#X obj 80 276 spigot; +#X msg 102 256 0; +#X msg 130 256 1; +#X text 453 135 (bitrate \, mode \, quality); +#X text 453 227 Note : resampling is not supported for now; +#X text 454 238 Note : see the README for allowed bitrate; +#X text 30 9 mp3live~ : mp3streamout~ / mp3streamin~; +#X text 30 20 peer-to-peer mp3 streaming \, written by ydegoyon@free.fr +; +#X msg 342 147 mpeg 32 2 9; +#X text 492 202 3 = mono ( not supported ); +#X text 455 153 bitrate: bitrate of stream \, def. 128kbit/s; +#X text 452 215 quality: 5 = high \, 9 = low; +#X text 85 360 streamer latency (ms); +#X obj 35 573 loadbang; +#X msg 343 123 mpeg 128 0 5; +#X obj 536 270 mp3streamin~ 5000 1; +#X symbolatom 639 300 10 0 0; +#X text 622 316 Incomer's address; +#X floatatom 229 496 5 0 0; +#X floatatom 327 498 5 0 0; +#X text 282 366 Step 3 bis : emit a file through the streamer; +#X msg 298 386 bang; +#X msg 299 423 open \$1; +#X msg 393 410 disconnect; +#X msg 393 391 connect localhost 5000; +#X msg 393 429 start; +#X msg 438 430 stop; +#X obj 298 406 openpanel; +#X text 292 522 Number of frames emitted; +#X text 160 515 Connection state; +#X text 31 36 Warning : mp3fileout~ will not read ANY mp3 file \,; +#X text 30 46 but \, at least \, those produced with mp3write~.; +#X msg 474 430 resume; +#X msg 524 429 seek 10000; +#X text 391 503 A bang is emitted at the end of the file; +#X obj 301 454 mp3fileout~; +#X obj 389 485 print thisistheend; +#X connect 7 0 9 0; +#X connect 9 0 8 0; +#X connect 10 0 9 0; +#X connect 11 0 12 0; +#X connect 12 0 15 0; +#X connect 13 0 14 0; +#X connect 15 0 16 0; +#X connect 15 1 18 0; +#X connect 16 0 17 0; +#X connect 17 0 13 0; +#X connect 18 0 20 0; +#X connect 20 0 24 0; +#X connect 21 0 9 0; +#X connect 21 0 9 1; +#X connect 22 0 21 0; +#X connect 22 0 28 0; +#X connect 22 0 35 0; +#X connect 24 0 16 1; +#X connect 27 0 29 0; +#X connect 28 0 32 0; +#X connect 29 0 30 0; +#X connect 30 0 31 0; +#X connect 31 0 33 0; +#X connect 32 0 34 0; +#X connect 33 0 28 1; +#X connect 34 0 33 1; +#X connect 35 0 33 1; +#X connect 41 0 9 0; +#X connect 46 0 0 0; +#X connect 47 0 9 0; +#X connect 48 0 6 0; +#X connect 48 0 27 0; +#X connect 48 1 6 1; +#X connect 48 2 49 0; +#X connect 54 0 60 0; +#X connect 55 0 68 0; +#X connect 56 0 68 0; +#X connect 57 0 68 0; +#X connect 58 0 68 0; +#X connect 59 0 68 0; +#X connect 60 0 55 0; +#X connect 65 0 68 0; +#X connect 66 0 68 0; +#X connect 68 0 51 0; +#X connect 68 1 52 0; +#X connect 68 2 69 0; diff --git a/externals/unauthorized/mp3live~/mp3streamout~.c b/externals/unauthorized/mp3streamout~.c similarity index 74% rename from externals/unauthorized/mp3live~/mp3streamout~.c rename to externals/unauthorized/mp3streamout~.c index a2b9475906debedb3cfa646b89fac75cebb072dc..3786c044d89cb8793027b99bbed7b5e757825d2f 100644 --- a/externals/unauthorized/mp3live~/mp3streamout~.c +++ b/externals/unauthorized/mp3streamout~.c @@ -70,8 +70,8 @@ extern void print_header_compact( struct frame* fr ); extern int head_check( unsigned long head, int check_layer ); #define MY_MP3_MALLOC_IN_SIZE 65536 - /* max size taken from lame readme */ -#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 +/* max size taken from lame readme */ +#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 #define MAXDATARATE 320 /* maximum mp3 data rate is 320kbit/s */ #define STRBUF_SIZE 32 @@ -84,12 +84,12 @@ typedef struct _mp3streamout { t_object x_obj; - /* LAME stuff */ + /* LAME stuff */ int x_lame; /* info about encoder status */ int x_lamechunk; /* chunk size for LAME encoder */ int x_mp3size; /* number of returned mp3 samples */ - /* buffer stuff */ + /* buffer stuff */ unsigned short x_inp; /* in position for buffer */ unsigned short x_outp; /* out position for buffer*/ short *x_mp3inbuf; /* data to be sent to LAME */ @@ -98,13 +98,13 @@ typedef struct _mp3streamout int x_bytesbuffered; /* number of unprocessed bytes in buffer */ int x_start; - /* mp3 format stuff */ + /* mp3 format stuff */ int x_samplerate; int x_bitrate; /* bitrate of mp3 stream */ int x_mp3mode; /* mode (mono, joint stereo, stereo, dual mono) */ int x_mp3quality; /* quality of encoding */ - /* connection data */ + /* connection data */ int x_fd; /* info about connection status */ int x_outpackets; /* mp3 packets sent */ @@ -114,28 +114,28 @@ typedef struct _mp3streamout } t_mp3streamout; - /* encode PCM data to mp3 stream */ +/* encode PCM data to mp3 stream */ static void mp3streamout_encode(t_mp3streamout *x) { unsigned short i, wp; int err = -1; int n = x->x_lamechunk; -#ifdef UNIX - if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) -#else +#ifdef _WIN32 if(x->x_lamechunk < sizeof(x->x_mp3inbuf)) +#else + if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) #endif { error("not enough memory!"); return; } - /* on start/reconnect set outpoint that it not interferes with inpoint */ + /* on start/reconnect set outpoint that it not interferes with inpoint */ if(x->x_start == -1) { post("mp3streamout~: initializing buffers"); - /* we try to keep 2.5 times the data the encoder needs in the buffer */ + /* we try to keep 2.5 times the data the encoder needs in the buffer */ if(x->x_inp > (2 * x->x_lamechunk)) { x->x_outp = (short) x->x_inp - (2.5 * x->x_lamechunk); @@ -150,10 +150,10 @@ static void mp3streamout_encode(t_mp3streamout *x) i = MY_MP3_MALLOC_IN_SIZE - x->x_outp; - /* read from buffer */ - if(x->x_lamechunk <= i) + /* read from buffer */ + if(x->x_lamechunk <= i) { - /* enough data until end of buffer */ + /* enough data until end of buffer */ for(n = 0; n < x->x_lamechunk; n++) /* fill encode buffer */ { x->x_mp3inbuf[n] = x->x_buffer[n + x->x_outp]; @@ -174,15 +174,15 @@ static void mp3streamout_encode(t_mp3streamout *x) x->x_outp = x->x_lamechunk - i; } - /* encode mp3 data */ + /* encode mp3 data */ - x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, - x->x_lamechunk/lame_get_num_channels(x->lgfp), + x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, + x->x_lamechunk/lame_get_num_channels(x->lgfp), x->x_mp3outbuf, MY_MP3_MALLOC_OUT_SIZE); x->x_mp3size+=lame_encode_flush( x->lgfp, x->x_mp3outbuf+x->x_mp3size, MY_MP3_MALLOC_OUT_SIZE-x->x_mp3size ); // post( "mp3streamout~ : encoding returned %d frames", x->x_mp3size ); - /* check result */ + /* check result */ if(x->x_mp3size<0) { lame_close( x->lgfp ); @@ -191,21 +191,21 @@ static void mp3streamout_encode(t_mp3streamout *x) } } - /* stream mp3 to the peer */ +/* stream mp3 to the peer */ static void mp3streamout_stream(t_mp3streamout *x) { - int count = -1, i; + int count = -1, i; struct frame hframe; /* header needs to be included in each packet */ for( i=0; ix_mp3size; i++ ) { - // track valid data - if ( head_check( *((unsigned long*)x->x_mp3outbuf+i), 3 ) ) - { - // post( "valid header emitted @ %d (byte %d)", i, i*sizeof(unsigned long) ); - } + // track valid data + if ( head_check( *((unsigned long*)x->x_mp3outbuf+i), 3 ) ) + { + // post( "valid header emitted @ %d (byte %d)", i, i*sizeof(unsigned long) ); + } } count = send(x->x_fd, x->x_mp3outbuf, x->x_mp3size, MSG_NOSIGNAL); @@ -214,30 +214,30 @@ static void mp3streamout_stream(t_mp3streamout *x) error("mp3streamout~: could not send encoded data to the peer (%d)", count); lame_close( x->lgfp ); x->x_lame = -1; -#ifndef UNIX +#ifdef _WIN32 closesocket(x->x_fd); #else close(x->x_fd); #endif x->x_fd = -1; outlet_float(x->x_obj.ob_outlet, 0); - } + } else { x->x_outpackets++; if ( x->x_outpackets%100 == 0 ) { - // post( "mp3streamout~ : emitted %d bytes (packets = %d)", count, x->x_outpackets ); + // post( "mp3streamout~ : emitted %d bytes (packets = %d)", count, x->x_outpackets ); } } if((count > 0)&&(count != x->x_mp3size)) { - error("mp3streamout~: %d bytes skipped", x->x_mp3size - count); + error("mp3streamout~: %d bytes skipped", x->x_mp3size - count); } } - - /* buffer data as channel interleaved PCM */ + +/* buffer data as channel interleaved PCM */ static t_int *mp3streamout_perform(t_int *w) { t_float *in1 = (t_float *)(w[1]); /* left audio inlet */ @@ -247,76 +247,94 @@ static t_int *mp3streamout_perform(t_int *w) unsigned short i,wp; float in; - /* copy the data into the buffer */ + /* copy the data into the buffer */ i = MY_MP3_MALLOC_IN_SIZE - x->x_inp; /* space left at the end of buffer */ - + n *= 2; /* two channels go into one buffer */ - if( n <= i ) + if( n <= i ) { /* the place between inp and MY_MP3_MALLOC_IN_SIZE */ /* is big enough to hold the data */ - for(wp = 0; wp < n; wp++) + for(wp = 0; wp < n; wp++) + { + if(wp%2) + { + in = *(in2++); /* right channel / inlet */ + } + else + { + in = *(in1++); /* left channel / inlet */ + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) { - if(wp%2) - { - in = *(in2++); /* right channel / inlet */ - } - else - { - in = *(in1++); /* left channel / inlet */ - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = -1.0; } - x->x_inp += n; /* n more samples written to buffer */ - } - else + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + x->x_inp += n; /* n more samples written to buffer */ + } + else { - /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ - /* big enough to hold the data */ - /* writing will take place in two turns, one from */ - /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ + /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ + /* big enough to hold the data */ + /* writing will take place in two turns, one from */ + /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ - for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + { + if(wp%2) { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = *(in2++); } - for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + else + { + in = *(in1++); + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + { + if(wp%2) { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp - i] = (short) (32767.0 * in); + in = *(in2++); } - x->x_inp = n - i; /* new writeposition in buffer */ + else + { + in = *(in1++); + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp - i] = (short) (32767.0 * in); + } + x->x_inp = n - i; /* new writeposition in buffer */ } if((x->x_fd >= 0)&&(x->x_lame >= 0)) - { - /* count buffered samples when things are running */ + { + /* count buffered samples when things are running */ x->x_bytesbuffered += n; - /* encode and send to the peer */ + /* encode and send to the peer */ if(x->x_bytesbuffered > x->x_lamechunk) { mp3streamout_encode(x); /* encode to mp3 */ @@ -336,13 +354,13 @@ static void mp3streamout_dsp(t_mp3streamout *x, t_signal **sp) dsp_add(mp3streamout_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); } - /* initialize the lame library */ +/* initialize the lame library */ static void mp3streamout_tilde_lame_init(t_mp3streamout *x) { int ret; x->lgfp = lame_init(); /* set default parameters for now */ -#ifndef UNIX +#ifdef _WIN32 /* load lame_enc.dll library */ HINSTANCE dll; dll=LoadLibrary("lame_enc.dll"); @@ -357,11 +375,13 @@ static void mp3streamout_tilde_lame_init(t_mp3streamout *x) } #endif { - const char *lameVersion = get_lame_version(); - post( "mp3streamout~ : using lame version : %s", lameVersion ); + const char *lameVersion = get_lame_version(); + char logbuf[MAXPDSTRING]; + sprintf(logbuf, "mp3streamout~ : using lame version : %s", lameVersion); + logpost(NULL, 4, "%s", logbuf ); } - /* setting lame parameters */ + /* setting lame parameters */ lame_set_num_channels( x->lgfp, 2); lame_set_in_samplerate( x->lgfp, sys_getsr() ); lame_set_out_samplerate( x->lgfp, x->x_samplerate ); @@ -372,34 +392,37 @@ static void mp3streamout_tilde_lame_init(t_mp3streamout *x) lame_set_original( x->lgfp, 1 ); lame_set_copyright( x->lgfp, 1 ); /* viva free music societies !!! */ lame_set_disable_reservoir( x->lgfp, 0 ); - lame_set_padding_type( x->lgfp, PAD_NO ); + //lame_set_padding_type( x->lgfp, PAD_NO ); /* deprecated in LAME */ ret = lame_init_params( x->lgfp ); - if ( ret<0 ) { - post( "mp3streamout~ : error : lame params initialization returned : %d", ret ); - } else { - x->x_lame=1; - /* magic formula copied from windows dll for MPEG-I */ - x->x_lamechunk = 2*1152; - - post( "mp3streamout~ : lame initialization done. (%d)", x->x_lame ); + if ( ret<0 ) + { + post( "mp3streamout~ : error : lame params initialization returned : %d", ret ); + } + else + { + x->x_lame=1; + /* magic formula copied from windows dll for MPEG-I */ + x->x_lamechunk = 2*1152; + + post( "mp3streamout~ : lame initialization done. (%d)", x->x_lame ); } lame_init_bitstream( x->lgfp ); } - /* connect to the peer */ +/* connect to the peer */ static void mp3streamout_connect(t_mp3streamout *x, t_symbol *hostname, t_floatarg fportno) { struct sockaddr_in csocket; struct hostent *hp; int portno = fportno; /* get port from message box */ - /* variables used for communication with the peer */ + /* variables used for communication with the peer */ const char *buf = 0; char resp[STRBUF_SIZE]; unsigned int len; int sockfd; -#ifndef UNIX +#ifdef _WIN32 unsigned int ret; #else int ret; @@ -418,13 +441,13 @@ static void mp3streamout_connect(t_mp3streamout *x, t_symbol *hostname, t_floata return; } - /* connect socket using hostname provided in command line */ + /* connect socket using hostname provided in command line */ csocket.sin_family = AF_INET; hp = gethostbyname(hostname->s_name); if (hp == 0) { post("mp3streamout~: bad host?"); -#ifndef UNIX +#ifdef _WIN32 closesocket(sockfd); #else close(sockfd); @@ -433,15 +456,15 @@ static void mp3streamout_connect(t_mp3streamout *x, t_symbol *hostname, t_floata } memcpy((char *)&csocket.sin_addr, (char *)hp->h_addr, hp->h_length); - /* assign client port number */ + /* assign client port number */ csocket.sin_port = htons((unsigned short)portno); - /* try to connect. */ + /* try to connect. */ post("mp3streamout~: connecting to port %d", portno); if (connect(sockfd, (struct sockaddr *) &csocket, sizeof (csocket)) < 0) { error("mp3streamout~: connection failed!\n"); -#ifndef UNIX +#ifdef _WIN32 closesocket(sockfd); #else close(sockfd); @@ -458,15 +481,16 @@ static void mp3streamout_connect(t_mp3streamout *x, t_symbol *hostname, t_floata } - /* close connection to the peer */ +/* close connection to the peer */ static void mp3streamout_disconnect(t_mp3streamout *x) { int err = -1; if(x->x_lame >= 0) { - /* ignore remaining bytes */ - if ( x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, 0) < 0 ) { + /* ignore remaining bytes */ + if ( x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, 0) < 0 ) + { post( "mp3streamout~ : warning : remaining encoded bytes" ); } lame_close( x->lgfp ); @@ -476,7 +500,7 @@ static void mp3streamout_disconnect(t_mp3streamout *x) if(x->x_fd >= 0) /* close socket */ { -#ifndef UNIX +#ifdef _WIN32 closesocket(x->x_fd); #else close(x->x_fd); @@ -487,66 +511,69 @@ static void mp3streamout_disconnect(t_mp3streamout *x) } } - /* settings for mp3 encoding */ +/* settings for mp3 encoding */ static void mp3streamout_mpeg(t_mp3streamout *x, t_floatarg fbitrate, - t_floatarg fmode, t_floatarg fquality) + t_floatarg fmode, t_floatarg fquality) { if ( fbitrate != 32 && fbitrate != 40 && fbitrate != 48 && fbitrate != 56 && - fbitrate != 64 && fbitrate != 80 && fbitrate != 96 && fbitrate != 112 && - fbitrate != 128 && fbitrate != 160 && fbitrate != 192 && fbitrate != 224 && - fbitrate != 256 && fbitrate != 320 ) { - post( "mp3streamout~ : wrong bitrate." ); - return; + fbitrate != 64 && fbitrate != 80 && fbitrate != 96 && fbitrate != 112 && + fbitrate != 128 && fbitrate != 160 && fbitrate != 192 && fbitrate != 224 && + fbitrate != 256 && fbitrate != 320 ) + { + post( "mp3streamout~ : wrong bitrate." ); + return; } - if ( fmode <0 || fmode>2 ) { - post( "mp3streamout~ : wrong mp3 mode." ); - if ( fmode == 3 ) - { - post( "mp3streamout~ : mone is not supported by streamout~ for now." ); - } - return; + if ( fmode <0 || fmode>2 ) + { + post( "mp3streamout~ : wrong mp3 mode." ); + if ( fmode == 3 ) + { + post( "mp3streamout~ : mone is not supported by streamout~ for now." ); + } + return; } /* there is a bug in lame 3.92 and quality below 5 will not work */ /* WAIT FOR A FIX */ - if ( fquality <5 || fquality>9 ) { - post( "mp3streamout~ : wrong quality." ); - return; + if ( fquality <5 || fquality>9 ) + { + post( "mp3streamout~ : wrong quality." ); + return; } x->x_bitrate = fbitrate; x->x_mp3mode = fmode; x->x_mp3quality = (int)fquality; post("mp3streamout~: setting mp3 stream to %dHz, %dkbit/s, mode %d, quality %d", - x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); + x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); mp3streamout_tilde_lame_init(x); } - /* print settings */ +/* print settings */ static void mp3streamout_print(t_mp3streamout *x) { - const char * buf = 0; + const char * buf = 0; - post(mp3streamout_version); + logpost(NULL, 4, "%s", mp3streamout_version); post(" LAME mp3 settings:\n" " output sample rate: %d Hz\n" " bitrate: %d kbit/s", x->x_samplerate, x->x_bitrate); switch(x->x_mp3mode) { - case 0 : - buf = "stereo"; - break; - case 1 : - buf = "joint stereo"; - break; - case 2 : - buf = "dual channel"; - break; - case 3 : - buf = "mono"; - break; + case 0 : + buf = "stereo"; + break; + case 1 : + buf = "joint stereo"; + break; + case 2 : + buf = "dual channel"; + break; + case 3 : + buf = "mono"; + break; } post(" mode: %s\n" " quality: %d", buf, x->x_mp3quality); -#ifndef UNIX +#ifdef _WIN32 if(x->x_lamechunk!=0)post(" calculated mp3 chunk size: %d", x->x_lamechunk); #else post(" mp3 chunk size: %d", x->x_lamechunk); @@ -557,15 +584,15 @@ static void mp3streamout_print(t_mp3streamout *x) } } - /* clean up */ -static void mp3streamout_free(t_mp3streamout *x) +/* clean up */ +static void mp3streamout_free(t_mp3streamout *x) { if(x->x_lame >= 0) lame_close( x->lgfp ); if(x->x_fd >= 0) -#ifndef UNIX +#ifdef _WIN32 closesocket(x->x_fd); #else close(x->x_fd); @@ -604,9 +631,9 @@ static void *mp3streamout_new(void) void mp3streamout_tilde_setup(void) { - post(mp3streamout_version); + logpost(NULL, 4, "%s", mp3streamout_version); mp3streamout_class = class_new(gensym("mp3streamout~"), (t_newmethod)mp3streamout_new, (t_method)mp3streamout_free, - sizeof(t_mp3streamout), 0, 0); + sizeof(t_mp3streamout), 0, 0); CLASS_MAINSIGNALIN(mp3streamout_class, t_mp3streamout, x_f ); class_addmethod(mp3streamout_class, (t_method)mp3streamout_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(mp3streamout_class, (t_method)mp3streamout_connect, gensym("connect"), A_SYMBOL, A_FLOAT, 0); diff --git a/externals/unauthorized/mp3write~/mp3write~-help.pd b/externals/unauthorized/mp3write~-help.pd similarity index 100% rename from externals/unauthorized/mp3write~/mp3write~-help.pd rename to externals/unauthorized/mp3write~-help.pd diff --git a/externals/unauthorized/mp3write~/mp3write~.c b/externals/unauthorized/mp3write~.c similarity index 70% rename from externals/unauthorized/mp3write~/mp3write~.c rename to externals/unauthorized/mp3write~.c index dc99c160ee1a120f9dc3ba24aaccd7931f394ae8..133ffa284a526b87dd146be9127d1352143d08b7 100644 --- a/externals/unauthorized/mp3write~/mp3write~.c +++ b/externals/unauthorized/mp3write~.c @@ -57,9 +57,16 @@ #include /* lame encoder stuff */ #include "m_pd.h" /* standard pd stuff */ +/* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_fopen fopen +#define sys_fclose fclose +#define sys_close close +#endif + #define MY_MP3_MALLOC_IN_SIZE 65536 - /* max size taken from lame readme */ -#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 +/* max size taken from lame readme */ +#define MY_MP3_MALLOC_OUT_SIZE 1.25*MY_MP3_MALLOC_IN_SIZE+7200 #define MAXDATARATE 320 /* maximum mp3 data rate is 320kbit/s */ #define STRBUF_SIZE 32 @@ -73,11 +80,11 @@ typedef struct _mp3write { t_object x_obj; - /* LAME stuff */ + /* LAME stuff */ int x_lame; /* info about encoder status */ int x_lamechunk; /* chunk size for LAME encoder */ - /* buffer stuff */ + /* buffer stuff */ unsigned short x_inp; /* in position for buffer */ unsigned short x_outp; /* out position for buffer*/ short *x_mp3inbuf; /* data to be sent to LAME */ @@ -87,13 +94,13 @@ typedef struct _mp3write int x_bytesbuffered; /* number of unprocessed bytes in buffer */ int x_start; - /* mp3 format stuff */ + /* mp3 format stuff */ int x_samplerate; int x_bitrate; /* bitrate of mp3 stream */ int x_mp3mode; /* mode (mono, joint stereo, stereo, dual mono) */ int x_mp3quality; /* quality of encoding */ - /* recording stuff */ + /* recording stuff */ int x_fd; /* file descriptor of the mp3 output */ int x_file_open_mode; /* file opening mode */ int x_byteswritten; /* number of bytes written */ @@ -106,28 +113,28 @@ typedef struct _mp3write } t_mp3write; - /* encode PCM data to mp3 stream */ +/* encode PCM data to mp3 stream */ static void mp3write_encode(t_mp3write *x) { unsigned short i, wp; int err = -1; int n = x->x_lamechunk; -#ifdef UNIX - if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) -#else +#ifdef _WIN32 if(x->x_lamechunk < sizeof(x->x_mp3inbuf)) +#else + if(x->x_lamechunk < (int)sizeof(x->x_mp3inbuf)) #endif { error("not enough memory!"); return; } - /* on start/reconnect set outpoint so that it won't interfere with inpoint */ + /* on start/reconnect set outpoint so that it won't interfere with inpoint */ if(x->x_start == -1) { post("mp3write~: reseting buffer positions"); - /* we try to keep 2.5 times the data the encoder needs in the buffer */ + /* we try to keep 2.5 times the data the encoder needs in the buffer */ if(x->x_inp > (2 * x->x_lamechunk)) { x->x_outp = (short) x->x_inp - (2.5 * x->x_lamechunk); @@ -142,10 +149,10 @@ static void mp3write_encode(t_mp3write *x) i = MY_MP3_MALLOC_IN_SIZE - x->x_outp; - /* read from buffer */ - if(x->x_lamechunk <= i) + /* read from buffer */ + if(x->x_lamechunk <= i) { - /* enough data until end of buffer */ + /* enough data until end of buffer */ for(n = 0; n < x->x_lamechunk; n++) /* fill encode buffer */ { x->x_mp3inbuf[n] = x->x_buffer[n + x->x_outp]; @@ -166,14 +173,14 @@ static void mp3write_encode(t_mp3write *x) x->x_outp = x->x_lamechunk - i; } - /* encode mp3 data */ + /* encode mp3 data */ - x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, - x->x_lamechunk/lame_get_num_channels(x->lgfp), + x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf, + x->x_lamechunk/lame_get_num_channels(x->lgfp), x->x_mp3outbuf, MY_MP3_MALLOC_OUT_SIZE); // post( "mp3write~ : encoding returned %d frames", x->x_mp3size ); - /* check result */ + /* check result */ if(x->x_mp3size<0) { lame_close( x->lgfp ); @@ -182,28 +189,29 @@ static void mp3write_encode(t_mp3write *x) } } - /* store mp3 frames in the file */ +/* store mp3 frames in the file */ static void mp3write_writeframes(t_mp3write *x) { int err = -1; /* error return code */ - if ( x->x_fd < 0 ) { - post( "mp3write~ : error : trying to write frames but no valid file is opened" ); - return; + if ( x->x_fd < 0 ) + { + post( "mp3write~ : error : trying to write frames but no valid file is opened" ); + return; } -#ifndef UNIX +#ifdef _WIN32 err = _write(x->x_fd, x->x_mp3outbuf, x->x_mp3size); #else err = write(x->x_fd, x->x_mp3outbuf, x->x_mp3size); -#endif +#endif if(err < 0) { error("mp3write~: could not write encoded data to file (%d)", err); lame_close( x->lgfp ); x->x_lame = -1; -#ifndef UNIX +#ifdef _WIN32 error("mp3write~: writing data"); _close(x->x_fd); #else @@ -211,17 +219,17 @@ static void mp3write_writeframes(t_mp3write *x) close(x->x_fd); #endif x->x_fd = -1; - } - else - { + } + else + { x->x_byteswritten += err; outlet_float( x->x_obj.ob_outlet, x->x_byteswritten ); - } + } if((err > 0)&&(err != x->x_mp3size))error("mp3write~: %d bytes skipped", x->x_mp3size - err); } - - /* buffer data as channel interleaved PCM */ + +/* buffer data as channel interleaved PCM */ static t_int *mp3write_perform(t_int *w) { t_float *in1 = (t_float *)(w[1]); /* left audio inlet */ @@ -231,76 +239,94 @@ static t_int *mp3write_perform(t_int *w) unsigned short i,wp; float in; - /* copy the data into the buffer */ + /* copy the data into the buffer */ i = MY_MP3_MALLOC_IN_SIZE - x->x_inp; /* space left at the end of buffer */ - + n *= 2; /* two channels go into one buffer */ - if( n <= i ) + if( n <= i ) { /* the place between inp and MY_MP3_MALLOC_IN_SIZE */ /* is big enough to hold the data */ - for(wp = 0; wp < n; wp++) + for(wp = 0; wp < n; wp++) + { + if(wp%2) + { + in = *(in2++); /* right channel / inlet */ + } + else { - if(wp%2) - { - in = *(in2++); /* right channel / inlet */ - } - else - { - in = *(in1++); /* left channel / inlet */ - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = *(in1++); /* left channel / inlet */ } - x->x_inp += n; /* n more samples written to buffer */ - } - else + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + x->x_inp += n; /* n more samples written to buffer */ + } + else { - /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ - /* big enough to hold the data */ - /* writing will take place in two turns, one from */ - /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ + /* the place between inp and MY_MP3_MALLOC_IN_SIZE is not */ + /* big enough to hold the data */ + /* writing will take place in two turns, one from */ + /* x->x_inp -> MY_MP3_MALLOC_IN_SIZE, then from 0 on */ - for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + for(wp = 0; wp < i; wp++) /* fill up to end of buffer */ + { + if(wp%2) + { + in = *(in2++); + } + else + { + in = *(in1++); + } + if (in > 1.0) + { + in = 1.0; + } + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + } + for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + { + if(wp%2) + { + in = *(in2++); + } + else { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp + x->x_inp] = (short) (32767.0 * in); + in = *(in1++); } - for(wp = i; wp < n; wp++) /* write rest at start of buffer */ + if (in > 1.0) { - if(wp%2) - { - in = *(in2++); - } - else - { - in = *(in1++); - } - if (in > 1.0) { in = 1.0; } - if (in < -1.0) { in = -1.0; } - x->x_buffer[wp - i] = (short) (32767.0 * in); + in = 1.0; } - x->x_inp = n - i; /* new writeposition in buffer */ + if (in < -1.0) + { + in = -1.0; + } + x->x_buffer[wp - i] = (short) (32767.0 * in); + } + x->x_inp = n - i; /* new writeposition in buffer */ } if((x->x_fd >= 0)&&(x->x_lame >= 0)&&(x->x_recflag)) - { - /* count buffered samples when things are running */ + { + /* count buffered samples when things are running */ x->x_bytesbuffered += n; - /* encode and send to server */ + /* encode and send to server */ if(x->x_bytesbuffered > x->x_lamechunk) { mp3write_encode(x); /* encode to mp3 */ @@ -320,15 +346,15 @@ static void mp3write_dsp(t_mp3write *x, t_signal **sp) dsp_add(mp3write_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); } - /* initialize the lame library */ +/* initialize the lame library */ static int mp3write_tilde_lame_init(t_mp3write *x) { - time_t now; + time_t now; int ret; x->lgfp = lame_init(); /* set default parameters for now */ -#ifndef UNIX +#ifdef _WIN32 /* load lame_enc.dll library */ HINSTANCE dll; dll=LoadLibrary("lame_enc.dll"); @@ -342,11 +368,13 @@ static int mp3write_tilde_lame_init(t_mp3write *x) } #endif { - const char *lameVersion = get_lame_version(); - post( "mp3write~ : using lame version : %s", lameVersion ); + const char *lameVersion = get_lame_version(); + char logbuf[MAXPDSTRING]; + sprintf(logbuf, "mp3write~ : using lame version : %s", lameVersion); + logpost(NULL, 4, "%s", logbuf ); } - /* setting lame parameters */ + /* setting lame parameters */ lame_set_num_channels( x->lgfp, 2); lame_set_in_samplerate( x->lgfp, sys_getsr() ); lame_set_out_samplerate( x->lgfp, x->x_samplerate ); @@ -357,17 +385,20 @@ static int mp3write_tilde_lame_init(t_mp3write *x) lame_set_original( x->lgfp, 1 ); lame_set_copyright( x->lgfp, 1 ); /* viva free music societies !!! */ lame_set_disable_reservoir( x->lgfp, 0 ); - lame_set_padding_type( x->lgfp, PAD_NO ); + //lame_set_padding_type( x->lgfp, PAD_NO ); /* deprecated in LAME */ ret = lame_init_params( x->lgfp ); - if ( ret<0 ) { - post( "mp3write~ : error : lame params initialization returned : %d", ret ); - return -1; - } else { - x->x_lame=1; - /* magic formula copied from windows dll for MPEG-I */ - x->x_lamechunk = 2*1152; - - post( "mp3write~ : lame initialization done. (%d)", x->x_lame ); + if ( ret<0 ) + { + post( "mp3write~ : error : lame params initialization returned : %d", ret ); + return -1; + } + else + { + x->x_lame=1; + /* magic formula copied from windows dll for MPEG-I */ + x->x_lamechunk = 2*1152; + + post( "mp3write~ : lame initialization done. (%d)", x->x_lame ); } lame_init_bitstream( x->lgfp ); @@ -379,53 +410,54 @@ static int mp3write_tilde_lame_init(t_mp3write *x) now=time(NULL); sprintf( x->x_title, "Started at %s", ctime(&now) ); id3tag_set_title(x->lgfp, x->x_title ); - + return 0; } - /* open file and initialize lame */ +/* open file and initialize lame */ static void mp3write_open(t_mp3write *x, t_symbol *sfile) { - if ( mp3write_tilde_lame_init(x) < 0 ) { - error( "mp3write~ : lame initialization failed ... check parameters."); - return; + if ( mp3write_tilde_lame_init(x) < 0 ) + { + error( "mp3write~ : lame initialization failed ... check parameters."); + return; } /* closing previous file descriptor */ - if ( x->x_fd > 0 ) { -#ifndef UNIX - if(_close(x->x_fd) < 0 ) -#else - if(close(x->x_fd) < 0) -#endif - { - perror( "mp3write~ : closing file" ); - } + if ( x->x_fd > 0 ) + { + if(sys_close(x->x_fd) < 0) + { + perror( "mp3write~ : closing file" ); + } } - if ( x->x_recflag ) { - x->x_recflag = 0; + if ( x->x_recflag ) + { + x->x_recflag = 0; } -#ifndef UNIX - if ( ( x->x_fd = _open( sfile->s_name, x->x_file_open_mode, _S_IREAD|_S_IWRITE) ) < 0 ) + +#ifdef _WIN32 + int mode = _S_IREAD|_S_IWRITE; #else - if ( ( x->x_fd = open( sfile->s_name, x->x_file_open_mode, S_IRWXU|S_IRWXG|S_IRWXO ) ) < 0 ) + int mode = S_IRWXU|S_IRWXG|S_IRWXO; #endif + if ( ( x->x_fd = sys_open( sfile->s_name, x->x_file_open_mode, mode) ) < 0 ) { - error( "mp3write~ : cannot open >%s<", sfile->s_name); - x->x_fd=-1; - return; + error( "mp3write~ : cannot open >%s<", sfile->s_name); + x->x_fd=-1; + return; } x->x_byteswritten = 0; - post( "mp3write~ : opened >%s< fd=%d", sfile->s_name, x->x_fd); -} + post( "mp3write~ : opened >%s< fd=%d", sfile->s_name, x->x_fd); +} - /* setting file write mode to append */ +/* setting file write mode to append */ static void mp3write_append(t_mp3write *x) { -#ifndef UNIX +#ifdef _WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_APPEND|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_APPEND|O_NONBLOCK; @@ -433,10 +465,10 @@ static void mp3write_append(t_mp3write *x) if(x->x_fd>=0)post("mp3write~ : mode set to append : open a new file to make changes take effect! "); } - /* setting file write mode to truncate */ +/* setting file write mode to truncate */ static void mp3write_truncate(t_mp3write *x) { -#ifndef UNIX +#ifdef _WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_TRUNC|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_TRUNC|O_NONBLOCK; @@ -444,9 +476,9 @@ static void mp3write_truncate(t_mp3write *x) if(x->x_fd>=0)post("mp3write~ : mode set to truncate : open a new file to make changes take effect! "); } - /* settings for mp3 encoding */ +/* settings for mp3 encoding */ static void mp3write_mpeg(t_mp3write *x, t_floatarg fsamplerate, t_floatarg fbitrate, - t_floatarg fmode, t_floatarg fquality) + t_floatarg fmode, t_floatarg fquality) { x->x_samplerate = fsamplerate; if(fbitrate > MAXDATARATE) @@ -457,36 +489,36 @@ static void mp3write_mpeg(t_mp3write *x, t_floatarg fsamplerate, t_floatarg fbit x->x_mp3mode = fmode; x->x_mp3quality = fquality; post("mp3write~: setting mp3 stream to %dHz, %dkbit/s, mode %d, quality %d", - x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); + x->x_samplerate, x->x_bitrate, x->x_mp3mode, x->x_mp3quality); if(x->x_fd>=0)post("mp3write~ : restart recording to make changes take effect! "); } - /* print settings */ +/* print settings */ static void mp3write_print(t_mp3write *x) { const char * buf = 0; - post(mp3write_version); + logpost(NULL, 4, "%s", mp3write_version); post(" LAME mp3 settings:\n" " output sample rate: %d Hz\n" " bitrate: %d kbit/s", x->x_samplerate, x->x_bitrate); switch(x->x_mp3mode) { - case 0 : - buf = "stereo"; - break; - case 1 : - buf = "joint stereo"; - break; - case 2 : - buf = "dual channel"; - break; - case 3 : - buf = "mono"; - break; + case 0 : + buf = "stereo"; + break; + case 1 : + buf = "joint stereo"; + break; + case 2 : + buf = "dual channel"; + break; + case 3 : + buf = "mono"; + break; } post(" mode: %s\n" " quality: %d", buf, x->x_mp3quality); -#ifndef UNIX +#ifdef _WIN32 if(x->x_lamechunk!=0)post(" calculated mp3 chunk size: %d", x->x_lamechunk); #else post(" mp3 chunk size: %d", x->x_lamechunk); @@ -497,56 +529,60 @@ static void mp3write_print(t_mp3write *x) } } - /* start recording */ +/* start recording */ static void mp3write_start(t_mp3write *x) { - if ( x->x_fd < 0 ) { - post("mp3write~: start received but no file has been set ... ignored."); - return; + if ( x->x_fd < 0 ) + { + post("mp3write~: start received but no file has been set ... ignored."); + return; } - - if ( x->x_recflag == 1 ) { - post("mp3write~: start received but recording is started ... ignored."); - return; + + if ( x->x_recflag == 1 ) + { + post("mp3write~: start received but recording is started ... ignored."); + return; } - + x->x_recflag = 1; post("mp3write~: start recording"); } - /* stop recording */ +/* stop recording */ static void mp3write_stop(t_mp3write *x) { int err = -1; - if ( x->x_fd < 0 ) { - post("mp3write~: stop received but no file has been set ... ignored."); - return; + if ( x->x_fd < 0 ) + { + post("mp3write~: stop received but no file has been set ... ignored."); + return; } - - if ( x->x_recflag == 0 ) { - post("mp3write~: stop received but recording is stopped ... ignored."); - return; + + if ( x->x_recflag == 0 ) + { + post("mp3write~: stop received but recording is stopped ... ignored."); + return; } - /* first stop recording / buffering and so on, than do the rest */ + /* first stop recording / buffering and so on, than do the rest */ x->x_recflag = 0; /* flushing remaining frames and tag */ - x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, MY_MP3_MALLOC_OUT_SIZE ); - + x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, MY_MP3_MALLOC_OUT_SIZE ); + mp3write_writeframes(x); /* write mp3 to file */ x->x_recflag = 0; post("mp3write~: stop recording, flushed %d bytes", x->x_mp3size); } - /* clean up */ -static void mp3write_free(t_mp3write *x) +/* clean up */ +static void mp3write_free(t_mp3write *x) { if(x->x_lame >= 0) lame_close( x->lgfp ); if(x->x_fd >= 0) -#ifndef UNIX +#ifdef _WIN32 _close(x->x_fd); #else close(x->x_fd); @@ -563,7 +599,7 @@ static void *mp3write_new(void) inlet_new (&x->x_obj, &x->x_obj.ob_pd, gensym ("signal"), gensym ("signal")); outlet_new (&x->x_obj, &s_float); x->x_fd = -1; -#ifndef UNIX +#ifdef _WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_APPEND|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_APPEND|O_NONBLOCK; @@ -593,9 +629,9 @@ static void *mp3write_new(void) void mp3write_tilde_setup(void) { - post(mp3write_version); + logpost(NULL, 4, "%s", mp3write_version); mp3write_class = class_new(gensym("mp3write~"), (t_newmethod)mp3write_new, (t_method)mp3write_free, - sizeof(t_mp3write), 0, 0); + sizeof(t_mp3write), 0, 0); CLASS_MAINSIGNALIN(mp3write_class, t_mp3write, x_f ); class_addmethod(mp3write_class, (t_method)mp3write_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(mp3write_class, (t_method)mp3write_open, gensym("open"), A_SYMBOL, 0); diff --git a/externals/unauthorized/mp3write~/INSTALL b/externals/unauthorized/mp3write~/INSTALL deleted file mode 100644 index 75f5f91c2df216fb6175f92df9ce55deb303d6ea..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -You need to get lame > v3.90 installed first. -libmp3lame.so is searched in /usr/local/lib -( no time to write configure scripts ). -if it's installed elsewhere, change the Makefile, -you won't die from that. - -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/mp3write~ - -make - -make install - -you're set !! diff --git a/externals/unauthorized/mp3write~/Makefile b/externals/unauthorized/mp3write~/Makefile deleted file mode 100644 index ec9fa829c92c8934435f7e0163db4c44174a1438..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -NAME=mp3write~ -CSYM=mp3write_tilde - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib -lmp3lame - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/mp3write~/README b/externals/unauthorized/mp3write~/README deleted file mode 100644 index 0633c5c19d4b356141ecb7b462abdb90ba5e0d3e..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/README +++ /dev/null @@ -1,94 +0,0 @@ -Version 0.01 -copyright (c) 2001 by Yves Degoyon - -mp3write~.dll is a MPEG I Layer III (mp3) file writer. - -To install mp3write~, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - -mp3write~ has been compiled for Linux using LAME 3.92. -The newest version of LAME can be found via freshmeat.net - -COPYING: you may use this source under GPL terms! - -PLEASE NOTE: This software may contain patented alogrithm (at least - patented in some countries). It may be not allowed to sell/use products - based on this source code in these countries. Check this out first! - -COPYRIGHT of MP3 music: - Please note, that the duplicating of copyrighted music without explicit - permission violates the rights of the owner. - -***************************************************************************** - - using mp3write~ external for Pure Data - -Open the help-mp3write~.pd to understand how it works. -In this patch, you must send the messages to mp3write~ -in the following order : - -1/ append|truncate if you wish to change file creation options ( default is append ) -2/ open /my/file -3/ start -5/ pd dsp 1 -4/ stop : the tag is written at this stage - -Parameters sent to mp3write~ object : - - Sampling Rate (Hz): -Possible values are 48000, 44100 and 32000. If Pd runs at a different sampling -rate, LAME will resample the signal. Default value for mp3 sampling rate is Pd's -sampling rate. - - Bitrate (kbit/s): -Possible values are 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 -and 320. Default is 224. - - Mode: -Possible values are 0 (stereo), 1 (joint stereo, the default), 2 (dual channel) -and 3 (mono). - - Outlet: -The outlet outputs an int, which the number of bytes written in this session. -this might be different from file size if you're using append mode. - - - Known Problems : - -All combinations of samplerate, bitrate, quality factor will not be accepted. - -ALLOWED QUALITY FACTOR : - - -q = 0...9. Default -q 5 - -q 0: Highest quality, very slow - -q 9: Poor quality, but fast - -h Same as -q 2. Recommended. - -f Same as -q 7. Fast, ok quality - -ALLOWED SAMPLERATE/BITRATES - -MPEG-1 layer III sample frequencies (kHz): 32 48 44.1 -bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 - -MPEG-2 layer III sample frequencies (kHz): 16 24 22.05 -bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 - -MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025 -bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 - -Furthermore, it seems that high quality factors will not work -with this release of lame ( 3.92 ). -The same errors can be obtained with the command line : -lame -q 1 file.wav -outputs errors and mp3write can't do better. - - diff --git a/externals/unauthorized/mp3write~/interface.h b/externals/unauthorized/mp3write~/interface.h deleted file mode 100644 index de3136a0c88b10e1d0e7a7bac704afc5ac835e86..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/interface.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Copyright (C) 2000 Albert L. Faber -** -** 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. -*/ - -#ifndef INTERFACE_H_INCLUDED -#define INTERFACE_H_INCLUDED - -// #include "common.h" -#include "interface.h" - -BOOL InitMP3(PMPSTR mp); -int decodeMP3(PMPSTR mp,unsigned char *inmemory,int inmemsize,char *outmemory,int outmemsize,int *done); -void ExitMP3(PMPSTR mp); - -/* added remove_buf to support mpglib seeking */ -void remove_buf(PMPSTR mp); - -#endif diff --git a/externals/unauthorized/mp3write~/mp3write~.libs b/externals/unauthorized/mp3write~/mp3write~.libs deleted file mode 100644 index 25f437cef030925f1de0f03eee1f4e9ae6dda016..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/mp3write~.libs +++ /dev/null @@ -1 +0,0 @@ --lmp3lame diff --git a/externals/unauthorized/mp3write~/mpg123.h b/externals/unauthorized/mp3write~/mpg123.h deleted file mode 100644 index 1c530d384d4ec30b38f2648b08e91ea76b618b22..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/mpg123.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef MPG123_H_INCLUDED -#define MPG123_H_INCLUDED - -#include - -#define STDC_HEADERS - -#ifdef STDC_HEADERS -# include -#else -# ifndef HAVE_STRCHR -# define strchr index -# define strrchr rindex -# endif -char *strchr (), *strrchr (); -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy ((s), (d), (n)) -# define memmove(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif - -#include - - -#if defined(__riscos__) && defined(FPA10) -#include "ymath.h" -#else -#include -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -#ifdef REAL_IS_FLOAT -# define real float -#elif defined(REAL_IS_LONG_DOUBLE) -# define real long double -#else -# define real double -#endif - -#define FALSE 0 -#define TRUE 1 - -#define SBLIMIT 32 -#define SSLIMIT 18 - -#define MPG_MD_STEREO 0 -#define MPG_MD_JOINT_STEREO 1 -#define MPG_MD_DUAL_CHANNEL 2 -#define MPG_MD_MONO 3 - -#define MAXFRAMESIZE 1792 - -/* AF: ADDED FOR LAYER1/LAYER2 */ -#define SCALE_BLOCK 12 - - -/* Pre Shift fo 16 to 8 bit converter table */ -#define AUSHIFT (3) - -struct frame { - int stereo; - int jsbound; - int single; - int lsf; - int mpeg25; - int header_change; - int lay; - int error_protection; - int bitrate_index; - int sampling_frequency; - int padding; - int extension; - int mode; - int mode_ext; - int copyright; - int original; - int emphasis; - int framesize; /* computed framesize */ - - /* AF: ADDED FOR LAYER1/LAYER2 */ -#if defined(USE_LAYER_2) || defined(USE_LAYER_1) - int II_sblimit; - struct al_table2 *alloc; - int down_sample_sblimit; - int down_sample; - -#endif - -}; - -struct gr_info_s { - int scfsi; - unsigned part2_3_length; - unsigned big_values; - unsigned scalefac_compress; - unsigned block_type; - unsigned mixed_block_flag; - unsigned table_select[3]; - unsigned subblock_gain[3]; - unsigned maxband[3]; - unsigned maxbandl; - unsigned maxb; - unsigned region1start; - unsigned region2start; - unsigned preflag; - unsigned scalefac_scale; - unsigned count1table_select; - real *full_gain[3]; - real *pow2gain; -}; - -struct III_sideinfo -{ - unsigned main_data_begin; - unsigned private_bits; - struct { - struct gr_info_s gr[2]; - } ch[2]; -}; - - -#endif diff --git a/externals/unauthorized/mp3write~/mpglib.h b/externals/unauthorized/mp3write~/mpglib.h deleted file mode 100644 index 1f4ef9aa829a1dd76e0fdf7dec0f953be0136114..0000000000000000000000000000000000000000 --- a/externals/unauthorized/mp3write~/mpglib.h +++ /dev/null @@ -1,65 +0,0 @@ -// #include "lame-analysis.h" - -#define NOANALYSIS - -#ifndef NOANALYSIS -extern plotting_data *mpg123_pinfo; -#endif - -struct buf { - unsigned char *pnt; - long size; - long pos; - struct buf *next; - struct buf *prev; -}; - -struct framebuf { - struct buf *buf; - long pos; - struct frame *next; - struct frame *prev; -}; - -typedef struct mpstr_tag { - struct buf *head,*tail; - int vbr_header; /* 1 if valid Xing vbr header detected */ - int num_frames; /* set if vbr header present */ - int enc_delay; /* set if vbr header present */ - int enc_padding; /* set if vbr header present */ - int header_parsed; - int side_parsed; - int data_parsed; - int free_format; /* 1 = free format frame */ - int old_free_format; /* 1 = last frame was free format */ - int bsize; - int framesize; - int ssize; - int dsize; - int fsizeold; - int fsizeold_nopadding; - struct frame fr; - unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ - real hybrid_block[2][2][SBLIMIT*SSLIMIT]; - int hybrid_blc[2]; - unsigned long header; - int bsnum; - real synth_buffs[2][2][0x110]; - int synth_bo; - int sync_bitstream; - -} MPSTR, *PMPSTR; - - -#if ( defined(_MSC_VER) || defined(__BORLANDC__) ) - typedef int BOOL; /* windef.h contains the same definition */ -#else - #define BOOL int -#endif - -#define MP3_ERR -1 -#define MP3_OK 0 -#define MP3_NEED_MORE 1 - - - diff --git a/externals/unauthorized/mp3amp~/mpg123.h b/externals/unauthorized/mpg123.h similarity index 100% rename from externals/unauthorized/mp3amp~/mpg123.h rename to externals/unauthorized/mpg123.h diff --git a/externals/unauthorized/mp3amp~/mpglib.h b/externals/unauthorized/mpglib.h similarity index 100% rename from externals/unauthorized/mp3amp~/mpglib.h rename to externals/unauthorized/mpglib.h diff --git a/externals/unauthorized/pd-unauthorized.info b/externals/unauthorized/pd-unauthorized.info deleted file mode 100644 index 101bde45a39114dbd8083bf93f13c14535d05f7f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pd-unauthorized.info +++ /dev/null @@ -1,16 +0,0 @@ -Title Unauthorized Externals for Pd -Version MSP standard paths -Description Yves Degoyon's 'Unauthorized' Externals -DefaultLocation /usr/local/lib -DeleteWarning - -### Package Flags - -NeedsAuthorization YES -Required NO -Relocatable YES -RequiresReboot NO -UseUserMask YES -OverwritePermissions NO -InstallFat NO -RootVolumeOnly NO diff --git a/externals/unauthorized/pianoroll/pianoroll-help.pd b/externals/unauthorized/pianoroll-help.pd similarity index 100% rename from externals/unauthorized/pianoroll/pianoroll-help.pd rename to externals/unauthorized/pianoroll-help.pd diff --git a/externals/unauthorized/pianoroll.c b/externals/unauthorized/pianoroll.c new file mode 100644 index 0000000000000000000000000000000000000000..bc4343e497fbf2bc2ed57da10b87e39b3aba57f2 --- /dev/null +++ b/externals/unauthorized/pianoroll.c @@ -0,0 +1,831 @@ +/* Copyright (c) 1997-1999 Miller Puckette. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ +/* */ +/* pianoroll : a graphical object which enables */ +/* to control a sequencer ( pitch and volume ) */ +/* */ +/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* "If you obey society's rules" */ +/* "You'll be society's fool" */ +/* Devo - Society's rules */ +/* ---------------------------------------------------------------------------- */ + + +#include +#include +#include +#include +#include +#include "m_pd.h" +#include "m_imp.h" +#include "g_canvas.h" + +#include "pianoroll.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + +/* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_fopen fopen +#define sys_fclose fclose +#define sys_close close +#endif + +/* needed to create a pianoroll from PD's menu +void canvas_objtext(t_glist *gl, int xpos, int ypos, int selected, t_binbuf *b); +void canvas_startmotion(t_canvas *x); +*/ + +#define DEFAULT_SEQUENCER_WIDTH 200 +#define DEFAULT_SEQUENCER_HEIGHT 200 +#define DEFAULT_SEQUENCER_STEPS 16 +#define DEFAULT_SEQUENCER_NBGRADES 31 +#define DEFAULT_SEQUENCER_PITCH_MIN -15 +#define DEFAULT_SEQUENCER_PITCH_MAX 15 + +static char *pianoroll_version = "pianoroll: a graphical sequencer controller, version 0.10 (ydegoyon@free.fr)"; + +t_widgetbehavior pianoroll_widgetbehavior; +static t_class *pianoroll_class; +static int pianorollcount=0; + +static int guidebug=0; +static int pointsize = 5; + +#define SYS_VGUI2(a,b) if (guidebug) \ + post(a,b);\ + sys_vgui(a,b) + +#define SYS_VGUI3(a,b,c) if (guidebug) \ + post(a,b,c);\ + sys_vgui(a,b,c) + +#define SYS_VGUI4(a,b,c,d) if (guidebug) \ + post(a,b,c,d);\ + sys_vgui(a,b,c,d) + +#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ + post(a,b,c,d,e);\ + sys_vgui(a,b,c,d,e) + +#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ + post(a,b,c,d,e,f,g );\ + sys_vgui(a,b,c,d,e,f,g) + +#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ + post(a,b,c,d,e,f,g,h,i );\ + sys_vgui(a,b,c,d,e,f,g,h,i) + +/* drawing functions */ +static void pianoroll_draw_update(t_pianoroll *x, t_glist *glist) +{ + t_int si; + t_canvas *canvas=glist_getcanvas(glist); + + for ( si=0; six_nbsteps; si++ ) + { + int vi = (int)((1.0-x->x_volumes[si])*(x->x_nbgrades-1)); + int pi = (int)((x->x_pmax-x->x_peaches[si])/(x->x_pmax-x->x_pmin)*(x->x_nbgrades-1)); + + x->x_ivolumes[ si ] = vi; + x->x_ipeaches[ si ] = pi; + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, pi); + SYS_VGUI5(".x%lx.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, vi); + } +} + +static void pianoroll_draw_new(t_pianoroll *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + // draw the grid + { + int gi, gj; + t_float xgstep = x->x_width/x->x_nbsteps; + t_float ygstep = x->x_height/x->x_nbgrades; + for ( gi=0; gix_nbsteps; gi++ ) + { + for ( gj=0; gjx_nbgrades; gj++ ) + { + SYS_VGUI9(".x%lx.c create rectangle %d %d %d %d -fill #771623 -outline #998121 -tags %xPITCH%.4d%.4d\n", + canvas, + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep), + text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), + text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep), + x, gi, gj ); + SYS_VGUI9(".x%lx.c create rectangle %d %d %d %d -fill #562663 -outline #998121 -tags %xVOLUME%.4d%.4d\n", + canvas, + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), + text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), + text_xpix(&x->x_obj, glist)+(int)((gi+1)*xgstep), + text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep), + x, gi, gj ); + } + } + // adjust height and width + x->x_width = (int)((x->x_nbsteps)*xgstep); + x->x_height = (int)((x->x_nbgrades)*ygstep); + } + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -tags %xIN\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) - 1, + text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist), + x); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -tags %xOUTL\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height+1, + text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) + x->x_height+2, + x); + SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -tags %xOUTR\n", + canvas, text_xpix(&x->x_obj, glist)+x->x_width-7, text_ypix(&x->x_obj, glist) + x->x_height+1, + text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist) + x->x_height+2, + x); + + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void pianoroll_draw_move(t_pianoroll *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + // move the grid + { + int gi, gj; + t_float xgstep = x->x_width/x->x_nbsteps; + t_float ygstep = x->x_height/x->x_nbgrades; + for ( gi=0; gix_nbsteps; gi++ ) + { + for ( gj=0; gjx_nbgrades; gj++ ) + { + SYS_VGUI9(".x%lx.c coords %xPITCH%.4d%.4d %d %d %d %d\n", + canvas, x, gi, gj, + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep), + text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), + text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep) + ); + SYS_VGUI9(".x%lx.c coords %xVOLUME%.4d%.4d %d %d %d %d\n", + canvas, x, gi, gj, + text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), + text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), + text_xpix(&x->x_obj, glist)+(int)((gi+1)*xgstep), + text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep) + ); + } + } + } + SYS_VGUI7(".x%lx.c coords %xIN %d %d %d %d \n", + canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) - 1, + text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) + ); + SYS_VGUI7(".x%lx.c coords %xOUTL %d %d %d %d\n", + canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height+1, + text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) + x->x_height+2 + ); + SYS_VGUI7(".x%lx.c coords %xOUTR %d %d %d %d\n", + canvas, x, text_xpix(&x->x_obj, glist)+x->x_width-7, text_ypix(&x->x_obj, glist) + x->x_height+1, + text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist) + x->x_height+2 + ); + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void pianoroll_draw_erase(t_pianoroll* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int i; + + SYS_VGUI3(".x%lx.c delete %xIN\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xOUTL\n", canvas, x); + SYS_VGUI3(".x%lx.c delete %xOUTR\n", canvas, x); + // delete the grid + { + int gi, gj; + for ( gi=0; gix_nbsteps; gi++ ) + { + for ( gj=0; gjx_nbgrades; gj++ ) + { + SYS_VGUI5(".x%lx.c delete %xPITCH%.4d%.4d\n", canvas, x, gi, gj); + SYS_VGUI5(".x%lx.c delete %xVOLUME%.4d%.4d\n", canvas, x, gi, gj); + } + } + } +} + +static void pianoroll_draw_select(t_pianoroll* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if(x->x_selected) + { + pd_bind(&x->x_obj.ob_pd, x->x_name); + /* sets the item in blue */ + } + else + { + pd_unbind(&x->x_obj.ob_pd, x->x_name); + } +} + +/* ------------------------ pianoroll widgetbehaviour----------------------------- */ + + +static void pianoroll_getrect(t_gobj *z, t_glist *owner, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_pianoroll* x = (t_pianoroll*)z; + + *xp1 = text_xpix(&x->x_obj, owner); + *yp1 = text_ypix(&x->x_obj, owner); + *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; + *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; +} + +static void pianoroll_save(t_gobj *z, t_binbuf *b) +{ + t_pianoroll *x = (t_pianoroll *)z; + t_int i; + + // post( "saving pianoroll : %s", x->x_name->s_name ); + binbuf_addv(b, "ssiissiiffiiifi", gensym("#X"),gensym("obj"), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, + atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), + x->x_name, x->x_width, x->x_height, + x->x_pmin, x->x_pmax, + x->x_nbgrades, x->x_nbsteps, + x->x_defvalue, x->x_transpose, x->x_save + ); + if ( x->x_save ) + { + for ( i=0; ix_nbsteps; i++ ) + { + binbuf_addv(b, "ff", x->x_peaches[i], x->x_volumes[i] ); + } + } + binbuf_addv(b, ";"); +} + +static void pianoroll_properties(t_gobj *z, t_glist *owner) +{ + char buf[800]; + t_pianoroll *x=(t_pianoroll *)z; + + sprintf(buf, "pdtk_pianoroll_dialog %%s %s %d %d %.2f %.2f %d %d %d %d\n", + x->x_name->s_name, x->x_width, x->x_height, x->x_pmin, x->x_pmax, + x->x_nbgrades, x->x_nbsteps, x->x_defvalue, x->x_save ); + // post("pianoroll_properties : %s", buf ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); +} + +static void pianoroll_select(t_gobj *z, t_glist *glist, int selected) +{ + t_pianoroll *x = (t_pianoroll *)z; + + x->x_selected = selected; + pianoroll_draw_select( x, glist ); +} + +static void pianoroll_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_pianoroll *x = (t_pianoroll *)z; + t_rtext *y; + + // post("pianoroll_vis : %d", vis ); + if (vis) + { + pianoroll_draw_new( x, glist ); + pianoroll_draw_update( x, glist ); + } + else + { + pianoroll_draw_erase( x, glist ); + } +} + +static void pianoroll_dialog(t_pianoroll *x, t_symbol *s, int argc, t_atom *argv) +{ + int si, onbsteps; + t_float *newpeaches, *newvolumes; + + if ( !x ) + { + post( "pianoroll : error :tried to set properties on an unexisting object" ); + } + if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) + { + post( "pianoroll : error : wrong number of steps or grades" ); + return; + } + if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) + { + post( "pianoroll : error : min pitch is >= to max pitch" ); + return; + } + if ( argc != 9 ) + { + post( "pianoroll : error in the number of arguments ( %d )", argc ); + return; + } + if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT || + argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT || + argv[8].a_type != A_FLOAT + ) + { + post( "pianoroll : wrong arguments" ); + return; + } + pianoroll_draw_erase(x, x->x_glist); + x->x_name = argv[0].a_w.w_symbol; + x->x_width = (int)argv[1].a_w.w_float; + x->x_height = (int)argv[2].a_w.w_float; + x->x_pmin = argv[3].a_w.w_float; + x->x_pmax = argv[4].a_w.w_float; + x->x_nbgrades = argv[5].a_w.w_float; + onbsteps = x->x_nbsteps; + x->x_nbsteps = argv[6].a_w.w_float; + x->x_defvalue = argv[7].a_w.w_float; + x->x_save = argv[8].a_w.w_float; + + if ( onbsteps != x->x_nbsteps ) + { + int cmindex = ( onbsteps > x->x_nbsteps ) ? x->x_nbsteps : onbsteps; + + newpeaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); + newvolumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); + for ( si=0; six_peaches[si]; + newvolumes[si] = x->x_volumes[si]; + } + freebytes( x->x_peaches, onbsteps*sizeof( t_float ) ); + freebytes( x->x_volumes, onbsteps*sizeof( t_float ) ); + x->x_peaches = newpeaches; + x->x_volumes = newvolumes; + for ( si=onbsteps; six_nbsteps; si++ ) + { + x->x_peaches[si] = x->x_defvalue; + x->x_volumes[si] = 1.0; + } + freebytes( x->x_ipeaches, onbsteps*sizeof( t_int ) ); + freebytes( x->x_ivolumes, onbsteps*sizeof( t_int ) ); + x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); + } + pianoroll_draw_new(x, x->x_glist); + pianoroll_draw_update(x, x->x_glist); +} + +static void pianoroll_delete(t_gobj *z, t_glist *glist) +{ + canvas_deletelinesfor(glist, (t_text *)z); +} + +static void pianoroll_displace(t_gobj *z, t_glist *glist, int dx, int dy) +{ + t_pianoroll *x = (t_pianoroll *)z; + int xold = text_xpix(&x->x_obj, glist); + int yold = text_ypix(&x->x_obj, glist); + + // post( "pianoroll_displace dx=%d dy=%d", dx, dy ); + + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; + if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix) + { + pianoroll_draw_move(x, x->x_glist); + } +} + +static int pianoroll_click(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_pianoroll* x = (t_pianoroll *)z; + t_canvas *canvas=glist_getcanvas(glist); + + if ( doit) + { + // calculate position to update + { + int si, gi; + t_float xgstep = x->x_width/x->x_nbsteps; + t_float ygstep = x->x_height/x->x_nbgrades; + + si = ( xpix - text_xpix(&x->x_obj, glist) ) / xgstep; + gi = ( ypix - text_ypix(&x->x_obj, glist) ) / ygstep; + + // post( "pianoroll : step : %d : grade : %d", si, gi ); + + if ( ( xpix - text_xpix(&x->x_obj, glist) ) > ( si*xgstep+2*xgstep/3 ) ) + { + { + SYS_VGUI5(".x%lx.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, si, x->x_ivolumes[ si ] ); + } + + x->x_volumes[ si ] = (((float)x->x_nbgrades-1-(float)gi))/(float)(x->x_nbgrades-1); + SYS_VGUI5(".x%lx.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, gi); + x->x_ivolumes[ si ] = gi; + } + else + { + { + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, si, x->x_ipeaches[ si ]); + } + + x->x_peaches[ si ] = x->x_pmin+(float)(x->x_nbgrades-1-gi)/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin); + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, gi); + x->x_ipeaches[ si ] = gi; + } + } + + } + return (1); +} + +static void pianoroll_transpose(t_pianoroll *x, t_floatarg ftranspose) +{ + x->x_transpose = ftranspose; +} + +static void pianoroll_save_file(t_pianoroll *x, t_symbol *ffile) +{ + FILE *tmph; + t_int si; + + if ( ( tmph = sys_fopen( ffile->s_name, "w" ) ) == NULL ) + { + post( "pianoroll : could not open file : %s for writing", ffile->s_name ); + return; + } + + // post( "saving pianoroll : %s", x->x_name->s_name ); + fprintf(tmph, "%d %d %f %f %d %d %d %f %d ", + x->x_width, x->x_height, + x->x_pmin, x->x_pmax, + (int)x->x_nbgrades, (int)x->x_nbsteps, + (int)x->x_defvalue, x->x_transpose, x->x_save ); + for ( si=0; six_nbsteps; si++ ) + { + fprintf(tmph, "%f %f ", x->x_peaches[si], x->x_volumes[si] ); + } + + if ( fclose( tmph ) == -1 ) + { + post( "pianoroll : could not close file : %s ", ffile->s_name ); + return; + } +} + +static void pianoroll_load(t_pianoroll *x, t_symbol *ffile) +{ + FILE *tmph; + t_int si; + + if ( ( tmph = sys_fopen( ffile->s_name, "r" ) ) == NULL ) + { + post( "pianoroll : could not open file : %s for reading", ffile->s_name ); + return; + } + + pianoroll_draw_erase(x, x->x_glist); + freebytes( x->x_peaches, x->x_nbsteps*sizeof( t_float ) ); + freebytes( x->x_volumes, x->x_nbsteps*sizeof( t_float ) ); + freebytes( x->x_ipeaches, x->x_nbsteps*sizeof( t_int ) ); + freebytes( x->x_ivolumes, x->x_nbsteps*sizeof( t_int ) ); + + if ( fscanf(tmph, "%d %d %f %f %d %d %d %f %d", + &x->x_width, &x->x_height, + &x->x_pmin, &x->x_pmax, + &x->x_nbgrades, &x->x_nbsteps, + &x->x_defvalue, &x->x_transpose, &x->x_save ) != 9 ) + { + post( "pianoroll : could not restore data from file : %s", ffile->s_name ); + return; + } + + x->x_peaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_volumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); + for ( si=0; six_nbsteps ; si++ ) + { + fscanf( tmph, "%f", &x->x_peaches[si] ); + fscanf( tmph, "%f", &x->x_volumes[si] ); + } + + pianoroll_draw_new(x, x->x_glist); + pianoroll_draw_update(x, x->x_glist); + + if ( fclose( tmph ) == -1 ) + { + post( "pianoroll : could not close file : %s ", ffile->s_name ); + return; + } +} + +static void pianoroll_init(t_pianoroll *x) +{ + t_int si; + + for ( si=0; six_nbsteps; si++ ) + { + x->x_peaches[si] = x->x_defvalue; + x->x_volumes[si] = 1.0; + } + pianoroll_draw_erase(x, x->x_glist ); + pianoroll_draw_new(x, x->x_glist ); + pianoroll_draw_update(x, x->x_glist ); +} + +static void pianoroll_pitch(t_pianoroll *x, t_floatarg fpos, t_floatarg fpitch) +{ + t_canvas *canvas=glist_getcanvas(x->x_glist); + t_int ipos; + + if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) ) + { + post( "pianoroll : wrong pitch position : %d", fpos ); + return; + } + ipos = (t_int) fpos; + if ( ( ( (t_int) fpitch ) < x->x_pmin ) || ( ( (t_int) fpitch ) > x->x_pmax ) ) + { + post( "pianoroll : wrong pitch value : %d", fpitch ); + return; + } + + { + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, ipos, x->x_ipeaches[ ipos ]); + + x->x_ipeaches[ ipos ] = (t_int) ( ( ( x->x_pmax - fpitch ) / ( x->x_pmax - x->x_pmin ) ) * ( x->x_nbgrades - 1 ) ); + x->x_peaches[ ipos ] = x->x_pmin+(float)(x->x_nbgrades-1-x->x_ipeaches[ ipos ])/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin); + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, ipos, x->x_ipeaches[ ipos ]); + } +} + +static void pianoroll_volume(t_pianoroll *x, t_floatarg fpos, t_floatarg fvol) +{ + t_canvas *canvas=glist_getcanvas(x->x_glist); + t_int ipos; + + if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) ) + { + post( "pianoroll : wrong volume position : %d", fpos ); + return; + } + ipos = (t_int) fpos; + if ( ( ( (t_int) fvol ) < 0.0 ) || ( ( (t_int) fvol ) > 1.0 ) ) + { + post( "pianoroll : wrong volume value : %d", fvol ); + return; + } + + { + SYS_VGUI5(".x%lx.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, ipos, x->x_ivolumes[ ipos ] ); + + x->x_ivolumes[ ipos ] = (t_int) ( ( 1 - fvol ) * (x->x_nbgrades-1) ); + x->x_volumes[ ipos ] = (((float)x->x_nbgrades-1-(float)x->x_ivolumes[ ipos ]))/(float)(x->x_nbgrades-1); + SYS_VGUI5(".x%lx.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, ipos, x->x_ivolumes[ ipos ] ); + } +} + +static void pianoroll_float(t_pianoroll *x, t_floatarg fposition) +{ + t_int pposition, rposition, rrposition; + t_float fpart; + t_int pi; + t_canvas *canvas; + + pposition = ( (int)fposition - 1 ) % x->x_nbsteps; + if ( pposition < 0 ) pposition += x->x_nbsteps; + rposition = ( (int)fposition ) % x->x_nbsteps; + if ( rposition < 0 ) rposition += x->x_nbsteps; + rrposition = ( (int)fposition +1 ) % x->x_nbsteps; + if ( rrposition < 0 ) rrposition += x->x_nbsteps; + + // post ( "pposition=%d rposition=%d rrposition=%d", pposition, rposition, rrposition ); + fpart = fposition - (int)fposition; + pi=-1; + canvas=glist_getcanvas(x->x_glist); + + outlet_float( x->x_pitch, x->x_peaches[ rposition ] + + fpart*(x->x_peaches[ rrposition ] - x->x_peaches[ rposition ] ) + + x->x_transpose ); + outlet_float( x->x_volume, x->x_volumes[ rposition ] + + fpart*(x->x_volumes[ rrposition ] - x->x_volumes[ rposition ] ) ); + + // graphical update + { + if ( x->x_scurrent != -1 ) + { + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, + x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]); + } + x->x_scurrent = rposition; + SYS_VGUI5(".x%lx.c itemconfigure %xPITCH%.4d%.4d -fill #00FF00\n", canvas, x, + x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]); + } +} + +static t_pianoroll *pianoroll_new(t_symbol *s, int argc, t_atom *argv) +{ + int si, i, zz; + t_pianoroll *x; + t_pd *x2; + char *str; + + // post( "pianoroll_new : create : %s argc =%d", s->s_name, argc ); + + x = (t_pianoroll *)pd_new(pianoroll_class); + // new pianoroll created from the gui + if ( argc != 0 ) + { + if ( argc < 10 ) + { + post( "pianoroll : error in the number of arguments ( %d )", argc ); + return NULL; + } + if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) + { + post( "pianoroll : error : wrong number of steps or grades" ); + return NULL; + } + if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) + { + post( "pianoroll : error : min pitch is > to max pitch" ); + return NULL; + } + if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT || + argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT || + argv[8].a_type != A_FLOAT || argv[9].a_type != A_FLOAT ) + { + post( "pianoroll : wrong arguments" ); + return NULL; + } + + // update pianoroll count + if (!strncmp((str = argv[0].a_w.w_symbol->s_name), "pianoroll", 9) + && (zz = atoi(str + 9)) > pianorollcount) + { + // post( "pianoroll : already %d objects", pianorollcount ); + pianorollcount = zz; + } + x->x_name = argv[0].a_w.w_symbol; + pd_bind(&x->x_obj.ob_pd, x->x_name); + x->x_width = argv[1].a_w.w_float; + x->x_height = argv[2].a_w.w_float; + x->x_pmin = argv[3].a_w.w_float; + x->x_pmax = argv[4].a_w.w_float; + x->x_nbgrades = argv[5].a_w.w_float; + x->x_nbsteps = argv[6].a_w.w_float; + x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_defvalue = argv[7].a_w.w_float; + x->x_transpose = argv[8].a_w.w_float; + x->x_save = argv[9].a_w.w_float; + } + else + { + char buf[40]; + + sprintf(buf, "pianoroll%d", ++pianorollcount); + s = gensym(buf); + + x->x_name = s; + pd_bind(&x->x_obj.ob_pd, x->x_name); + + x->x_width = DEFAULT_SEQUENCER_WIDTH; + x->x_height = DEFAULT_SEQUENCER_HEIGHT; + x->x_pmin = DEFAULT_SEQUENCER_PITCH_MIN; + x->x_pmax = DEFAULT_SEQUENCER_PITCH_MAX; + x->x_nbgrades = DEFAULT_SEQUENCER_NBGRADES; + x->x_nbsteps = DEFAULT_SEQUENCER_STEPS; + x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); + x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); + x->x_defvalue = 0; + x->x_transpose = 0; + x->x_save = 1; + + } + + // common fields for new and restored pianorolls + x->x_selected = 0; + x->x_scurrent = -1; + x->x_glist = (t_glist *) canvas_getcurrent(); + x->x_pitch = outlet_new(&x->x_obj, &s_float ); + x->x_volume = outlet_new(&x->x_obj, &s_float ); + // post( "pianoroll : argc : %d", argc ); + if ( ( argc != 0 ) && ( x->x_save ) ) + { + int ai = 10; + int si = 0; + + while ( ai < argc ) + { + x->x_peaches[si] = argv[ai++].a_w.w_float; + if ( ai >= argc ) break; + x->x_volumes[si++] = argv[ai++].a_w.w_float; + } + } + else // following arguments are the values of pitch, volumes + { + for ( si=0; six_nbsteps; si++ ) + { + x->x_peaches[si] = x->x_defvalue; + x->x_volumes[si] = 1.0; + } + } + + // post( "pianoroll_new name : %s width: %d height : %d", x->x_name->s_name, x->x_width, x->x_height ); + + return (x); +} + +static void pianoroll_free(t_pianoroll *x) +{ + // post( "pianoroll~: pianoroll_free" ); + if ( x->x_peaches ) + { + freebytes( x->x_peaches, x->x_nbsteps*sizeof(t_float) ); + } + if ( x->x_ipeaches ) + { + freebytes( x->x_ipeaches, x->x_nbsteps*sizeof(t_int) ); + } + if ( x->x_volumes ) + { + freebytes( x->x_volumes, x->x_nbsteps*sizeof(t_float) ); + } + if ( x->x_ivolumes ) + { + freebytes( x->x_ivolumes, x->x_nbsteps*sizeof(t_int) ); + } +} + +void pianoroll_setup(void) +{ + logpost(NULL, 4, "%s", pianoroll_version ); + pianoroll_class = class_new(gensym("pianoroll"), (t_newmethod)pianoroll_new, + (t_method)pianoroll_free, sizeof(t_pianoroll), 0, A_GIMME, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_float, &s_float, A_FLOAT, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_transpose, gensym("transpose"), + A_FLOAT, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_init, gensym("init"), 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_dialog, gensym("dialog"), A_GIMME, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_save_file, gensym("save"), A_SYMBOL, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_load, gensym("load"), A_SYMBOL, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_pitch, gensym("pitch"), A_FLOAT, A_FLOAT, 0); + class_addmethod(pianoroll_class, (t_method)pianoroll_volume, gensym("volume"), A_FLOAT, A_FLOAT, 0); + + + pianoroll_widgetbehavior.w_getrectfn = pianoroll_getrect; + pianoroll_widgetbehavior.w_displacefn = pianoroll_displace; + pianoroll_widgetbehavior.w_selectfn = pianoroll_select; + pianoroll_widgetbehavior.w_activatefn = NULL; + pianoroll_widgetbehavior.w_deletefn = pianoroll_delete; + pianoroll_widgetbehavior.w_visfn = pianoroll_vis; + pianoroll_widgetbehavior.w_clickfn = pianoroll_click; + +#if PD_MINOR_VERSION >= 37 + class_setpropertiesfn(pianoroll_class, pianoroll_properties); + class_setsavefn(pianoroll_class, pianoroll_save); +#else + pianoroll_widgetbehavior.w_propertiesfn = pianoroll_properties; + pianoroll_widgetbehavior.w_savefn = pianoroll_save; +#endif + + class_setwidget(pianoroll_class, &pianoroll_widgetbehavior); + + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + pianoroll_class->c_externdir->s_name, + pianoroll_class->c_name->s_name); +} diff --git a/externals/unauthorized/pianoroll/pianoroll.h b/externals/unauthorized/pianoroll.h similarity index 100% rename from externals/unauthorized/pianoroll/pianoroll.h rename to externals/unauthorized/pianoroll.h diff --git a/externals/unauthorized/pianoroll/pianoroll.tk b/externals/unauthorized/pianoroll.tcl similarity index 98% rename from externals/unauthorized/pianoroll/pianoroll.tk rename to externals/unauthorized/pianoroll.tcl index 245304701fbd48c9aac7123b8ecd1e46860e8b88..b3bec5320cb8aa4fc410c2c72c78f6cbf9ae12bc 100644 --- a/externals/unauthorized/pianoroll/pianoroll.tk +++ b/externals/unauthorized/pianoroll.tcl @@ -34,13 +34,13 @@ proc pianoroll_apply {id} { [eval concat $$var_graph_defvalue] \ [eval concat $$var_graph_save] \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc pianoroll_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc pianoroll_ok {id} { @@ -79,7 +79,7 @@ proc pdtk_pianoroll_dialog {id name width height pmin pmax nbgrades nbsteps defv set $var_graph_defvalue $defvalue set $var_graph_save $save - toplevel $id -class [winfo class .] + toplevel $id wm title $id {pianoroll} wm protocol $id WM_DELETE_WINDOW [concat pianoroll_cancel $id] diff --git a/externals/unauthorized/pianoroll/INSTALL b/externals/unauthorized/pianoroll/INSTALL deleted file mode 100644 index b7c38be066e3d61ff25e5c99672004c234864a0f..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/pianoroll - -make clean - -make - -make install - -open help-pianoroll.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/pianoroll/Makefile b/externals/unauthorized/pianoroll/Makefile deleted file mode 100644 index c05d24c60bf20dadc893702422124aa2069b91fd..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -NAME=pianoroll -CSYM=pianoroll - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch #-Werror - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk >$*.tk2c - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/pianoroll/README b/externals/unauthorized/pianoroll/README deleted file mode 100644 index dfbf64274581b8689f4146322c8c02a669ce4149..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/README +++ /dev/null @@ -1,18 +0,0 @@ -Version 0.01 -copyleft 2001 by Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -pianoroll : a graphical sequencer controller - -To install pianoroll, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - diff --git a/externals/unauthorized/pianoroll/pianoroll.c b/externals/unauthorized/pianoroll/pianoroll.c deleted file mode 100644 index c71735cc28f85597101fd8e19adc1d978a43b752..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/pianoroll.c +++ /dev/null @@ -1,815 +0,0 @@ -/* Copyright (c) 1997-1999 Miller Puckette. */ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ -/* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -/* */ -/* pianoroll : a graphical object which enables */ -/* to control a sequencer ( pitch and volume ) */ -/* */ -/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* "If you obey society's rules" */ -/* "You'll be society's fool" */ -/* Devo - Society's rules */ -/* ---------------------------------------------------------------------------- */ - - -#include -#include -#include -#include -#include -#include "m_pd.h" -#include "m_imp.h" -#include "g_canvas.h" - -#include "pianoroll.h" - -#ifdef NT -#include -#else -#include -#endif - -/* needed to create a pianoroll from PD's menu -void canvas_objtext(t_glist *gl, int xpos, int ypos, int selected, t_binbuf *b); -void canvas_startmotion(t_canvas *x); -*/ - -#define DEFAULT_SEQUENCER_WIDTH 200 -#define DEFAULT_SEQUENCER_HEIGHT 200 -#define DEFAULT_SEQUENCER_STEPS 16 -#define DEFAULT_SEQUENCER_NBGRADES 31 -#define DEFAULT_SEQUENCER_PITCH_MIN -15 -#define DEFAULT_SEQUENCER_PITCH_MAX 15 - -static char *pianoroll_version = "pianoroll: a graphical sequencer controller, version 0.10 (ydegoyon@free.fr)"; - -t_widgetbehavior pianoroll_widgetbehavior; -static t_class *pianoroll_class; -static int pianorollcount=0; - -static int guidebug=0; -static int pointsize = 5; - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g );\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i );\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -/* drawing functions */ -static void pianoroll_draw_update(t_pianoroll *x, t_glist *glist) -{ - t_int si; - t_canvas *canvas=glist_getcanvas(glist); - - for ( si=0; six_nbsteps; si++ ) - { - int vi = (int)((1.0-x->x_volumes[si])*(x->x_nbgrades-1)); - int pi = (int)((x->x_pmax-x->x_peaches[si])/(x->x_pmax-x->x_pmin)*(x->x_nbgrades-1)); - - x->x_ivolumes[ si ] = vi; - x->x_ipeaches[ si ] = pi; - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, pi); - SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, vi); - } -} - -static void pianoroll_draw_new(t_pianoroll *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - // draw the grid - { - int gi, gj; - t_float xgstep = x->x_width/x->x_nbsteps; - t_float ygstep = x->x_height/x->x_nbgrades; - for ( gi=0; gix_nbsteps; gi++ ) - { - for ( gj=0; gjx_nbgrades; gj++ ) - { - SYS_VGUI9(".x%x.c create rectangle %d %d %d %d -fill #771623 -outline #998121 -tags %xPITCH%.4d%.4d\n", - canvas, - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep), - text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), - text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep), - x, gi, gj ); - SYS_VGUI9(".x%x.c create rectangle %d %d %d %d -fill #562663 -outline #998121 -tags %xVOLUME%.4d%.4d\n", - canvas, - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), - text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), - text_xpix(&x->x_obj, glist)+(int)((gi+1)*xgstep), - text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep), - x, gi, gj ); - } - } - // adjust height and width - x->x_width = (int)((x->x_nbsteps)*xgstep); - x->x_height = (int)((x->x_nbgrades)*ygstep); - } - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xIN\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) - 1, - text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist), - x); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xOUTL\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height+1, - text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) + x->x_height+2, - x); - SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %xOUTR\n", - canvas, text_xpix(&x->x_obj, glist)+x->x_width-7, text_ypix(&x->x_obj, glist) + x->x_height+1, - text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist) + x->x_height+2, - x); - - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void pianoroll_draw_move(t_pianoroll *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - // move the grid - { - int gi, gj; - t_float xgstep = x->x_width/x->x_nbsteps; - t_float ygstep = x->x_height/x->x_nbgrades; - for ( gi=0; gix_nbsteps; gi++ ) - { - for ( gj=0; gjx_nbgrades; gj++ ) - { - SYS_VGUI9(".x%x.c coords %xPITCH%.4d%.4d %d %d %d %d\n", - canvas, x, gi, gj, - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep), - text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), - text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep) - ); - SYS_VGUI9(".x%x.c coords %xVOLUME%.4d%.4d %d %d %d %d\n", - canvas, x, gi, gj, - text_xpix(&x->x_obj, glist)+(int)(gi*xgstep)+(int)(2*xgstep/3), - text_ypix(&x->x_obj, glist)+(int)(gj*ygstep), - text_xpix(&x->x_obj, glist)+(int)((gi+1)*xgstep), - text_ypix(&x->x_obj, glist)+(int)((gj+1)*ygstep) - ); - } - } - } - SYS_VGUI7(".x%x.c coords %xIN %d %d %d %d \n", - canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) - 1, - text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) - ); - SYS_VGUI7(".x%x.c coords %xOUTL %d %d %d %d\n", - canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist) + x->x_height+1, - text_xpix(&x->x_obj, glist)+7, text_ypix(&x->x_obj, glist) + x->x_height+2 - ); - SYS_VGUI7(".x%x.c coords %xOUTR %d %d %d %d\n", - canvas, x, text_xpix(&x->x_obj, glist)+x->x_width-7, text_ypix(&x->x_obj, glist) + x->x_height+1, - text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist) + x->x_height+2 - ); - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void pianoroll_draw_erase(t_pianoroll* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int i; - - SYS_VGUI3(".x%x.c delete %xIN\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xOUTL\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xOUTR\n", canvas, x); - // delete the grid - { - int gi, gj; - for ( gi=0; gix_nbsteps; gi++ ) - { - for ( gj=0; gjx_nbgrades; gj++ ) - { - SYS_VGUI5(".x%x.c delete %xPITCH%.4d%.4d\n", canvas, x, gi, gj); - SYS_VGUI5(".x%x.c delete %xVOLUME%.4d%.4d\n", canvas, x, gi, gj); - } - } - } -} - -static void pianoroll_draw_select(t_pianoroll* x,t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if(x->x_selected) - { - pd_bind(&x->x_obj.ob_pd, x->x_name); - /* sets the item in blue */ - } - else - { - pd_unbind(&x->x_obj.ob_pd, x->x_name); - } -} - -/* ------------------------ pianoroll widgetbehaviour----------------------------- */ - - -static void pianoroll_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - t_pianoroll* x = (t_pianoroll*)z; - - *xp1 = text_xpix(&x->x_obj, owner); - *yp1 = text_ypix(&x->x_obj, owner); - *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; - *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; -} - -static void pianoroll_save(t_gobj *z, t_binbuf *b) -{ - t_pianoroll *x = (t_pianoroll *)z; - t_int i; - - // post( "saving pianoroll : %s", x->x_name->s_name ); - binbuf_addv(b, "ssiissiiffiiifi", gensym("#X"),gensym("obj"), - (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_name, x->x_width, x->x_height, - x->x_pmin, x->x_pmax, - x->x_nbgrades, x->x_nbsteps, - x->x_defvalue, x->x_transpose, x->x_save - ); - if ( x->x_save ) - { - for ( i=0; ix_nbsteps; i++ ) - { - binbuf_addv(b, "ff", x->x_peaches[i], x->x_volumes[i] ); - } - } - binbuf_addv(b, ";"); -} - -static void pianoroll_properties(t_gobj *z, t_glist *owner) -{ - char buf[800]; - t_pianoroll *x=(t_pianoroll *)z; - - sprintf(buf, "pdtk_pianoroll_dialog %%s %s %d %d %.2f %.2f %d %d %d %d\n", - x->x_name->s_name, x->x_width, x->x_height, x->x_pmin, x->x_pmax, - x->x_nbgrades, x->x_nbsteps, x->x_defvalue, x->x_save ); - // post("pianoroll_properties : %s", buf ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); -} - -static void pianoroll_select(t_gobj *z, t_glist *glist, int selected) -{ - t_pianoroll *x = (t_pianoroll *)z; - - x->x_selected = selected; - pianoroll_draw_select( x, glist ); -} - -static void pianoroll_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_pianoroll *x = (t_pianoroll *)z; - t_rtext *y; - - // post("pianoroll_vis : %d", vis ); - if (vis) - { - pianoroll_draw_new( x, glist ); - pianoroll_draw_update( x, glist ); - } - else - { - pianoroll_draw_erase( x, glist ); - } -} - -static void pianoroll_dialog(t_pianoroll *x, t_symbol *s, int argc, t_atom *argv) -{ - int si, onbsteps; - t_float *newpeaches, *newvolumes; - - if ( !x ) { - post( "pianoroll : error :tried to set properties on an unexisting object" ); - } - if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) { - post( "pianoroll : error : wrong number of steps or grades" ); - return; - } - if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) { - post( "pianoroll : error : min pitch is >= to max pitch" ); - return; - } - if ( argc != 9 ) - { - post( "pianoroll : error in the number of arguments ( %d )", argc ); - return; - } - if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT || - argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT || - argv[8].a_type != A_FLOAT - ) { - post( "pianoroll : wrong arguments" ); - return; - } - pianoroll_draw_erase(x, x->x_glist); - x->x_name = argv[0].a_w.w_symbol; - x->x_width = (int)argv[1].a_w.w_float; - x->x_height = (int)argv[2].a_w.w_float; - x->x_pmin = argv[3].a_w.w_float; - x->x_pmax = argv[4].a_w.w_float; - x->x_nbgrades = argv[5].a_w.w_float; - onbsteps = x->x_nbsteps; - x->x_nbsteps = argv[6].a_w.w_float; - x->x_defvalue = argv[7].a_w.w_float; - x->x_save = argv[8].a_w.w_float; - - if ( onbsteps != x->x_nbsteps ) - { - int cmindex = ( onbsteps > x->x_nbsteps ) ? x->x_nbsteps : onbsteps; - - newpeaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); - newvolumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); - for ( si=0; six_peaches[si]; - newvolumes[si] = x->x_volumes[si]; - } - freebytes( x->x_peaches, onbsteps*sizeof( t_float ) ); - freebytes( x->x_volumes, onbsteps*sizeof( t_float ) ); - x->x_peaches = newpeaches; - x->x_volumes = newvolumes; - for ( si=onbsteps; six_nbsteps; si++ ) - { - x->x_peaches[si] = x->x_defvalue; - x->x_volumes[si] = 1.0; - } - freebytes( x->x_ipeaches, onbsteps*sizeof( t_int ) ); - freebytes( x->x_ivolumes, onbsteps*sizeof( t_int ) ); - x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); - } - pianoroll_draw_new(x, x->x_glist); - pianoroll_draw_update(x, x->x_glist); -} - -static void pianoroll_delete(t_gobj *z, t_glist *glist) -{ - canvas_deletelinesfor(glist, (t_text *)z); -} - -static void pianoroll_displace(t_gobj *z, t_glist *glist, int dx, int dy) -{ - t_pianoroll *x = (t_pianoroll *)z; - int xold = text_xpix(&x->x_obj, glist); - int yold = text_ypix(&x->x_obj, glist); - - // post( "pianoroll_displace dx=%d dy=%d", dx, dy ); - - x->x_obj.te_xpix += dx; - x->x_obj.te_ypix += dy; - if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix) - { - pianoroll_draw_move(x, x->x_glist); - } -} - -static int pianoroll_click(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) -{ - t_pianoroll* x = (t_pianoroll *)z; - t_canvas *canvas=glist_getcanvas(glist); - - if ( doit) - { - // calculate position to update - { - int si, gi; - t_float xgstep = x->x_width/x->x_nbsteps; - t_float ygstep = x->x_height/x->x_nbgrades; - - si = ( xpix - text_xpix(&x->x_obj, glist) ) / xgstep; - gi = ( ypix - text_ypix(&x->x_obj, glist) ) / ygstep; - - // post( "pianoroll : step : %d : grade : %d", si, gi ); - - if ( ( xpix - text_xpix(&x->x_obj, glist) ) > ( si*xgstep+2*xgstep/3 ) ) - { - { - SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, si, x->x_ivolumes[ si ] ); - } - - x->x_volumes[ si ] = (((float)x->x_nbgrades-1-(float)gi))/(float)(x->x_nbgrades-1); - SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, si, gi); - x->x_ivolumes[ si ] = gi; - } - else - { - { - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, si, x->x_ipeaches[ si ]); - } - - x->x_peaches[ si ] = x->x_pmin+(float)(x->x_nbgrades-1-gi)/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin); - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, si, gi); - x->x_ipeaches[ si ] = gi; - } - } - - } - return (1); -} - -static void pianoroll_transpose(t_pianoroll *x, t_floatarg ftranspose) -{ - x->x_transpose = ftranspose; -} - -static void pianoroll_save_file(t_pianoroll *x, t_symbol *ffile) -{ - FILE *tmph; - t_int si; - - if ( ( tmph = fopen( ffile->s_name, "w" ) ) == NULL ) - { - post( "pianoroll : could not open file : %s for writing", ffile->s_name ); - return; - } - - // post( "saving pianoroll : %s", x->x_name->s_name ); - fprintf(tmph, "%d %d %f %f %d %d %d %f %d ", - x->x_width, x->x_height, - x->x_pmin, x->x_pmax, - x->x_nbgrades, x->x_nbsteps, - x->x_defvalue, x->x_transpose, x->x_save ); - for ( si=0; six_nbsteps; si++ ) - { - fprintf(tmph, "%f %f ", x->x_peaches[si], x->x_volumes[si] ); - } - - if ( fclose( tmph ) == -1 ) - { - post( "pianoroll : could not close file : %s ", ffile->s_name ); - return; - } -} - -static void pianoroll_load(t_pianoroll *x, t_symbol *ffile) -{ - FILE *tmph; - t_int si; - - if ( ( tmph = fopen( ffile->s_name, "r" ) ) == NULL ) - { - post( "pianoroll : could not open file : %s for reading", ffile->s_name ); - return; - } - - pianoroll_draw_erase(x, x->x_glist); - freebytes( x->x_peaches, x->x_nbsteps*sizeof( t_float ) ); - freebytes( x->x_volumes, x->x_nbsteps*sizeof( t_float ) ); - freebytes( x->x_ipeaches, x->x_nbsteps*sizeof( t_int ) ); - freebytes( x->x_ivolumes, x->x_nbsteps*sizeof( t_int ) ); - - if ( fscanf(tmph, "%d %d %f %f %d %d %d %f %d", - &x->x_width, &x->x_height, - &x->x_pmin, &x->x_pmax, - &x->x_nbgrades, &x->x_nbsteps, - &x->x_defvalue, &x->x_transpose, &x->x_save ) != 9 ) - { - post( "pianoroll : could not restore data from file : %s", ffile->s_name ); - return; - } - - x->x_peaches = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_volumes = ( t_float* ) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_ipeaches = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_ivolumes = ( t_int* ) getbytes( x->x_nbsteps*sizeof(t_int) ); - for ( si=0; six_nbsteps ; si++ ) - { - fscanf( tmph, "%f", &x->x_peaches[si] ); - fscanf( tmph, "%f", &x->x_volumes[si] ); - } - - pianoroll_draw_new(x, x->x_glist); - pianoroll_draw_update(x, x->x_glist); - - if ( fclose( tmph ) == -1 ) - { - post( "pianoroll : could not close file : %s ", ffile->s_name ); - return; - } -} - -static void pianoroll_init(t_pianoroll *x) -{ - t_int si; - - for ( si=0; six_nbsteps; si++ ) - { - x->x_peaches[si] = x->x_defvalue; - x->x_volumes[si] = 1.0; - } - pianoroll_draw_erase(x, x->x_glist ); - pianoroll_draw_new(x, x->x_glist ); - pianoroll_draw_update(x, x->x_glist ); -} - -static void pianoroll_pitch(t_pianoroll *x, t_floatarg fpos, t_floatarg fpitch) -{ - t_canvas *canvas=glist_getcanvas(x->x_glist); - t_int ipos; - - if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) ) - { - post( "pianoroll : wrong pitch position : %d", fpos ); - return; - } - ipos = (t_int) fpos; - if ( ( ( (t_int) fpitch ) < x->x_pmin ) || ( ( (t_int) fpitch ) > x->x_pmax ) ) - { - post( "pianoroll : wrong pitch value : %d", fpitch ); - return; - } - - { - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #761623\n", canvas, x, ipos, x->x_ipeaches[ ipos ]); - - x->x_ipeaches[ ipos ] = (t_int) ( ( ( x->x_pmax - fpitch ) / ( x->x_pmax - x->x_pmin ) ) * ( x->x_nbgrades - 1 ) ); - x->x_peaches[ ipos ] = x->x_pmin+(float)(x->x_nbgrades-1-x->x_ipeaches[ ipos ])/(float)(x->x_nbgrades-1)*(float)(x->x_pmax-x->x_pmin); - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, ipos, x->x_ipeaches[ ipos ]); - } -} - -static void pianoroll_volume(t_pianoroll *x, t_floatarg fpos, t_floatarg fvol) -{ - t_canvas *canvas=glist_getcanvas(x->x_glist); - t_int ipos; - - if ( ( ( (t_int) fpos ) < 0 ) || ( ( (t_int) fpos ) >= x->x_nbsteps ) ) - { - post( "pianoroll : wrong volume position : %d", fpos ); - return; - } - ipos = (t_int) fpos; - if ( ( ( (t_int) fvol ) < 0.0 ) || ( ( (t_int) fvol ) > 1.0 ) ) - { - post( "pianoroll : wrong volume value : %d", fvol ); - return; - } - - { - SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #562663\n", canvas, x, ipos, x->x_ivolumes[ ipos ] ); - - x->x_ivolumes[ ipos ] = (t_int) ( ( 1 - fvol ) * (x->x_nbgrades-1) ); - x->x_volumes[ ipos ] = (((float)x->x_nbgrades-1-(float)x->x_ivolumes[ ipos ]))/(float)(x->x_nbgrades-1); - SYS_VGUI5(".x%x.c itemconfigure %xVOLUME%.4d%.4d -fill #FF0000\n", canvas, x, ipos, x->x_ivolumes[ ipos ] ); - } -} - -static void pianoroll_float(t_pianoroll *x, t_floatarg fposition) -{ - t_int pposition, rposition, rrposition; - t_float fpart; - t_int pi; - t_canvas *canvas; - - pposition = ( (int)fposition - 1 ) % x->x_nbsteps; - if ( pposition < 0 ) pposition += x->x_nbsteps; - rposition = ( (int)fposition ) % x->x_nbsteps; - if ( rposition < 0 ) rposition += x->x_nbsteps; - rrposition = ( (int)fposition +1 ) % x->x_nbsteps; - if ( rrposition < 0 ) rrposition += x->x_nbsteps; - - // post ( "pposition=%d rposition=%d rrposition=%d", pposition, rposition, rrposition ); - fpart = fposition - (int)fposition; - pi=-1; - canvas=glist_getcanvas(x->x_glist); - - outlet_float( x->x_pitch, x->x_peaches[ rposition ] + - fpart*(x->x_peaches[ rrposition ] - x->x_peaches[ rposition ] ) + - x->x_transpose ); - outlet_float( x->x_volume, x->x_volumes[ rposition ] + - fpart*(x->x_volumes[ rrposition ] - x->x_volumes[ rposition ] ) ); - - // graphical update - { - if ( x->x_scurrent != -1 ) - { - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #FFFF00\n", canvas, x, - x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]); - } - x->x_scurrent = rposition; - SYS_VGUI5(".x%x.c itemconfigure %xPITCH%.4d%.4d -fill #00FF00\n", canvas, x, - x->x_scurrent, x->x_ipeaches[ x->x_scurrent ]); - } -} - -static t_pianoroll *pianoroll_new(t_symbol *s, int argc, t_atom *argv) -{ - int si, i, zz; - t_pianoroll *x; - t_pd *x2; - char *str; - - // post( "pianoroll_new : create : %s argc =%d", s->s_name, argc ); - - x = (t_pianoroll *)pd_new(pianoroll_class); - // new pianoroll created from the gui - if ( argc != 0 ) - { - if ( argc < 10 ) - { - post( "pianoroll : error in the number of arguments ( %d )", argc ); - return NULL; - } - if ( ( argv[5].a_w.w_float <= 0 ) || ( argv[5].a_w.w_float <= 0 ) ) { - post( "pianoroll : error : wrong number of steps or grades" ); - return NULL; - } - if ( ( argv[3].a_w.w_float >= argv[4].a_w.w_float ) ) { - post( "pianoroll : error : min pitch is > to max pitch" ); - return NULL; - } - if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT || - argv[6].a_type != A_FLOAT || argv[7].a_type != A_FLOAT || - argv[8].a_type != A_FLOAT || argv[9].a_type != A_FLOAT ) { - post( "pianoroll : wrong arguments" ); - return NULL; - } - - // update pianoroll count - if (!strncmp((str = argv[0].a_w.w_symbol->s_name), "pianoroll", 9) - && (zz = atoi(str + 9)) > pianorollcount) - { - // post( "pianoroll : already %d objects", pianorollcount ); - pianorollcount = zz; - } - x->x_name = argv[0].a_w.w_symbol; - pd_bind(&x->x_obj.ob_pd, x->x_name); - x->x_width = argv[1].a_w.w_float; - x->x_height = argv[2].a_w.w_float; - x->x_pmin = argv[3].a_w.w_float; - x->x_pmax = argv[4].a_w.w_float; - x->x_nbgrades = argv[5].a_w.w_float; - x->x_nbsteps = argv[6].a_w.w_float; - x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_defvalue = argv[7].a_w.w_float; - x->x_transpose = argv[8].a_w.w_float; - x->x_save = argv[9].a_w.w_float; - } - else - { - char buf[40]; - - sprintf(buf, "pianoroll%d", ++pianorollcount); - s = gensym(buf); - - x->x_name = s; - pd_bind(&x->x_obj.ob_pd, x->x_name); - - x->x_width = DEFAULT_SEQUENCER_WIDTH; - x->x_height = DEFAULT_SEQUENCER_HEIGHT; - x->x_pmin = DEFAULT_SEQUENCER_PITCH_MIN; - x->x_pmax = DEFAULT_SEQUENCER_PITCH_MAX; - x->x_nbgrades = DEFAULT_SEQUENCER_NBGRADES; - x->x_nbsteps = DEFAULT_SEQUENCER_STEPS; - x->x_peaches = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_ipeaches = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_volumes = (t_float*) getbytes( x->x_nbsteps*sizeof(t_float) ); - x->x_ivolumes = (t_int*) getbytes( x->x_nbsteps*sizeof(t_int) ); - x->x_defvalue = 0; - x->x_transpose = 0; - x->x_save = 1; - - } - - // common fields for new and restored pianorolls - x->x_selected = 0; - x->x_scurrent = -1; - x->x_glist = (t_glist *) canvas_getcurrent(); - x->x_pitch = outlet_new(&x->x_obj, &s_float ); - x->x_volume = outlet_new(&x->x_obj, &s_float ); - // post( "pianoroll : argc : %d", argc ); - if ( ( argc != 0 ) && ( x->x_save ) ) - { - int ai = 10; - int si = 0; - - while ( ai < argc ) - { - x->x_peaches[si] = argv[ai++].a_w.w_float; - if ( ai >= argc ) break; - x->x_volumes[si++] = argv[ai++].a_w.w_float; - } - } - else // following arguments are the values of pitch, volumes - { - for ( si=0; six_nbsteps; si++ ) - { - x->x_peaches[si] = x->x_defvalue; - x->x_volumes[si] = 1.0; - } - } - - // post( "pianoroll_new name : %s width: %d height : %d", x->x_name->s_name, x->x_width, x->x_height ); - - return (x); -} - -static void pianoroll_free(t_pianoroll *x) -{ - // post( "pianoroll~: pianoroll_free" ); - if ( x->x_peaches ) - { - freebytes( x->x_peaches, x->x_nbsteps*sizeof(t_float) ); - } - if ( x->x_ipeaches ) - { - freebytes( x->x_ipeaches, x->x_nbsteps*sizeof(t_int) ); - } - if ( x->x_volumes ) - { - freebytes( x->x_volumes, x->x_nbsteps*sizeof(t_float) ); - } - if ( x->x_ivolumes ) - { - freebytes( x->x_ivolumes, x->x_nbsteps*sizeof(t_int) ); - } -} - -void pianoroll_setup(void) -{ - post( pianoroll_version ); -#include "pianoroll.tk2c" - pianoroll_class = class_new(gensym("pianoroll"), (t_newmethod)pianoroll_new, - (t_method)pianoroll_free, sizeof(t_pianoroll), 0, A_GIMME, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_float, &s_float, A_FLOAT, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_transpose, gensym("transpose"), - A_FLOAT, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_init, gensym("init"), 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_save_file, gensym("save"), A_SYMBOL, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_load, gensym("load"), A_SYMBOL, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_pitch, gensym("pitch"), A_FLOAT, A_FLOAT, 0); - class_addmethod(pianoroll_class, (t_method)pianoroll_volume, gensym("volume"), A_FLOAT, A_FLOAT, 0); - - - pianoroll_widgetbehavior.w_getrectfn = pianoroll_getrect; - pianoroll_widgetbehavior.w_displacefn = pianoroll_displace; - pianoroll_widgetbehavior.w_selectfn = pianoroll_select; - pianoroll_widgetbehavior.w_activatefn = NULL; - pianoroll_widgetbehavior.w_deletefn = pianoroll_delete; - pianoroll_widgetbehavior.w_visfn = pianoroll_vis; - pianoroll_widgetbehavior.w_clickfn = pianoroll_click; - -#if PD_MINOR_VERSION >= 37 - class_setpropertiesfn(pianoroll_class, pianoroll_properties); - class_setsavefn(pianoroll_class, pianoroll_save); -#else - pianoroll_widgetbehavior.w_propertiesfn = pianoroll_properties; - pianoroll_widgetbehavior.w_savefn = pianoroll_save; -#endif - - class_setwidget(pianoroll_class, &pianoroll_widgetbehavior); - -} diff --git a/externals/unauthorized/pianoroll/pianoroll.tk2c b/externals/unauthorized/pianoroll/pianoroll.tk2c deleted file mode 100755 index a857b9aacfb5ce8c3863d0671b60e282043ebb4a..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/pianoroll.tk2c +++ /dev/null @@ -1,131 +0,0 @@ -// ########### pianoroll procedures -- ydegoyon@free.fr ######### -sys_gui("proc pianoroll_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_name [concat graph_name_$vid]\n"); -sys_gui("global $var_graph_name\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_pmin [concat graph_pmin_$vid]\n"); -sys_gui("global $var_graph_pmin\n"); -sys_gui("set var_graph_pmax [concat graph_pmax_$vid]\n"); -sys_gui("global $var_graph_pmax\n"); -sys_gui("set var_graph_nbgrades [concat graph_nbgrades_$vid]\n"); -sys_gui("global $var_graph_nbgrades\n"); -sys_gui("set var_graph_nbsteps [concat graph_nbsteps_$vid]\n"); -sys_gui("global $var_graph_nbsteps\n"); -sys_gui("set var_graph_defvalue [concat graph_defvalue_$vid]\n"); -sys_gui("global $var_graph_defvalue\n"); -sys_gui("set var_graph_save [concat graph_save_$vid]\n"); -sys_gui("global $var_graph_save\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_name] [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_pmin] [eval concat $$var_graph_pmax] [eval concat $$var_graph_nbgrades] [eval concat $$var_graph_nbsteps] [eval concat $$var_graph_defvalue] [eval concat $$var_graph_save] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc pianoroll_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc pianoroll_ok {id} {\n"); -sys_gui("pianoroll_apply $id\n"); -sys_gui("pianoroll_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_pianoroll_dialog {id name width height pmin pmax nbgrades nbsteps defvalue save } {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_name [concat graph_name_$vid]\n"); -sys_gui("global $var_graph_name\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height_$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_pmin [concat graph_pmin_$vid]\n"); -sys_gui("global $var_graph_pmin\n"); -sys_gui("set var_graph_pmax [concat graph_pmax_$vid]\n"); -sys_gui("global $var_graph_pmax\n"); -sys_gui("set var_graph_nbgrades [concat graph_nbgrades_$vid]\n"); -sys_gui("global $var_graph_nbgrades\n"); -sys_gui("set var_graph_nbsteps [concat graph_nbsteps_$vid]\n"); -sys_gui("global $var_graph_nbsteps\n"); -sys_gui("set var_graph_defvalue [concat graph_defvalue_$vid]\n"); -sys_gui("global $var_graph_defvalue\n"); -sys_gui("set var_graph_save [concat graph_save_$vid]\n"); -sys_gui("global $var_graph_save\n"); -sys_gui("set $var_graph_name $name\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_pmin $pmin\n"); -sys_gui("set $var_graph_pmax $pmax\n"); -sys_gui("set $var_graph_nbgrades $nbgrades\n"); -sys_gui("set $var_graph_nbsteps $nbsteps\n"); -sys_gui("set $var_graph_defvalue $defvalue\n"); -sys_gui("set $var_graph_save $save\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {pianoroll}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat pianoroll_cancel $id]\n"); -sys_gui("label $id.label -text {PIANOROLL PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"pianoroll_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"pianoroll_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"pianoroll_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lname -text \"Name :\"\n"); -sys_gui("entry $id.1rangef.name -textvariable $var_graph_name -width 15\n"); -sys_gui("pack $id.1rangef.lname $id.1rangef.name -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.2rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.2rangef.lwidth $id.2rangef.width -side left\n"); -sys_gui("frame $id.3rangef\n"); -sys_gui("pack $id.3rangef -side top\n"); -sys_gui("label $id.3rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.3rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.3rangef.lheight $id.3rangef.height -side left\n"); -sys_gui("frame $id.4rangef\n"); -sys_gui("pack $id.4rangef -side top\n"); -sys_gui("label $id.4rangef.lpmin -text \"Pitch low :\"\n"); -sys_gui("entry $id.4rangef.pmin -textvariable $var_graph_pmin -width 7\n"); -sys_gui("pack $id.4rangef.lpmin $id.4rangef.pmin -side left\n"); -sys_gui("frame $id.5rangef\n"); -sys_gui("pack $id.5rangef -side top\n"); -sys_gui("label $id.5rangef.lpmax -text \"Pitch high :\"\n"); -sys_gui("entry $id.5rangef.pmax -textvariable $var_graph_pmax -width 7\n"); -sys_gui("pack $id.5rangef.lpmax $id.5rangef.pmax -side left\n"); -sys_gui("frame $id.6rangef\n"); -sys_gui("pack $id.6rangef -side top\n"); -sys_gui("label $id.6rangef.lnbgrades -text \"Grades :\"\n"); -sys_gui("entry $id.6rangef.nbgrades -textvariable $var_graph_nbgrades -width 7\n"); -sys_gui("pack $id.6rangef.lnbgrades $id.6rangef.nbgrades -side left\n"); -sys_gui("frame $id.7rangef\n"); -sys_gui("pack $id.7rangef -side top\n"); -sys_gui("label $id.7rangef.lnbsteps -text \"Steps :\"\n"); -sys_gui("entry $id.7rangef.nbsteps -textvariable $var_graph_nbsteps -width 7\n"); -sys_gui("pack $id.7rangef.lnbsteps $id.7rangef.nbsteps -side left\n"); -sys_gui("frame $id.8rangef\n"); -sys_gui("pack $id.8rangef -side top\n"); -sys_gui("label $id.8rangef.ldefvalue -text \"Default Value :\"\n"); -sys_gui("entry $id.8rangef.defvalue -textvariable $var_graph_defvalue -width 7\n"); -sys_gui("pack $id.8rangef.ldefvalue $id.8rangef.defvalue -side left\n"); -sys_gui("checkbutton $id.save -text {Save contents} -variable $var_graph_save -anchor w\n"); -sys_gui("pack $id.save -side top\n"); -sys_gui("bind $id.1rangef.name [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.2rangef.width [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.3rangef.height [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.4rangef.pmin [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.5rangef.pmax [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.6rangef.nbgrades [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.7rangef.nbsteps [concat pianoroll_ok $id]\n"); -sys_gui("bind $id.8rangef.defvalue [concat pianoroll_ok $id]\n"); -sys_gui("focus $id.1rangef.name\n"); -sys_gui("}\n"); -// ########### pianoroll procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/pianoroll/tk2c.bash b/externals/unauthorized/pianoroll/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/pianoroll/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/playlist/playlist-help.pd b/externals/unauthorized/playlist-help.pd similarity index 92% rename from externals/unauthorized/playlist/playlist-help.pd rename to externals/unauthorized/playlist-help.pd index b035bc32260b4b33c8dabe255b08642624adea71..db2502ca7d649a46da88d7f64aec4a9abed9b776 100644 --- a/externals/unauthorized/playlist/playlist-help.pd +++ b/externals/unauthorized/playlist-help.pd @@ -30,7 +30,6 @@ red; #X obj 395 107 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X text 499 110 Use alphabetical or creation time order; -#X obj 87 140 loadbang; #X text 628 136 Change the font; #X msg 300 136 font Helvetica normal 14; #X msg 478 136 font Courier bold 24; @@ -53,12 +52,11 @@ red; #X connect 25 0 9 0; #X connect 26 0 9 0; #X connect 27 0 26 0; -#X connect 29 0 20 0; +#X connect 30 0 9 0; #X connect 31 0 9 0; #X connect 32 0 9 0; #X connect 33 0 9 0; -#X connect 34 0 9 0; -#X connect 36 0 37 0; -#X connect 37 0 9 0; -#X connect 39 0 36 0; -#X connect 40 0 39 0; +#X connect 35 0 36 0; +#X connect 36 0 9 0; +#X connect 38 0 35 0; +#X connect 39 0 38 0; diff --git a/externals/unauthorized/playlist.c b/externals/unauthorized/playlist.c new file mode 100644 index 0000000000000000000000000000000000000000..f663152b09f8ace73d760d33d292aa7ca392c1bd --- /dev/null +++ b/externals/unauthorized/playlist.c @@ -0,0 +1,1005 @@ +/*------------------------ playlist~ ------------------------------------------ */ +/* */ +/* playlist~ : lets you choose a file with 1 click */ +/* or by sending a 'seek #' message */ +/* constructor : playlist */ +/* */ +/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* "If a man's made of blood and iron" */ +/* "Doctor, doctor, what's in my chest ????" */ +/* Gang Of Four -- Guns Before Butter */ +/* ---------------------------------------------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "m_pd.h" +#include "m_imp.h" +#include "g_canvas.h" +#include + +#ifdef _WIN32 +#include +#include +#include + +int scandir(const char *dir, struct dirent ***namelist, + int (*select)(const struct dirent *), + int (*compar)(const struct dirent **, const struct dirent **)) +{ + DIR *d; + struct dirent *entry; + register int i=0; + size_t entrysize; + + if ((d=opendir(dir)) == NULL) + return(-1); + + *namelist=NULL; + while ((entry=readdir(d)) != NULL) + { + if (select == NULL || (select != NULL && (*select)(entry))) + { + *namelist=(struct dirent **)realloc((void *)(*namelist), + (size_t)((i+1)*sizeof(struct dirent *))); + if (*namelist == NULL) return(-1); + entrysize=sizeof(struct dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1; + (*namelist)[i]=(struct dirent *)malloc(entrysize); + if ((*namelist)[i] == NULL) return(-1); + memcpy((*namelist)[i], entry, entrysize); + i++; + } + } + if (closedir(d)) return(-1); + if (i == 0) return(-1); + if (compar != NULL) + qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar); + + return(i); +} + +int alphasort(const struct dirent **a, const struct dirent **b) +{ + return(strcmp((*a)->d_name, (*b)->d_name)); +} + +int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); +int alphasort(const struct dirent **, const struct dirent **); + +#else +#include +#endif + +t_widgetbehavior playlist_widgetbehavior; +static t_class *playlist_class; + +static char *playlist_version = "playlist: 1 click file chooser : version 0.12, written by Yves Degoyon (ydegoyon@free.fr)"; + +#define MIN(a,b) (a>b?b:a) + +typedef struct _playlist +{ + t_object x_obj; + t_glist *x_glist; + t_outlet *x_fullpath; + t_outlet *x_file; + t_outlet *x_dir; + char *x_extension; /* extension to selected files */ + t_int x_height; /* height of the playlist */ + t_int x_width; /* width of the playlist */ + t_int x_itemselected; /* index of the selected item */ + t_int x_selected; /* stores selected state */ + t_int x_graphics; /* flag to draw graphics or not */ + char **x_dentries; /* directory entries */ + t_int x_nentries; /* number of entries in the current dir */ + t_int x_pnentries; /* previous size of entries list */ + t_int x_firstseen; /* first displayed entry */ + t_int x_lastseen; /* last displayed entry */ + t_int x_cdy; /* cumulated y drag */ + t_int x_sort; /* sorting option flag */ + char x_curdir[MAXPDSTRING];/* current directory informations */ + char *x_font; /* font used for entries */ + t_int x_charheight; /* height of characters */ + t_int x_charwidth; /* width of characters */ + char *x_bgcolor; /* background color */ + char *x_sbcolor; /* scrollbar color */ + char *x_fgcolor; /* foreground color */ + char *x_secolor; /* selection color */ +} t_playlist; + + +static void playlist_update_dir(t_playlist *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int i; + char wrappedname[ MAXPDSTRING ]; + struct timespec tv; + + tv.tv_sec = 0; + tv.tv_nsec = 10000000; + + // set title + sys_vgui(".x%lx.c delete %xTITLE\n", canvas, x); + if ( x->x_graphics ) + { + sys_vgui(".x%lx.c create text %d %d -width %d -text \"%s\" -anchor w -font {%s} -tags %xTITLE\n", + canvas, + text_xpix(&x->x_obj, glist)+5, + text_ypix(&x->x_obj, glist)-10, + x->x_width, + x->x_curdir, + x->x_font, + x ); + } + + // delete previous entries + for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) + { + sys_vgui(".x%lx.c delete %xENTRY%d\n", canvas, x, i); + } + + // display the content of current directory + { + t_int nentries, i; + struct dirent** dentries; /* all directory entries */ + + // post( "playlist : scandir : %s", x->x_curdir ); + if ( ( nentries = scandir(x->x_curdir, &dentries, NULL, (x->x_sort==1)?alphasort:NULL ) ) == -1 ) + { + pd_error(x, "playlist : could not scan current directory ( where the hell are you ??? )" ); + perror( "scandir" ); + return; + } + + x->x_firstseen = 0; + if ( x->x_dentries ) + { + for ( i=0; ix_nentries; i++ ) + { + // post( "playlist : freeing entry %d size=%d : %s", i, strlen( x->x_dentries[i] ) + 1, x->x_dentries[i] ); + freebytes( x->x_dentries[i], strlen( x->x_dentries[i] ) + 1 ); + } + } + if ( x->x_pnentries != -1 ) + { + freebytes( x->x_dentries, x->x_pnentries*sizeof(char**) ); + } + + x->x_nentries = 0; + // post( "playlist : allocating dentries %d", nentries ); + x->x_dentries = (char **) getbytes( nentries*sizeof(char**) ) ; + x->x_pnentries = nentries; + for ( i=0; id_name ) ) != NULL ) ) || + ( strstr( dentries[i]->d_name, x->x_extension ) ) || + ( !strcmp( x->x_extension, "all" ) ) + ) + { + // close temporarily opened dir + if ( tmpdir ) + { + if ( closedir( tmpdir ) < 0 ) + { + post( "playlist : could not close directory %s", dentries[i]->d_name ); + } + } + + // post( "playlist : allocating entry %d %d : %s", x->x_nentries, strlen( dentries[i]->d_name ) + 1, dentries[i]->d_name ); + x->x_dentries[x->x_nentries] = ( char * ) getbytes( strlen( dentries[i]->d_name ) + 1 ); + strcpy( x->x_dentries[x->x_nentries], dentries[i]->d_name ); + + // display the entry if displayable + if ( x->x_nentries*x->x_charheight+5 < x->x_height ) + { + // nanosleep( &tv, NULL ); + x->x_lastseen = x->x_nentries; + strncpy( wrappedname, x->x_dentries[x->x_nentries], MIN(x->x_width/x->x_charwidth, MAXPDSTRING) ); + wrappedname[ x->x_width/x->x_charwidth ] = '\0'; + sys_vgui(".x%lx.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" -anchor w -font {%s} -tags %xENTRY%d\n", + canvas, + text_xpix(&x->x_obj, glist)+5, + text_ypix(&x->x_obj, glist)+5+(x->x_nentries-x->x_firstseen)*x->x_charheight, + x->x_fgcolor, + x->x_secolor, + x->x_width, + wrappedname, + x->x_font, + x, x->x_nentries ); + } + x->x_nentries++; + } + + } + + } +} + +static void playlist_output_current(t_playlist* x) +{ + // output the selected dir+file + // check that it's not a directory + if ( chdir( x->x_dentries[x->x_itemselected] ) == 0 ) + { + chdir( x->x_curdir ); + return; + } + + if ( x->x_dentries && x->x_itemselected < x->x_nentries && x->x_itemselected >= 0 ) + { + char* tmpstring = (char*) getbytes( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected]) + 2 ); + + sprintf( tmpstring, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); + outlet_symbol( x->x_dir, gensym( x->x_curdir ) ); + outlet_symbol( x->x_file, gensym( x->x_dentries[x->x_itemselected] ) ); + outlet_symbol( x->x_fullpath, gensym( tmpstring ) ); + freebytes( tmpstring, strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected]) + 2 ); + } +} + +static void playlist_sort(t_playlist* x, t_floatarg fsort) +{ + if ( ( (t_int)fsort != 0 ) && ( (t_int)fsort != 1 ) ) + { + post( "playlist : wrong argument to playlist message : %d", (t_int)fsort ); + return; + } + + x->x_sort = (t_int) fsort; + playlist_update_dir( x, x->x_glist ); +} + +static void playlist_font(t_playlist* x, t_symbol *fname, t_symbol *fcase, t_floatarg fsize) +{ + if ( (t_int)fsize <= 4 ) + { + post( "playlist : wrong font size in font message : %d", (t_int)fsize ); + return; + } + sprintf( x->x_font, "{%s %d %s}", fname->s_name, (int)fsize, fcase->s_name ); + x->x_charheight = (t_int)fsize; + x->x_charwidth = (2*x->x_charheight)/3; + post( "playlist : setting font to : %s", x->x_font ); + playlist_update_dir( x, x->x_glist ); +} + +static void playlist_draw_new(t_playlist *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + x->x_glist = glist; + if ( x->x_graphics ) + { + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xPLAYLIST\n", + canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, + x->x_bgcolor, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xSCROLLLIST\n", + canvas, text_xpix(&x->x_obj, glist)+4*x->x_width/5, text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, + x->x_sbcolor, x); + } + playlist_update_dir( x, glist ); + +} + +static void playlist_draw_move(t_playlist *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int i; + struct timespec tv; + + tv.tv_sec = 0; + tv.tv_nsec = 10000000; + + if ( x->x_graphics ) + { + sys_vgui(".x%lx.c coords %xPLAYLIST %d %d %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist)+x->x_width, + text_ypix(&x->x_obj, glist)+x->x_height); + sys_vgui(".x%lx.c coords %xSCROLLLIST %d %d %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist)+4*x->x_width/5, text_ypix(&x->x_obj, glist), + text_xpix(&x->x_obj, glist)+x->x_width, + text_ypix(&x->x_obj, glist)+x->x_height); + sys_vgui(".x%lx.c coords %xTITLE %d %d\n", + canvas, x, + text_xpix(&x->x_obj, glist)+5, text_ypix(&x->x_obj, glist)-10 ); + } + for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) + { + // nanosleep( &tv, NULL ); + sys_vgui(".x%lx.c coords %xENTRY%d %d %d\n", + canvas, x, i, + text_xpix(&x->x_obj, glist)+5, + text_ypix(&x->x_obj, glist)+5+(i-x->x_firstseen)*x->x_charheight); + } + + canvas_fixlinesfor( canvas, (t_text*)x ); +} + +static void playlist_draw_erase(t_playlist* x, t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + t_int i; + + if ( x->x_graphics ) + { + sys_vgui(".x%lx.c delete %xPLAYLIST\n", canvas, x); + sys_vgui(".x%lx.c delete %xSCROLLLIST\n", canvas, x); + sys_vgui(".x%lx.c delete %xTITLE\n", canvas, x); + } + for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) + { + sys_vgui(".x%lx.c delete %xENTRY%d\n", canvas, x, i); + } +} + +static void playlist_draw_select(t_playlist* x, t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + // post( "playlist : select" ); + if(x->x_selected) + { + /* sets the item in blue */ + if (x->x_graphics) sys_vgui(".x%lx.c itemconfigure %xPLAYLIST -outline #0000FF\n", canvas, x); + } + else + { + if (x->x_graphics) sys_vgui(".x%lx.c itemconfigure %xPLAYLIST -outline #000000\n", canvas, x); + } +} + +/* ------------------------ playlist widgetbehaviour----------------------------- */ + + +static void playlist_getrect(t_gobj *z, t_glist *owner, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_playlist* x = (t_playlist*)z; + + *xp1 = text_xpix(&x->x_obj, owner); + *yp1 = text_ypix(&x->x_obj, owner); + *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; + *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; +} + +static void playlist_save(t_gobj *z, t_binbuf *b) +{ + t_playlist *x = (t_playlist *)z; + + // post( "saving playlist : %s", x->x_extension ); + binbuf_addv(b, "ssiissiisssss", gensym("#X"), gensym("obj"), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, + gensym("playlist"), gensym(x->x_extension), x->x_width, x->x_height, + gensym(x->x_font), gensym(x->x_bgcolor), gensym(x->x_sbcolor), + gensym(x->x_fgcolor), gensym(x->x_secolor) ); + binbuf_addv(b, ";"); +} + +static void playlist_select(t_gobj *z, t_glist *glist, int selected) +{ + t_playlist *x = (t_playlist *)z; + + x->x_selected = selected; + + playlist_draw_select( x, glist ); +} + +static void playlist_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_playlist *x = (t_playlist *)z; + + x->x_glist = glist; + if (vis) + { + playlist_draw_new( x, glist ); + } + else + { + playlist_draw_erase( x, glist ); + } +} + +static void playlist_delete(t_gobj *z, t_glist *glist) +{ + canvas_deletelinesfor(glist, (t_text *)z); +} + +static void playlist_displace(t_gobj *z, t_glist *glist, int dx, int dy) +{ + t_playlist *x = (t_playlist *)z; + t_int xold = text_xpix(&x->x_obj, glist); + t_int yold = text_ypix(&x->x_obj, glist); + + // post( "playlist_displace dx=%d dy=%d", dx, dy ); + + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; + if(xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist)) + { + playlist_draw_move(x, glist); + } +} + +static void playlist_motion(t_playlist *x, t_floatarg dx, t_floatarg dy) +{ + t_int i; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + x->x_cdy+=dy; + + // check if we need to scroll + if ( ( x->x_lastseen < x->x_nentries ) ) + { + // eventually, move down + if ( x->x_cdy >= x->x_charheight ) + { + x->x_cdy = 0; + if ( x->x_firstseen < x->x_nentries - ( x->x_height/x->x_charheight ) ) + { + if ( x->x_firstseen + 1 < x->x_nentries ) + { + for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) + { + sys_vgui(".x%lx.c delete %xENTRY%d\n", canvas, x, i); + } + x->x_firstseen++; + for ( i=x->x_firstseen; i< x->x_nentries; i++ ) + { + char *wrappedname = (char *) getbytes( x->x_width ); + + if ( (i-x->x_firstseen)*x->x_charheight < x->x_height ) + { + x->x_lastseen = i; + strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); + wrappedname[ x->x_width/x->x_charwidth ] = '\0'; + sys_vgui(".x%lx.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" -anchor w -font {%s} -tags %xENTRY%d\n", + canvas, + text_xpix(&x->x_obj, x->x_glist)+5, + text_ypix(&x->x_obj, x->x_glist)+5+(i-x->x_firstseen)*x->x_charheight, + x->x_fgcolor, + x->x_secolor, + x->x_width, + wrappedname, + x->x_font, + x, i ); + } + else break; + } + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", + canvas, x, x->x_itemselected, x->x_secolor); + // post( "playlist : moved down first=%d last=%d", x->x_firstseen, x->x_lastseen ); + } + } + } + // eventually, move up + if ( x->x_cdy <= -x->x_charheight ) + { + x->x_cdy = 0; + if ( x->x_lastseen >= ( x->x_height/x->x_charheight ) ) + { + if ( x->x_firstseen - 1 >= 0 ) + { + for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) + { + sys_vgui(".x%lx.c delete %xENTRY%d\n", canvas, x, i); + } + x->x_firstseen--; + for ( i=x->x_firstseen; i< x->x_nentries; i++ ) + { + char *wrappedname = (char *) getbytes( x->x_width ); + + if ( (i-x->x_firstseen)*x->x_charheight < x->x_height ) + { + x->x_lastseen = i; + strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); + wrappedname[ x->x_width/x->x_charwidth ] = '\0'; + sys_vgui(".x%lx.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" \ + -anchor w -font {%s} -tags %xENTRY%d\n", + canvas, + text_xpix(&x->x_obj, x->x_glist)+5, + text_ypix(&x->x_obj, x->x_glist)+5+(i-x->x_firstseen)*x->x_charheight, + x->x_fgcolor, + x->x_secolor, + x->x_width, + wrappedname, + x->x_font, + x, i ); + } + else break; + } + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", + canvas, x, x->x_itemselected, x->x_secolor); + // post( "playlist : moved up first=%d last=%d", x->x_firstseen, x->x_lastseen ); + } + } + } + } // scroll test +} + +static void playlist_scroll(t_playlist *x, t_floatarg fdy) +{ + t_int nbsteps, si; + + nbsteps = (t_int)abs(fdy/x->x_charheight); + // post( "playlist : iterations %d", nbsteps ); + + for (si=0; six_charheight); + } +} + +static void playlist_graphics(t_playlist *x, t_floatarg fgraphics) +{ + if ( ( (t_int)fgraphics == 0 ) || ( (t_int)fgraphics == 1 ) ) + { + playlist_draw_erase(x, x->x_glist); + x->x_graphics = (t_int) fgraphics; + playlist_draw_new(x, x->x_glist); + } +} + +static int playlist_click(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_playlist* x = (t_playlist *)z; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if (doit) + { + // leave a margin for scrolling without selection + if ( (xpix-text_xpix(&x->x_obj, glist)) < 4*x->x_width/5 ) + { + // deselect previously selected item + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", + canvas, x, x->x_itemselected, x->x_fgcolor); + x->x_itemselected = x->x_firstseen + (ypix-text_ypix(&x->x_obj, glist))/x->x_charheight; + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", + canvas, x, x->x_itemselected, x->x_secolor); + // post( "playlist : selected item : %d", x->x_itemselected ); + if ( x->x_dentries && ( x->x_itemselected < x->x_nentries ) ) + { + char *tmpstring = (char *) getbytes( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected] ) + 2 ); + sprintf( tmpstring, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); + // post( "playlist : chdir : %s", tmpstring ); + if ( chdir( tmpstring ) < 0 ) + { + playlist_output_current(x); + } + else + { + if ( !strcmp( x->x_dentries[ x->x_itemselected ], ".." ) ) + { + char *iamthelastslash; + + iamthelastslash = strrchr( x->x_curdir, '/' ); + *iamthelastslash = '\0'; + + if ( !strcmp( x->x_curdir, "" ) ) + { + strcpy( x->x_curdir, "/" ); + } + } + else if ( !strcmp( x->x_dentries[ x->x_itemselected ], "." ) ) + { + // nothing + } + else + { + if ( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected] ) + 2 > MAXPDSTRING ) + { + pd_error(x, "playlist : maximum dir length reached : cannot change directory" ); + return -1; + } + if ( strcmp( x->x_curdir, "/" ) ) + { + sprintf( x->x_curdir, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); + } + else + { + sprintf( x->x_curdir, "/%s", x->x_dentries[x->x_itemselected] ); + } + } + + playlist_update_dir( x, glist ); + } + } + } + x->x_glist = glist; + glist_grab( glist, &x->x_obj.te_g, (t_glistmotionfn)playlist_motion, + NULL, xpix, ypix ); + } + return (1); +} + +static void playlist_properties(t_gobj *z, t_glist *owner) +{ + char buf[800]; + t_playlist *x=(t_playlist *)z; + + sprintf(buf, "pdtk_playlist_dialog %%s %s %d %d %s %s %s %s %s\n", + x->x_extension, (int)x->x_width, (int)x->x_height, + x->x_font, x->x_bgcolor, x->x_sbcolor, + x->x_fgcolor, x->x_secolor ); + // post("playlist_properties : %s", buf ); + gfxstub_new(&x->x_obj.ob_pd, x, buf); +} + +static void playlist_dialog(t_playlist *x, t_symbol *s, int argc, t_atom *argv) +{ + if ( !x ) + { + pd_error(x, "playlist : error :tried to set properties on an unexisting object" ); + } + if ( argc != 10 ) + { + pd_error(x, "playlist : error in the number of arguments ( %d instead of 10 )", argc ); + return; + } + if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || + argv[2].a_type != A_FLOAT || argv[3].a_type != A_SYMBOL || + argv[4].a_type != A_FLOAT || argv[5].a_type != A_SYMBOL || + argv[6].a_type != A_SYMBOL || argv[7].a_type != A_SYMBOL || + argv[8].a_type != A_SYMBOL || argv[9].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments" ); + return; + } + x->x_extension = argv[0].a_w.w_symbol->s_name; + x->x_width = (int)argv[1].a_w.w_float; + x->x_height = (int)argv[2].a_w.w_float; + sprintf( x->x_font, "{%s %d %s}", argv[3].a_w.w_symbol->s_name, + (int)argv[4].a_w.w_float, argv[5].a_w.w_symbol->s_name ); + x->x_charheight = (t_int)argv[4].a_w.w_float; + strcpy( x->x_bgcolor, argv[6].a_w.w_symbol->s_name ); + strcpy( x->x_sbcolor, argv[7].a_w.w_symbol->s_name ); + strcpy( x->x_fgcolor, argv[8].a_w.w_symbol->s_name ); + strcpy( x->x_secolor, argv[9].a_w.w_symbol->s_name ); + + playlist_draw_erase(x, x->x_glist); + playlist_draw_new(x, x->x_glist); +} + + +static t_playlist *playlist_new(t_symbol *s, int argc, t_atom *argv ) +{ + t_int argoffset=0; + t_playlist *x; + + x = (t_playlist *)pd_new(playlist_class); + + x->x_extension = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_extension, "all" ); + x->x_width = 400; + x->x_height = 300; + x->x_font = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_font, "{Helvetica 10 bold}" ); + x->x_charheight = 10; + x->x_charwidth = (2*10)/3; + x->x_bgcolor = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_bgcolor, "#457782" ); + x->x_sbcolor = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_sbcolor, "yellow" ); + x->x_fgcolor = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_fgcolor, "black" ); + x->x_secolor = ( char * ) getbytes( MAXPDSTRING ); + sprintf( x->x_secolor, "red" ); + + if ( argc >= 1 ) + { + if ( argv[0].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong argument (extension : 1)" ); + return NULL; + } + if ( !strcmp( argv[0].a_w.w_symbol->s_name, "" ) ) + { + pd_error(x, "playlist : no extension specified" ); + pd_error(x, "playlist : usage : playlist " ); + return NULL; + } + strcpy( x->x_extension, argv[0].a_w.w_symbol->s_name ); + } + if ( argc >= 2 ) + { + if ( argv[1].a_type != A_FLOAT ) + { + pd_error(x, "playlist : wrong argument (width : 2)" ); + return NULL; + } + if ( (int)argv[1].a_w.w_float <= 0 ) + { + pd_error(x, "playlist : wrong width (%d)", (int)argv[1].a_w.w_float ); + pd_error(x, "playlist : usage : playlist " ); + return NULL; + } + x->x_width = (int)argv[1].a_w.w_float; + } + if ( argc >= 3 ) + { + if ( argv[2].a_type != A_FLOAT ) + { + pd_error(x, "playlist : wrong argument (height : 3)" ); + return NULL; + } + if ( (int)argv[2].a_w.w_float <= 0 ) + { + pd_error(x, "playlist : wrong height (%d)", (int)argv[2].a_w.w_float ); + pd_error(x, "playlist : usage : playlist " ); + return NULL; + } + x->x_height = (int)argv[2].a_w.w_float; + } + if ( argc >= 6 ) + { + if ( argv[3].a_type != A_SYMBOL || + argv[5].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments (font : 4,6)" ); + pd_error(x, "argument types : %d %d", argv[3].a_type, argv[5].a_type ); + return NULL; + } + if ( argv[4].a_type != A_SYMBOL && + argv[4].a_type != A_FLOAT ) + { + pd_error(x, "playlist : wrong arguments (font size : 5)" ); + pd_error(x, "argument types : %d", argv[4].a_type ); + return NULL; + } + if ( argv[4].a_type == A_SYMBOL ) + { + sprintf( x->x_font, "%s", argv[3].a_w.w_symbol->s_name ); + x->x_charheight = (t_int)atoi( strstr( argv[3].a_w.w_symbol->s_name, " ") ); + argoffset=2; + } + if ( argv[4].a_type == A_FLOAT ) + { + x->x_charheight = (t_int)argv[4].a_w.w_float; + sprintf( x->x_font, "%s %d %s", argv[3].a_w.w_symbol->s_name, + (int)x->x_charheight, argv[5].a_w.w_symbol->s_name ); + argoffset=0; + } + logpost(NULL, 4, "playlist : font : %s, size : %d", x->x_font, (int)x->x_charheight ); + } + if ( argc >= 7-argoffset ) + { + if ( argv[6-argoffset].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments (background color : %d)", 7-(int)argoffset ); + return NULL; + } + strcpy( x->x_bgcolor, argv[6-argoffset].a_w.w_symbol->s_name ); + } + if ( argc >= 8-argoffset ) + { + if ( argv[7-argoffset].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments (scrollbar color : %d)", 8-(int)argoffset ); + return NULL; + } + strcpy( x->x_sbcolor, argv[7-argoffset].a_w.w_symbol->s_name ); + } + if ( argc >= 9-argoffset ) + { + if ( argv[8-argoffset].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments (foreground color : %d)", 9-(int)argoffset ); + return NULL; + } + strcpy( x->x_fgcolor, argv[8-argoffset].a_w.w_symbol->s_name ); + } + if ( argc >= 10-argoffset ) + { + if ( argv[9-argoffset].a_type != A_SYMBOL ) + { + pd_error(x, "playlist : wrong arguments (selection color : %d)", 10-(int)argoffset ); + return NULL; + } + strcpy( x->x_secolor, argv[9-argoffset].a_w.w_symbol->s_name ); + } + + x->x_fullpath = outlet_new(&x->x_obj, &s_symbol ); + x->x_file = outlet_new(&x->x_obj, &s_symbol ); + x->x_dir = outlet_new(&x->x_obj, &s_symbol ); + + x->x_glist = (t_glist *) canvas_getcurrent(); + x->x_nentries = 0; + x->x_pnentries = 0; + x->x_dentries = NULL; + + // get current directory full path + t_symbol *cwd = canvas_getdir(x->x_glist); + strncpy( x->x_curdir, cwd->s_name, MAXPDSTRING ); + + x->x_selected = 0; + x->x_itemselected = -1; + + x->x_sort = 1; + x->x_graphics = 1; + + // post( "playlist : built extension=%s width=%d height=%d", x->x_extension, x->x_width, x->x_height ); + + return (x); +} + +static void playlist_free(t_playlist *x) +{ + // post( "playlist : playlist_free" ); + if ( x->x_extension ) + { + freebytes( x->x_extension, MAXPDSTRING ); + } + if ( x->x_font ) + { + freebytes( x->x_font, MAXPDSTRING ); + } + if ( x->x_bgcolor ) + { + freebytes( x->x_bgcolor, MAXPDSTRING ); + } + if ( x->x_sbcolor ) + { + freebytes( x->x_sbcolor, MAXPDSTRING ); + } + if ( x->x_fgcolor ) + { + freebytes( x->x_fgcolor, MAXPDSTRING ); + } + if ( x->x_secolor ) + { + freebytes( x->x_secolor, MAXPDSTRING ); + } +} + +static void playlist_seek(t_playlist *x, t_floatarg fseeked) +{ + t_int iout=0; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + if ( fseeked < 0 ) + { + pd_error(x, "playlist : wrong searched file : %f", fseeked ); + return; + } + + if ( x->x_nentries > 2 ) + { + // do not select . or .. + iout = (int)fseeked % (x->x_nentries-2) + 2; + } + else + { + return; + } + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", canvas, x, x->x_itemselected, x->x_fgcolor); + x->x_itemselected = iout; + sys_vgui(".x%lx.c itemconfigure %xENTRY%d -fill %s\n", canvas, x, x->x_itemselected, x->x_secolor); + playlist_output_current(x); +} + +static void playlist_location(t_playlist *x, t_symbol *flocation) +{ + char olddir[ MAXPDSTRING ]; /* remember old location */ + + strcpy( olddir, x->x_curdir ); + + if ( !strcmp( flocation->s_name, ".." ) ) + { + char *iamthelastslash; + + iamthelastslash = strrchr( x->x_curdir, '/' ); + *iamthelastslash = '\0'; + + if ( !strcmp( x->x_curdir, "" ) ) + { + strcpy( x->x_curdir, "/" ); + } + } + else if ( !strncmp( flocation->s_name, "/", 1 ) ) + { + // absolute path required + if ( strlen( flocation->s_name ) >= MAXPDSTRING ) + { + pd_error(x, "playlist : maximum dir length reached : cannot change directory" ); + return; + } + strncpy( x->x_curdir, flocation->s_name, MAXPDSTRING ); + } + else + { + // relative path + if ( strlen( x->x_curdir ) + strlen( flocation->s_name ) + 2 > MAXPDSTRING ) + { + pd_error(x, "playlist : maximum dir length reached : cannot change directory" ); + return; + } + if ( strcmp( x->x_curdir, "/" ) ) + { + sprintf( x->x_curdir, "%s/%s", x->x_curdir, flocation->s_name ); + } + else + { + sprintf( x->x_curdir, "/%s", flocation->s_name ); + } + } + + if ( chdir( x->x_curdir ) < 0 ) + { + pd_error(x, "playlist : requested location '%s' is not a directory", x->x_curdir ); + strcpy( x->x_curdir, olddir ); + return; + } + + playlist_update_dir( x, x->x_glist ); +} + +void playlist_setup(void) +{ + logpost(NULL, 4, "%s", playlist_version ); + playlist_class = class_new(gensym("playlist"), (t_newmethod)playlist_new, + (t_method)playlist_free, sizeof(t_playlist), + CLASS_DEFAULT, A_GIMME, 0); + class_addmethod(playlist_class, (t_method)playlist_seek, gensym("seek"), A_DEFFLOAT, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_location, gensym("location"), A_SYMBOL, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_dialog, gensym("dialog"), A_GIMME, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_sort, gensym("sort"), A_DEFFLOAT, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_graphics, gensym("graphics"), A_DEFFLOAT, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_scroll, gensym("scroll"), A_DEFFLOAT, A_NULL ); + class_addmethod(playlist_class, (t_method)playlist_font, gensym("font"), A_SYMBOL, + A_SYMBOL, A_DEFFLOAT, A_NULL ); + + playlist_widgetbehavior.w_getrectfn = playlist_getrect; + playlist_widgetbehavior.w_displacefn = playlist_displace; + playlist_widgetbehavior.w_selectfn = playlist_select; + playlist_widgetbehavior.w_activatefn = NULL; + playlist_widgetbehavior.w_deletefn = playlist_delete; + playlist_widgetbehavior.w_visfn = playlist_vis; + playlist_widgetbehavior.w_clickfn = playlist_click; + +#if PD_MINOR_VERSION >= 37 + class_setpropertiesfn(playlist_class, playlist_properties); + class_setsavefn(playlist_class, playlist_save); +#else + playlist_widgetbehavior.w_propertiesfn = playlist_properties; + playlist_widgetbehavior.w_savefn = playlist_save; +#endif + + class_setwidget(playlist_class, &playlist_widgetbehavior); + + sys_vgui("eval [read [open {%s/%s.tcl}]]\n", + playlist_class->c_externdir->s_name, + playlist_class->c_name->s_name); +} diff --git a/externals/unauthorized/playlist/playlist.tk b/externals/unauthorized/playlist.tcl similarity index 98% rename from externals/unauthorized/playlist/playlist.tk rename to externals/unauthorized/playlist.tcl index 542b22af376c45fbd7c620148794fb103d324bc9..a4ce6b505d68f04fd3760f1bdd6591024293f023 100644 --- a/externals/unauthorized/playlist/playlist.tk +++ b/externals/unauthorized/playlist.tcl @@ -32,13 +32,13 @@ proc playlist_apply {id} { [eval concat $$var_graph_secolor] \ \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc playlist_cancel {id} { set cmd [concat $id cancel \;] #puts stderr $cmd - pd $cmd + pdsend $cmd } proc playlist_ok {id} { @@ -74,7 +74,7 @@ proc pdtk_playlist_dialog {id extension width height font bgcolor sbcolor fgcolo set $var_graph_fgcolor $fgcolor set $var_graph_secolor $secolor - toplevel $id -class [winfo class .] + toplevel $id wm title $id {playlist} wm protocol $id WM_DELETE_WINDOW [concat playlist_cancel $id] diff --git a/externals/unauthorized/playlist/INSTALL b/externals/unauthorized/playlist/INSTALL deleted file mode 100644 index 972bba0209eae12a2155a985cbaaf76b8446bdb6..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/INSTALL +++ /dev/null @@ -1,15 +0,0 @@ -untar in /my/pd/dir/externs - -cd /my/pd/dir/externs/playlist - -make clean - -make - -make install - -open help-playlist.pd - -Thanx for getting here. -Yves/ -comments and bugs @ ydegoyon@free.fr diff --git a/externals/unauthorized/playlist/Makefile b/externals/unauthorized/playlist/Makefile deleted file mode 100644 index 960d5d1db5a2d9ec83483ae76ab8e90f1972885e..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -NAME=playlist -CSYM=playlist - -current: pd_linux - -# ----------------------- NT ----------------------- - -pd_nt: $(NAME).dll - -.SUFFIXES: .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="C:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: $(NAME).pd_irix5 - -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I../../src - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: $(NAME).pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: $(NAME).pd_linux - -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wno-shadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch -Werror -g - -LINUXINCLUDE = -I../../src - -.c.pd_linux: - ./tk2c.bash < $*.tk > $*.tk2c - gcc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm -f $*.o ../$*.pd_linux - ln -s $*/$*.pd_linux .. - -# ---------------------------------------------------------- - -install: - cp help-*.pd ../../doc/5.reference - -clean: - rm -f *.o *.pd_* so_locations diff --git a/externals/unauthorized/playlist/README b/externals/unauthorized/playlist/README deleted file mode 100644 index dff1892c7e57076ed0a3faa17b594cc95bf81b5b..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/README +++ /dev/null @@ -1,20 +0,0 @@ -Version 0.01 -copyleft 2001 by Yves Degoyon -tarballs and updates available @ http://ydegoyon.free.fr - -playlist : choose a file in 1 click with space, numeric, ... characters -you can also send a seek message to select a file automatically. - -To install playlist, follow the steps from INSTALL - -This software is published under GPL terms. - -This is software with ABSOLUTELY NO WARRANTY. -Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing -due to a bug or for other reasons. -We do not warrant that the program is free of infringement of any third-party -patents. - -***************************************************************************** - - diff --git a/externals/unauthorized/playlist/playlist.c b/externals/unauthorized/playlist/playlist.c deleted file mode 100644 index fce68a8ca33102346f72864951c027bff8d451c8..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/playlist.c +++ /dev/null @@ -1,1017 +0,0 @@ -/*------------------------ playlist~ ------------------------------------------ */ -/* */ -/* playlist~ : lets you choose a file with 1 click */ -/* or by sending a 'seek #' message */ -/* constructor : playlist */ -/* */ -/* Copyleft Yves Degoyon ( ydegoyon@free.fr ) */ -/* */ -/* 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. */ -/* */ -/* See file LICENSE for further informations on licensing terms. */ -/* */ -/* 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. */ -/* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ -/* "If a man's made of blood and iron" */ -/* "Doctor, doctor, what's in my chest ????" */ -/* Gang Of Four -- Guns Before Butter */ -/* ---------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "m_pd.h" -#include "m_imp.h" -#include "g_canvas.h" - - -#ifdef _WIN32 -#include -#else -#include -#include -#include -#endif - -t_widgetbehavior playlist_widgetbehavior; -static t_class *playlist_class; - -static int guidebug=0; - -static char *playlist_version = "playlist: 1 click file chooser : version 0.12, written by Yves Degoyon (ydegoyon@free.fr)"; - -#define MAX_DIR_LENGTH 2048 // maximum length for a directory name - -#define MIN(a,b) (a>b?b:a) - -#define SYS_VGUI2(a,b) if (guidebug) \ - post(a,b);\ - sys_vgui(a,b) - -#define SYS_VGUI3(a,b,c) if (guidebug) \ - post(a,b,c);\ - sys_vgui(a,b,c) - -#define SYS_VGUI4(a,b,c,d) if (guidebug) \ - post(a,b,c,d);\ - sys_vgui(a,b,c,d) - -#define SYS_VGUI5(a,b,c,d,e) if (guidebug) \ - post(a,b,c,d,e);\ - sys_vgui(a,b,c,d,e) - -#define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \ - post(a,b,c,d,e,f);\ - sys_vgui(a,b,c,d,e,f) - -#define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \ - post(a,b,c,d,e,f,g);\ - sys_vgui(a,b,c,d,e,f,g) - -#define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \ - post(a,b,c,d,e,f,g,h);\ - sys_vgui(a,b,c,d,e,f,g,h) - -#define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i );\ - sys_vgui(a,b,c,d,e,f,g,h,i) - -#define SYS_VGUI10(a,b,c,d,e,f,g,h,i,j) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j );\ - sys_vgui(a,b,c,d,e,f,g,h,i,j) - -#define SYS_VGUI11(a,b,c,d,e,f,g,h,i,j,k) if (guidebug) \ - post(a,b,c,d,e,f,g,h,i,j,k );\ - sys_vgui(a,b,c,d,e,f,g,h,i,j,k) - - -typedef struct _playlist -{ - t_object x_obj; - t_glist *x_glist; - t_outlet *x_fullpath; - t_outlet *x_file; - t_outlet *x_dir; - char *x_extension; /* extension to selected files */ - t_int x_height; /* height of the playlist */ - t_int x_width; /* width of the playlist */ - t_int x_itemselected; /* index of the selected item */ - t_int x_selected; /* stores selected state */ - t_int x_graphics; /* flag to draw graphics or not */ - char **x_dentries; /* directory entries */ - t_int x_nentries; /* number of entries in the current dir */ - t_int x_pnentries; /* previous size of entries list */ - t_int x_firstseen; /* first displayed entry */ - t_int x_lastseen; /* last displayed entry */ - t_int x_cdy; /* cumulated y drag */ - t_int x_sort; /* sorting option flag */ - char *x_curdir; /* current directory informations */ - char *x_font; /* font used for entries */ - t_int x_charheight; /* height of characters */ - t_int x_charwidth; /* width of characters */ - char *x_bgcolor; /* background color */ - char *x_sbcolor; /* scrollbar color */ - char *x_fgcolor; /* foreground color */ - char *x_secolor; /* selection color */ -} t_playlist; - - -static void playlist_update_dir(t_playlist *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int i; - char wrappedname[ MAX_DIR_LENGTH ]; - struct timespec tv; - - tv.tv_sec = 0; - tv.tv_nsec = 10000000; - - // set title - SYS_VGUI3(".x%x.c delete %xTITLE\n", canvas, x); - if ( x->x_graphics ) - { - SYS_VGUI8(".x%x.c create text %d %d -width %d -text \"%s\" -anchor w -font %s -tags %xTITLE\n", - canvas, - text_xpix(&x->x_obj, glist)+5, - text_ypix(&x->x_obj, glist)-10, - x->x_width, - x->x_curdir, - x->x_font, - x ); - } - - // delete previous entries - for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) - { - SYS_VGUI4(".x%x.c delete %xENTRY%d\n", canvas, x, i); - } - - // display the content of current directory - { - t_int nentries, i; - struct dirent** dentries; /* all directory entries */ - - // post( "playlist : scandir : %s", x->x_curdir ); - if ( ( nentries = scandir(x->x_curdir, &dentries, NULL, (x->x_sort==1)?alphasort:NULL ) ) == -1 ) - { - post( "playlist : could not scan current directory ( where the hell are you ??? )" ); - perror( "scandir" ); - return; - } - - x->x_firstseen = 0; - if ( x->x_dentries ) - { - for ( i=0; ix_nentries; i++ ) - { - // post( "playlist : freeing entry %d size=%d : %s", i, strlen( x->x_dentries[i] ) + 1, x->x_dentries[i] ); - freebytes( x->x_dentries[i], strlen( x->x_dentries[i] ) + 1 ); - } - } - if ( x->x_pnentries != -1 ) - { - freebytes( x->x_dentries, x->x_pnentries*sizeof(char**) ); - } - - x->x_nentries = 0; - // post( "playlist : allocating dentries %d", nentries ); - x->x_dentries = (char **) getbytes( nentries*sizeof(char**) ) ; - x->x_pnentries = nentries; - for ( i=0; id_name ) ) != NULL ) ) || - ( strstr( dentries[i]->d_name, x->x_extension ) ) || - ( !strcmp( x->x_extension, "all" ) ) - ) - { - // close temporarily opened dir - if ( tmpdir ) - { - if ( closedir( tmpdir ) < 0 ) - { - post( "playlist : could not close directory %s", dentries[i]->d_name ); - } - } - - // post( "playlist : allocating entry %d %d : %s", x->x_nentries, strlen( dentries[i]->d_name ) + 1, dentries[i]->d_name ); - x->x_dentries[x->x_nentries] = ( char * ) getbytes( strlen( dentries[i]->d_name ) + 1 ); - strcpy( x->x_dentries[x->x_nentries], dentries[i]->d_name ); - - // display the entry if displayable - if ( x->x_nentries*x->x_charheight+5 < x->x_height ) - { - // nanosleep( &tv, NULL ); - x->x_lastseen = x->x_nentries; - strncpy( wrappedname, x->x_dentries[x->x_nentries], MIN(x->x_width/x->x_charwidth, MAX_DIR_LENGTH) ); - wrappedname[ x->x_width/x->x_charwidth ] = '\0'; - SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" -anchor w -font %s -tags %xENTRY%d\n", - canvas, - text_xpix(&x->x_obj, glist)+5, - text_ypix(&x->x_obj, glist)+5+(x->x_nentries-x->x_firstseen)*x->x_charheight, - x->x_fgcolor, - x->x_secolor, - x->x_width, - wrappedname, - x->x_font, - x, x->x_nentries ); - } - x->x_nentries++; - } - - } - - } -} - -static void playlist_output_current(t_playlist* x) -{ - // output the selected dir+file - // check that it's not a directory - if ( chdir( x->x_dentries[x->x_itemselected] ) == 0 ) - { - chdir( x->x_curdir ); - return; - } - - if ( x->x_dentries && x->x_itemselected < x->x_nentries && x->x_itemselected >= 0 ) - { - char* tmpstring = (char*) getbytes( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected]) + 2 ); - - sprintf( tmpstring, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); - outlet_symbol( x->x_dir, gensym( x->x_curdir ) ); - outlet_symbol( x->x_file, gensym( x->x_dentries[x->x_itemselected] ) ); - outlet_symbol( x->x_fullpath, gensym( tmpstring ) ); - freebytes( tmpstring, strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected]) + 2 ); - } -} - -static void playlist_sort(t_playlist* x, t_floatarg fsort) -{ - if ( ( (t_int)fsort != 0 ) && ( (t_int)fsort != 1 ) ) - { - post( "playlist : wrong argument to playlist message : %d", (t_int)fsort ); - return; - } - - x->x_sort = (t_int) fsort; - playlist_update_dir( x, x->x_glist ); -} - -static void playlist_font(t_playlist* x, t_symbol *fname, t_symbol *fcase, t_floatarg fsize) -{ - if ( (t_int)fsize <= 4 ) - { - post( "playlist : wrong font size in font message : %d", (t_int)fsize ); - return; - } - sprintf( x->x_font, "{%s %d %s}", fname->s_name, (int)fsize, fcase->s_name ); - x->x_charheight = (t_int)fsize; - x->x_charwidth = (2*x->x_charheight)/3; - post( "playlist : setting font to : %s", x->x_font ); - playlist_update_dir( x, x->x_glist ); -} - -static void playlist_draw_new(t_playlist *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - x->x_glist = glist; - if ( x->x_graphics ) - { - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xPLAYLIST\n", - canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, - x->x_bgcolor, x); - SYS_VGUI8(".x%x.c create rectangle %d %d %d %d -fill %s -tags %xSCROLLLIST\n", - canvas, text_xpix(&x->x_obj, glist)+4*x->x_width/5, text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height, - x->x_sbcolor, x); - } - playlist_update_dir( x, glist ); - -} - -static void playlist_draw_move(t_playlist *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int i; - struct timespec tv; - - tv.tv_sec = 0; - tv.tv_nsec = 10000000; - - if ( x->x_graphics ) - { - SYS_VGUI7(".x%x.c coords %xPLAYLIST %d %d %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist)+x->x_width, - text_ypix(&x->x_obj, glist)+x->x_height); - SYS_VGUI7(".x%x.c coords %xSCROLLLIST %d %d %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist)+4*x->x_width/5, text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist)+x->x_width, - text_ypix(&x->x_obj, glist)+x->x_height); - SYS_VGUI5(".x%x.c coords %xTITLE %d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist)+5, text_ypix(&x->x_obj, glist)-10 ); - } - for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) - { - // nanosleep( &tv, NULL ); - SYS_VGUI6(".x%x.c coords %xENTRY%d %d %d\n", - canvas, x, i, - text_xpix(&x->x_obj, glist)+5, - text_ypix(&x->x_obj, glist)+5+(i-x->x_firstseen)*x->x_charheight); - } - - canvas_fixlinesfor( canvas, (t_text*)x ); -} - -static void playlist_draw_erase(t_playlist* x, t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - t_int i; - - if ( x->x_graphics ) - { - SYS_VGUI3(".x%x.c delete %xPLAYLIST\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xSCROLLLIST\n", canvas, x); - SYS_VGUI3(".x%x.c delete %xTITLE\n", canvas, x); - } - for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) - { - SYS_VGUI4(".x%x.c delete %xENTRY%d\n", canvas, x, i); - } -} - -static void playlist_draw_select(t_playlist* x, t_glist* glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - // post( "playlist : select" ); - if(x->x_selected) - { - /* sets the item in blue */ - if (x->x_graphics) SYS_VGUI3(".x%x.c itemconfigure %xPLAYLIST -outline #0000FF\n", canvas, x); - } - else - { - if (x->x_graphics) SYS_VGUI3(".x%x.c itemconfigure %xPLAYLIST -outline #000000\n", canvas, x); - } -} - -/* ------------------------ playlist widgetbehaviour----------------------------- */ - - -static void playlist_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - t_playlist* x = (t_playlist*)z; - - *xp1 = text_xpix(&x->x_obj, owner); - *yp1 = text_ypix(&x->x_obj, owner); - *xp2 = text_xpix(&x->x_obj, owner)+x->x_width; - *yp2 = text_ypix(&x->x_obj, owner)+x->x_height; -} - -static void playlist_save(t_gobj *z, t_binbuf *b) -{ - t_playlist *x = (t_playlist *)z; - - // post( "saving playlist : %s", x->x_extension ); - binbuf_addv(b, "ssiissiisssss", gensym("#X"), gensym("obj"), - (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - gensym("playlist"), gensym(x->x_extension), x->x_width, x->x_height, - gensym(x->x_font), gensym(x->x_bgcolor), gensym(x->x_sbcolor), - gensym(x->x_fgcolor), gensym(x->x_secolor) ); - binbuf_addv(b, ";"); -} - -static void playlist_select(t_gobj *z, t_glist *glist, int selected) -{ - t_playlist *x = (t_playlist *)z; - - x->x_selected = selected; - - playlist_draw_select( x, glist ); -} - -static void playlist_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_playlist *x = (t_playlist *)z; - - x->x_glist = glist; - if (vis) - { - playlist_draw_new( x, glist ); - } - else - { - playlist_draw_erase( x, glist ); - } -} - -static void playlist_delete(t_gobj *z, t_glist *glist) -{ - canvas_deletelinesfor(glist, (t_text *)z); -} - -static void playlist_displace(t_gobj *z, t_glist *glist, int dx, int dy) -{ - t_playlist *x = (t_playlist *)z; - t_int xold = text_xpix(&x->x_obj, glist); - t_int yold = text_ypix(&x->x_obj, glist); - - // post( "playlist_displace dx=%d dy=%d", dx, dy ); - - x->x_obj.te_xpix += dx; - x->x_obj.te_ypix += dy; - if(xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist)) - { - playlist_draw_move(x, glist); - } -} - -static void playlist_motion(t_playlist *x, t_floatarg dx, t_floatarg dy) -{ - t_int i; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - x->x_cdy+=dy; - - // check if we need to scroll - if ( ( x->x_lastseen < x->x_nentries ) ) - { - // eventually, move down - if ( x->x_cdy >= x->x_charheight ) - { - x->x_cdy = 0; - if ( x->x_firstseen < x->x_nentries - ( x->x_height/x->x_charheight ) ) - { - if ( x->x_firstseen + 1 < x->x_nentries ) - { - for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) - { - SYS_VGUI4(".x%x.c delete %xENTRY%d\n", canvas, x, i); - } - x->x_firstseen++; - for ( i=x->x_firstseen; i< x->x_nentries; i++ ) - { - char *wrappedname = (char *) getbytes( x->x_width ); - - if ( (i-x->x_firstseen)*x->x_charheight < x->x_height ) - { - x->x_lastseen = i; - strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); - wrappedname[ x->x_width/x->x_charwidth ] = '\0'; - SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" -anchor w -font %s -tags %xENTRY%d\n", - canvas, - text_xpix(&x->x_obj, x->x_glist)+5, - text_ypix(&x->x_obj, x->x_glist)+5+(i-x->x_firstseen)*x->x_charheight, - x->x_fgcolor, - x->x_secolor, - x->x_width, - wrappedname, - x->x_font, - x, i ); - } - else break; - } - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", - canvas, x, x->x_itemselected, x->x_secolor); - // post( "playlist : moved down first=%d last=%d", x->x_firstseen, x->x_lastseen ); - } - } - } - // eventually, move up - if ( x->x_cdy <= -x->x_charheight ) - { - x->x_cdy = 0; - if ( x->x_lastseen >= ( x->x_height/x->x_charheight ) ) - { - if ( x->x_firstseen - 1 >= 0 ) - { - for ( i=x->x_firstseen; i<=x->x_lastseen; i++ ) - { - SYS_VGUI4(".x%x.c delete %xENTRY%d\n", canvas, x, i); - } - x->x_firstseen--; - for ( i=x->x_firstseen; i< x->x_nentries; i++ ) - { - char *wrappedname = (char *) getbytes( x->x_width ); - - if ( (i-x->x_firstseen)*x->x_charheight < x->x_height ) - { - x->x_lastseen = i; - strncpy( wrappedname, x->x_dentries[i], x->x_width/x->x_charwidth ); - wrappedname[ x->x_width/x->x_charwidth ] = '\0'; - SYS_VGUI11(".x%x.c create text %d %d -fill %s -activefill %s -width %d -text \"%s\" \ - -anchor w -font %s -tags %xENTRY%d\n", - canvas, - text_xpix(&x->x_obj, x->x_glist)+5, - text_ypix(&x->x_obj, x->x_glist)+5+(i-x->x_firstseen)*x->x_charheight, - x->x_fgcolor, - x->x_secolor, - x->x_width, - wrappedname, - x->x_font, - x, i ); - } - else break; - } - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", - canvas, x, x->x_itemselected, x->x_secolor); - // post( "playlist : moved up first=%d last=%d", x->x_firstseen, x->x_lastseen ); - } - } - } - } // scroll test -} - -static void playlist_scroll(t_playlist *x, t_floatarg fdy) -{ - t_int nbsteps, si; - - nbsteps = (t_int)abs(fdy/x->x_charheight); - // post( "playlist : iterations %d", nbsteps ); - - for (si=0; six_charheight); - } -} - -static void playlist_graphics(t_playlist *x, t_floatarg fgraphics) -{ - if ( ( (t_int)fgraphics == 0 ) || ( (t_int)fgraphics == 1 ) ) - { - playlist_draw_erase(x, x->x_glist); - x->x_graphics = (t_int) fgraphics; - playlist_draw_new(x, x->x_glist); - } -} - -static int playlist_click(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) -{ - t_playlist* x = (t_playlist *)z; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if (doit) - { - // leave a margin for scrolling without selection - if ( (xpix-text_xpix(&x->x_obj, glist)) < 4*x->x_width/5 ) - { - // deselect previously selected item - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", - canvas, x, x->x_itemselected, x->x_fgcolor); - x->x_itemselected = x->x_firstseen + (ypix-text_ypix(&x->x_obj, glist))/x->x_charheight; - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", - canvas, x, x->x_itemselected, x->x_secolor); - // post( "playlist : selected item : %d", x->x_itemselected ); - if ( x->x_dentries && ( x->x_itemselected < x->x_nentries ) ) - { - char *tmpstring = (char *) getbytes( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected] ) + 2 ); - sprintf( tmpstring, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); - // post( "playlist : chdir : %s", tmpstring ); - if ( chdir( tmpstring ) < 0 ) - { - playlist_output_current(x); - } - else - { - if ( !strcmp( x->x_dentries[ x->x_itemselected ], ".." ) ) - { - char *iamthelastslash; - - iamthelastslash = strrchr( x->x_curdir, '/' ); - *iamthelastslash = '\0'; - - if ( !strcmp( x->x_curdir, "" ) ) - { - strcpy( x->x_curdir, "/" ); - } - } - else - if ( !strcmp( x->x_dentries[ x->x_itemselected ], "." ) ) - { - // nothing - } - else - { - if ( strlen( x->x_curdir ) + strlen( x->x_dentries[x->x_itemselected] ) + 2 > MAX_DIR_LENGTH ) - { - post( "playlist : maximum dir length reached : cannot change directory" ); - return -1; - } - if ( strcmp( x->x_curdir, "/" ) ) - { - sprintf( x->x_curdir, "%s/%s", x->x_curdir, x->x_dentries[x->x_itemselected] ); - } - else - { - sprintf( x->x_curdir, "/%s", x->x_dentries[x->x_itemselected] ); - } - } - - playlist_update_dir( x, glist ); - } - } - } - x->x_glist = glist; - glist_grab( glist, &x->x_obj.te_g, (t_glistmotionfn)playlist_motion, - NULL, xpix, ypix ); - } - return (1); -} - -static void playlist_properties(t_gobj *z, t_glist *owner) -{ - char buf[800]; - t_playlist *x=(t_playlist *)z; - - sprintf(buf, "pdtk_playlist_dialog %%s %s %d %d %s %s %s %s %s\n", - x->x_extension, (int)x->x_width, (int)x->x_height, - x->x_font, x->x_bgcolor, x->x_sbcolor, - x->x_fgcolor, x->x_secolor ); - // post("playlist_properties : %s", buf ); - gfxstub_new(&x->x_obj.ob_pd, x, buf); -} - -static void playlist_dialog(t_playlist *x, t_symbol *s, int argc, t_atom *argv) -{ - if ( !x ) { - post( "playlist : error :tried to set properties on an unexisting object" ); - } - if ( argc != 10 ) - { - post( "playlist : error in the number of arguments ( %d instead of 10 )", argc ); - return; - } - if ( argv[0].a_type != A_SYMBOL || argv[1].a_type != A_FLOAT || - argv[2].a_type != A_FLOAT || argv[3].a_type != A_SYMBOL || - argv[4].a_type != A_FLOAT || argv[5].a_type != A_SYMBOL || - argv[6].a_type != A_SYMBOL || argv[7].a_type != A_SYMBOL || - argv[8].a_type != A_SYMBOL || argv[9].a_type != A_SYMBOL ) { - post( "playlist : wrong arguments" ); - return; - } - x->x_extension = argv[0].a_w.w_symbol->s_name; - x->x_width = (int)argv[1].a_w.w_float; - x->x_height = (int)argv[2].a_w.w_float; - sprintf( x->x_font, "{%s %d %s}", argv[3].a_w.w_symbol->s_name, - (int)argv[4].a_w.w_float, argv[5].a_w.w_symbol->s_name ); - x->x_charheight = (t_int)argv[4].a_w.w_float; - strcpy( x->x_bgcolor, argv[6].a_w.w_symbol->s_name ); - strcpy( x->x_sbcolor, argv[7].a_w.w_symbol->s_name ); - strcpy( x->x_fgcolor, argv[8].a_w.w_symbol->s_name ); - strcpy( x->x_secolor, argv[9].a_w.w_symbol->s_name ); - - playlist_draw_erase(x, x->x_glist); - playlist_draw_new(x, x->x_glist); -} - - -static t_playlist *playlist_new(t_symbol *s, int argc, t_atom *argv ) -{ - t_int i, argoffset=0; - t_playlist *x; - char *tmpcurdir; - - x = (t_playlist *)pd_new(playlist_class); - - x->x_extension = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_extension, "all" ); - x->x_width = 400; - x->x_height = 300; - x->x_font = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_font, "{Helvetica 10 bold}" ); - x->x_charheight = 10; - x->x_charwidth = (2*10)/3; - x->x_bgcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_bgcolor, "#457782" ); - x->x_sbcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_sbcolor, "yellow" ); - x->x_fgcolor = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_fgcolor, "black" ); - x->x_secolor = ( char * ) getbytes( MAX_DIR_LENGTH ); - sprintf( x->x_secolor, "red" ); - - if ( argc >= 1 ) - { - if ( argv[0].a_type != A_SYMBOL ) - { - error( "playlist : wrong argument (extension : 1)" ); - return NULL; - } - if ( !strcmp( argv[0].a_w.w_symbol->s_name, "" ) ) - { - error( "playlist : no extension specified" ); - error( "playlist : usage : playlist " ); - return NULL; - } - strcpy( x->x_extension, argv[0].a_w.w_symbol->s_name ); - } - if ( argc >= 2 ) - { - if ( argv[1].a_type != A_FLOAT ) - { - error( "playlist : wrong argument (width : 2)" ); - return NULL; - } - if ( (int)argv[1].a_w.w_float <= 0 ) - { - error( "playlist : wrong width (%d)", (t_int)(int)argv[1].a_w.w_float ); - error( "playlist : usage : playlist " ); - return NULL; - } - x->x_width = (int)argv[1].a_w.w_float; - } - if ( argc >= 3 ) - { - if ( argv[2].a_type != A_FLOAT ) - { - error( "playlist : wrong argument (height : 3)" ); - return NULL; - } - if ( (int)argv[2].a_w.w_float <= 0 ) - { - error( "playlist : wrong height (%d)", (t_int)(int)argv[2].a_w.w_float ); - error( "playlist : usage : playlist " ); - return NULL; - } - x->x_height = (int)argv[2].a_w.w_float; - } - if ( argc >= 6 ) - { - if ( argv[3].a_type != A_SYMBOL || - argv[5].a_type != A_SYMBOL ) - { - error( "playlist : wrong arguments (font : 4,6)" ); - error( "argument types : %d %d", argv[3].a_type, argv[5].a_type ); - return NULL; - } - if ( argv[4].a_type != A_SYMBOL && - argv[4].a_type != A_FLOAT ) - { - error( "playlist : wrong arguments (font size : 5)" ); - error( "argument types : %d", argv[4].a_type ); - return NULL; - } - if ( argv[4].a_type == A_SYMBOL ) - { - sprintf( x->x_font, "%s", argv[3].a_w.w_symbol->s_name ); - x->x_charheight = (t_int)atoi( strstr( argv[3].a_w.w_symbol->s_name, " ") ); - argoffset=2; - } - if ( argv[4].a_type == A_FLOAT ) - { - x->x_charheight = (t_int)argv[4].a_w.w_float; - sprintf( x->x_font, "%s %d %s", argv[3].a_w.w_symbol->s_name, - (int)x->x_charheight, argv[5].a_w.w_symbol->s_name ); - argoffset=0; - } - post( "playlist : font : %s, size : %d", x->x_font, x->x_charheight ); - } - if ( argc >= 7-argoffset ) - { - if ( argv[6-argoffset].a_type != A_SYMBOL ) - { - error( "playlist : wrong arguments (background color : %d)", 7-argoffset ); - return NULL; - } - strcpy( x->x_bgcolor, argv[6-argoffset].a_w.w_symbol->s_name ); - } - if ( argc >= 8-argoffset ) - { - if ( argv[7-argoffset].a_type != A_SYMBOL ) - { - error( "playlist : wrong arguments (scrollbar color : %d)", 8-argoffset ); - return NULL; - } - strcpy( x->x_sbcolor, argv[7-argoffset].a_w.w_symbol->s_name ); - } - if ( argc >= 9-argoffset ) - { - if ( argv[8-argoffset].a_type != A_SYMBOL ) - { - error( "playlist : wrong arguments (foreground color : %d)", 9-argoffset ); - return NULL; - } - strcpy( x->x_fgcolor, argv[8-argoffset].a_w.w_symbol->s_name ); - } - if ( argc >= 10-argoffset ) - { - if ( argv[9-argoffset].a_type != A_SYMBOL ) - { - error( "playlist : wrong arguments (selection color : %d)", 10-argoffset ); - return NULL; - } - strcpy( x->x_secolor, argv[9-argoffset].a_w.w_symbol->s_name ); - } - - x->x_fullpath = outlet_new(&x->x_obj, &s_symbol ); - x->x_file = outlet_new(&x->x_obj, &s_symbol ); - x->x_dir = outlet_new(&x->x_obj, &s_symbol ); - - x->x_glist = (t_glist *) canvas_getcurrent(); - x->x_nentries = 0; - x->x_pnentries = 0; - x->x_dentries = NULL; - - // get current directory full path - x->x_curdir = ( char * ) getbytes( MAX_DIR_LENGTH ); - if ( ( tmpcurdir = getenv( "PWD" ) ) == NULL ) - { - post( "playlist : could not get current directory ( where the hell are you ??? )" ); - return NULL; - } - strncpy( x->x_curdir, tmpcurdir, strlen( tmpcurdir ) ); - x->x_curdir[ strlen( tmpcurdir ) ] = '\0'; - - x->x_selected = 0; - x->x_itemselected = -1; - - x->x_sort = 1; - x->x_graphics = 1; - - // post( "playlist : built extension=%s width=%d height=%d", x->x_extension, x->x_width, x->x_height ); - - return (x); -} - -static void playlist_free(t_playlist *x) -{ - // post( "playlist : playlist_free" ); - if ( x->x_extension ) - { - freebytes( x->x_extension, MAX_DIR_LENGTH ); - } - if ( x->x_curdir ) - { - freebytes( x->x_curdir, MAX_DIR_LENGTH ); - } - if ( x->x_font ) - { - freebytes( x->x_font, MAX_DIR_LENGTH ); - } - if ( x->x_bgcolor ) - { - freebytes( x->x_bgcolor, MAX_DIR_LENGTH ); - } - if ( x->x_sbcolor ) - { - freebytes( x->x_sbcolor, MAX_DIR_LENGTH ); - } - if ( x->x_fgcolor ) - { - freebytes( x->x_fgcolor, MAX_DIR_LENGTH ); - } - if ( x->x_secolor ) - { - freebytes( x->x_secolor, MAX_DIR_LENGTH ); - } -} - -static void playlist_seek(t_playlist *x, t_floatarg fseeked) -{ - t_int iout=0; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - if ( fseeked < 0 ) - { - post( "playlist : wrong searched file : %f", fseeked ); - return; - } - - if ( x->x_nentries > 2 ) - { - // do not select . or .. - iout = (int)fseeked % (x->x_nentries-2) + 2; - } - else - { - return; - } - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", canvas, x, x->x_itemselected, x->x_fgcolor); - x->x_itemselected = iout; - SYS_VGUI5(".x%x.c itemconfigure %xENTRY%d -fill %s\n", canvas, x, x->x_itemselected, x->x_secolor); - playlist_output_current(x); -} - -static void playlist_location(t_playlist *x, t_symbol *flocation) -{ - int iout=0; - char olddir[ MAX_DIR_LENGTH ]; /* remember old location */ - - strcpy( olddir, x->x_curdir ); - - if ( !strcmp( flocation->s_name, ".." ) ) - { - char *iamthelastslash; - - iamthelastslash = strrchr( x->x_curdir, '/' ); - *iamthelastslash = '\0'; - - if ( !strcmp( x->x_curdir, "" ) ) - { - strcpy( x->x_curdir, "/" ); - } - } - else - if ( !strncmp( flocation->s_name, "/", 1 ) ) - { - // absolute path required - if ( strlen( flocation->s_name ) >= MAX_DIR_LENGTH ) - { - error( "playlist : maximum dir length reached : cannot change directory" ); - return; - } - strncpy( x->x_curdir, flocation->s_name, MAX_DIR_LENGTH ); - } - else - { - // relative path - if ( strlen( x->x_curdir ) + strlen( flocation->s_name ) + 2 > MAX_DIR_LENGTH ) - { - post( "playlist : maximum dir length reached : cannot change directory" ); - return; - } - if ( strcmp( x->x_curdir, "/" ) ) - { - sprintf( x->x_curdir, "%s/%s", x->x_curdir, flocation->s_name ); - } - else - { - sprintf( x->x_curdir, "/%s", flocation->s_name ); - } - } - - if ( chdir( x->x_curdir ) < 0 ) - { - error( "playlist : requested location >%s< is not a directory", x->x_curdir ); - strcpy( x->x_curdir, olddir ); - return; - } - - playlist_update_dir( x, x->x_glist ); -} - -void playlist_setup(void) -{ - post( playlist_version ); -#include "playlist.tk2c" - playlist_class = class_new(gensym("playlist"), (t_newmethod)playlist_new, - (t_method)playlist_free, sizeof(t_playlist), - CLASS_DEFAULT, A_GIMME, 0); - class_addmethod(playlist_class, (t_method)playlist_seek, gensym("seek"), A_DEFFLOAT, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_location, gensym("location"), A_SYMBOL, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_dialog, gensym("dialog"), A_GIMME, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_sort, gensym("sort"), A_DEFFLOAT, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_graphics, gensym("graphics"), A_DEFFLOAT, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_scroll, gensym("scroll"), A_DEFFLOAT, A_NULL ); - class_addmethod(playlist_class, (t_method)playlist_font, gensym("font"), A_SYMBOL, - A_SYMBOL, A_DEFFLOAT, A_NULL ); - - playlist_widgetbehavior.w_getrectfn = playlist_getrect; - playlist_widgetbehavior.w_displacefn = playlist_displace; - playlist_widgetbehavior.w_selectfn = playlist_select; - playlist_widgetbehavior.w_activatefn = NULL; - playlist_widgetbehavior.w_deletefn = playlist_delete; - playlist_widgetbehavior.w_visfn = playlist_vis; - playlist_widgetbehavior.w_clickfn = playlist_click; - -#if PD_MINOR_VERSION >= 37 - class_setpropertiesfn(playlist_class, playlist_properties); - class_setsavefn(playlist_class, playlist_save); -#else - playlist_widgetbehavior.w_propertiesfn = playlist_properties; - playlist_widgetbehavior.w_savefn = playlist_save; -#endif - - class_setwidget(playlist_class, &playlist_widgetbehavior); - -} diff --git a/externals/unauthorized/playlist/playlist.tk2c b/externals/unauthorized/playlist/playlist.tk2c deleted file mode 100644 index a8a9f6f0b4e847764e73b3dce3bfcb7045be42aa..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/playlist.tk2c +++ /dev/null @@ -1,123 +0,0 @@ -// ########### playlist procedures -- ydegoyon@free.fr ######### -sys_gui("proc playlist_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_extension [concat graph_extension_$vid]\n"); -sys_gui("global $var_graph_extension\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_font [concat graph_font$vid]\n"); -sys_gui("global $var_graph_font\n"); -sys_gui("set var_graph_bgcolor [concat graph_bgcolor$vid]\n"); -sys_gui("global $var_graph_bgcolor\n"); -sys_gui("set var_graph_sbcolor [concat graph_sbcolor$vid]\n"); -sys_gui("global $var_graph_sbcolor\n"); -sys_gui("set var_graph_fgcolor [concat graph_fgcolor$vid]\n"); -sys_gui("global $var_graph_fgcolor\n"); -sys_gui("set var_graph_secolor [concat graph_secolor$vid]\n"); -sys_gui("global $var_graph_secolor\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_extension] [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_font] [eval concat $$var_graph_bgcolor] [eval concat $$var_graph_sbcolor] [eval concat $$var_graph_fgcolor] [eval concat $$var_graph_secolor] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc playlist_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc playlist_ok {id} {\n"); -sys_gui("playlist_apply $id\n"); -sys_gui("playlist_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_playlist_dialog {id extension width height font bgcolor sbcolor fgcolor secolor} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_extension [concat graph_extension_$vid]\n"); -sys_gui("global $var_graph_extension\n"); -sys_gui("set var_graph_width [concat graph_width_$vid]\n"); -sys_gui("global $var_graph_width\n"); -sys_gui("set var_graph_height [concat graph_height$vid]\n"); -sys_gui("global $var_graph_height\n"); -sys_gui("set var_graph_font [concat graph_font$vid]\n"); -sys_gui("global $var_graph_font\n"); -sys_gui("set var_graph_bgcolor [concat graph_bgcolor$vid]\n"); -sys_gui("global $var_graph_bgcolor\n"); -sys_gui("set var_graph_sbcolor [concat graph_sbcolor$vid]\n"); -sys_gui("global $var_graph_sbcolor\n"); -sys_gui("set var_graph_fgcolor [concat graph_fgcolor$vid]\n"); -sys_gui("global $var_graph_fgcolor\n"); -sys_gui("set var_graph_secolor [concat graph_secolor$vid]\n"); -sys_gui("global $var_graph_secolor\n"); -sys_gui("set $var_graph_extension $extension\n"); -sys_gui("set $var_graph_width $width\n"); -sys_gui("set $var_graph_height $height\n"); -sys_gui("set $var_graph_font $font\n"); -sys_gui("set $var_graph_bgcolor $bgcolor\n"); -sys_gui("set $var_graph_sbcolor $sbcolor\n"); -sys_gui("set $var_graph_fgcolor $fgcolor\n"); -sys_gui("set $var_graph_secolor $secolor\n"); -sys_gui("toplevel $id -class [winfo class .]\n"); -sys_gui("wm title $id {playlist}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat playlist_cancel $id]\n"); -sys_gui("label $id.label -text {PLAYLIST PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"playlist_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"playlist_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"playlist_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.1rangef\n"); -sys_gui("pack $id.1rangef -side top\n"); -sys_gui("label $id.1rangef.lextension -text \"Files Extension :\"\n"); -sys_gui("entry $id.1rangef.extension -textvariable $var_graph_extension -width 7\n"); -sys_gui("pack $id.1rangef.lextension $id.1rangef.extension -side left\n"); -sys_gui("frame $id.2rangef\n"); -sys_gui("pack $id.2rangef -side top\n"); -sys_gui("label $id.2rangef.lwidth -text \"Width :\"\n"); -sys_gui("entry $id.2rangef.width -textvariable $var_graph_width -width 7\n"); -sys_gui("pack $id.2rangef.lwidth $id.2rangef.width -side left\n"); -sys_gui("frame $id.3rangef\n"); -sys_gui("pack $id.3rangef -side top\n"); -sys_gui("label $id.3rangef.lheight -text \"Height :\"\n"); -sys_gui("entry $id.3rangef.height -textvariable $var_graph_height -width 7\n"); -sys_gui("pack $id.3rangef.lheight $id.3rangef.height -side left\n"); -sys_gui("frame $id.3_5rangef\n"); -sys_gui("pack $id.3_5rangef -side top\n"); -sys_gui("label $id.3_5rangef.lfont -text \"Font :\"\n"); -sys_gui("entry $id.3_5rangef.font -textvariable $var_graph_font -width 30\n"); -sys_gui("pack $id.3_5rangef.lfont $id.3_5rangef.font -side left\n"); -sys_gui("frame $id.4rangef\n"); -sys_gui("pack $id.4rangef -side top\n"); -sys_gui("label $id.4rangef.lbgcolor -text \"Background Color :\"\n"); -sys_gui("entry $id.4rangef.bgcolor -textvariable $var_graph_bgcolor -width 7\n"); -sys_gui("pack $id.4rangef.lbgcolor $id.4rangef.bgcolor -side left\n"); -sys_gui("frame $id.5rangef\n"); -sys_gui("pack $id.5rangef -side top\n"); -sys_gui("label $id.5rangef.lsbcolor -text \"Scroll Bar Color :\"\n"); -sys_gui("entry $id.5rangef.sbcolor -textvariable $var_graph_sbcolor -width 7\n"); -sys_gui("pack $id.5rangef.lsbcolor $id.5rangef.sbcolor -side left\n"); -sys_gui("frame $id.6rangef\n"); -sys_gui("pack $id.6rangef -side top\n"); -sys_gui("label $id.6rangef.lfgcolor -text \"Foreground Color :\"\n"); -sys_gui("entry $id.6rangef.fgcolor -textvariable $var_graph_fgcolor -width 7\n"); -sys_gui("pack $id.6rangef.lfgcolor $id.6rangef.fgcolor -side left\n"); -sys_gui("frame $id.7rangef\n"); -sys_gui("pack $id.7rangef -side top\n"); -sys_gui("label $id.7rangef.lsecolor -text \"Selection Color :\"\n"); -sys_gui("entry $id.7rangef.secolor -textvariable $var_graph_secolor -width 7\n"); -sys_gui("pack $id.7rangef.lsecolor $id.7rangef.secolor -side left\n"); -sys_gui("bind $id.1rangef.extension [concat playlist_ok $id]\n"); -sys_gui("bind $id.2rangef.width [concat playlist_ok $id]\n"); -sys_gui("bind $id.3rangef.height [concat playlist_ok $id]\n"); -sys_gui("bind $id.3_5rangef.font [concat playlist_ok $id]\n"); -sys_gui("bind $id.4rangef.bgcolor [concat playlist_ok $id]\n"); -sys_gui("bind $id.5rangef.sbcolor [concat playlist_ok $id]\n"); -sys_gui("bind $id.6rangef.fgcolor [concat playlist_ok $id]\n"); -sys_gui("bind $id.7rangef.secolor [concat playlist_ok $id]\n"); -sys_gui("}\n"); -// ########### playlist procedures END -- ydegoyon@free.fr ######### diff --git a/externals/unauthorized/playlist/tk2c.bash b/externals/unauthorized/playlist/tk2c.bash deleted file mode 100755 index 9dfeb0301c72225db73fbed97b66f52b51dbb7b1..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done diff --git a/externals/unauthorized/playlist/xmms.pd b/externals/unauthorized/playlist/xmms.pd deleted file mode 100644 index b9282cdf278a55f62542e52721eab14b1b1f7190..0000000000000000000000000000000000000000 --- a/externals/unauthorized/playlist/xmms.pd +++ /dev/null @@ -1,144 +0,0 @@ -#N canvas 146 29 755 574 10; -#X obj 411 144 mp3fileout~; -#X floatatom 411 165 5 0 0; -#X floatatom 456 165 5 0 0; -#X msg 409 113 open \$1; -#X msg 466 113 start; -#X msg 511 114 stop; -#X text 534 154 Number of frames emitted; -#X text 396 184 Connection state; -#X symbolatom 127 286 80 0 0; -#X floatatom 520 63 5 0 0; -#X obj 20 57 playlist mp3 300 200; -#X msg 651 37 bang; -#X text 23 17 Step 1 : point to your MP3s directory; -#X obj 357 513 dac~; -#X symbolatom 131 438 10 0 0; -#X text 127 452 Incomer's address; -#X obj 349 470 *~ 1; -#X floatatom 461 513 5 0 0; -#X obj 427 513 / 100; -#X obj 390 470 *~ 1; -#X text 501 515 Volume; -#X msg 336 38 connect localhost 5672; -#X obj 95 341 mp3streamin~ 5672 1; -#X text 295 15 Step 2 : connect to the streamer; -#X text 65 285 Playing :; -#X msg 463 64 seek \$1; -#X text 566 11 Step 3 :start random play; -#X obj 657 410 loadbang; -#X msg 656 434 \; pd dsp 1; -#X msg 379 220 seek \$1; -#X obj 437 219 hsl 128 15 0 1e+07 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 0; -#X msg 547 114 disconnect; -#X obj 573 37 random 1000; -#X msg 620 73 seed \$1; -#X floatatom 673 73 5 0 0; -#X msg 634 220 bang; -#X text 575 264 Step 3 bis :start seq play; -#X obj 592 220 countn; -#X obj 578 242 - 1; -#X floatatom 531 243 5 0 0; -#X obj 551 187 spigot; -#X obj 599 186 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 -1; -#X msg 624 186 1; -#X obj 618 95 spigot; -#X obj 666 94 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1 1 -; -#X msg 691 94 1; -#X obj 362 441 ekwalizer --------------------------; -#X msg 544 315 100; -#X obj 385 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 7900 1; -#X obj 408 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 7900 1; -#X obj 432 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 7900 1; -#X obj 454 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 7900 1; -#X obj 477 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 498 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 516 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 534 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 552 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 573 343 vsl 15 80 0 100 0 0 empty empty empty 20 8 0 8 -262144 --1 -1 0 1; -#X obj 579 315 loadbang; -#X obj 494 539 loadbang; -#X msg 463 539 50; -#X obj 259 486 compressor~; -#X floatatom 279 434 5 0 0; -#X obj 241 509 env~; -#X obj 266 463 / 100; -#X connect 0 0 1 0; -#X connect 0 1 2 0; -#X connect 0 2 40 0; -#X connect 0 2 43 0; -#X connect 3 0 0 0; -#X connect 4 0 0 0; -#X connect 5 0 0 0; -#X connect 10 0 8 0; -#X connect 10 0 3 0; -#X connect 11 0 32 0; -#X connect 11 0 45 0; -#X connect 16 0 61 0; -#X connect 17 0 18 0; -#X connect 18 0 16 1; -#X connect 18 0 19 1; -#X connect 19 0 61 0; -#X connect 21 0 0 0; -#X connect 21 0 4 0; -#X connect 22 0 46 0; -#X connect 22 1 46 0; -#X connect 22 2 14 0; -#X connect 25 0 10 0; -#X connect 27 0 28 0; -#X connect 29 0 0 0; -#X connect 30 0 29 0; -#X connect 31 0 0 0; -#X connect 32 0 9 0; -#X connect 32 0 25 0; -#X connect 33 0 32 0; -#X connect 34 0 33 0; -#X connect 35 0 37 0; -#X connect 35 0 42 0; -#X connect 37 0 38 0; -#X connect 38 0 25 0; -#X connect 38 0 39 0; -#X connect 40 0 37 0; -#X connect 41 0 40 1; -#X connect 42 0 41 0; -#X connect 43 0 32 0; -#X connect 44 0 43 1; -#X connect 45 0 44 0; -#X connect 46 0 19 0; -#X connect 46 0 16 0; -#X connect 47 0 48 0; -#X connect 47 0 49 0; -#X connect 47 0 50 0; -#X connect 47 0 51 0; -#X connect 48 0 46 1; -#X connect 49 0 46 2; -#X connect 50 0 46 3; -#X connect 51 0 46 4; -#X connect 52 0 46 5; -#X connect 53 0 46 6; -#X connect 54 0 46 7; -#X connect 55 0 46 8; -#X connect 56 0 46 9; -#X connect 57 0 46 10; -#X connect 58 0 47 0; -#X connect 59 0 60 0; -#X connect 60 0 17 0; -#X connect 61 0 13 0; -#X connect 61 0 13 1; -#X connect 61 0 63 0; -#X connect 62 0 64 0; -#X connect