diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /noatun-plugins/tyler | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun-plugins/tyler')
-rw-r--r-- | noatun-plugins/tyler/AUTHORS | 8 | ||||
-rw-r--r-- | noatun-plugins/tyler/COPYING | 340 | ||||
-rw-r--r-- | noatun-plugins/tyler/Makefile.am | 21 | ||||
-rw-r--r-- | noatun-plugins/tyler/README | 89 | ||||
-rw-r--r-- | noatun-plugins/tyler/README.Infinity | 89 | ||||
-rw-r--r-- | noatun-plugins/tyler/compute.c | 188 | ||||
-rw-r--r-- | noatun-plugins/tyler/compute.h | 23 | ||||
-rw-r--r-- | noatun-plugins/tyler/display.c | 481 | ||||
-rw-r--r-- | noatun-plugins/tyler/display.h | 40 | ||||
-rw-r--r-- | noatun-plugins/tyler/file.cpp | 81 | ||||
-rw-r--r-- | noatun-plugins/tyler/file.h | 31 | ||||
-rw-r--r-- | noatun-plugins/tyler/main.cpp | 100 | ||||
-rw-r--r-- | noatun-plugins/tyler/main.h | 30 | ||||
-rw-r--r-- | noatun-plugins/tyler/renderer.c | 195 | ||||
-rw-r--r-- | noatun-plugins/tyler/renderer.h | 69 | ||||
-rw-r--r-- | noatun-plugins/tyler/tyler.cpp | 72 | ||||
-rw-r--r-- | noatun-plugins/tyler/tyler.h | 34 | ||||
-rw-r--r-- | noatun-plugins/tyler/tyler.plugin | 70 | ||||
-rw-r--r-- | noatun-plugins/tyler/tylerstates | bin | 0 -> 928 bytes |
19 files changed, 1961 insertions, 0 deletions
diff --git a/noatun-plugins/tyler/AUTHORS b/noatun-plugins/tyler/AUTHORS new file mode 100644 index 0000000..be639e7 --- /dev/null +++ b/noatun-plugins/tyler/AUTHORS @@ -0,0 +1,8 @@ +Noatun conversion +Neil Stevens <multivac@fcmail.com> + +Original XMMS plugin "Infinity" +Julien Carme <julien.carme@acm.org> + +with optimisations by +Mitja Horvat <Mitja.Horvat@hermes.si> diff --git a/noatun-plugins/tyler/COPYING b/noatun-plugins/tyler/COPYING new file mode 100644 index 0000000..623b625 --- /dev/null +++ b/noatun-plugins/tyler/COPYING @@ -0,0 +1,340 @@ + 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 Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 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. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/noatun-plugins/tyler/Makefile.am b/noatun-plugins/tyler/Makefile.am new file mode 100644 index 0000000..b42b7a0 --- /dev/null +++ b/noatun-plugins/tyler/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES= $(all_includes) $(SDL_CFLAGS) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = noatuntyler.la + +noatuntyler_la_SOURCES = tyler.cpp +noatuntyler_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatuntyler_la_LIBADD = $(LIB_KFILE) -lnoatun -lm + +bin_PROGRAMS = noatuntyler.bin + +noatuntyler_bin_SOURCES = main.cpp file.cpp compute.c display.c renderer.c +noatuntyler_bin_LDFLAGS = $(all_libraries) $(KDE_RPATH) +noatuntyler_bin_LDADD = $(LIB_KDECORE) -lm $(SDL_LIBS) + +noatun_DATA = tyler.plugin tylerstates +noatundir = $(kde_datadir)/noatun + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/tyler.pot diff --git a/noatun-plugins/tyler/README b/noatun-plugins/tyler/README new file mode 100644 index 0000000..246a966 --- /dev/null +++ b/noatun-plugins/tyler/README @@ -0,0 +1,89 @@ +Infinity -- An XMMS Visualization Plug-in +------------------------------------ + +version 0.2 + +by Julien Carme Copyright(C) 2000 + +Infinity is a XMMS plug-in which generate full-screen interactive light effects +according to a music. + +The installation can be done by a very standard ./configure && make && make install + +To run the plug-in, +-run xmms +-enter the visualization plug-ins menu (Ctrl-V), +-choose Infinity. +-choose Configure, and your resolution. +-choose Enable, and press Tab to enter Full-Screen mode. +-to stop it, press Tab again and disable it. + +You can change the resolution in the configuration menu. In full-screen mode,SDL +should choose the best possible resolution according to the resolution you asked +for. For example, 640x300 will display a letter-box screen in 640x480. +See SDL section for more information about the scale factor. + +You don't need to be root to enter the full-screen mode. + +There is two different modes in this plug-in, the default mode is non-interactive: + +-Non-Interactive Mode: + +States and palettes are selected randomly, and change sometimes. + + Keys: + - Space: change effect. + - F12: change palette. + - Tab: toggle full-screen. + - Enter: switch to interactive mode. + - F11: screenshot + + +-Interactive Mode: + +You can control the effect: + + Keys: + + - F12: change palette. + - Tab: toggle full-screen. + - Enter: switch to non-interactive mode. + - F1-F10: choose transformation vector field + - a,z: change curve 1 lighting + - q,s: change curve 2 lighting + - e,r: change curve 1 amplitude + - d,f: change curve 2 amplitude + - w: change curve 2 type + - mouse: change curve 2 position + - F11: screensh +. + +Speed: +------ +Infinity need a smooth animation to be interesting. +To increase speed, you can: +-compile with pgcc and full (-O6) optimisations. +-use low resolutions and letter box effect. +In 320x160, it should run on a small pentiums. + +SDL: +---- +You must have installed a recent version of SDL(>=1.0.6) to run this program. +If you experience problems with SDL, refer to their documentation first. +If you cannot obtain low resolutions, you should add them to the +screen section of your /etc/XF86Config (you can use your X configurator +instead of editing it yourself). If and only if you cannot change your +XF86Config, you can change the scale factor in the preference menu. But +the program will be much slower. + +Known Bugs: +----------- +Your X has to be at least in 16 bpp to make this program work. If you have more +than 16 bpp, it should work but may be very slow. If you still use a 8 bpp X, +mail me, I would really like to know if an implementation of it could interest +somebody. +Preferences cannot be saved, and cannot be changed while the plug-in is enabled. + + +Please send questions, comments, suggestions, bug reports or anything else to: +julien.carme@acm.org diff --git a/noatun-plugins/tyler/README.Infinity b/noatun-plugins/tyler/README.Infinity new file mode 100644 index 0000000..246a966 --- /dev/null +++ b/noatun-plugins/tyler/README.Infinity @@ -0,0 +1,89 @@ +Infinity -- An XMMS Visualization Plug-in +------------------------------------ + +version 0.2 + +by Julien Carme Copyright(C) 2000 + +Infinity is a XMMS plug-in which generate full-screen interactive light effects +according to a music. + +The installation can be done by a very standard ./configure && make && make install + +To run the plug-in, +-run xmms +-enter the visualization plug-ins menu (Ctrl-V), +-choose Infinity. +-choose Configure, and your resolution. +-choose Enable, and press Tab to enter Full-Screen mode. +-to stop it, press Tab again and disable it. + +You can change the resolution in the configuration menu. In full-screen mode,SDL +should choose the best possible resolution according to the resolution you asked +for. For example, 640x300 will display a letter-box screen in 640x480. +See SDL section for more information about the scale factor. + +You don't need to be root to enter the full-screen mode. + +There is two different modes in this plug-in, the default mode is non-interactive: + +-Non-Interactive Mode: + +States and palettes are selected randomly, and change sometimes. + + Keys: + - Space: change effect. + - F12: change palette. + - Tab: toggle full-screen. + - Enter: switch to interactive mode. + - F11: screenshot + + +-Interactive Mode: + +You can control the effect: + + Keys: + + - F12: change palette. + - Tab: toggle full-screen. + - Enter: switch to non-interactive mode. + - F1-F10: choose transformation vector field + - a,z: change curve 1 lighting + - q,s: change curve 2 lighting + - e,r: change curve 1 amplitude + - d,f: change curve 2 amplitude + - w: change curve 2 type + - mouse: change curve 2 position + - F11: screensh +. + +Speed: +------ +Infinity need a smooth animation to be interesting. +To increase speed, you can: +-compile with pgcc and full (-O6) optimisations. +-use low resolutions and letter box effect. +In 320x160, it should run on a small pentiums. + +SDL: +---- +You must have installed a recent version of SDL(>=1.0.6) to run this program. +If you experience problems with SDL, refer to their documentation first. +If you cannot obtain low resolutions, you should add them to the +screen section of your /etc/XF86Config (you can use your X configurator +instead of editing it yourself). If and only if you cannot change your +XF86Config, you can change the scale factor in the preference menu. But +the program will be much slower. + +Known Bugs: +----------- +Your X has to be at least in 16 bpp to make this program work. If you have more +than 16 bpp, it should work but may be very slow. If you still use a 8 bpp X, +mail me, I would really like to know if an implementation of it could interest +somebody. +Preferences cannot be saved, and cannot be changed while the plug-in is enabled. + + +Please send questions, comments, suggestions, bug reports or anything else to: +julien.carme@acm.org diff --git a/noatun-plugins/tyler/compute.c b/noatun-plugins/tyler/compute.c new file mode 100644 index 0000000..78d6f90 --- /dev/null +++ b/noatun-plugins/tyler/compute.c @@ -0,0 +1,188 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#include <math.h> +#include "renderer.h" +#include "compute.h" + +#define PI 3.14159 + +t_complex fct(t_complex a,int n,int p1,int p2) /*p1 et p2:0-4 */ +{ + t_complex b; + float fact; + float an; + float circle_size; + float speed; + float co,si; + + a.x-=scr_par.width/2; + a.y-=scr_par.height/2; + + switch (n) { + + case 0: + an=0.025*(p1-2)+0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.25; + speed=2000+p2*500; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + case 1: + an=0.015*(p1-2)+0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.45; + speed=4000+p2*1000; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + fact=(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + case 2: + an=0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.25; + speed=400+p2*100; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + case 3: + an=(sin(sqrt(a.x*a.x+a.y*a.y)/20)/20)+0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.25; + speed=4000; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + case 4: + an=0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.25; + speed=sin(sqrt(a.x*a.x+a.y*a.y)/5)*3000+4000; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + case 5: + b.x=a.x*1.02; + b.y=a.y*1.02; + break; + + case 6: + an=0.002; + co=cos(an); + si=sin(an); + circle_size=scr_par.height*0.25; + fact=1+cos(atan(a.x/(a.y+0.00001))*6)*0.02; + b.x=(co*a.x-si*a.y); + b.y=(si*a.x+co*a.y); + b.x=(b.x*fact); + b.y=(b.y*fact); + break; + + } + + b.x+=scr_par.width/2; + b.y+=scr_par.height/2; + if (b.x<0) + b.x=0; + if (b.y<0) + b.y=0; + if (b.x>scr_par.width-1) + b.x=scr_par.width-1; + if (b.y>scr_par.height-1) + b.y=scr_par.height-1; + + return b; +} + + +void generate_sector(int g,int f,int p1,int p2,int debut,int step,t_interpol* vector_field); + +void generate_sector(int g,int f,int p1,int p2,int debut,int step,t_interpol* vector_field) +{ + int fin=debut+step; + const int prop_transmitted=249; + const int b_add=g*scr_par.width*scr_par.height; + t_coord c; + + + if (fin>scr_par.height) + fin=scr_par.height; + for (c.y=debut;c.y<fin;c.y++) + for (c.x=0;c.x<scr_par.width;c.x++) { + t_complex a; + float fpy; + int rw,lw,add; + unsigned int w1,w2,w3,w4; + unsigned int x,y; + + a.x=(float)c.x; + a.y=(float)c.y; + a=fct(a,f,p1,p2); + add=c.x+c.y*scr_par.width; + x=(int)(a.x); + y=(int)(a.y); + vector_field[b_add+add].coord=(x<<16)|y; + + fpy=a.y-floor(a.y); + rw=(int)((a.x-floor(a.x))*prop_transmitted); + lw=prop_transmitted-rw; + w4=(int)(fpy*rw); + w2=rw-w4; + w3=(int)(fpy*lw); + w1=lw-w3; + vector_field[b_add+add].weight=(w1<<24)|(w2<<16)|(w3<<8)|w4; + } +} + +void generate_vector_field(t_interpol* vector_field) +{ + int f; + int i,p1,p2; + + for (f=0;f<NB_FCT;f++) { + p1=2; + p2=2; + for (i=0;i<scr_par.height;i+=10) + generate_sector(f,f,p1,p2,i,10,vector_field); + } +} diff --git a/noatun-plugins/tyler/compute.h b/noatun-plugins/tyler/compute.h new file mode 100644 index 0000000..5025360 --- /dev/null +++ b/noatun-plugins/tyler/compute.h @@ -0,0 +1,23 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#define NB_FCT 7 + +t_complex fct(t_complex a,int n,int p1,int p2); +void generate_vector_field(t_interpol* vector_field); + diff --git a/noatun-plugins/tyler/display.c b/noatun-plugins/tyler/display.c new file mode 100644 index 0000000..6b4f295 --- /dev/null +++ b/noatun-plugins/tyler/display.c @@ -0,0 +1,481 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#include "renderer.h" +#include "main.h" +#include "display.h" +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <SDL.h> + + +SDL_Color color_table[NB_PALETTES][256]; +short current_colors[256]; + +byte* surface1; +byte* surface2; + +void generate_colors(void) +{ + int i,k; + float colors[NB_PALETTES][2][3]={{{1,1,1},{1,1,1}}, + {{2,1.5,0},{0,0.5,2}}, + {{0,1,2},{0,1,0}}, + {{0,2,1},{0,0,1}}, + {{2,0,0},{0,1,1}}}; + + for (k=0;k<NB_PALETTES;k++) + { + for ( i=0; i<128; i++ ) + { + color_table[k][i].r = colors[k][0][0]*i; + color_table[k][i].g = colors[k][0][1]*i; + color_table[k][i].b = colors[k][0][2]*i; + } + + for ( i=0; i<128; i++ ) + { + color_table[k][i+128].r = colors[k][0][0]*127+colors[k][1][0]*i; + color_table[k][i+128].g = colors[k][0][1]*127+colors[k][1][1]*i; + color_table[k][i+128].b = colors[k][0][2]*127+colors[k][1][2]*i; + } + } +} + +void change_color(int t2,int t1,int w) +{ + unsigned int i; + + for (i=0;i<255;i++) + { + int r,g,b; + r = (color_table[t1][i].r*w+color_table[t2][i].r*(256-w) )>>11; + g = (color_table[t1][i].g*w+color_table[t2][i].g*(256-w) )>>10; + b = (color_table[t1][i].b*w+color_table[t2][i].b*(256-w) )>>11; + current_colors[i]=(r<<11)+(g<<5)+b; + } +} + +void compute_surface(t_interpol* vector_field) +{ + int i,j; + int add_dest=0; + int add_src; + t_interpol *interpol; + register byte* ptr_pix; + int color; + byte* ptr_swap; + + for (j=0;j<scr_par.height;j++) + { + for (i=0;i<scr_par.width;i++) + { + interpol=&vector_field[add_dest]; + add_src=(interpol->coord & 0xFFFF)*scr_par.width+(interpol->coord>>16); + ptr_pix=&((byte*)surface1)[add_src]; + color=(*(ptr_pix)*(interpol->weight>>24) + +*(ptr_pix+1)*((interpol->weight & 0xFFFFFF)>>16) + +*(ptr_pix+scr_par.width)*((interpol->weight & 0xFFFF)>>8) + +*(ptr_pix+scr_par.width+1)*(interpol->weight & 0xFF))>>8; + + if (color>255) + surface2[add_dest]=255; + else + surface2[add_dest]=color; + add_dest++; + } + } + + ptr_swap=surface1; + surface1=surface2; + surface2=ptr_swap; +} + +void display_surface(void) +{ + int i,j; + + if (scr_par.scale>1) + { + for (i=0;i<scr_par.height;i++) + { + short* pdest=(short*)(screen->pixels+i*screen->pitch*scr_par.scale); + byte* psrc=surface1+i*scr_par.width; + + if (scr_par.scale==2) + { + for (j=1; j<scr_par.width; j++) + { + *pdest = current_colors[*psrc++]; + pdest++; + *pdest = *(pdest-1); + pdest++; + } + + memcpy(screen->pixels+i*screen->pitch*2+screen->pitch, + screen->pixels+i*screen->pitch*2,screen->pitch); + } +/* else + { + for (j=1;j<scr_par.width;j++) { + *(pdest++)=current_colors[*psrc++]; + *(pdest++)=*(pdest-1); + *(pdest++)=*(pdest-1); + } + memcpy(screen->pixels+i*screen->pitch*3+screen->pitch, + screen->pixels+i*screen->pitch*3,screen->pitch); + memcpy(screen->pixels+i*screen->pitch*3+screen->pitch*2, + screen->pixels+i*screen->pitch*3,screen->pitch); + + } +*/ + } + } + else + { + byte* psrc=surface1; + for (i=0;i<scr_par.height;i++) + { + short* pdest=(short*)(screen->pixels+i*screen->pitch); + for (j=0;j<scr_par.width;j++) + *pdest++=current_colors[*psrc++]; + } + } + SDL_UpdateRect(screen, 0, 0, 0, 0); +} + +void blur(t_interpol* vector_field) +{ + compute_surface(vector_field); + display_surface(); +} + +void plot1(int x,int y,int c); +void plot1(int x,int y,int c) +{ + if (x>0 && x<scr_par.width-3 && y>0 && y<scr_par.height-3) + assign_max(&(surface1)[x+y*scr_par.width],c); +} + +void plot2(int x,int y,int c); +void plot2(int x,int y,int c) +{ + int ty; + + if (x>0 && x<scr_par.width-3 && y>0 && y<scr_par.height-3) { + ty = y*scr_par.width; + assign_max(&(surface1)[x+ty],c); + assign_max(&(surface1)[x+1+ty],c); + assign_max(&(surface1)[x+ty+scr_par.width],c); + assign_max(&(surface1)[x+1+ty+scr_par.width],c); + } +} + + +void plot3(int x,int y,int c); +void plot3(int x,int y,int c) +{ + int ty; + + if (x>0 && x<scr_par.width-3 && y>0 && y<scr_par.height-3) { + ty = y*scr_par.width; + assign_max(&(surface1)[x+ty],c/3); + assign_max(&(surface1)[x+1+ty],c>>1); + assign_max(&(surface1)[x+ty+scr_par.width],c>>1); + assign_max(&(surface1)[x+1+ty+scr_par.width],c); + assign_max(&(surface1)[x+ty+(scr_par.width<<1)],c/3); + assign_max(&(surface1)[x+2+ty+(scr_par.width<<1)],c/3); + assign_max(&(surface1)[x+1+ty+(scr_par.width<<1)],c>>1); + assign_max(&(surface1)[x+2+ty+scr_par.width],c>>1); + assign_max(&(surface1)[x+2+ty+scr_par.width],c/3); + } +} + +#if 0 +void line(int x1,int y1,int x2,int y2,int c) +{ + int i,j; + float x,y,vx,vy,d; + const float step=1; + + if (x1==x2 && y1==y2) + plot3(x1,y1,255); + else { + x=x1; + y=y1; + d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); + vx=step*(x2-x1)/d; + vy=step*(y2-y1)/d; + for (i=0;i<(int)(d/step)+1;i++) { + plot1(x,y,c); + x+=vx; + y+=vy; + } + } +} +#endif + +#define SWAP(x,y) \ + x = x + y; \ + y = x - y; \ + x = x - y; + +void line(int _x1, int _y1, int _x2, int _y2, int _c) +{ + int dx, dy, cxy, dxy; + /* calculate the distances */ + dx = abs(_x1 - _x2); + dy = abs(_y1 - _y2); + + cxy = 0; + if (dy > dx) + { + /* Follow Y axis */ + if (_y1 > _y2) + { + SWAP(_y1, _y2); + SWAP(_x1, _x2); + } + + if (_x1 > _x2) + dxy = -1; + else + dxy = 1; + + for (_y1=_y1; _y1<_y2; _y1++) + { + cxy += dx; + if (cxy >= dy) + { + _x1+= dxy; + cxy -= dy; + } + plot1(_x1, _y1, _c); + } + } + else + { + /* Follow X axis */ + if (_x1 > _x2) + { + SWAP(_x1, _x2); + SWAP(_y1, _y2); + } + + if (_y1 > _y2) + dxy = -1; + else + dxy = 1; + + for (_x1=_x1; _x1<_x2; _x1++) + { + cxy += dy; + if (cxy >= dx) + { + _y1+=dxy; + cxy -= dx; + } + plot1(_x1, _y1, _c); + } + } +} + +struct sincos +{ + int i; + float *f; +}; + +/* Little optimization for cos/sin functions */ +static struct sincos cosw = { 0, NULL }; +static struct sincos sinw = { 0, NULL }; + +void spectral(t_effect* current_effect,short data[2][512]) +{ + int i, halfheight, halfwidth; + float old_y1,old_y2; + float _y1=(((data[0][0]+data[1][0])>>9)*current_effect->spectral_amplitude*scr_par.height)>>12; + float _y2=(((data[0][0]+data[1][0])>>9)*current_effect->spectral_amplitude*scr_par.height)>>12; + const int density_lines=5; + const int step=4; + const int shift=(current_effect->spectral_shift*scr_par.height)>>8; + + if (cosw.i != scr_par.width || sinw.i != scr_par.width) + { + free(cosw.f); + free(sinw.f); + sinw.f = cosw.f = NULL; + sinw.i = cosw.i = 0; + } + + if (cosw.i == 0 || cosw.f == NULL) + { + float halfPI = (float)PI/2; + cosw.i = scr_par.width; + cosw.f = malloc(sizeof(float)*scr_par.width); + for (i=0; i<scr_par.width;i+=step) + cosw.f[i] = cos((float)i/scr_par.width*PI+halfPI); + } + + if (sinw.i == 0 || sinw.f == NULL) + { + float halfPI = (float)PI/2; + sinw.i = scr_par.width; + sinw.f = malloc(sizeof(float)*scr_par.width); + for (i=0; i<scr_par.width;i+=step) + sinw.f[i] = sin((float)i/scr_par.width*PI+halfPI); + } + + if (current_effect->mode_spectre==3) + { + if (_y1<0) + _y1=0; + + if (_y2<0) + _y2=0; + } + + halfheight = scr_par.height >> 1; + halfwidth = scr_par.width >> 1; + for (i=step;i<scr_par.width;i+=step) + { + old_y1=_y1; + old_y2=_y2; + _y1=((data[1][(i<<9)/scr_par.width/density_lines]>>8)* + current_effect->spectral_amplitude*scr_par.height)>>12; + _y2=((data[0][(i<<9)/scr_par.width/density_lines]>>8)* + current_effect->spectral_amplitude*scr_par.height)>>12; + + switch (current_effect->mode_spectre) + { + case 0: + line(i-step,halfheight+shift+old_y2, + i,halfheight+shift+_y2, + current_effect->spectral_color); + break; + case 1: + line(i-step,halfheight+shift+old_y1, + i,halfheight+shift+_y1, + current_effect->spectral_color); + line(i-step,halfheight-shift+old_y2, + i,halfheight-shift+_y2, + current_effect->spectral_color); + break; + case 2: + line(i-step,halfheight+shift+old_y1, + i,halfheight+shift+_y1, + current_effect->spectral_color); + line(i-step,halfheight-shift+old_y1, + i,halfheight-shift+_y1, + current_effect->spectral_color); + line(halfwidth+shift+old_y2,i-step, + halfwidth+shift+_y2,i, + current_effect->spectral_color); + line(halfwidth-shift+old_y2,i-step, + halfwidth-shift+_y2,i, + current_effect->spectral_color); + break; + case 3: + if (_y1<0) + _y1=0; + if (_y2<0) + _y2=0; + case 4: + line(halfwidth + cosw.f[i-step] * (shift+old_y1), + halfheight + sinw.f[i-step] * (shift+old_y1), + halfwidth + cosw.f[i] * (shift+_y1), + halfheight + sinw.f[i] * (shift+_y1), + current_effect->spectral_color); + line(halfwidth - cosw.f[i-step] * (shift+old_y2), + halfheight + sinw.f[i-step] * (shift+old_y2), + halfwidth - cosw.f[i] * (shift+_y2), + halfheight + sinw.f[i] * (shift+_y2), + current_effect->spectral_color); + break; + } + } + + if (current_effect->mode_spectre==3 || current_effect->mode_spectre==4) + line(halfwidth + cosw.f[scr_par.width - step] * (shift+_y1), + halfheight + sinw.f[scr_par.width - step] * (shift+_y1), + halfwidth - cosw.f[scr_par.width - step] * (shift+_y2), + halfheight + sinw.f[scr_par.width - step] * (shift+_y2), + current_effect->spectral_color); +} + +void curve(t_effect* current_effect) +{ + int i,j,k; + float v,vr; + float x,y; + float amplitude=(float)current_effect->curve_amplitude/256; + + for (j=0;j<2;j++) + { + v=80; + vr=0.001; + k=current_effect->x_curve; + for (i=0;i<64;i++) + { + x=cos((float)(k)/(v+v*j*1.34))*scr_par.height*amplitude; + y=sin((float)(k)/(1.756*(v+v*j*0.93)))*scr_par.height*amplitude; + plot2(x*cos((float)k*vr)+y*sin((float)k*vr)+scr_par.width/2, + x*sin((float)k*vr)-y*cos((float)k*vr)+scr_par.height/2, + current_effect->curve_color); + k++; + } + } + current_effect->x_curve=k; +} + + +void init_sdl(void) +{ + surface1=(byte*)malloc(scr_par.width*scr_par.height); + surface2=(byte*)malloc(scr_par.width*scr_par.height); + + if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) + { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); + } + + SDL_WM_SetCaption("Tyler", 0L); + screen = SDL_SetVideoMode(scr_par.width * scr_par.scale, + scr_par.height * scr_par.scale, 16, VIDEO_FLAGS); + + if ( screen == NULL ) + { + fprintf(stderr, "Couldn't init video mode: %s\n", SDL_GetError()); + exit(1); + } + SDL_ShowCursor(0); + SDL_EnableKeyRepeat(0,0); +} + +void toggle_fullscreen(void) +{ + SDL_WM_ToggleFullScreen(screen); +} + +void close_sdl(void) +{ + SDL_Quit(); +} diff --git a/noatun-plugins/tyler/display.h b/noatun-plugins/tyler/display.h new file mode 100644 index 0000000..d71b6c6 --- /dev/null +++ b/noatun-plugins/tyler/display.h @@ -0,0 +1,40 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#ifndef _DISPLAY_H_ +#define _DISPLAY_H_ + +#define NB_PALETTES 5 +#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) +#define assign_max(p,a) ( *p = ( *p > a ? *p : a )) +#define PI 3.14159 + +#define VIDEO_FLAGS (SDL_HWSURFACE|SDL_HWPALETTE) + +void generate_colors(void); +void change_color(int old_p,int p,int w); +void compute_surface(t_interpol* vector_field); +void display_surface(void); +void blur(t_interpol* vector_field); +void spectral(t_effect* current_effect,short data[2][512]); +void line(int _x1, int _y1, int _x2, int _y2, int _c); +void curve(t_effect* current_effect); +void init_sdl(void); +void toggle_fullscreen(void); +void close_sdl(void); +#endif diff --git a/noatun-plugins/tyler/file.cpp b/noatun-plugins/tyler/file.cpp new file mode 100644 index 0000000..58ddd79 --- /dev/null +++ b/noatun-plugins/tyler/file.cpp @@ -0,0 +1,81 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +extern "C" +{ +#include "renderer.h" +#include <stdlib.h> +} + +#include <qfile.h> +#include <kglobal.h> +#include <kstandarddirs.h> + +static QString getDataPath(void) +{ + KStandardDirs &dirs = *KGlobal::dirs(); + + return dirs.findResource("data", "noatun/tylerstates"); +} + +static QString getSavePath(void) +{ + KStandardDirs &dirs = *KGlobal::dirs(); + return dirs.saveLocation("data", "noatun/") + "tylerstates"; +} + +extern "C" void save_effect(t_effect *effect) +{ + QFile file(getSavePath()); + if(!file.open(IO_WriteOnly)) + return; + + for(unsigned i = 0; i < sizeof(t_effect); i++) + file.putch( *((byte *)effect + i) ); +} + +t_effect effects[100]; +int nb_effects=0; + +extern "C" void load_effects() +{ + QFile file(getDataPath()); + if(!file.open(IO_ReadOnly)) + exit(1); + + unsigned int i; + nb_effects = 0; + while(!file.atEnd()) + { + byte* ptr_effect = (byte *)&effects[nb_effects++]; + for(i = 0; i < sizeof(t_effect); i++) + ptr_effect[i] = file.getch(); + } +} + +extern "C" void load_random_effect(t_effect *effect) +{ + if(nb_effects > 0) + { + int num_effect = rand() % nb_effects; + unsigned int i; + + for(i = 0; i < sizeof(t_effect) ; i++) + *((byte*)effect+i)=*((byte*)(&effects[num_effect])+i); + } +} diff --git a/noatun-plugins/tyler/file.h b/noatun-plugins/tyler/file.h new file mode 100644 index 0000000..270bbea --- /dev/null +++ b/noatun-plugins/tyler/file.h @@ -0,0 +1,31 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#ifndef FILE_H +#define FILE_H + +#include <stdio.h> +#include "renderer.h" +#include <stdlib.h> + +extern void save_effect(t_effect *_effect); +extern void load_effects(void); +void load_random_effect(t_effect *effect); + +#endif // FILE_H + diff --git a/noatun-plugins/tyler/main.cpp b/noatun-plugins/tyler/main.cpp new file mode 100644 index 0000000..219c6ed --- /dev/null +++ b/noatun-plugins/tyler/main.cpp @@ -0,0 +1,100 @@ +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Charles Samuels <charles@kde.org> +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 + +#include <kinstance.h> + +extern "C" +{ +#include <SDL.h> +#include <SDL_syswm.h> +#include <SDL_thread.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> +#include <sys/types.h> + +#include "renderer.h" +#include "display.h" +} + +// stuff in main.h +extern "C" +{ +typedef struct t_config { + int xres,yres,sres; + int teff,tcol; +} t_config; + +t_config config = {512, 352, 1, 100, 100}; +//t_config config = {640, 480, 1, 100, 100}; + +bool finished; +SDL_Thread *thread; +SDL_mutex *synchro_mutex, *access_mutex; +short pcm_data[2][512]; +SDL_Surface *screen; +} + +int winID(void) +{ + SDL_SysWMinfo info; + info.version.major = SDL_MAJOR_VERSION; + info.subsystem = SDL_SYSWM_X11; + + SDL_GetWMInfo(&info); + return info.info.x11.wmwindow; +} + +int main(int, char **) +{ + fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL) & ~O_NONBLOCK); + + atexit(SDL_Quit); + + KInstance in("noatuntyler"); + + finished = false; + access_mutex = SDL_CreateMutex(); + + init_renderer1(); + printf("%u\n", winID()); + fflush(stdout); + init_renderer2(); + thread = SDL_CreateThread((int (*)(void *))renderer, NULL); + + fd_set set; + struct timeval tv; + while(check_finished() != 1) + { + FD_ZERO(&set); + FD_SET(STDIN_FILENO, &set); + tv.tv_sec = 0; + tv.tv_usec = 250; + if(0 < select(STDIN_FILENO + 1, &set, 0, 0, &tv)) + { + SDL_mutexP(access_mutex); + read(STDIN_FILENO, (void *)pcm_data, sizeof(short) * 2 * 512); + SDL_mutexV(access_mutex); + } + usleep(5); + } + /*fprintf(stderr,"exiting main()\n");*/ + SDL_WaitThread(thread, NULL); +} diff --git a/noatun-plugins/tyler/main.h b/noatun-plugins/tyler/main.h new file mode 100644 index 0000000..9b500b0 --- /dev/null +++ b/noatun-plugins/tyler/main.h @@ -0,0 +1,30 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#include <SDL.h> + +typedef struct t_config { + int xres,yres,sres; + int teff,tcol; +} t_config; + +extern int finished; +extern SDL_mutex *synchro_mutex,*access_mutex; +extern short pcm_data[2][512]; +extern t_config config; +extern SDL_Surface *screen; diff --git a/noatun-plugins/tyler/renderer.c b/noatun-plugins/tyler/renderer.c new file mode 100644 index 0000000..cd32959 --- /dev/null +++ b/noatun-plugins/tyler/renderer.c @@ -0,0 +1,195 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#include "file.h" +#include "main.h" +#include "renderer.h" +#include "compute.h" +#include "display.h" + +#include <SDL.h> +#include <SDL_keysym.h> +#include <stdlib.h> + +#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) + +t_interpol* vector_field; +t_effect current_effect; +t_screen_parametres scr_par; +t_general_parametres gen_par; +int old_color=0,color=0; +int t_last_color,t_last_effect; +int mode_interactif=0; + +void check_events(void) +{ + SDL_Event event; + byte* keystate; + int i; + int sx,sy; + if (mode_interactif) + { + SDL_GetMouseState(&sx,&sy); + current_effect.spectral_shift=sx; + } + + SDL_PollEvent(&event); + + if (event.type == SDL_KEYDOWN) + { + switch(event.key.keysym.sym) + { + case SDLK_RETURN: + mode_interactif=!mode_interactif; + break; + case SDLK_SPACE: + toggle_fullscreen(); + break; + case SDLK_TAB: + load_random_effect(¤t_effect); + t_last_effect=0; + break; + case SDLK_F12: + if (t_last_color>32) + { + t_last_color=0; + old_color=color; + color=(color+1)%NB_PALETTES; + } + break; + case SDLK_m: + if (mode_interactif) save_effect(¤t_effect); + break; + case SDLK_w: + if (mode_interactif) current_effect.mode_spectre=(current_effect.mode_spectre+1)%5; + break; + default: + break; + } + } + else if (event.type == SDL_QUIT) + { + finished = 1; + return; + } + + keystate = SDL_GetKeyState(NULL); + if (mode_interactif) + { + if ( keystate[SDLK_a]) + current_effect.curve_color=wrap(current_effect.curve_color-32); + if ( keystate[SDLK_z]) + current_effect.curve_color=wrap(current_effect.curve_color+32); + if ( keystate[SDLK_q]) + current_effect.spectral_color=wrap(current_effect.spectral_color-32); + if ( keystate[SDLK_s]) + current_effect.spectral_color=wrap(current_effect.spectral_color+32); + + for (i=0;i<10;i++) + { + if ( keystate[SDLK_F1+i]) + current_effect.num_effect=i%NB_FCT; + } + + if (keystate[SDLK_d]) { + current_effect.spectral_amplitude=(current_effect.spectral_amplitude-1); + } + if (keystate[SDLK_f]) { + current_effect.spectral_amplitude=(current_effect.spectral_amplitude+1); + } + if (keystate[SDLK_e]) { + current_effect.curve_amplitude=(current_effect.curve_amplitude-1); + } + if (keystate[SDLK_r]) { + current_effect.curve_amplitude=(current_effect.curve_amplitude+1); + } + } +} + + +int check_finished(void) +{ + return finished; +} + + +void init_renderer1(void) +{ + scr_par.width=config.xres; + scr_par.height=config.yres; + scr_par.scale=config.sres; + + gen_par.t_between_effects=config.teff; + gen_par.t_between_colors=config.tcol; + + init_sdl(); +} + +void init_renderer2(void) +{ + generate_colors(); + load_effects(); + load_random_effect(¤t_effect); + + vector_field=(t_interpol*)malloc(scr_par.width*scr_par.height*NB_FCT*sizeof(t_interpol)); + generate_vector_field(vector_field); +} + + +void renderer(void) +{ + while (check_finished() != 1) + { + check_events(); + blur(&vector_field[scr_par.width*scr_par.height*current_effect.num_effect]); + spectral(¤t_effect,pcm_data); + curve(¤t_effect); + if (t_last_color<=32) + { + change_color(old_color, + color, + t_last_color*8); + } + t_last_color+=1; + t_last_effect+=1; + if (t_last_effect%gen_par.t_between_effects==0) + { + if (!mode_interactif) { + load_random_effect(¤t_effect); + t_last_effect=0; + } + } + if (t_last_color%gen_par.t_between_colors==0) + { + if (!mode_interactif) { + old_color=color; + color=rand()%NB_PALETTES; + t_last_color=0; + } + } + } + /*fprintf(stderr,"exiting thread\n");*/ + close_renderer(); +} + +void close_renderer(void) +{ + free(vector_field); + close_sdl(); + SDL_mutexV(synchro_mutex); +} diff --git a/noatun-plugins/tyler/renderer.h b/noatun-plugins/tyler/renderer.h new file mode 100644 index 0000000..06aa326 --- /dev/null +++ b/noatun-plugins/tyler/renderer.h @@ -0,0 +1,69 @@ +/* +// Copyright (C) 2000 Julien Carme +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2, as +// published by the Free Software Foundation. +// +// 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 +*/ + +#ifndef RENDERER_H +#define RENDERER_H + +void check_events(void); +int check_finished(void); +void init_renderer1(void); +void init_renderer2(void); +void renderer(void); +void close_renderer(void); + +typedef unsigned char byte; + +typedef struct t_coord { + int x,y; +} t_coord; + +typedef struct t_complex { + float x,y; +} t_complex; + +typedef struct t_interpol { + unsigned int coord ; /* coordinates of the top left pixel.*/ + unsigned int weight; /*32 bits = 4*8= weights of the four corners */ +} t_interpol; + +typedef struct t_effect { + int num_effect; + int x_curve; + int curve_color; + int curve_amplitude; + int spectral_amplitude; + int spectral_color; + int mode_spectre; + int spectral_shift; +} t_effect; + +typedef struct t_screen_parametres { + int width; + int height; + int scale; + int bpp; /*bytes per pixels. */ +} t_screen_parametres; + +typedef struct t_general_parametres { + int t_between_effects; + int t_between_colors; +} t_general_parametres; + +extern t_screen_parametres scr_par; + +#endif diff --git a/noatun-plugins/tyler/tyler.cpp b/noatun-plugins/tyler/tyler.cpp new file mode 100644 index 0000000..7990ae2 --- /dev/null +++ b/noatun-plugins/tyler/tyler.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2001 Charles Samuels <charles@kde.org> +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> + +#include "tyler.h" + +#include <noatun/conversion.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprocess.h> +#include <kstandarddirs.h> +#include <noatun/app.h> +#include <kdebug.h> + +extern "C" Plugin *create_plugin() +{ + KGlobal::locale()->insertCatalogue("tyler"); + return new Tyler(); +} + +const int Tyler::bufferSize = 512; + +Tyler::Tyler() + : QObject() + , StereoScope(25) + , Plugin() +{ + setSamples(bufferSize*2); + mBuffer = new char[bufferSize * 16 * 2]; +} + +Tyler::~Tyler() +{ + delete [] mBuffer; +} + +void Tyler::init() +{ + process << KStandardDirs::findExe("noatuntyler.bin"); + connect(&process, SIGNAL(processExited(KProcess *)), this, SLOT(processExited(KProcess *))); + + // Note that process.start() will fail if findExe fails, so there's no real need + // for two separate checks. + if(!process.start(KProcess::NotifyOnExit, (KProcess::Communication)(KProcess::Stdin | KProcess::Stdout))) + { + KMessageBox::error(0, i18n("Unable to start noatuntyler.bin. Check your installation.")); + unload(); + } + else + start(); + +} + +void Tyler::scopeEvent(float *left, float *right, int size) +{ + if(process.isRunning()) + { + Conversion::convertMonoFloatTo16le((unsigned long)size, right, + (unsigned char*)mBuffer); + + Conversion::convertMonoFloatTo16le((unsigned long)size, left, + ((unsigned char*)mBuffer)+bufferSize*2); + process.writeStdin((char *)mBuffer, bufferSize*2*2); + } +} + +void Tyler::processExited(KProcess *) +{ + unload(); +} + +#include "tyler.moc" diff --git a/noatun-plugins/tyler/tyler.h b/noatun-plugins/tyler/tyler.h new file mode 100644 index 0000000..ff72a80 --- /dev/null +++ b/noatun-plugins/tyler/tyler.h @@ -0,0 +1,34 @@ +// Copyright (C) 2001 Charles Samuels <charles@kde.org> +// Copyright (C) 2001 Neil Stevens <neil@qualityassistant.com> + +#ifndef TYLER_H +#define TYLER_H + +#include <noatun/conversion.h> +#include <noatun/plugin.h> +#include <kprocess.h> +#include <qwidget.h> + +class Tyler : public QObject, public StereoScope, public Plugin +{ +Q_OBJECT + +public: + Tyler(); + virtual ~Tyler(); + + void init(); + +private slots: + void processExited(KProcess *); + +protected: + virtual void scopeEvent(float *left, float *right, int bands); + +private: + char *mBuffer; + static const int bufferSize; + KProcess process; +}; + +#endif diff --git a/noatun-plugins/tyler/tyler.plugin b/noatun-plugins/tyler/tyler.plugin new file mode 100644 index 0000000..4eb0412 --- /dev/null +++ b/noatun-plugins/tyler/tyler.plugin @@ -0,0 +1,70 @@ +Filename=noatuntyler.la +Author=Neil Stevens, Julien Carme +Site=http://noatun.kde.org/ +Email=neil@qualityassistant.com +Type=visualization +License=GPL +Name=Tyler +Name[hi]=टायलर +Name[hr]=Slagač +Name[it]=Tessuto +Name[ne]=टाइलर +Name[ru]=Тайлер +Name[ta]=டைலர் +Name[tg]=Тайлер +Comment=Ported from Infinity from XMMS +Comment[ar]=منقولة من XMMS Infinity +Comment[az]=Infinity-dən XMMS-ə port edilmişdir +Comment[bg]=Приставка, която наподобява темата Infinity от плеъра XMMS +Comment[br]=Porzhed eus Infinity ouzh XMMS +Comment[bs]=Portovano sa Infinity dodatka za XMMS +Comment[ca]=Portat des de l'Infinity de l'XMMS +Comment[cs]=Přenesený modul Infinity z XMMS +Comment[cy]=Troswyd o Infinity oddiwrth XMMS +Comment[da]=Porteret fra Infinity fra XMMS +Comment[de]=Portiert aus Infinity von XMMS +Comment[el]=Προσαρμογή από το Infinity για το XMMS +Comment[eo]=Portita el Infinity el XMMS +Comment[es]=Portado a partir de Infinity desde XMMS +Comment[et]=XMMSi Infinity port +Comment[eu]=XMMSren Infinity-tik etorria +Comment[fi]=Käännetty XMMS Infinitystä +Comment[fr]=Portage d'Infinity de XMMS +Comment[fy]=Oerdroegen fanút Infinity fan XMMS +Comment[gl]=Portado a partir de Infinity de XMMS +Comment[he]=הוסב מ־Infinity מ־XMMS +Comment[hi]=इनफिनिटी से एक्सएमएमएस पर पोर्टेड +Comment[hr]=Prebačeno iz Infinity-a, iz XMMS-a +Comment[hu]=Az XMMS Infinity átirata +Comment[is]=Flutt úr Infinity frá XMMS +Comment[it]=Preso da Infinity di XMMS +Comment[ja]=XMMS の Infinity から移植 +Comment[ka]=XMMS-იდან გადმოტანილი უსასრულობის გამოსახულება +Comment[kk]=XMMS Infinity-ден көшірілген көрініс +Comment[km]=បានការពារពីអនន្តរភាពពី XMMS +Comment[lt]=Perkeltas iš Infinity iš XMMS +Comment[mk]=Пренесена од Infinity од XMMS +Comment[ms]=Diangkut dari Infiniti dari XMMS +Comment[nb]=Overført fra XMMS til Infinity +Comment[nds]=Vun Infinity vun XMMS porteert +Comment[ne]=एक्सएमएमएसबाट अनन्तसम्म पोर्टेट गरिएको +Comment[nl]=Overgedragen vanuit Infinity van XMMS +Comment[nn]=Overført frå Infinity frå XMMS +Comment[pl]=Przeniesiona wtyczka Infinity z XMMS +Comment[pt]=Transposto a partir do Infinity do XMMS +Comment[pt_BR]=Portado do Infinity e do XMMS +Comment[ro]=Portat din Infinity din XMMS +Comment[ru]=Зрительный образ, портированный с образа Infinity из XMMS +Comment[sk]=Portované z Infinity z XMMS +Comment[sl]=Prenos iz Infinity iz XMMS +Comment[sr]=Пребачено са Infinity-ја са XMMS-а +Comment[sr@Latn]=Prebačeno sa Infinity-ja sa XMMS-a +Comment[sv]=Överförd från Infinity i XMMS +Comment[ta]=XMMS-ல் இருந்து முடிவில்லாத்து நுழைக்கப்பட்டது +Comment[tg]=Намуди тамошобин, ки бо намуди Infinity аз XMMS интиқол шудааст +Comment[tr]=XMMS'deki Infinity'den taşındı +Comment[uk]=Запозичене з Infinity від XMMS +Comment[vi]=Chuyển từ Infinity từ XMML +Comment[xh]=Iphathe okusuka kokungenasiphelo ukusuka kwi XMMS +Comment[zh_CN]=从 XMMS 的 Infinity 处移植来的 +Comment[zh_TW]=移自 XMMS 與 Infinity diff --git a/noatun-plugins/tyler/tylerstates b/noatun-plugins/tyler/tylerstates Binary files differnew file mode 100644 index 0000000..d784758 --- /dev/null +++ b/noatun-plugins/tyler/tylerstates |