pax_global_header00006660000000000000000000000064124651715200014515gustar00rootroot0000000000000052 comment=4ac23704cc50524c940ad9f3515c5f46333c96c3 vlevel-0.5.1/000077500000000000000000000000001246517152000130155ustar00rootroot00000000000000vlevel-0.5.1/.gitignore000066400000000000000000000011161246517152000150040ustar00rootroot00000000000000 # Created by http://www.gitignore.io ### C ### # Object files *.o *.ko *.obj *.elf # Libraries *.lib *.a # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex ### OSX ### .DS_Store .AppleDouble .LSOverride # Icon must end with two \r Icon # Thumbnails ._* # Files that might appear on external disk .Spotlight-V100 .Trashes # Directories potentially created on remote AFP share .AppleDB .AppleDesktop Network Trash Folder Temporary Items .apdisk vlevel-bin autom4te.cache autoscan.log configure.ac configure.scan vlevel-0.5.1/COPYING000066400000000000000000000634761246517152000140700ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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 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.1 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 Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! vlevel-0.5.1/INSTALL000066400000000000000000000007031246517152000140460ustar00rootroot00000000000000VLevel 0.3 INSTALL VLevel is distributed as source code. To build it, type "make". To install it, login as root (type "su") and type "make install". You can change where it is installed by editing Makefile before doing the above. I test VLevel on a Linux system, but it should build on any similar system. It should compile on Windows, but it won't be very useful until I write a Ruby script with a nice cross-platform GUI and SOX integration. vlevel-0.5.1/Makefile000066400000000000000000000042001246517152000144510ustar00rootroot00000000000000# This file is part of VLevel, a dynamic volume normalizer. # # Copyright 2003 Tom Felker # # 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.1 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 # User-editable options: # Change this to suit your preferences (maybe add -march=cputype) # This is what works fastest with GCC on my system # # I'd be interested to see how setting -DEXPECT impacts performance - # on my system, it makes it a bit worse. #export CXXFLAGS = -Wall -O3 -fPIC -DPIC -g -march=pentium4 export CXXFLAGS = -Wall -O3 -fPIC -DPIC # On my system, ICC is quite a bit faster, with these options: #export CC=icc #export CXX=icc #export LD=icc #export CXXFLAGS = -fPIC -DPIC -g -O3 -rcd # This is where it will be installed export PREFIX = /usr/local/ export LADSPA_PATH = $(PREFIX)/lib/ladspa/ # End of user-editable options. # Note: this probably isn't the best way to have one makefile for # source in several directories. Someday I'll figure out automake. # Writing Makefiles always makes me feel like I'm reinventing the # wheel. # This is evil, but it makes implicit link rules use g++, not gcc export CC = $(CXX) .PHONY: all install clean all: make -C volumeleveler all make -C vlevel-bin all make -C vlevel-ladspa all make -C vlevel-jack all install: all make -C volumeleveler install make -C vlevel-bin install make -C vlevel-ladspa install make -C vlevel-jack install clean: make -C volumeleveler clean make -C vlevel-bin clean make -C vlevel-ladspa clean make -C vlevel-jack clean vlevel-0.5.1/README.md000066400000000000000000000042121246517152000142730ustar00rootroot00000000000000#VLevel 0.5.1 ##What is VLevel? VLevel is a tool to amplify the soft parts of music so you don't have to fiddle with the volume control. It looks ahead a few seconds, so it can change the volume gradually without ever clipping. Because the volume is changed gradually, "dynamic contrast" is preserved. **This repository is a fork of the original vlevel code** since the last release of the original source is from 2004. Although this, the code is robust and it works pretty much unmodified nowadays. We imported form the old svn repository and added a new module in order to use it as a JACK client. After several months of test in a working production (a 24/7 broadcasting environment) we can confirm the software is reliable. ##What are the supported platform? We known VLevel to works in Linux and OSX Environments. We cannot at this moment test it on other platform, but we encourage you to collaborate ##How do I install VLevel? See the file INSTALL. For the impatient: `sudo make install`. ##How do I use VLevel? Original VLevel is a filter, meaning you pipe raw data to it, and it outputs the leveled data. For example: vlevel-bin < in.cdda > out.cdda There are options to control the length of the look-ahead buffer, the strength of the effect, and the maximum amplification, as well as the format of the raw data. Type "vlevel-bin --help" for details. Vlevel works also as a JACK client. for Example: vlevel-jack --length 22050 --max-multiplier 20 --strength 0.8 will create 2 capture ports and 2 playback ports on the JACK graph that can be used in combination with any other JACK client. VLevel also works as a LADSPA plugin. See http://www.ladspa.org for a lists of hosts that VLevel can plug into. ##What other features are planed? a Lv2 Plugin and a GUI (especially for vlevel-jack) ##Can I distribute VLevel? Please do. VLevel is licenced under the GPL, for more information, see the COPYING file. ##Where can I get more info? There is documentation in the docs directory. Documentation, help, and more are available from the website: http://vlevel.sourceforge.net Also support http://www.radiocicletta.it, our beloved webradio :3 vlevel-0.5.1/README.orig000066400000000000000000000024441246517152000146400ustar00rootroot00000000000000VLevel 0.5 README What is VLevel? VLevel is a tool to amplify the soft parts of music so you don't have to fiddle with the volume control. It looks ahead a few seconds, so it can change the volume gradually without ever clipping. Because the volume is changed gradually, "dynamic contrast" is preserved. How do I install VLevel? See the file INSTALL. For the impatient: "sudo make install". How do I use VLevel? VLevel is a filter, meaning you pipe raw data to it, and it outputs the leveled data. For example: vlevel-bin < in.cdda > out.cdda There are options to control the length of the look-ahead buffer, the strength of the effect, and the maximum amplification, as well as the format of the raw data. Type "vlevel-bin --help" for details. VLevel also works as a LADSPA plugin. See http://www.ladspa.org for a lists of hosts that VLevel can plug into. What other features are planed? A Ruby cross-platform GUI drag-n-drop converter that uses SOX. Can I distribute VLevel? Please do. VLevel is licenced under the GPL, for more information, see the COPYING file. Where can I get more info? There is documentation in the docs directory. News, new versions, contact info, help, and more are available from the website: http://vlevel.sourceforge.net vlevel-0.5.1/TODO000066400000000000000000000006201246517152000135030ustar00rootroot00000000000000More extensive testing, exotic channel config, feedback on other platforms Optimize for mono and stereo special cases - i tried this, and I couldn't do better than -O3 -march=pentium4 - someone else can try their hand, but beware. Cool FXRuby GUI with SOX Hopefully usable Winamp plugin before next version. Yay! Rememember: when updating version, change in docs, readme, and vlevel-bin.cpp vlevel-0.5.1/docs/000077500000000000000000000000001246517152000137455ustar00rootroot00000000000000vlevel-0.5.1/docs/notes.txt000066400000000000000000000027621246517152000156450ustar00rootroot00000000000000VLevel 0.3 notes.txt Channels VLevel abstracts audio into samples, each of which has as many values as there are channels, and most of the functions confusingly accept length in samples, but work on arrays of length (samples * values) doubles. You'd think this would be inneficient, but it's not. I tried changing the code to just work on arrays of double (which would only affect the lowest order bits, except for very short look-ahead), and it was actually a bit slower. I think the reason for this is that although when using channels, there is much more integer math and 2-iteration for loops, it means that the expensive slope calculation (not the whole search, but each slope = dy / dx) only has to be done half (1 / channels) as often. The moral is: channels aren't inneficient, don't waste your time abolishing them. Floating-point probably is, but fixed point may be even more ugly. The code currently allows for different functions to be called depending on the number of channels. For now, the generic code that works for any number of channels is fine, but speed optimization may be possible in the common mono and stereo cases. GCC Versions I discovered that while GCC 3.2 generates faster code than GCC 2.96, it's iostream implementation is slower by two orders of magnitude. I've changed the code to use FILE*, which is fast in either version, but that's ugly. I haven't tried other platforms or versions, but I see no reason they wouldn't work. vlevel-0.5.1/docs/technical.txt000066400000000000000000000124711246517152000164450ustar00rootroot00000000000000VLevel 0.3 technical.txt This is an outline of how VLevel works, which will hopefully be useful to anyone who helps develop it. (And me in a month.) Code Layout The core of VLevel is the VolumeLeveler class. It contains the look-ahead buffer. It works on blocks of double-precision numbers, called values (value_t). Some number (channels) of values makes up a sample. Many of VolumeLeveler's functions take lengths in samples instead of values, so be careful. vlevel-bin drives the VolumeLeveler class, and also uses CommandLine to parse it's options. Soon, there will be a Ruby script using SOX that makes Ogg, FLAC, and wav files work with a nice drag-n-drop GUI. General Idea The intent is to make the quiet parts louder. This is done by computing the volume at each point, then scaling it as described in the Math section. The complex part is finding out what the volume is at each point (VolumeLeveler::avg_amp). It must vary smoothly so the volume changes aren't obvious, but it must always be above the peaks of the waveform, or clipping could occur. To do this, there is a fifo buffer. Imagine a graph of position vs. amplitude showing the contents of the buffer. A horizontal line is drawn across it, representing VolumeLeveler::avg_amp. From where avg_amp crosses the y-axis, a line is drawn with the maximum possible slope to intercept one of the amplitude points. This line which is as steep as possible, is the smooth line that avg_amp will follow. When the value at the head of the buffer is removed, it is scaled based on avg_amp. avg_amp is then incremented by the slope of the line. If we reach the point the line was drawn to (max_slope_pos), we search the fifo for the next point of highest slope. Otherwise, we only need to check the incoming sample to see if a line drawn to it has the highest slope. y y (a few samples later) ^ ^ ^ | / max_slope | | / | | /s |s\---------- avg_amp | / s |s \ | / s |s \ max_slope | / s s |s s \ |--s-ss-s----avg_amp |s s \ | ss ss s s |s s ss |ssssssssss |ssssss +------------> x +---------> x Sorry for the ASCII art. The result is that the average amplitude (avg_amp) varies slowly and always stays above the amplitude of each sample. When the samples are removed, they are scaled based on the next section. Math Once we have avg_amp, each sample is scaled when it is output according to this: output_sample = sample * avg_amp ^ (-strength) This is derived as follows: First, we convert the amplitude of avg_amp to decibels (1 = 0dB): avg_amp_db = 10 * log10(avg_amp) avg_amp_db is less than zero. We want to scale it to be closer to zero, in such a way that if strength is 1, it will become zero, and if strength is 0 it will remain unchanged. ideal_amp_db = avg_amp_db * (1 - strength) ideal_amp_db = 10 * log10(avg_amp) * (1 - strength) Now we convert back to samples: ideal_amp = 10 ^ (ideal_amp_db / 10) ideal_amp = 10 ^ (log10(avg_amp) * (1 - strength)) ideal_amp = (10 ^ log10(avg_amp)) ^ (1 - strength) ideal_amp = avg_amp ^ (1 - strength) Now we find out what we should multiply the samples by to change their peak amplitude, avg_amp, to their ideal peak amplitude, ideal_amp: multiplier = ideal_amp / avg_amp multiplier = avg_amp ^ (1 - strength) / avg_amp multiplier = avg_amp ^ (-strength) And finally, we multiply the sample by the multiplier: output_sample = sample * multiplier output_sample = sample * avg_amp ^ (-strength) Undoing the effect If the original values for strength weren't too close to 1, you can undo the VLevel by giving the undo option. It works by changing strength as shown below. When we first leveled, we scaled the amplitudes like so: ideal_amp_db = avg_amp_db * (1 - strength) To get that back, we solve for avg_amp_db avg_amp_db = ideal_amp_db * 1 / (1 - strength) In this pass, however, the original avg_amp_db becomes ideal_amp_db, and the original (1 - strength) becomes 1 / (1 - strength). Now we skip ahead a bit: multiplier = avg_amp ^ (1 - strength) / avg_amp Substituting as explained above and continuing: multiplier = avg_amp ^ (1 / (1 - strength)) / avg_amp multiplier = avg_amp ^ ((1 / (1 - strength)) - 1) multiplier = avg_amp ^ (strength / (1 - strength)) But how do we get VLevel to do this? Well, we can give it any strength, and it does this: multiplier = avg_amp ^ -strength And we want it to do this: multiplier = avg_amp ^ (undo_strength / (1 - undo_strength)) So... -strength = undo_strength / (1 - undo_strength) strength = undo_strength / (undo_strength - 1) By choosing strength as above before starting VLevel, we can then undo the first VLevel, with no change to the main algorithm. To be totally precise, we'd also have to make a min_multiplier with a value of 1 / orig_max_multiplier, but that would be slow, and does anybody care if we drop the static anyway? It's not perfect, probably because avg_amp moves linearly, not logarithmically, so there are some rounding errors. Someday I might try changing that, but it's a big change. vlevel-0.5.1/utils/000077500000000000000000000000001246517152000141555ustar00rootroot00000000000000vlevel-0.5.1/utils/README000066400000000000000000000002211246517152000150300ustar00rootroot00000000000000These are a few scripts I use to make VLeveling stuff easier. They mostly work on Ogg files, and use SOX. They are short and self-explanatory. vlevel-0.5.1/utils/levelplay000077500000000000000000000001651246517152000161020ustar00rootroot00000000000000#!/bin/sh # uses vlevel to play .ogg files named on the command line ogg123 -d raw -f - "$@" | vlevel-bin | artscat vlevel-0.5.1/utils/raw2wav000077500000000000000000000001001246517152000154630ustar00rootroot00000000000000#!/bin/sh sox -raw -r44100 -s -w -c2 $1 `basename $1 .raw`.wav vlevel-0.5.1/utils/vlevel-dir000077500000000000000000000002171246517152000161540ustar00rootroot00000000000000#!/bin/sh mkdir vlevel for i in *.ogg do sox $i -t raw - | vlevel-bin $@ | sox -t raw -r 44100 -c 2 -ws - vlevel/`basename $i .ogg`.wav donevlevel-0.5.1/vlevel-bin/000077500000000000000000000000001246517152000150605ustar00rootroot00000000000000vlevel-0.5.1/vlevel-bin/Makefile000066400000000000000000000034241246517152000165230ustar00rootroot00000000000000# This file is part of VLevel, a dynamic volume normalizer. # # Copyright 2003 Tom Felker # # 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.1 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 # This is evil, but it makes implicit link rules use g++, not gcc CC = $(CXX) .PHONY: all all: vlevel-bin .PHONY: install install: all cp -f vlevel-bin $(PREFIX)/bin/ .PHONY: clean clean: -rm -f *.o vlevel-bin # This isn't ideal - if ../volumeleveler/volumeleveler.cpp was changed, # but make wasn't yet run there, then the .o file won't be new, so # the project will be improperly built. Also, if volumeleveler.o doesn't # exist yet, then make won't build it. Unfortunately, it's discouraged # to make it a .PHONY, and besides, that causes relinking every time # make is run here, even during install (which leaves root's files). # Make sucks. ../volumeleveler/volumeleveler.o: make -C ../volumeleveler all vlevel-bin: vlevel-bin.o \ commandline.o \ ../volumeleveler/volumeleveler.o vlevel-bin.o: vlevel-bin.cpp \ commandline.h \ ../volumeleveler/volumeleveler.h \ commandline.o: commandline.cpp commandline.h vlevel-0.5.1/vlevel-bin/commandline.cpp000066400000000000000000000054621246517152000200610ustar00rootroot00000000000000// This file is part of CommandLine, a C++ argument processing class. // // Copyright 2003 Tom Felker // // 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.1 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 // commandline.cpp // defines the CommandLine class #include #include #include #include #include "commandline.h" using namespace std; // argv is a pointer to a const pointer to a const char CommandLine::CommandLine(int argc, const char * const * argv) { if(argc < 1) throw out_of_range("CommandLine::CommandLine(): argc < 1"); for(int i = argc - 1; i > 0; --i) args.push(argv[i]); in_short = false; cur_is_arg = false; no_more_options = false; program_name = argv[0]; } string CommandLine::GetOption() { if(no_more_options || args.empty()) return ""; if(cur_is_arg) { cerr << "ignoring an argument" << endl; args.pop(); if(args.empty()) return ""; } while(true) { if(args.top().empty()) { args.pop(); if(args.empty()) return ""; in_short = false; } else { break; } } if(in_short) { string retval(args.top().substr(0, 1)); args.top().erase(0, 1); return retval; } if(args.top() == "--") { no_more_options = true; args.pop(); return ""; } if(args.top().substr(0,2) == "--") { args.top().erase(0, 2); size_t eq_pos = args.top().find("="); string retval(args.top().substr(0, eq_pos)); args.top().erase(0, eq_pos); if(args.top().empty()) { args.pop(); } else { args.top().erase(0, 1); cur_is_arg = true; } return retval; } if(args.top() == "-") return ""; if(args.top().substr(0, 1) == "-") { args.top().erase(0, 1); in_short = true; string retval(args.top().substr(0, 1)); args.top().erase(0, 1); if(args.top().empty()) args.pop(); return retval; } return ""; } string CommandLine::GetArgument() { if(args.empty()) return ""; string retval = args.top(); if(!cur_is_arg && retval == "--") { args.pop(); if(args.empty()) return ""; retval = args.top(); } args.pop(); cur_is_arg = false; in_short = false; return retval; } string CommandLine::GetProgramName() { return program_name; } bool CommandLine::End() const { return args.empty(); } vlevel-0.5.1/vlevel-bin/commandline.h000066400000000000000000000025711246517152000175240ustar00rootroot00000000000000// This file is part of CommandLine, a C++ argument processing class. // // Copyright 2003 Tom Felker // // 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.1 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 // commandline.h // declares the CommandLine class #include #include //////////////////////// // note: ill rewrite this to use a list of strings class CommandLine { public: // argv is a pointer to a const pointer to a const char CommandLine(int argc, const char * const * argv); std::string GetProgramName(); std::string GetOption(); std::string GetArgument(); bool End() const; private: std::string program_name; std::stack args; bool in_short; bool cur_is_arg; bool no_more_options; }; vlevel-0.5.1/vlevel-bin/vlevel-bin.cpp000066400000000000000000000164661246517152000176440ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // vlevel-bin.cpp - the vlevel-bin command, uses VolumeLeveler #include #include #include #include #include #include #include #include "../volumeleveler/volumeleveler.h" #include "commandline.h" using namespace std; void LevelRaw(istream &in, ostream& out, VolumeLeveler &vl, unsigned int bits_per_value); void Help(); void LevelRaw(FILE *in, FILE *out, VolumeLeveler &vl, unsigned int bits_per_value) { assert(bits_per_value % 8 == 0); // figure out the size of things size_t samples = vl.GetSamples(); size_t channels = vl.GetChannels(); size_t values = samples * channels; size_t bytes_per_value = bits_per_value / 8; size_t bytes = values * bytes_per_value; size_t s, ch; // VC++ 5.0's scoping rules are wrong, oh well. // allocate our interleaved buffers char *raw_buf = new char[bytes]; value_t *raw_value_buf = new value_t[values]; // allocate our per-channel buffers value_t **bufs = new value_t*[channels]; for(ch = 0; ch < channels; ++ch) bufs[ch] = new value_t[samples]; // how much data in the buffer is good size_t good_values, good_samples; // how much from the front of the buffer should be ignored size_t silence_values, silence_samples; while(!ferror(in) && !feof(in)) { // read and convert to value_t good_values = fread(raw_buf, bytes_per_value, values, in); good_samples = good_values / channels; ToValues(raw_buf, raw_value_buf, good_values, bits_per_value, true); // de-interleave the data for(size_t s = 0; s < good_samples; ++s) for(size_t ch = 0; ch < channels; ++ch) bufs[ch][s] = raw_value_buf[s * channels + ch]; // do the exchange silence_samples = vl.Exchange(bufs, bufs, good_samples); silence_values = silence_samples * channels; good_samples -= silence_samples; good_values -= silence_values; // interleave the data for(s = silence_samples; s < silence_samples + good_samples; ++s) for(size_t ch = 0; ch < channels; ++ch) raw_value_buf[s * channels + ch] = bufs[ch][s]; // write the data FromValues(&raw_value_buf[silence_values], raw_buf, good_values, bits_per_value, true); fwrite(raw_buf, bytes_per_value, good_values, out); } // silence the data for(s = 0; s < samples; ++s) for(size_t ch = 0; ch < channels; ++ch) bufs[ch][s] = 0; // exchange the data, silence_samples = vl.Exchange(bufs, bufs, samples); silence_values = silence_samples * channels; // good_samples = samples - silence_samples; good_values = values - silence_values; //interlace for(s = silence_samples; s < samples; ++s) for(size_t ch = 0; ch < channels; ++ch) raw_value_buf[s * channels + ch] = bufs[ch][s]; FromValues(&raw_value_buf[silence_values], raw_buf, good_values, bits_per_value, true); fwrite(raw_buf, bytes_per_value, good_values, out); delete [] raw_buf; delete [] raw_value_buf; for(ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; } void Help() { cerr << "VLevel v0.5" << endl << endl << "usage:" << endl << "\tvlevel-bin [options] < infile > outfile" << endl << endl << "options: (abbreviations also work)" << endl << "\t--length num" << endl << "\t\tSets the buffer to num samples long" << endl << "\t\tDefault is 132300 (three seconds at 44.1kHz)" << endl << "\t--channels num" << endl << "\t\tEach sample has num channels" << endl << "\t\tDefault is 2" << endl << "\t--strength num" << endl << "\t\tEffect strength, 1 is max, 0 is no effect." << endl << "\t\tDefault is .8" << endl << "\t--max-multiplier num" << endl << "\t\tSets the maximum amount a sample will be multiplied" << endl << "\t\tDefault is 20" << endl << "\t--undo" << endl << "\t\tReverses the effect of a previous VLevel" << endl; } int main(int argc, char *argv[]) { CommandLine cmd(argc, argv); size_t length = 3 * 44100; size_t channels = 2; value_t strength = .8, max_multiplier = 20; bool undo = false; string option, argument; while(option = cmd.GetOption(), !option.empty()) { if(option == "length" || option == "l") { if((istringstream(cmd.GetArgument()) >> length).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --length" << endl; return 2; } if(length < 2) { cerr << cmd.GetProgramName() << ": --length must be greater than 1" << endl; return 2; } } else if(option == "channels" || option == "c") { if((istringstream(cmd.GetArgument()) >> channels).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --channels" << endl; return 2; } if(channels < 1) { cerr << cmd.GetProgramName() << ": --channels must be greater than 0" << endl; return 2; } } else if(option == "strength" || option == "s") { if((istringstream(cmd.GetArgument()) >> strength).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --strength" << endl; return 2; } if(strength < 0 || strength > 1) { cerr << cmd.GetProgramName() << ": --strength must be between 0 and 1 inclusive." << endl; return 2; } } else if(option == "max-multiplier" || option == "m") { if((istringstream(cmd.GetArgument()) >> max_multiplier).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --max-multiplier" << endl << cmd.GetProgramName() << ": for no max multiplier, give a negative number" << endl; return 2; } } else if(option == "undo" || option == "u") { undo = true; } else if(option == "help" || option == "h") { Help(); return 0; } else { cerr << cmd.GetProgramName() << ": unrecognized option " << option << endl; Help(); return 2; } } // This works, see docs/technical.txt if(undo) strength = strength / (strength - 1); cerr << "Beginning VLevel with:" << endl << "length: " << length << endl << "channels: " << channels << endl << "strength: " << strength << endl << "max_multiplier: " << max_multiplier << endl; FILE *in = stdin; FILE *out = stdout; argument = cmd.GetArgument(); if(!argument.empty() && argument != "-") { in = fopen(argument.c_str(), "rb"); if(!in) { cerr << "Couldn't open input file '" << argument << "'.\n" << endl; return 2; } } argument = cmd.GetArgument(); if(!argument.empty() && argument != "-") { out = fopen(argument.c_str(), "wb"); if(!in) { cerr << "Couldn't open output file '" << argument << "'.\n" << endl; return 2; } } VolumeLeveler l(length, channels, strength, max_multiplier); LevelRaw(in, out, l, 16); return 0; } vlevel-0.5.1/vlevel-jack/000077500000000000000000000000001246517152000152205ustar00rootroot00000000000000vlevel-0.5.1/vlevel-jack/Makefile000066400000000000000000000042231246517152000166610ustar00rootroot00000000000000# This file is part of VLevel, a dynamic volume normalizer. # # Copyright 2003 Tom Felker # # 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.1 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 # commented out rules weer used to build it on OSX (yes, it works) # # This is evil, but it makes implicit link rules use g++, not gcc CC = $(CXX) #LDFLAGS = -L/opt/local/lib LDFLAGS = ` pkg-config --libs-only-L jack ` #LDLIBS = -ljack -lpthread -framework CoreAudio -framework CoreServices -framework AudioUnit LDLIBS = ` pkg-config --libs-only-l jack ` CXXFLAGS = ` pkg-config --cflags jack ` #CXXFLAGS= -I/opt/local/include -g -v CFLAGS = $(CXXFLAGS) .PHONY: all all: vlevel-jack .PHONY: install install: all cp -f vlevel-jack $(PREFIX)/bin/ .PHONY: clean clean: -rm -f *.o vlevel-jack # This isn't ideal - if ../volumeleveler/volumeleveler.cpp was changed, # but make wasn't yet run there, then the .o file won't be new, so # the project will be improperly built. Also, if volumeleveler.o doesn't # exist yet, then make won't build it. Unfortunately, it's discouraged # to make it a .PHONY, and besides, that causes relinking every time # make is run here, even during install (which leaves root's files). # Make sucks. ../volumeleveler/volumeleveler.o: make -C ../volumeleveler all vlevel-jack: vlevel-jack.o \ commandline.o \ ../volumeleveler/volumeleveler.o vlevel-jack.o: vlevel-jack.cpp \ commandline.h \ ../volumeleveler/volumeleveler.h \ commandline.o: commandline.cpp commandline.h vlevel-0.5.1/vlevel-jack/commandline.cpp000066400000000000000000000054621246517152000202210ustar00rootroot00000000000000// This file is part of CommandLine, a C++ argument processing class. // // Copyright 2003 Tom Felker // // 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.1 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 // commandline.cpp // defines the CommandLine class #include #include #include #include #include "commandline.h" using namespace std; // argv is a pointer to a const pointer to a const char CommandLine::CommandLine(int argc, const char * const * argv) { if(argc < 1) throw out_of_range("CommandLine::CommandLine(): argc < 1"); for(int i = argc - 1; i > 0; --i) args.push(argv[i]); in_short = false; cur_is_arg = false; no_more_options = false; program_name = argv[0]; } string CommandLine::GetOption() { if(no_more_options || args.empty()) return ""; if(cur_is_arg) { cerr << "ignoring an argument" << endl; args.pop(); if(args.empty()) return ""; } while(true) { if(args.top().empty()) { args.pop(); if(args.empty()) return ""; in_short = false; } else { break; } } if(in_short) { string retval(args.top().substr(0, 1)); args.top().erase(0, 1); return retval; } if(args.top() == "--") { no_more_options = true; args.pop(); return ""; } if(args.top().substr(0,2) == "--") { args.top().erase(0, 2); size_t eq_pos = args.top().find("="); string retval(args.top().substr(0, eq_pos)); args.top().erase(0, eq_pos); if(args.top().empty()) { args.pop(); } else { args.top().erase(0, 1); cur_is_arg = true; } return retval; } if(args.top() == "-") return ""; if(args.top().substr(0, 1) == "-") { args.top().erase(0, 1); in_short = true; string retval(args.top().substr(0, 1)); args.top().erase(0, 1); if(args.top().empty()) args.pop(); return retval; } return ""; } string CommandLine::GetArgument() { if(args.empty()) return ""; string retval = args.top(); if(!cur_is_arg && retval == "--") { args.pop(); if(args.empty()) return ""; retval = args.top(); } args.pop(); cur_is_arg = false; in_short = false; return retval; } string CommandLine::GetProgramName() { return program_name; } bool CommandLine::End() const { return args.empty(); } vlevel-0.5.1/vlevel-jack/commandline.h000066400000000000000000000025711246517152000176640ustar00rootroot00000000000000// This file is part of CommandLine, a C++ argument processing class. // // Copyright 2003 Tom Felker // // 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.1 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 // commandline.h // declares the CommandLine class #include #include //////////////////////// // note: ill rewrite this to use a list of strings class CommandLine { public: // argv is a pointer to a const pointer to a const char CommandLine(int argc, const char * const * argv); std::string GetProgramName(); std::string GetOption(); std::string GetArgument(); bool End() const; private: std::string program_name; std::stack args; bool in_short; bool cur_is_arg; bool no_more_options; }; vlevel-0.5.1/vlevel-jack/vlevel-jack.cpp000066400000000000000000000173041246517152000201340ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // ___ _ _ _ _ _ _ // | _ \__ _ __| (_)___ __(_)__| |___| |_| |_ __ _ // | / _` / _` | / _ \/ _| / _| / -_) _| _/ _` | // |_|_\__,_\__,_|_\___/\__|_\__|_\___|\__|\__\__,_| // La radio sempre in bolletta. #include #include #include #include #include #include #include #include #include #include #include #include #include "../volumeleveler/volumeleveler.h" #include "commandline.h" using namespace std; typedef jack_default_audio_sample_t sample_t; size_t sample_size = sizeof(jack_default_audio_sample_t); size_t lookahead_size = 512; size_t channels = 2; value_t strength = .8; value_t max_multiplier = 20; jack_client_t * client = NULL; VolumeLeveler * leveler = NULL; jack_port_t ** input_ports = NULL; jack_port_t ** output_ports = NULL; value_t ** input_bufferlist = NULL; value_t ** output_bufferlist = NULL; int vlevel_buffer_size_change_callback(jack_nframes_t nframes, void *arg) { size_t buffer_size = sizeof(value_t) * nframes; if (leveler) { delete leveler; free(input_bufferlist); free(output_bufferlist); } input_bufferlist = (value_t **) calloc(channels, sizeof(value_t *)); output_bufferlist = (value_t **) calloc(channels, sizeof(value_t *)); leveler = new VolumeLeveler(lookahead_size, channels, strength, max_multiplier); return 0; } int vlevel_process_callback(jack_nframes_t nframes, void *arg) { for (int i = 0; i < channels; i++) { sample_t * jack_input = (sample_t *)jack_port_get_buffer(input_ports[i], nframes); sample_t * jack_output = (sample_t *)jack_port_get_buffer(output_ports[i], nframes); input_bufferlist[i] = jack_input; output_bufferlist[i] = jack_output; } leveler->Exchange(input_bufferlist, output_bufferlist, nframes); return 0; } void jack_shutdown(void *arg) { cout << "Jack server shutdown" << endl; exit(0); } void vlevel_help() { cerr << "VLevel v0.5 JACK edition" << endl << endl << "usage:" << endl << "\tvlevel-bin [options] < infile > outfile" << endl << endl << "options: (abbreviations also work)" << endl << "\t--length num" << endl << "\t\tSize of the lookahead buffer. The longer, the slowest" << endl << "\t\tDefault is 512" << endl << "\t--channels num" << endl << "\t\tEach sample has num channels" << endl << "\t\tDefault is 2" << endl << "\t--strength num" << endl << "\t\tEffect strength, 1 is max, 0 is no effect." << endl << "\t\tDefault is .8" << endl << "\t--max-multiplier num" << endl << "\t\tSets the maximum amount a sample will be multiplied" << endl << "\t\tDefault is 20" << endl << "\t--undo" << endl << "\t\tReverses the effect of a previous VLevel" << endl; } int vlevel_parse_options( // in int argc, const char *const* argv, // out size_t * lookahead_size, size_t * channels, value_t * strength, value_t * max_multiplier ) { string option; string argument; bool undo(false); CommandLine cmd(argc, argv); while(option = cmd.GetOption(), !option.empty()) { if(option == "length" || option == "l") { if((istringstream(cmd.GetArgument()) >> *lookahead_size).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --length" << endl; return 2; } if(*channels < 1) { cerr << cmd.GetProgramName() << ": --channels must be greater than 0" << endl; return 2; } } else if(option == "channels" || option == "c") { if((istringstream(cmd.GetArgument()) >> *channels).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --channels" << endl; return 2; } if(*channels < 1) { cerr << cmd.GetProgramName() << ": --channels must be greater than 0" << endl; return 2; } } else if(option == "strength" || option == "s") { if((istringstream(cmd.GetArgument()) >> *strength).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --strength" << endl; return 2; } if(*strength < 0 || *strength > 1) { cerr << cmd.GetProgramName() << ": --strength must be between 0 and 1 inclusive." << endl; return 2; } } else if(option == "max-multiplier" || option == "m") { if((istringstream(cmd.GetArgument()) >> *max_multiplier).fail()) { cerr << cmd.GetProgramName() << ": bad or no option for --max-multiplier" << endl << cmd.GetProgramName() << ": for no max multiplier, give a negative number" << endl; return 2; } } else if(option == "undo" || option == "u") { undo = true; } else if(option == "help" || option == "h") { vlevel_help(); return 0; } else { cerr << cmd.GetProgramName() << ": unrecognized option " << option << endl; vlevel_help(); return 2; } } // This works, see docs/technical.txt if(undo) *strength = *strength / (*strength - 1); return 0; } int main(int argc, char *argv[]) { int retval = vlevel_parse_options(argc, argv, &lookahead_size, &channels, &strength, &max_multiplier); if (retval != 0) exit(retval); cerr << "Beginning VLevel with:" << endl << "channels: " << channels << endl << "strength: " << strength << endl << "max_multiplier: " << max_multiplier << endl; if ((client = jack_client_open("vlevel", JackNullOption, NULL)) == 0) { cerr << "jack server not running?" << endl; return 1; } if (jack_set_buffer_size_callback(client, vlevel_buffer_size_change_callback, NULL)) { cerr << "failed to set buffer size callback" << endl; return 1; } jack_on_shutdown (client, jack_shutdown, NULL); input_ports = (jack_port_t **)calloc(channels, sizeof(jack_port_t *)); output_ports = (jack_port_t **)calloc(channels, sizeof(jack_port_t *)); char out [256]; char in [256]; for (int i = 0; i < channels; i++){ sprintf(in, "capture_%d", i + 1); sprintf(out, "playback_%d", i + 1); input_ports[i] = jack_port_register(client, in, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); output_ports[i] = jack_port_register(client, out, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); } if (jack_set_process_callback(client, vlevel_process_callback, NULL)) { cerr << "cannot set process callback" << endl; return 1; } if (jack_activate (client)) { cerr << "cannot activate client" << endl; return 1; } sleep(-1); return 0; } vlevel-0.5.1/vlevel-ladspa/000077500000000000000000000000001246517152000155545ustar00rootroot00000000000000vlevel-0.5.1/vlevel-ladspa/Makefile000066400000000000000000000035441246517152000172220ustar00rootroot00000000000000# This file is part of VLevel, a dynamic volume normalizer. # # Copyright 2003 Tom Felker # # 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.1 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 # This is evil, but it makes implicit link rules use g++, not gcc CC = $(CXX) .PHONY: all all: vlevel-ladspa.so .PHONY: install install: all cp -f vlevel-ladspa.so $(LADSPA_PATH)/ .PHONY: clean clean: -rm -f *.o vlevel-ladspa.so # This isn't ideal - if ../volumeleveler/volumeleveler.cpp was changed, # but make wasn't yet run there, then the .o file won't be new, so # the project will be improperly built. Also, if volumeleveler.o doesn't # exist yet, then make won't build it. Unfortunately, it's discouraged # to make it a .PHONY, and besides, that causes relinking every time # make is run here, even during install (which leaves root's files). # Make sucks. ../volumeleveler/volumeleveler.o: make -C ../volumeleveler all vlevel-ladspa.so: vlevel-ladspa.o ../volumeleveler/volumeleveler.o $(CXX) $(CXXFLAGS) -shared -o vlevel-ladspa.so vlevel-ladspa.o ../volumeleveler/volumeleveler.o vlevel-ladspa.o: vlevel-ladspa.cpp \ vlevel-ladspa.h \ ladspa.h \ ../volumeleveler/volumeleveler.h \ vlevel-0.5.1/vlevel-ladspa/ladspa.h000066400000000000000000000657111246517152000172030ustar00rootroot00000000000000/* ladspa.h Linux Audio Developer's Simple Plugin API Version 1.1[LGPL]. Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, Stefan Westerfeld. 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.1 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. */ #ifndef LADSPA_INCLUDED #define LADSPA_INCLUDED #define LADSPA_VERSION "1.1" #define LADSPA_VERSION_MAJOR 1 #define LADSPA_VERSION_MINOR 1 #ifdef __cplusplus extern "C" { #endif /*****************************************************************************/ /* Overview: There is a large number of synthesis packages in use or development on the Linux platform at this time. This API (`The Linux Audio Developer's Simple Plugin API') attempts to give programmers the ability to write simple `plugin' audio processors in C/C++ and link them dynamically (`plug') into a range of these packages (`hosts'). It should be possible for any host and any plugin to communicate completely through this interface. This API is deliberately short and simple. To achieve compatibility with a range of promising Linux sound synthesis packages it attempts to find the `greatest common divisor' in their logical behaviour. Having said this, certain limiting decisions are implicit, notably the use of a fixed type (LADSPA_Data) for all data transfer and absence of a parameterised `initialisation' phase. See below for the LADSPA_Data typedef. Plugins are expected to distinguish between control and audio data. Plugins have `ports' that are inputs or outputs for audio or control data and each plugin is `run' for a `block' corresponding to a short time interval measured in samples. Audio data is communicated using arrays of LADSPA_Data, allowing a block of audio to be processed by the plugin in a single pass. Control data is communicated using single LADSPA_Data values. Control data has a single value at the start of a call to the `run()' or `run_adding()' function, and may be considered to remain this value for its duration. The plugin may assume that all its input and output ports have been connected to the relevant data location (see the `connect_port()' function below) before it is asked to run. Plugins will reside in shared object files suitable for dynamic linking by dlopen() and family. The file will provide a number of `plugin types' that can be used to instantiate actual plugins (sometimes known as `plugin instances') that can be connected together to perform tasks. This API contains very limited error-handling. */ /*****************************************************************************/ /* Fundamental data type passed in and out of plugin. This data type is used to communicate audio samples and control values. It is assumed that the plugin will work sensibly given any numeric input value although it may have a preferred range (see hints below). For audio it is generally assumed that 1.0f is the `0dB' reference amplitude and is a `normal' signal level. */ typedef float LADSPA_Data; /*****************************************************************************/ /* Special Plugin Properties: Optional features of the plugin type are encapsulated in the LADSPA_Properties type. This is assembled by ORing individual properties together. */ typedef int LADSPA_Properties; /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a real-time dependency (e.g. listens to a MIDI device) and so its output must not be cached or subject to significant latency. */ #define LADSPA_PROPERTY_REALTIME 0x1 /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin may cease to work correctly if the host elects to use the same data location for both input and output (see connect_port()). This should be avoided as enabling this flag makes it impossible for hosts to use the plugin to process audio `in-place.' */ #define LADSPA_PROPERTY_INPLACE_BROKEN 0x2 /* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin is capable of running not only in a conventional host but also in a `hard real-time' environment. To qualify for this the plugin must satisfy all of the following: (1) The plugin must not use malloc(), free() or other heap memory management within its run() or run_adding() functions. All new memory used in run() must be managed via the stack. These restrictions only apply to the run() function. (2) The plugin will not attempt to make use of any library functions with the exceptions of functions in the ANSI standard C and C maths libraries, which the host is expected to provide. (3) The plugin will not access files, devices, pipes, sockets, IPC or any other mechanism that might result in process or thread blocking. (4) The plugin will take an amount of time to execute a run() or run_adding() call approximately of form (A+B*SampleCount) where A and B depend on the machine and host in use. This amount of time may not depend on input signals or plugin state. The host is left the responsibility to perform timings to estimate upper bounds for A and B. */ #define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4 #define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME) #define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN) #define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE) /*****************************************************************************/ /* Plugin Ports: Plugins have `ports' that are inputs or outputs for audio or data. Ports can communicate arrays of LADSPA_Data (for audio inputs/outputs) or single LADSPA_Data values (for control input/outputs). This information is encapsulated in the LADSPA_PortDescriptor type which is assembled by ORing individual properties together. Note that a port must be an input or an output port but not both and that a port must be a control or audio port but not both. */ typedef int LADSPA_PortDescriptor; /* Property LADSPA_PORT_INPUT indicates that the port is an input. */ #define LADSPA_PORT_INPUT 0x1 /* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */ #define LADSPA_PORT_OUTPUT 0x2 /* Property LADSPA_PORT_CONTROL indicates that the port is a control port. */ #define LADSPA_PORT_CONTROL 0x4 /* Property LADSPA_PORT_AUDIO indicates that the port is a audio port. */ #define LADSPA_PORT_AUDIO 0x8 #define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT) #define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT) #define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL) #define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO) /*****************************************************************************/ /* Plugin Port Range Hints: The host may wish to provide a representation of data entering or leaving a plugin (e.g. to generate a GUI automatically). To make this more meaningful, the plugin should provide `hints' to the host describing the usual values taken by the data. Note that these are only hints. The host may ignore them and the plugin must not assume that data supplied to it is meaningful. If the plugin receives invalid input data it is expected to continue to run without failure and, where possible, produce a sensible output (e.g. a high-pass filter given a negative cutoff frequency might switch to an all-pass mode). Hints are meaningful for all input and output ports but hints for input control ports are expected to be particularly useful. More hint information is encapsulated in the LADSPA_PortRangeHintDescriptor type which is assembled by ORing individual hint types together. Hints may require further LowerBound and UpperBound information. All the hint information for a particular port is aggregated in the LADSPA_PortRangeHint structure. */ typedef int LADSPA_PortRangeHintDescriptor; /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field of the LADSPA_PortRangeHint should be considered meaningful. The value in this field should be considered the (inclusive) lower bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also specified then the value of LowerBound should be multiplied by the sample rate. */ #define LADSPA_HINT_BOUNDED_BELOW 0x1 /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field of the LADSPA_PortRangeHint should be considered meaningful. The value in this field should be considered the (inclusive) upper bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also specified then the value of UpperBound should be multiplied by the sample rate. */ #define LADSPA_HINT_BOUNDED_ABOVE 0x2 /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be considered a Boolean toggle. Data less than or equal to zero should be considered `off' or `false,' and data above zero should be considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or LADSPA_HINT_DEFAULT_1. */ #define LADSPA_HINT_TOGGLED 0x4 /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified should be interpreted as multiples of the sample rate. For instance, a frequency range from 0Hz to the Nyquist frequency (half the sample rate) could be requested by this hint in conjunction with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds at all must support this hint to retain meaning. */ #define LADSPA_HINT_SAMPLE_RATE 0x8 /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the user will find it more intuitive to view values using a logarithmic scale. This is particularly useful for frequencies and gains. */ #define LADSPA_HINT_LOGARITHMIC 0x10 /* Hint LADSPA_HINT_INTEGER indicates that a user interface would probably wish to provide a stepped control taking only integer values. Any bounds set should be slightly wider than the actual integer range required to avoid floating point rounding errors. For instance, the integer set {0,1,2,3} might be described as [-0.1, 3.1]. */ #define LADSPA_HINT_INTEGER 0x20 /* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' value for the port that is sensible as a default. For instance, this value is suitable for use as an initial value in a user interface or as a value the host might assign to a control port when the user has not provided one. Defaults are encoded using a mask so only one default may be specified for a port. Some of the hints make use of lower and upper bounds, in which case the relevant bound or bounds must be available and LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting default must be rounded if LADSPA_HINT_INTEGER is present. Default values were introduced in LADSPA v1.1. */ #define LADSPA_HINT_DEFAULT_MASK 0x3C0 /* This default values indicates that no default is provided. */ #define LADSPA_HINT_DEFAULT_NONE 0x0 /* This default hint indicates that the suggested lower bound for the port should be used. */ #define LADSPA_HINT_DEFAULT_MINIMUM 0x40 /* This default hint indicates that a low value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper * 0.25). */ #define LADSPA_HINT_DEFAULT_LOW 0x80 /* This default hint indicates that a middle value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * 0.5). */ #define LADSPA_HINT_DEFAULT_MIDDLE 0xC0 /* This default hint indicates that a high value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper * 0.75). */ #define LADSPA_HINT_DEFAULT_HIGH 0x100 /* This default hint indicates that the suggested upper bound for the port should be used. */ #define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 /* This default hint indicates that the number 0 should be used. Note that this default may be used in conjunction with LADSPA_HINT_TOGGLED. */ #define LADSPA_HINT_DEFAULT_0 0x200 /* This default hint indicates that the number 1 should be used. Note that this default may be used in conjunction with LADSPA_HINT_TOGGLED. */ #define LADSPA_HINT_DEFAULT_1 0x240 /* This default hint indicates that the number 100 should be used. */ #define LADSPA_HINT_DEFAULT_100 0x280 /* This default hint indicates that the Hz frequency of `concert A' should be used. This will be 440 unless the host uses an unusual tuning convention, in which case it may be within a few Hz. */ #define LADSPA_HINT_DEFAULT_440 0x2C0 #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) #define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE) #define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED) #define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE) #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) #define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER) #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MINIMUM) #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_LOW) #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MIDDLE) #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_HIGH) #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MAXIMUM) #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_0) #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_1) #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_100) #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_440) typedef struct _LADSPA_PortRangeHint { /* Hints about the port. */ LADSPA_PortRangeHintDescriptor HintDescriptor; /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When LADSPA_HINT_SAMPLE_RATE is also active then this value should be multiplied by the relevant sample rate. */ LADSPA_Data LowerBound; /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When LADSPA_HINT_SAMPLE_RATE is also active then this value should be multiplied by the relevant sample rate. */ LADSPA_Data UpperBound; } LADSPA_PortRangeHint; /*****************************************************************************/ /* Plugin Handles: This plugin handle indicates a particular instance of the plugin concerned. It is valid to compare this to NULL (0 for C++) but otherwise the host should not attempt to interpret it. The plugin may use it to reference internal instance data. */ typedef void * LADSPA_Handle; /*****************************************************************************/ /* Descriptor for a Type of Plugin: This structure is used to describe a plugin type. It provides a number of functions to examine the type, instantiate it, link it to buffers and workspaces and to run it. */ typedef struct _LADSPA_Descriptor { /* This numeric identifier indicates the plugin type uniquely. Plugin programmers may reserve ranges of IDs from a central body to avoid clashes. Hosts may assume that IDs are below 0x1000000. */ unsigned long UniqueID; /* This identifier can be used as a unique, case-sensitive identifier for the plugin type within the plugin file. Plugin types should be identified by file and label rather than by index or plugin name, which may be changed in new plugin versions. Labels must not contain white-space characters. */ const char * Label; /* This indicates a number of properties of the plugin. */ LADSPA_Properties Properties; /* This member points to the null-terminated name of the plugin (e.g. "Sine Oscillator"). */ const char * Name; /* This member points to the null-terminated string indicating the maker of the plugin. This can be an empty string but not NULL. */ const char * Maker; /* This member points to the null-terminated string indicating any copyright applying to the plugin. If no Copyright applies the string "None" should be used. */ const char * Copyright; /* This indicates the number of ports (input AND output) present on the plugin. */ unsigned long PortCount; /* This member indicates an array of port descriptors. Valid indices vary from 0 to PortCount-1. */ const LADSPA_PortDescriptor * PortDescriptors; /* This member indicates an array of null-terminated strings describing ports (e.g. "Frequency (Hz)"). Valid indices vary from 0 to PortCount-1. */ const char * const * PortNames; /* This member indicates an array of range hints for each port (see above). Valid indices vary from 0 to PortCount-1. */ const LADSPA_PortRangeHint * PortRangeHints; /* This may be used by the plugin developer to pass any custom implementation data into an instantiate call. It must not be used or interpreted by the host. It is expected that most plugin writers will not use this facility as LADSPA_Handle should be used to hold instance data. */ void * ImplementationData; /* This member is a function pointer that instantiates a plugin. A handle is returned indicating the new plugin instance. The instantiation function accepts a sample rate as a parameter. The plugin descriptor from which this instantiate function was found must also be passed. This function must return NULL if instantiation fails. Note that instance initialisation should generally occur in activate() rather than here. */ LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, unsigned long SampleRate); /* This member is a function pointer that connects a port on an instantiated plugin to a memory location at which a block of data for the port will be read/written. The data location is expected to be an array of LADSPA_Data for audio ports or a single LADSPA_Data value for control ports. Memory issues will be managed by the host. The plugin must read/write the data at these locations every time run() or run_adding() is called and the data present at the time of this connection call should not be considered meaningful. connect_port() may be called more than once for a plugin instance to allow the host to change the buffers that the plugin is reading or writing. These calls may be made before or after activate() or deactivate() calls. connect_port() must be called at least once for each port before run() or run_adding() is called. When working with blocks of LADSPA_Data the plugin should pay careful attention to the block size passed to the run function as the block allocated may only just be large enough to contain the block of samples. Plugin writers should be aware that the host may elect to use the same buffer for more than one port and even use the same buffer for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). However, overlapped buffers or use of a single buffer for both audio and control data may result in unexpected behaviour. */ void (*connect_port)(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation); /* This member is a function pointer that initialises a plugin instance and activates it for use. This is separated from instantiate() to aid real-time support and so that hosts can reinitialise a plugin instance by calling deactivate() and then activate(). In this case the plugin instance must reset all state information dependent on the history of the plugin instance except for any data locations provided by connect_port() and any gain set by set_run_adding_gain(). If there is nothing for activate() to do then the plugin writer may provide a NULL rather than an empty function. When present, hosts must call this function once before run() (or run_adding()) is called for the first time. This call should be made as close to the run() call as possible and indicates to real-time plugins that they are now live. Plugins should not rely on a prompt call to run() after activate(). activate() may not be called again unless deactivate() is called first. Note that connect_port() may be called before or after a call to activate(). */ void (*activate)(LADSPA_Handle Instance); /* This method is a function pointer that runs an instance of a plugin for a block. Two parameters are required: the first is a handle to the particular instance to be run and the second indicates the block size (in samples) for which the plugin instance may run. Note that if an activate() function exists then it must be called before run() or run_adding(). If deactivate() is called for a plugin instance then the plugin instance may not be reused until activate() has been called again. If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE then there are various things that the plugin should not do within the run() or run_adding() functions (see above). */ void (*run)(LADSPA_Handle Instance, unsigned long SampleCount); /* This method is a function pointer that runs an instance of a plugin for a block. This has identical behaviour to run() except in the way data is output from the plugin. When run() is used, values are written directly to the memory areas associated with the output ports. However when run_adding() is called, values must be added to the values already present in the memory areas. Furthermore, output values written must be scaled by the current gain set by set_run_adding_gain() (see below) before addition. run_adding() is optional. When it is not provided by a plugin, this function pointer must be set to NULL. When it is provided, the function set_run_adding_gain() must be provided also. */ void (*run_adding)(LADSPA_Handle Instance, unsigned long SampleCount); /* This method is a function pointer that sets the output gain for use when run_adding() is called (see above). If this function is never called the gain is assumed to default to 1. Gain information should be retained when activate() or deactivate() are called. This function should be provided by the plugin if and only if the run_adding() function is provided. When it is absent this function pointer must be set to NULL. */ void (*set_run_adding_gain)(LADSPA_Handle Instance, LADSPA_Data Gain); /* This is the counterpart to activate() (see above). If there is nothing for deactivate() to do then the plugin writer may provide a NULL rather than an empty function. Hosts must deactivate all activated units after they have been run() (or run_adding()) for the last time. This call should be made as close to the last run() call as possible and indicates to real-time plugins that they are no longer live. Plugins should not rely on prompt deactivation. Note that connect_port() may be called before or after a call to deactivate(). Deactivation is not similar to pausing as the plugin instance will be reinitialised when activate() is called to reuse it. */ void (*deactivate)(LADSPA_Handle Instance); /* Once an instance of a plugin has been finished with it can be deleted using the following function. The instance handle passed ceases to be valid after this call. If activate() was called for a plugin instance then a corresponding call to deactivate() must be made before cleanup() is called. */ void (*cleanup)(LADSPA_Handle Instance); } LADSPA_Descriptor; /**********************************************************************/ /* Accessing a Plugin: */ /* The exact mechanism by which plugins are loaded is host-dependent, however all most hosts will need to know is the name of shared object file containing the plugin types. To allow multiple hosts to share plugin types, hosts may wish to check for environment variable LADSPA_PATH. If present, this should contain a colon-separated path indicating directories that should be searched (in order) when loading plugin types. A plugin programmer must include a function called "ladspa_descriptor" with the following function prototype within the shared object file. This function will have C-style linkage (if you are using C++ this is taken care of by the `extern "C"' clause at the top of the file). A host will find the plugin shared object file by one means or another, find the ladspa_descriptor() function, call it, and proceed from there. Plugin types are accessed by index (not ID) using values from 0 upwards. Out of range indexes must result in this function returning NULL, so the plugin count can be determined by checking for the least index that results in NULL being returned. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); /* Datatype corresponding to the ladspa_descriptor() function. */ typedef const LADSPA_Descriptor * (*LADSPA_Descriptor_Function)(unsigned long Index); /**********************************************************************/ #ifdef __cplusplus } #endif #endif /* LADSPA_INCLUDED */ /* EOF */ vlevel-0.5.1/vlevel-ladspa/vlevel-ladspa.cpp000066400000000000000000000141061246517152000210210ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // vlevel-ladspa.cpp - the ladspa plugin #include "../volumeleveler/volumeleveler.h" #include "ladspa.h" #include "vlevel-ladspa.h" using namespace std; // Is there a reason this must be allocated? It seems to work without it. // Why not just a LADSPA_Port struct with names and hints? LADSPA_PortDescriptor vlevel_port_descriptors[] = { LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO }; char *vlevel_port_names[] = { "Look-ahead (seconds)", "Strength", "Limit Multiplier", "Multiplier Limit", "Undo", "Current Multiplier", "Input 1", "Output 1", "Input 2", "Output 2" }; // Why can't I just specify the default, instead of _LOW _HIGH masks? LADSPA_PortRangeHint vlevel_port_range_hints[] = { { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE, 0, 5 }, { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_HIGH, 0, 1 }, { LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_1, 0, 0 }, { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE, 0, 20 }, { LADSPA_HINT_TOGGLED | LADSPA_HINT_DEFAULT_0, 0, 0 }, { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0, 20 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; LADSPA_Descriptor vlevel_descriptor_mono = { // UniqueID UID_MONO, // Label "vlevel_mono", // Properties 0, // Name "VLevel (Mono)", // Maker "Tom Felker", // Copyright "GPL", // PortCount CONTROL_PORT_COUNT + 2, // PortDescriptors vlevel_port_descriptors, // PortNames vlevel_port_names, // PortRangeHints vlevel_port_range_hints, // ImplementationData 0, // instantiate Instantiate, // connect_port ConnectPort, // activate Activate, // run Run, // run_adding 0, // set_run_adding_gain 0, // deactivate Deactivate, // cleanup Cleanup }; LADSPA_Descriptor vlevel_descriptor_stereo = { // UniqueID UID_STEREO, // Label "vlevel_stereo", // Properties 0, // Name "VLevel (Stereo)", // Maker "Tom Felker", // Copyright "GPL", // PortCount CONTROL_PORT_COUNT + 4, // PortDescriptors vlevel_port_descriptors, // PortNames vlevel_port_names, // PortRangeHints vlevel_port_range_hints, // ImplementationData 0, // instantiate Instantiate, // connect_port ConnectPort, // activate Activate, // run Run, // run_adding 0, // set_run_adding_gain 0, // deactivate Deactivate, // cleanup Cleanup }; const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { switch(index) { case 0: return &vlevel_descriptor_mono; case 1: return &vlevel_descriptor_stereo; default: return 0; } } VLevelInstance::VLevelInstance(size_t channels, unsigned long rate): vl(2, channels), nch(channels), sample_rate(rate) { ports = new value_t*[CONTROL_PORT_COUNT + 2 * nch]; in = new value_t*[nch]; out = new value_t*[nch]; } VLevelInstance::~VLevelInstance() { delete [] ports; delete [] in; delete [] out; } void VLevelInstance::ConnectPort(unsigned long port, value_t *data_location) { ports[port] = data_location; if(port >= CONTROL_PORT_COUNT) // is a control port if((port - CONTROL_PORT_COUNT) % 2 == 0) // is an input port in[(port - CONTROL_PORT_COUNT) / 2] = data_location; else if((port - CONTROL_PORT_COUNT) % 2 == 1) // is an output port out[(port - CONTROL_PORT_COUNT) / 2] = data_location; } void VLevelInstance::Activate() { vl.Flush(); } void VLevelInstance::Run(unsigned long sample_count) { size_t samples = (size_t) (*ports[CONTROL_PORT_LOOK_AHEAD] * sample_rate); if(samples != vl.GetSamples()) { if(samples > 60 * sample_rate) samples = 60 * sample_rate; if(samples < 2) samples = 2; vl.SetSamplesAndChannels(samples, nch); } if(*ports[CONTROL_PORT_USE_MAX_MULTIPLIER] > 0) { vl.SetMaxMultiplier(*ports[CONTROL_PORT_MAX_MULTIPLIER]); } else { vl.SetMaxMultiplier(-1); } value_t strength = *ports[CONTROL_PORT_STRENGTH]; if(*ports[CONTROL_PORT_UNDO] > 0) strength /= (strength - 1); vl.SetStrength(strength); vl.Exchange(in, out, sample_count); *ports[CONTROL_PORT_OUTPUT_MULTIPLIER] = vl.GetMultiplier(); } void VLevelInstance::Deactivate() {} LADSPA_Handle Instantiate(const LADSPA_Descriptor *descriptor, unsigned long sample_rate) { switch(descriptor->UniqueID) { case UID_MONO: return (LADSPA_Handle)new VLevelInstance(1, sample_rate); case UID_STEREO: return (LADSPA_Handle)new VLevelInstance(2, sample_rate); } return 0; } void ConnectPort(LADSPA_Handle instance, unsigned long port, value_t *data_location) { ((VLevelInstance *)instance)->ConnectPort(port, data_location); } void Activate(LADSPA_Handle instance) { ((VLevelInstance *)instance)->Activate(); } void Run(LADSPA_Handle instance, unsigned long sample_count) { ((VLevelInstance *)instance)->Run(sample_count); } void Deactivate(LADSPA_Handle instance) { ((VLevelInstance *)instance)->Deactivate(); } void Cleanup(LADSPA_Handle instance) { delete (VLevelInstance *)instance; } vlevel-0.5.1/vlevel-ladspa/vlevel-ladspa.h000066400000000000000000000042761246517152000204750ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // vlevel-ladspa.h - for the LADSPA plugin #ifndef VLEVEL_LADSPA_H #define VLEVEL_LADSPA_H #include #include "../volumeleveler/volumeleveler.h" #include "ladspa.h" typedef LADSPA_Data value_t; #define CONTROL_PORT_COUNT 6 #define CONTROL_PORT_LOOK_AHEAD 0 #define CONTROL_PORT_STRENGTH 1 #define CONTROL_PORT_USE_MAX_MULTIPLIER 2 #define CONTROL_PORT_MAX_MULTIPLIER 3 #define CONTROL_PORT_UNDO 4 #define CONTROL_PORT_OUTPUT_MULTIPLIER 5 #define AUDIO_PORT_INPUT_1 6 #define AUDIO_PORT_OUTPUT_1 7 #define AUDIO_PORT_INPUT_2 8 #define AUDIO_PORT_OUTPUT_2 9 #define UID_MONO 1981 #define UID_STEREO 1982 class VLevelInstance { public: VLevelInstance(size_t channels, unsigned long rate); ~VLevelInstance(); void ConnectPort(unsigned long port, value_t *data_location); void Activate(); void Run(unsigned long sample_count); void Deactivate(); private: VolumeLeveler vl; size_t nch; value_t **ports; value_t **in; value_t **out; unsigned long sample_rate; }; LADSPA_Handle Instantiate(const LADSPA_Descriptor *descriptor, unsigned long sample_rate); void ConnectPort(LADSPA_Handle instance, unsigned long port, value_t *data_location); void Activate(LADSPA_Handle instance); void Run(LADSPA_Handle instance, unsigned long sample_count); void Deactivate(LADSPA_Handle instance); void Cleanup(LADSPA_Handle instance); #endif // ndef VLEVEL_LADSPA_H vlevel-0.5.1/vlevel-winamp/000077500000000000000000000000001246517152000156035ustar00rootroot00000000000000vlevel-0.5.1/vlevel-winamp/dsp.h000066400000000000000000000032151246517152000165430ustar00rootroot00000000000000// DSP plugin interface // notes: // any window that remains in foreground should optimally pass unused // keystrokes to the parent (winamp's) window, so that the user // can still control it. As for storing configuration, // Configuration data should be stored in \plugin.ini // (look at the vis plugin for configuration code) #ifndef INCLUDED_DSP_H #define INCLUDED_DSP_H typedef struct winampDSPModule { char *description; // description HWND hwndParent; // parent window (filled in by calling app) HINSTANCE hDllInstance; // instance handle to this DLL (filled in by calling app) void (*Config)(struct winampDSPModule *this_mod); // configuration dialog (if needed) int (*Init)(struct winampDSPModule *this_mod); // 0 on success, creates window, etc (if needed) // modify waveform samples: returns number of samples to actually write // (typically numsamples, but no more than twice numsamples, and no less than half numsamples) // numsamples should always be at least 128. should, but I'm not sure int (*ModifySamples)(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); void (*Quit)(struct winampDSPModule *this_mod); // called when unloading void *userData; // user data, optional } winampDSPModule; typedef struct { int version; // DSP_HDRVER char *description; // description of library winampDSPModule* (*getModule)(int); // module retrieval function } winampDSPHeader; // exported symbols typedef winampDSPHeader* (*winampDSPGetHeaderType)(); // header version: 0x20 == 0.20 == winamp 2.0 #define DSP_HDRVER 0x20 #endif //#ifndef INCLUDED_DSP_Hvlevel-0.5.1/vlevel-winamp/gpl.txt000066400000000000000000000431311246517152000171300ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. vlevel-0.5.1/vlevel-winamp/readme.txt000066400000000000000000000031331246517152000176010ustar00rootroot00000000000000vlevel winamp plugin 0.1 Copyright (C) 2003 Markus Sablatnig 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. vlevel ====== A big part of this software is the vlevel-library. VLevel is a dynamic compressor which amplifies the quiet parts of music. It uses a look-ahead buffer, so the changes are gradual and the audio never clips. VLevel was written by Tom Felker and is distributed under the Terms of the GNU Lesser General Public License(lGPL). More information at: www.sf.net/projects/vlevel What does this plugin do? ========================= It brings the benefits of vLevel to Nullsoft WinAmp. Basics ====== Version: Winamp2 or higher Platform: Win32 License: GPL Todo ==== - test conversion function in wrapper class - add config-dialog resource - save/restore values to/from registry(or ini) on init/quit - write installer/uninstaller - maybe skinning support? Done ==== - DLL framework - wrapper class - reorder project files (use ..\volumeleveler; directory structure; ...) vlevel-0.5.1/vlevel-winamp/vlevel/000077500000000000000000000000001246517152000171005ustar00rootroot00000000000000vlevel-0.5.1/vlevel-winamp/vlevel/lgpl.txt000066400000000000000000000634761246517152000206170ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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 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.1 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 Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! vlevel-0.5.1/vlevel-winamp/vlevel/vlevel.h000066400000000000000000000023361246517152000205520ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // vlevel.h - included by all #ifndef VLEVEL_H #define VLEVEL_H // Float actually is slightly less accurate (900/65536 in my tests), // but is needed by LADSPA. typedef float value_t; #define VLEVEL_ABS(x) fabsf(x) // same speed as above //#define VLEVEL_ABS(x) ((x) > 0 ? (x) : -(x)) // a bit faster on 2.96, a bit slower(!) on 3.2 //#define VLEVEL_ABS(x) (x) #endif // ndef VLEVEL_H vlevel-0.5.1/vlevel-winamp/vlevel/volumeleveler.cpp000066400000000000000000000117251246517152000225000ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // volumeleveler.cpp - defines the VolumeLeveler class #include #include #include #include #include "vlevel.h" #include "volumeleveler.h" using namespace std; VolumeLeveler::VolumeLeveler(size_t l, size_t c, value_t s, value_t m) { bufs = 0; SetSamplesAndChannels(l, c); SetStrength(s); SetMaxMultiplier(m); } VolumeLeveler::~VolumeLeveler() { for(size_t ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; } void VolumeLeveler::SetStrength(value_t s) { strength = s; } void VolumeLeveler::SetMaxMultiplier(value_t m) { if(m <= 0) m = HUGE_VAL; max_multiplier = m; } void VolumeLeveler::SetSamplesAndChannels(size_t s, size_t c) { assert(s > 1 && c > 0); if(bufs) { for(size_t ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; } bufs = new value_t*[c]; for(size_t ch = 0; ch < c; ++ch) bufs[ch] = new value_t[s]; samples = s; channels = c; Flush(); } void VolumeLeveler::Flush() { for(size_t ch = 0; ch < channels; ++ch) for(size_t i = 0; i < samples; ++i) bufs[ch][i] = 0; silence = samples; pos = max_slope_pos = 0; max_slope = max_slope_val = avg_amp = 0; } value_t VolumeLeveler::GetMultiplier() { value_t multiplier = pow(avg_amp, -strength); if(multiplier > max_multiplier) multiplier = max_multiplier; return multiplier; } size_t VolumeLeveler::Exchange(value_t **in_bufs, value_t **out_bufs, size_t in_samples) { switch(channels) { //case 1: // Exchange_1(in_bufs, out_bufs, in_samples); // break; //case 2: // Exchange_2(in_bufs, out_bufs, in_samples); // break; default: Exchange_n(in_bufs, out_bufs, in_samples); } if(silence >= in_samples) { silence -= in_samples; return in_samples; } else { size_t returned_silence = silence; silence = 0; return returned_silence; } } void VolumeLeveler::Exchange_n(value_t **in_bufs, value_t **out_bufs, size_t in_samples) { // for each user_pos in user_buf for(size_t user_pos = 0; user_pos < in_samples; ++user_pos) { // compute multiplier value_t multiplier = pow(avg_amp, -strength); // if avg_amp <= 0, then the above line sets multiplier to Inf, so // samples will scale to Inf or NaN. This causes a tick on the // first sample after a Flush() unless max_multiplier is not Inf. // hopefully this fix isn't too slow. if(avg_amp <= 0) multiplier = 0; // limit multiplier to max_multiplier. max_multiplier can be Inf // to disable this. if(multiplier > max_multiplier) multiplier = max_multiplier; // swap buf[pos] with user_buf[user_pos], scaling user[buf] by // multiplier and finding max of the new sample value_t new_val = 0; for(size_t ch = 0; ch < channels; ++ch) { value_t in = in_bufs[ch][user_pos]; out_bufs[ch][user_pos] = bufs[ch][pos] * multiplier; bufs[ch][pos] = in; if(VLEVEL_ABS(in) > new_val) new_val = fabs(in); } pos = (pos + 1) % samples; // now pos is the oldest, new one is pos-1 avg_amp += max_slope; if(pos == max_slope_pos) { // recompute (this is expensive) max_slope = -HUGE_VAL; for(size_t i = 1; i < samples; ++i) { value_t sample_val = 0; for(size_t ch = 0; ch < channels; ++ch) { value_t ch_val = VLEVEL_ABS(bufs[ch][(pos + i) % samples]); if(ch_val > sample_val) sample_val = ch_val; } value_t slope = (sample_val - avg_amp) / i; if(slope >= max_slope) { // must be >=, otherwise clipping causes excessive computation max_slope_pos = (pos + i) % samples; max_slope = slope; max_slope_val = sample_val; } } } else { // only chance of higher slope is the new sample // recomputing max_slope isn't really necessary... max_slope = (max_slope_val - avg_amp) / ((max_slope_pos - pos + samples) % samples); // ...but it doesn't take long and has a small effect. value_t slope = (new_val - avg_amp) / (samples - 1); if(slope >= max_slope) { // probably needs to be >= for same reason as above max_slope_pos = (pos - 1) % samples; max_slope = slope; max_slope_val = new_val; } } } } vlevel-0.5.1/vlevel-winamp/vlevel/volumeleveler.h000066400000000000000000000066011246517152000221420ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // volumeleveler.h - declares the VolumeLeveler class // // A note on terminology: atoms are indivual value_t values; samples // are one or more atoms, for example, for stereo, a sample has 2 // atoms, and channels is 2. #ifndef VOLUMELEVELER_H #define VOLUMELEVELER_H #include #include "vlevel.h" class VolumeLeveler { public: // constructs and destructs a VolumeLeveler with a length of l // samples with c channels each, an effect strength of s and a // maximum multiplier of m VolumeLeveler(size_t l = 44100, size_t c = 2, value_t s = .8, value_t m = 25); ~VolumeLeveler(); // Reallocates a buffer of l samples and c channels (contents are // lost) void SetSamplesAndChannels(size_t l, size_t c); // set and get the strength (between 0 and 1) (set doesn't affect // the buffer) if undo is true, vlevel will do the exact opposite, // so you can remove a vlevel. void SetStrength(value_t s); // set and get the max multiplier (set doesn't affect the buffer) void SetMaxMultiplier(value_t m); // get stuff inline size_t GetSamples() { return samples; }; inline size_t GetChannels() { return channels; }; inline value_t GetStrength() { return strength; }; inline value_t GetMaxMultiplier() { return max_multiplier; }; inline size_t GetSilence() { return silence; }; // get stats value_t GetMultiplier(); // fills the buffers with silence void Flush(); // replaces raw with processed, returns how many samples are // residual silence from when the buffers were empty. size_t Exchange(value_t **in_buf, value_t **out_buf, size_t in_samples); private: //void Exchange_1(value_t **in_buf, value_t **out_buf, size_t in_samples); //void Exchange_2(value_t **in_buf, value_t **out_buf, size_t in_samples); void Exchange_n(value_t **in_buf, value_t **out_buf, size_t in_samples); // the buffer value_t **bufs; // the length of the buffers size_t samples; // the number of channels size_t channels; // the strength of the effect (between 0 and 1) value_t strength; // the maximum value by which a sample will be scaled value_t max_multiplier; // the amount of silence (data that wasn't input) left in the buffer (samples). size_t silence; // position about to be returned (samples) size_t pos; // position of the max slope (samples) size_t max_slope_pos; // the current "blanket" amplitude value_t avg_amp; // the maximum slope value_t max_slope; // the value at the maximum slope value_t max_slope_val; }; #endif // ndef VOLUMELEVELER_H vlevel-0.5.1/vlevel-winamp/vlevel_winamp.cpp000066400000000000000000000073621246517152000211670ustar00rootroot00000000000000/////////////////////////////////////////////////////////////////////////////// // // vlevel_winamp.cpp - this file is part of vlevel winamp plugin 0.1 // Copyright (C) 2003 Markus Sablatnig // // 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. // /////////////////////////////////////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN #include #include #include #include "dsp.h" #include "vlevel_wrapper.h" // avoid stupid CRT silliness BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { return TRUE; } // module getter. winampDSPModule *getModule(int which); void config(struct winampDSPModule *this_mod); int init(struct winampDSPModule *this_mod); void quit(struct winampDSPModule *this_mod); int modify_samples(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); // Module header, includes version, description, and address of the module retriever function winampDSPHeader hdr = { DSP_HDRVER, "VLevel-Winamp v0.2 - an automatic volume leveler", getModule }; // first module winampDSPModule mod = { "VLevel-Winamp v0.2", NULL, // hwndParent NULL, // hDllInstance config, init, modify_samples, quit }; #ifdef __cplusplus extern "C" { #endif // this is the only exported symbol. returns our main header. __declspec( dllexport ) winampDSPHeader *winampDSPGetHeader2() { return &hdr; } #ifdef __cplusplus } #endif winampDSPModule *getModule(int which) { if( which == 0 ) return &mod; else return NULL; } void config(struct winampDSPModule *this_mod) { // TODO: Code this. MessageBox(this_mod->hwndParent,"Not implemented.", "TestMsg",MB_OK); } int init(struct winampDSPModule *this_mod) { CVLWrapper* pvlw_userData = 0; try { pvlw_userData = new CVLWrapper; if( !pvlw_userData ) return 1; this_mod->userData = static_cast(pvlw_userData); // TODO: read values from the ini file. // dsp.h says configuration data should be stored in \plugin.ini }//try catch(...) { if( pvlw_userData ) delete pvlw_userData; this_mod->userData = pvlw_userData = 0; return 1; }//catch return 0; } void quit(struct winampDSPModule *this_mod) { if( this_mod->userData ) delete this_mod->userData; this_mod->userData = 0; }//quit int modify_samples(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate) { assert(this_mod && this_mod->userData); return ((CVLWrapper *)(this_mod->userData))->Exchange((void *)samples, numsamples, bps, nch, srate); } // TODO: ...but maybe impossible. // We could elimate the delay caused by seeking if we flushed VLevel's internal buffer // before seeking. So if there's a way to intercept a seek, set a flag, and flush // the VolumeLeveler on the next modify_samples, it would be better. // TODO: ...but almost certainly impossible. // I think there will be an issue with the last buffer-ful of the song being discarded. // We can eliminate this if there was a way to instruct the host to call modify_samples // until it returns zero. I can dream, can't I? vlevel-0.5.1/vlevel-winamp/vlevel_winamp.dsp000066400000000000000000000111321246517152000211610ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="vlevel_winamp" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=vlevel_winamp - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "vlevel_winamp.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "vlevel_winamp.mak" CFG="vlevel_winamp - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "vlevel_winamp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "vlevel_winamp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "vlevel_winamp - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VLEVEL_WINAMP_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VLEVEL_WINAMP_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "NDEBUG" # ADD RSC /l 0xc07 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "vlevel_winamp - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VLEVEL_WINAMP_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MD /W3 /GX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "_DEBUG" # ADD RSC /l 0xc07 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /pdb:none /machine:I386 /out:"C:\Program Files\Winamp\Plugins\dsp_vlevel.dll" # SUBTRACT LINK32 /debug !ENDIF # Begin Target # Name "vlevel_winamp - Win32 Release" # Name "vlevel_winamp - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\vlevel_winamp.cpp # End Source File # Begin Source File SOURCE=.\vlevel_wrapper.cpp # End Source File # Begin Source File SOURCE=..\volumeleveler\volumeleveler.cpp # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=\vlevel\volumeleveler\compiler.h # End Source File # Begin Source File SOURCE=.\DSP.H # End Source File # Begin Source File SOURCE=.\vlevel\vlevel.h # End Source File # Begin Source File SOURCE=.\vlevel_wrapper.h # End Source File # Begin Source File SOURCE=.\vlevel\volumeleveler.h # End Source File # End Group # Begin Group "Ressourcendateien" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project vlevel-0.5.1/vlevel-winamp/vlevel_winamp.dsw000066400000000000000000000011011246517152000211630ustar00rootroot00000000000000Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! ############################################################################### Project: "vlevel_winamp"=.\vlevel_winamp.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### vlevel-0.5.1/vlevel-winamp/vlevel_wrapper.cpp000066400000000000000000000127571246517152000213600ustar00rootroot00000000000000/////////////////////////////////////////////////////////////////////////////// // // vlevel_wrapper.cpp - this file is part of vlevel winamp plugin 0.1 // Copyright (C) 2003 Markus Sablatnig // Copyright (C) 2003 Tom Felker // // 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 #include #include "..\\volumeleveler\\volumeleveler.h" #include "vlevel_wrapper.h" CVLWrapper::CVLWrapper(): ms_samples(44100), ms_channels(2), mv_strength(.8), mv_maxMultiplier(25), mv_length(1), ms_rate(44100), mb_samplesOrChannelsChanged(false), mb_strengthChanged(false), mb_maxMultiplierChanged(false) { mpvl_wrapped = new VolumeLeveler(ms_samples, ms_channels, mv_strength, mv_maxMultiplier); // I'm surprised this isn't automatic. if(!mpvl_wrapped) throw std::bad_alloc(); } // CVLWrapper::CVLWrapper CVLWrapper::~CVLWrapper() { delete mpvl_wrapped; // TODO: when I cache the buffer allocations, I must delete them here. } void CVLWrapper::SetCachedChannels(size_t s_channels) { assert(s_channels > 0); if(ms_channels != s_channels) { ms_channels = s_channels; mb_samplesOrChannelsChanged = true; } } // CVLWrapper::SetCachedChannels void CVLWrapper::SetCachedStrength(value_t v_strength) { mv_strength = v_strength; mb_strengthChanged = true; } // CVLWrapper::SetCachedStrength void CVLWrapper::SetCachedMaxMultiplier(value_t v_maxMultiplier) { mv_maxMultiplier = v_maxMultiplier; mb_maxMultiplierChanged = true; } // CVLWrapper::SetCachedMaxMultiplier void CVLWrapper::SetCachedLength(value_t v_length) { mv_length = v_length; SetCachedSamples(GetCachedLength() * GetCachedRate()); } // CVLWrapper::SetCachedLength void CVLWrapper::SetCachedRate(size_t s_rate) { ms_rate = s_rate; ms_samples = mv_length * ms_rate; SetCachedSamples(GetCachedLength() * GetCachedRate()); } // CVLWrapper::SetCachedRate // Don't call this unless you've just computed s_amples from mv_length and ms_rate. void CVLWrapper::SetCachedSamples(size_t s_samples) { assert(s_samples > 1); if(ms_samples != s_samples) { ms_samples = s_samples; mb_samplesOrChannelsChanged = true; } } // CVLWrapper::SetCachedSamples void CVLWrapper::CacheFlush() { if( mb_samplesOrChannelsChanged) { mpvl_wrapped->SetSamplesAndChannels(ms_samples, ms_channels); mb_samplesOrChannelsChanged = false; } // if if( mb_strengthChanged ) { mpvl_wrapped->SetStrength(mv_strength); mb_strengthChanged = false; } // if if(mb_maxMultiplierChanged) { mpvl_wrapped->SetMaxMultiplier(mv_maxMultiplier); SetCachedMaxMultiplier(mpvl_wrapped->GetMaxMultiplier()); // turns negative mms to HUGE_VAL mb_maxMultiplierChanged = false; } // if } // CVLWrapper::CacheFlush int CVLWrapper::Exchange(void *raw_buf, int samples, int bits_per_value, int channels, int rate) { SetCachedChannels(channels); SetCachedRate(rate); CacheFlush(); size_t values = samples * channels; // TODO: cache these allocations for performance. // This buffer holds interleaved value_t data. value_t *raw_value_buf = new value_t[values]; // Allocate our per-channel value_t buffers. // This is the format VolumeLeveler requires. value_t **bufs = new value_t*[channels]; for(size_t ch = 0; ch < channels; ++ch) bufs[ch] = new value_t[samples]; // Take data from supplied integer raw_buf to allocated value_t interleaved raw_value_buf. ToValues((char *)raw_buf, raw_value_buf, values, bits_per_value, true); // true because data is signed. // De-interleave the data. for(size_t s = 0; s < samples; ++s) for(size_t ch = 0; ch < channels; ++ch) bufs[ch][s] = raw_value_buf[s * channels + ch]; // Perform the effect. // silence_samples is how many samples at the beginning of the returned buffer // are silent because the real data hasn't worked through VLevel's buffer yet. size_t silence_samples = mpvl_wrapped->Exchange(bufs, bufs, samples); size_t good_samples = samples - silence_samples; size_t good_values = good_samples * channels; // Re-interleave the data. // Visual C++ improperly lets the s defined above persist outside that loop. // Notice that leading silence_samples are stripped and good data is shifted. for(/* size_t */ s = 0; s < good_samples; ++s) for(size_t ch = 0; ch < channels; ++ch) raw_value_buf[s * channels + ch] = bufs[ch][s + silence_samples]; // Put the good data back into the supplied integer buffer. FromValues(raw_value_buf, (char *)raw_buf, good_values, bits_per_value, true); // Deallocate our buffers. for(/* size_t */ ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; delete [] raw_value_buf; // Winamp is sloppy about using int when size_t is correct. Oh, well. // dsp.h says we shouldn't return less than half as many samples as we're given, // but returning 0 seems to work fine. return good_samples; } // CVLWrapper::Exchange vlevel-0.5.1/vlevel-winamp/vlevel_wrapper.h000066400000000000000000000063371246517152000210220ustar00rootroot00000000000000/////////////////////////////////////////////////////////////////////////////// // // vlevel_wrapper.h - this file is part of vlevel winamp plugin 0.1 // Copyright (C) 2003 Markus Sablatnig // Copyright (C) 2003 Tom Felker // // 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 INCLUDED_VLEVEL_WRAPPER_H #define INCLUDED_VLEVEL_WRAPPER_H // This is now the only volumeleveler header #include "..\\volumeleveler\\volumeleveler.h" // This class is a wrapper for VolumeLeveler. // It caches some settings and de-/interlaces // Exchange()'s in and output buffers class CVLWrapper { public: CVLWrapper(); ~CVLWrapper(); //these automatically mark the values as 'changed' inline void SetCachedChannels(size_t channels); // at least 1 inline void SetCachedStrength(value_t v_strength); // 0.0 to 1.0 inline void SetCachedMaxMultiplier(value_t v_maxMultiplier); // negative for no limit // these affect the internal representation of ms_samples inline void SetCachedLength(value_t v_length); // in seconds inline void SetCachedRate(size_t s_rate); // in Hz //these Get functions might be useful inline size_t GetCachedChannels() { return ms_channels; }; inline value_t GetCachedStrength() { return mv_strength; }; inline value_t GetCachedMaxMultiplier() { return mv_maxMultiplier; }; inline value_t GetCachedLength() { return mv_length; }; inline size_t GetCachedRate() { return ms_rate; }; inline size_t GetCachedSamples() { return ms_samples; }; // write cached values to the wrapped object // This is called automatically in Exchange() inline void CacheFlush( void ); // Exchange() handles it's own de- and re-interlacing and CacheFlush()s. // Each sample has nch values - just use the same convention as Winamp and VLevel. int Exchange(void *samples, int numsamples, int bps, int nch, int rate); private: // Instead of setting this directly, use SetLength() and SetRate(). inline void SetCachedSamples( size_t s_samples ); // main object VolumeLeveler* mpvl_wrapped; // cached values size_t ms_samples; size_t ms_channels; value_t mv_strength; value_t mv_maxMultiplier; // ms_samples is recomputed when these are changed. value_t mv_length; size_t ms_rate; // Using change flags is faster and more accurate. // It can cause unnecessary flushes when rate and length are changed inversely, // but perfect is the enemy of good in this case. bool mb_samplesOrChannelsChanged; bool mb_strengthChanged; bool mb_maxMultiplierChanged; }; //CVLWrapper #endif //#ifndef VLEVEL_WRAPPER_H vlevel-0.5.1/volumeleveler/000077500000000000000000000000001246517152000157035ustar00rootroot00000000000000vlevel-0.5.1/volumeleveler/Makefile000066400000000000000000000017461246517152000173530ustar00rootroot00000000000000# This file is part of VLevel, a dynamic volume normalizer. # # Copyright 2003 Tom Felker # # 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.1 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 .PHONY: all all: volumeleveler.o .PHONY: install install: all .PHONY: clean clean: -rm -f volumeleveler.o volumeleveler.o: volumeleveler.cpp volumeleveler.h vlevel-0.5.1/volumeleveler/volumeleveler.cpp000066400000000000000000000164071246517152000213050ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // volumeleveler.cpp - defines the VolumeLeveler class #include #include #include #include "volumeleveler.h" using namespace std; VolumeLeveler::VolumeLeveler(size_t l, size_t c, value_t s, value_t m) { bufs = 0; SetSamplesAndChannels(l, c); SetStrength(s); SetMaxMultiplier(m); } VolumeLeveler::~VolumeLeveler() { for(size_t ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; } void VolumeLeveler::SetStrength(value_t s) { strength = s; } void VolumeLeveler::SetMaxMultiplier(value_t m) { if(m <= 0) m = HUGE_VAL; max_multiplier = m; } void VolumeLeveler::SetSamplesAndChannels(size_t s, size_t c) { assert(s > 1 && c > 0); if(bufs) { for(size_t ch = 0; ch < channels; ++ch) delete [] bufs[ch]; delete [] bufs; } bufs = new value_t*[c]; for(size_t ch = 0; ch < c; ++ch) bufs[ch] = new value_t[s]; samples = s; channels = c; Flush(); } void VolumeLeveler::Flush() { for(size_t ch = 0; ch < channels; ++ch) for(size_t i = 0; i < samples; ++i) bufs[ch][i] = 0; silence = samples; pos = max_slope_pos = 0; max_slope = max_slope_val = avg_amp = 0; } value_t VolumeLeveler::GetMultiplier() { value_t multiplier = pow(avg_amp, -strength); if(multiplier > max_multiplier) multiplier = max_multiplier; return multiplier; } size_t VolumeLeveler::Exchange(value_t **in_bufs, value_t **out_bufs, size_t in_samples) { switch(channels) { //case 1: // Exchange_1(in_bufs, out_bufs, in_samples); // break; //case 2: // Exchange_2(in_bufs, out_bufs, in_samples); // break; default: Exchange_n(in_bufs, out_bufs, in_samples); } if(silence >= in_samples) { silence -= in_samples; return in_samples; } else { size_t returned_silence = silence; silence = 0; return returned_silence; } } void VolumeLeveler::Exchange_n(value_t **in_bufs, value_t **out_bufs, size_t in_samples) { // for each user_pos in user_buf for(size_t user_pos = 0; user_pos < in_samples; ++user_pos) { // compute multiplier value_t multiplier = pow(avg_amp, -strength); // if avg_amp <= 0, then the above line sets multiplier to Inf, so // samples will scale to Inf or NaN. This causes a tick on the // first sample after a Flush() unless max_multiplier is not Inf. // hopefully this fix isn't too slow. if(unlikely(avg_amp <= 0)) multiplier = 0; // untested! // The advantage of using floats is that you can be // sloppy with going over 1. Since we have this nifty // average_amp calculation, let's apply it to limit // the audio to varying normally below 1. Again, // hopefully this won't slow things down too much. if(unlikely(avg_amp > 1)) multiplier = 1 / avg_amp; // limit multiplier to max_multiplier. max_multiplier can be Inf // to disable this. if(unlikely(multiplier > max_multiplier)) multiplier = max_multiplier; // swap buf[pos] with user_buf[user_pos], scaling user[buf] by // multiplier and finding max of the new sample value_t new_val = 0; for(size_t ch = 0; ch < channels; ++ch) { value_t in = in_bufs[ch][user_pos]; out_bufs[ch][user_pos] = bufs[ch][pos] * multiplier; bufs[ch][pos] = in; if(VLEVEL_ABS(in) > new_val) new_val = VLEVEL_ABS(in); } pos = (pos + 1) % samples; // now pos is the oldest, new one is pos-1 avg_amp += max_slope; if(unlikely(pos == max_slope_pos)) { // recompute (this is expensive) max_slope = -HUGE_VAL; for(size_t i = 1; i < samples; ++i) { value_t sample_val = 0; for(size_t ch = 0; ch < channels; ++ch) { value_t ch_val = VLEVEL_ABS(bufs[ch][(pos + i) % samples]); if(ch_val > sample_val) sample_val = ch_val; } value_t slope = (sample_val - avg_amp) / i; // must be >=, otherwise clipping causes excessive computation // TODO: maybe optimize - just save i, then compute slope, pos, and val only once later. // maybe unlikely() if(unlikely(slope >= max_slope)) { max_slope_pos = (pos + i) % samples; max_slope = slope; max_slope_val = sample_val; } } } else { // only chance of higher slope is the new sample // recomputing max_slope isn't really necessary... max_slope = (max_slope_val - avg_amp) / ((max_slope_pos - pos + samples) % samples); // ...but it doesn't take long and has a small effect. value_t slope = (new_val - avg_amp) / (samples - 1); // probably needs to be >= for same reason as above // maybe unlikely() if(unlikely(slope >= max_slope)) { max_slope_pos = (pos - 1) % samples; max_slope = slope; max_slope_val = new_val; } } } } // this code has been proven correct, but not tested much. ;-) void ToValues(char *in, value_t *out, size_t values, size_t bits_per_value, bool has_sign) { switch(bits_per_value) { case 32: if(has_sign) { for(size_t i = 0; i < values; ++i) out[i] = ((value_t)((int32_t *)in)[i]) / 2147483648; } else { for(size_t i = 0; i < values; ++i) out[i] = (((value_t)((u_int32_t *)in)[i]) - 2147483648) / 2147483648; } break; case 16: if(has_sign) { for(size_t i = 0; i < values; ++i) out[i] = ((value_t)((int16_t *)in)[i]) / 32768; } else { for(size_t i = 0; i < values; ++i) out[i] = (((value_t)((u_int16_t *)in)[i]) - 32768) / 32768; } break; case 8: if(has_sign) { for(size_t i = 0; i < values; ++i) out[i] = ((value_t)((int8_t *)in)[i]) / 128; } else { for(size_t i = 0; i < values; ++i) out[i] = (((value_t)((u_int8_t *)in)[i]) - 128) / 128; } break; default: assert(false); } } // note: no clipping, just wrap. I don't know how badly clipping will perform. void FromValues(value_t *in, char *out, size_t values, size_t bits_per_value, bool has_sign) { switch(bits_per_value) { case 32: if(has_sign) { for(size_t i = 0; i < values; ++i) ((int32_t *)out)[i] = (int32_t)(in[i] * 2147483647); } else { for(size_t i = 0; i < values; ++i) ((u_int32_t *)out)[i] = (u_int32_t)((in[i] * 2147483647) + 2147483647); } break; case 16: if(has_sign) { for(size_t i = 0; i < values; ++i) ((int16_t *)out)[i] = (int16_t)(in[i] * 32767); } else { for(size_t i = 0; i < values; ++i) ((u_int16_t *)out)[i] = (u_int16_t)((in[i] * 32767) + 32767); } break; case 8: if(has_sign) { for(size_t i = 0; i < values; ++i) ((int8_t *)out)[i] = (int8_t)(in[i] * 127); } else { for(size_t i = 0; i < values; ++i) ((u_int8_t *)out)[i] = (u_int8_t)((in[i] * 127) + 127); } break; default: assert(false); } } vlevel-0.5.1/volumeleveler/volumeleveler.h000066400000000000000000000112761246517152000207510ustar00rootroot00000000000000// This file is part of VLevel, a dynamic volume normalizer. // // Copyright 2003 Tom Felker // // 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.1 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 // volumeleveler.h - declares the VolumeLeveler class // // A note on terminology: atoms are indivual value_t values; samples // are one or more atoms, for example, for stereo, a sample has 2 // atoms, and channels is 2. #ifndef VOLUMELEVELER_H #define VOLUMELEVELER_H #include typedef float value_t; #define VLEVEL_ABS(x) fabsf(x) // same speed as above //#define VLEVEL_ABS(x) ((x) > 0 ? (x) : -(x)) // a bit faster on 2.96, a bit slower(!) on 3.2 //#define VLEVEL_ABS(x) (x) // TODO: VLEVEL_MAX? or maybe that's not worth it // Branch Prediction: // // NOTE: for some strange reason, doing nothing is fastest, my // hand-tuned unlikely() macros is slightly slower, and letting // -fprofile-arcs and -fbranch-probabilities help the optimization is // slowest yet. This is the exact opposite of what I'd expect. Hmm. // I wish somebody would optimize GCC up to the speed of ICC. // // XXX: should be only for GCC versions that support this: // taken from linux/include/linux/compiler.h #ifdef EXPECT #warning using tweaks #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else #define likely(x) (x) #define unlikely(x) (x) #endif // Converts from an integer format to value_t // values is the number of values in out, in needs values*bits/8 bytes. void ToValues(char *in, value_t *out, size_t values, size_t bits_per_value, bool has_sign); // Converts from value_t to an integer format // values is the number of values in in, out needs values*bits/8 bytes. void FromValues(value_t *in, char *out, size_t values, size_t bits_per_value, bool has_sign); class VolumeLeveler { public: // constructs and destructs a VolumeLeveler with a length of l // samples with c channels each, an effect strength of s and a // maximum multiplier of m VolumeLeveler(size_t l = 44100, size_t c = 2, value_t s = .8, value_t m = 25); ~VolumeLeveler(); // Reallocates a buffer of l samples and c channels (contents are // lost) void SetSamplesAndChannels(size_t l, size_t c); // set and get the strength (between 0 and 1) (set doesn't affect // the buffer) if undo is true, vlevel will do the exact opposite, // so you can remove a vlevel. void SetStrength(value_t s); // set and get the max multiplier (set doesn't affect the buffer) void SetMaxMultiplier(value_t m); // get stuff inline size_t GetSamples() { return samples; }; inline size_t GetChannels() { return channels; }; inline value_t GetStrength() { return strength; }; inline value_t GetMaxMultiplier() { return max_multiplier; }; inline size_t GetSilence() { return silence; }; // get stats value_t GetMultiplier(); inline value_t GetAverageAmp() { return avg_amp; }; // fills the buffers with silence void Flush(); // replaces raw with processed, returns how many samples are // residual silence from when the buffers were empty. size_t Exchange(value_t **in_buf, value_t **out_buf, size_t in_samples); private: //void Exchange_1(value_t **in_buf, value_t **out_buf, size_t in_samples); //void Exchange_2(value_t **in_buf, value_t **out_buf, size_t in_samples); void Exchange_n(value_t **in_buf, value_t **out_buf, size_t in_samples); // the buffer value_t **bufs; // the length of the buffers size_t samples; // the number of channels size_t channels; // the strength of the effect (between 0 and 1) value_t strength; // the maximum value by which a sample will be scaled value_t max_multiplier; // the amount of silence (data that wasn't input) left in the buffer (samples). size_t silence; // position about to be returned (samples) size_t pos; // position of the max slope (samples) size_t max_slope_pos; // the current "blanket" amplitude value_t avg_amp; // the maximum slope value_t max_slope; // the value at the maximum slope value_t max_slope_val; }; #endif // ndef VOLUMELEVELER_H