banshee r4167 - in trunk/banshee: . gstreamer gstreamer/equalizer



Author: abock
Date: Wed Jun 18 21:27:10 2008
New Revision: 4167
URL: http://svn.gnome.org/viewvc/banshee?rev=4167&view=rev

Log:
2008-06-18  Aaron Bockover  <abock gnome org>

    * gstreamer/equalizer/: Copied the GStreamer equalizer (10-band) element
    from GStreamer CVS so we can include it without depending on the very
    latest GStreamer. It has a number of necessary bug fixes which won't
    be available to many users for quite some time through normal distribution
    channels

    * gstreamer/COPYING: A copy of the LGPL
    
    * gstreamer/gst-package.mk: Define some metadata required for GStreamer
    plugins inside of the main GStreamer build environment



Added:
   trunk/banshee/gstreamer/
   trunk/banshee/gstreamer/COPYING
   trunk/banshee/gstreamer/Makefile.am
   trunk/banshee/gstreamer/equalizer/
   trunk/banshee/gstreamer/equalizer/Makefile.am
   trunk/banshee/gstreamer/equalizer/gstiirequalizer.c
   trunk/banshee/gstreamer/equalizer/gstiirequalizer.h
   trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.c
   trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.h
   trunk/banshee/gstreamer/equalizer/remove-n-and-3-bands.diff
   trunk/banshee/gstreamer/gst-package.mk
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/Makefile.am
   trunk/banshee/configure.ac

Modified: trunk/banshee/Makefile.am
==============================================================================
--- trunk/banshee/Makefile.am	(original)
+++ trunk/banshee/Makefile.am	Wed Jun 18 21:27:10 2008
@@ -2,6 +2,7 @@
 	build \
 	data \
 	libbanshee \
+	gstreamer \
 	src \
 	docs \
 	tests \

Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac	(original)
+++ trunk/banshee/configure.ac	Wed Jun 18 21:27:10 2008
@@ -116,6 +116,9 @@
 
 libbanshee/Makefile
 
+gstreamer/Makefile
+gstreamer/equalizer/Makefile
+
 src/Makefile
 src/AssemblyInfo.cs
 

Added: trunk/banshee/gstreamer/COPYING
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/COPYING	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,504 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[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.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

Added: trunk/banshee/gstreamer/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/Makefile.am	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,5 @@
+SUBDIRS = \
+	equalizer
+
+MAINTAINERCLEANFILES = Makefile.in
+

Added: trunk/banshee/gstreamer/equalizer/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/Makefile.am	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,17 @@
+include $(srcdir)/../gst-package.mk
+
+plugindir = $(pkglibdir)/gstreamer-0.10
+plugin_LTLIBRARIES = libgstequalizer.la
+
+libgstequalizer_la_SOURCES = \
+        gstiirequalizer.c gstiirequalizer.h \
+        gstiirequalizer10bands.c gstiirequalizer10bands.h
+
+libgstequalizer_la_CFLAGS = $(GST_CFLAGS) $(GST_INFO_FLAGS)
+libgstequalizer_la_LIBADD = $(GST_LIBS)
+libgstequalizer_la_LDFLAGS = -avoid-version -module
+
+noinst_HEADERS = gstiirequalizer.h
+
+MAINTAINERCLEANFILES = Makefile.in
+

Added: trunk/banshee/gstreamer/equalizer/gstiirequalizer.c
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/gstiirequalizer.c	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,737 @@
+/* GStreamer
+ * Copyright (C) <2004> Benjamin Otte <otte gnome org>
+ *               <2007> Stefan Kost <ensonic users sf net>
+ *               <2007> Sebastian DrÃge <slomo circular-chaos org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "gstiirequalizer.h"
+#include "gstiirequalizer10bands.h"
+
+GST_DEBUG_CATEGORY (equalizer_debug);
+#define GST_CAT_DEFAULT equalizer_debug
+
+static void gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
+    gpointer iface_data);
+
+static void gst_iir_equalizer_finalize (GObject * object);
+
+static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter,
+    GstRingBufferSpec * fmt);
+static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
+    GstBuffer * buf);
+
+GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
+#define GST_CAT_DEFAULT equalizer_debug
+
+#define ALLOWED_CAPS \
+    "audio/x-raw-int,"                                                \
+    " depth=(int)16,"                                                 \
+    " width=(int)16,"                                                 \
+    " endianness=(int)BYTE_ORDER,"                                    \
+    " signed=(bool)TRUE,"                                             \
+    " rate=(int)[1000,MAX],"                                          \
+    " channels=(int)[1,MAX]; "                                        \
+    "audio/x-raw-float,"                                              \
+    " width=(int) { 32, 64 } ,"                                       \
+    " endianness=(int)BYTE_ORDER,"                                    \
+    " rate=(int)[1000,MAX],"                                          \
+    " channels=(int)[1,MAX]"
+
+static void
+_do_init (GType object_type)
+{
+  const GInterfaceInfo child_proxy_interface_info = {
+    (GInterfaceInitFunc) gst_iir_equalizer_child_proxy_interface_init,
+    NULL,                       /* interface_finalize */
+    NULL                        /* interface_data */
+  };
+
+  g_type_add_interface_static (object_type, GST_TYPE_CHILD_PROXY,
+      &child_proxy_interface_info);
+}
+
+GST_BOILERPLATE_FULL (GstIirEqualizer, gst_iir_equalizer,
+    GstAudioFilter, GST_TYPE_AUDIO_FILTER, _do_init);
+
+/* child object */
+
+enum
+{
+  ARG_GAIN = 1,
+  ARG_FREQ,
+  ARG_BANDWIDTH
+};
+
+typedef struct _GstIirEqualizerBandClass GstIirEqualizerBandClass;
+
+#define GST_TYPE_IIR_EQUALIZER_BAND \
+  (gst_iir_equalizer_band_get_type())
+#define GST_IIR_EQUALIZER_BAND(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_BAND,GstIirEqualizerBand))
+#define GST_IIR_EQUALIZER_BAND_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_BAND,GstIirEqualizerBandClass))
+#define GST_IS_IIR_EQUALIZER_BAND(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_BAND))
+#define GST_IS_IIR_EQUALIZER_BAND_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_BAND))
+
+struct _GstIirEqualizerBand
+{
+  GstObject object;
+
+  /*< private > */
+  /* center frequency and gain */
+  gdouble freq;
+  gdouble gain;
+  gdouble width;
+
+  /* second order iir filter */
+  gdouble b1, b2;               /* IIR coefficients for outputs */
+  gdouble a0, a1, a2;           /* IIR coefficients for inputs */
+};
+
+struct _GstIirEqualizerBandClass
+{
+  GstObjectClass parent_class;
+};
+
+static GType gst_iir_equalizer_band_get_type (void);
+
+static void setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band);
+
+static void set_passthrough (GstIirEqualizer * equ);
+
+static void
+gst_iir_equalizer_band_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstIirEqualizerBand *band = GST_IIR_EQUALIZER_BAND (object);
+
+  switch (prop_id) {
+    case ARG_GAIN:{
+      gdouble gain;
+
+      gain = g_value_get_double (value);
+      GST_DEBUG_OBJECT (band, "gain = %lf -> %lf", band->gain, gain);
+      if (gain != band->gain) {
+        GstIirEqualizer *equ =
+            GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band)));
+
+        equ->need_new_coefficients = equ->need_new_coefficients ||
+            (band->gain != gain);
+        band->gain = gain;
+
+        gst_object_unref (equ);
+        GST_DEBUG_OBJECT (band, "changed gain = %lf ", band->gain);
+      }
+      break;
+    }
+    case ARG_FREQ:{
+      gdouble freq;
+
+      freq = g_value_get_double (value);
+      GST_DEBUG_OBJECT (band, "freq = %lf -> %lf", band->freq, freq);
+      if (freq != band->freq) {
+        GstIirEqualizer *equ =
+            GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band)));
+
+        equ->need_new_coefficients = equ->need_new_coefficients ||
+            (band->freq != freq);
+        band->freq = freq;
+        gst_object_unref (equ);
+        GST_DEBUG_OBJECT (band, "changed freq = %lf ", band->freq);
+      }
+      break;
+    }
+    case ARG_BANDWIDTH:{
+      gdouble width;
+
+      width = g_value_get_double (value);
+      GST_DEBUG_OBJECT (band, "width = %lf -> %lf", band->width, width);
+      if (width != band->width) {
+        GstIirEqualizer *equ =
+            GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band)));
+
+        equ->need_new_coefficients = equ->need_new_coefficients ||
+            (band->width != width);
+        band->width = width;
+        gst_object_unref (equ);
+        GST_DEBUG_OBJECT (band, "changed width = %lf ", band->width);
+      }
+      break;
+    }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_iir_equalizer_band_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstIirEqualizerBand *band = GST_IIR_EQUALIZER_BAND (object);
+
+  switch (prop_id) {
+    case ARG_GAIN:
+      g_value_set_double (value, band->gain);
+      break;
+    case ARG_FREQ:
+      g_value_set_double (value, band->freq);
+      break;
+    case ARG_BANDWIDTH:
+      g_value_set_double (value, band->width);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_iir_equalizer_band_class_init (GstIirEqualizerBandClass * klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = gst_iir_equalizer_band_set_property;
+  gobject_class->get_property = gst_iir_equalizer_band_get_property;
+
+  g_object_class_install_property (gobject_class, ARG_GAIN,
+      g_param_spec_double ("gain", "gain",
+          "gain for the frequency band ranging from -24.0 dB to +12.0 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+
+  g_object_class_install_property (gobject_class, ARG_FREQ,
+      g_param_spec_double ("freq", "freq",
+          "center frequency of the band",
+          0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+
+  g_object_class_install_property (gobject_class, ARG_BANDWIDTH,
+      g_param_spec_double ("bandwidth", "bandwidth",
+          "difference between bandedges in Hz",
+          0.0, 100000.0, 1.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+}
+
+static void
+gst_iir_equalizer_band_init (GstIirEqualizerBand * band,
+    GstIirEqualizerBandClass * klass)
+{
+  band->freq = 0.0;
+  band->gain = 0.0;
+  band->width = 1.0;
+}
+
+static GType
+gst_iir_equalizer_band_get_type (void)
+{
+  static GType type = 0;
+
+  if (G_UNLIKELY (!type)) {
+    const GTypeInfo type_info = {
+      sizeof (GstIirEqualizerBandClass),
+      NULL,
+      NULL,
+      (GClassInitFunc) gst_iir_equalizer_band_class_init,
+      NULL,
+      NULL,
+      sizeof (GstIirEqualizerBand),
+      0,
+      (GInstanceInitFunc) gst_iir_equalizer_band_init,
+    };
+    type =
+        g_type_register_static (GST_TYPE_OBJECT, "GstIirEqualizerBand",
+        &type_info, 0);
+  }
+  return (type);
+}
+
+
+/* child proxy iface */
+static GstObject *
+gst_iir_equalizer_child_proxy_get_child_by_index (GstChildProxy * child_proxy,
+    guint index)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (child_proxy);
+
+  g_return_val_if_fail (index < equ->freq_band_count, NULL);
+
+  GST_LOG ("return child[%d] '%s'", index, GST_OBJECT_NAME (equ->bands[index]));
+  return (gst_object_ref (equ->bands[index]));
+}
+
+static guint
+gst_iir_equalizer_child_proxy_get_children_count (GstChildProxy * child_proxy)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (child_proxy);
+
+  GST_LOG ("we have %d children", equ->freq_band_count);
+  return (equ->freq_band_count);
+}
+
+static void
+gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
+    gpointer iface_data)
+{
+  GstChildProxyInterface *iface = g_iface;
+
+  GST_DEBUG ("initializing iface");
+
+  iface->get_child_by_index = gst_iir_equalizer_child_proxy_get_child_by_index;
+  iface->get_children_count = gst_iir_equalizer_child_proxy_get_children_count;
+}
+
+
+/* equalizer implementation */
+
+static void
+gst_iir_equalizer_base_init (gpointer g_class)
+{
+  GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (g_class);
+
+  GstCaps *caps;
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
+  gst_caps_unref (caps);
+}
+
+static void
+gst_iir_equalizer_class_init (GstIirEqualizerClass * klass)
+{
+  GstAudioFilterClass *audio_filter_class = (GstAudioFilterClass *) klass;
+
+  GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
+
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+
+  gobject_class->finalize = gst_iir_equalizer_finalize;
+
+  audio_filter_class->setup = gst_iir_equalizer_setup;
+  btrans_class->transform_ip = gst_iir_equalizer_transform_ip;
+}
+
+static void
+gst_iir_equalizer_init (GstIirEqualizer * eq, GstIirEqualizerClass * g_class)
+{
+  eq->need_new_coefficients = TRUE;
+}
+
+static void
+gst_iir_equalizer_finalize (GObject * object)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
+
+  gint i;
+
+  for (i = 0; i < equ->freq_band_count; i++) {
+    if (equ->bands[i])
+      gst_object_unparent (GST_OBJECT (equ->bands[i]));
+    equ->bands[i] = NULL;
+  }
+  equ->freq_band_count = 0;
+
+  g_free (equ->bands);
+  g_free (equ->history);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static inline gdouble
+arg_to_scale (gdouble arg)
+{
+  return (pow (10.0, arg / 20.0));
+}
+
+/* Filter taken from
+ *
+ * The Equivalence of Various Methods of Computing
+ * Biquad Coefficients for Audio Parametric Equalizers
+ *
+ * by Robert Bristow-Johnson
+ *
+ * http://www.aes.org/e-lib/browse.cfm?elib=6326
+ * http://www.musicdsp.org/files/EQ-Coefficients.pdf
+ *
+ * The bandwidth method that we use here is the preferred
+ * one from this article transformed from octaves to frequency
+ * in Hz.
+ */
+static void
+setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
+{
+  g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
+
+  /* FIXME: we need better filters
+   * - we need shelf-filter for 1st and last band
+   */
+  {
+    gdouble gain, omega, bw;
+
+    gdouble edge_gain, gamma;
+
+    gdouble alpha, beta;
+
+
+    gain = arg_to_scale (band->gain);
+
+    if (band->freq / GST_AUDIO_FILTER (equ)->format.rate > 0.5)
+      omega = M_PI;
+    else if (band->freq < 0.0)
+      omega = 0.0;
+    else
+      omega = 2.0 * M_PI * (band->freq / GST_AUDIO_FILTER (equ)->format.rate);
+
+    if (band->width / GST_AUDIO_FILTER (equ)->format.rate >= 0.5) {
+      /* If bandwidth == 0.5 the calculation below fails as tan(M_PI/2)
+       * is undefined. So set the bandwidth to a slightly smaller value.
+       */
+      bw = M_PI - 0.00000001;
+    } else if (band->width <= 0.0) {
+      /* If bandwidth == 0 this band won't change anything so set
+       * the coefficients accordingly. The coefficient calculation
+       * below would create coefficients that for some reason amplify
+       * the band.
+       */
+      band->a0 = 1.0;
+      band->a1 = 0.0;
+      band->a2 = 0.0;
+      band->b1 = 0.0;
+      band->b2 = 0.0;
+      gain = 1.0;
+      goto out;
+    } else {
+      bw = 2.0 * M_PI * (band->width / GST_AUDIO_FILTER (equ)->format.rate);
+    }
+
+    edge_gain = sqrt (gain);
+    gamma = tan (bw / 2.0);
+
+    alpha = gamma * edge_gain;
+    beta = gamma / edge_gain;
+
+    band->a0 = (1.0 + alpha) / (1.0 + beta);
+    band->a1 = (-2.0 * cos (omega)) / (1.0 + beta);
+    band->a2 = (1.0 - alpha) / (1.0 + beta);
+    band->b1 = (2.0 * cos (omega)) / (1.0 + beta);
+    band->b2 = -(1.0 - beta) / (1.0 + beta);
+
+  out:
+    GST_INFO
+        ("gain = %7.5g, , bandwidth= %7.5g, frequency = %7.5g, a0 = %7.5g, a1 = %7.5g, a2=%7.5g b1 = %7.5g, b2 = %7.5g",
+        band->gain, band->width, band->freq, band->a0, band->a1, band->a2,
+        band->b1, band->b2);
+  }
+}
+
+static void
+set_passthrough (GstIirEqualizer * equ)
+{
+  gint i;
+
+  gboolean passthrough = TRUE;
+
+  for (i = 0; i < equ->freq_band_count; i++) {
+    passthrough = passthrough && (equ->bands[i]->gain == 0.0);
+  }
+
+  gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (equ), passthrough);
+  GST_DEBUG ("Passthrough mode: %d\n", passthrough);
+}
+
+static void
+update_coefficients (GstIirEqualizer * equ)
+{
+  gint i;
+
+  for (i = 0; i < equ->freq_band_count; i++) {
+    setup_filter (equ, equ->bands[i]);
+  }
+}
+
+void
+gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count)
+{
+  guint old_count, i;
+
+  gdouble freq0, freq1, step;
+
+  gchar name[20];
+
+  old_count = equ->freq_band_count;
+  equ->freq_band_count = new_count;
+  GST_DEBUG ("bands %u -> %u", old_count, new_count);
+
+  if (old_count < new_count) {
+    /* add new bands */
+    equ->bands = g_realloc (equ->bands, sizeof (GstObject *) * new_count);
+    for (i = old_count; i < new_count; i++) {
+      equ->bands[i] = g_object_new (GST_TYPE_IIR_EQUALIZER_BAND, NULL);
+      /* otherwise they get names like 'iirequalizerband5' */
+      sprintf (name, "band%u", i);
+      gst_object_set_name (GST_OBJECT (equ->bands[i]), name);
+
+      gst_object_set_parent (GST_OBJECT (equ->bands[i]), GST_OBJECT (equ));
+      gst_child_proxy_child_added (GST_OBJECT (equ),
+          GST_OBJECT (equ->bands[i]));
+    }
+  } else {
+    /* free unused bands */
+    for (i = new_count; i < old_count; i++) {
+      GST_DEBUG ("removing band[%d]=%p", i, equ->bands[i]);
+      gst_child_proxy_child_removed (GST_OBJECT (equ),
+          GST_OBJECT (equ->bands[i]));
+      gst_object_unparent (GST_OBJECT (equ->bands[i]));
+      equ->bands[i] = NULL;
+    }
+  }
+
+  /* free + alloc = no memcpy */
+  g_free (equ->history);
+  equ->history =
+      g_malloc0 (equ->history_size * GST_AUDIO_FILTER (equ)->format.channels *
+      new_count);
+
+  /* set center frequencies and name band objects
+   * FIXME: arg! we can't change the name of parented objects :(
+   *   application should read band->freq to get the name
+   */
+
+  step = pow (HIGHEST_FREQ / LOWEST_FREQ, 1.0 / new_count);
+  freq0 = LOWEST_FREQ;
+  for (i = 0; i < new_count; i++) {
+    freq1 = freq0 * step;
+    equ->bands[i]->freq = freq0 + ((freq1 - freq0) / 2.0);
+    equ->bands[i]->width = freq1 - freq0;
+    GST_DEBUG ("band[%2d] = '%lf'", i, equ->bands[i]->freq);
+    /*
+       if(equ->bands[i]->freq<10000.0)
+       sprintf (name,"%dHz",(gint)equ->bands[i]->freq);
+       else
+       sprintf (name,"%dkHz",(gint)(equ->bands[i]->freq/1000.0));
+       gst_object_set_name( GST_OBJECT (equ->bands[i]), name);
+       GST_DEBUG ("band[%2d] = '%s'",i,name);
+     */
+    freq0 = freq1;
+  }
+
+  equ->need_new_coefficients = TRUE;
+}
+
+/* start of code that is type specific */
+
+#define CREATE_OPTIMIZED_FUNCTIONS_INT(TYPE,BIG_TYPE,MIN_VAL,MAX_VAL)   \
+typedef struct {                                                        \
+  BIG_TYPE x1, x2;          /* history of input values for a filter */  \
+  BIG_TYPE y1, y2;          /* history of output values for a filter */ \
+} SecondOrderHistory ## TYPE;                                           \
+                                                                        \
+static inline BIG_TYPE                                                  \
+one_step_ ## TYPE (GstIirEqualizerBand *filter,                         \
+    SecondOrderHistory ## TYPE *history, BIG_TYPE input)                \
+{                                                                       \
+  /* calculate output */                                                \
+  BIG_TYPE output = floor (filter->a0 * input +                         \
+      filter->a1 * history->x1 + filter->a2 * history->x2 +             \
+      filter->b1 * history->y1 + filter->b2 * history->y2 + 0.5);       \
+  /* update history */                                                  \
+  history->y2 = history->y1;                                            \
+  history->y1 = output;                                                 \
+  history->x2 = history->x1;                                            \
+  history->x1 = input;                                                  \
+                                                                        \
+  return output;                                                        \
+}                                                                       \
+                                                                        \
+static const guint                                                      \
+history_size_ ## TYPE = sizeof (SecondOrderHistory ## TYPE);            \
+                                                                        \
+static void                                                             \
+gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data,       \
+guint size, guint channels)                                             \
+{                                                                       \
+  guint frames = size / channels / sizeof (TYPE);                       \
+  guint i, c, f;                                                        \
+  BIG_TYPE cur;                                                         \
+                                                                        \
+  for (i = 0; i < frames; i++) {                                        \
+    for (c = 0; c < channels; c++) {                                    \
+      SecondOrderHistory ## TYPE *history = equ->history;               \
+      cur = *((TYPE *) data);                                           \
+      for (f = 0; f < equ->freq_band_count; f++) {                      \
+        GstIirEqualizerBand *filter = equ->bands[f];                    \
+                                                                        \
+        cur = one_step_ ## TYPE (filter, history, cur);                 \
+        history++;                                                      \
+      }                                                                 \
+      cur = CLAMP (cur, MIN_VAL, MAX_VAL);                              \
+      *((TYPE *) data) = (TYPE) cur;                                    \
+      data += sizeof (TYPE);                                            \
+    }                                                                   \
+  }                                                                     \
+}
+
+#define CREATE_OPTIMIZED_FUNCTIONS(TYPE)       \
+typedef struct {                                                        \
+  TYPE x1, x2;          /* history of input values for a filter */  \
+  TYPE y1, y2;          /* history of output values for a filter */ \
+} SecondOrderHistory ## TYPE;                                           \
+                                                                        \
+static inline TYPE                                                  \
+one_step_ ## TYPE (GstIirEqualizerBand *filter,                         \
+    SecondOrderHistory ## TYPE *history, TYPE input)                \
+{                                                                       \
+  /* calculate output */                                                \
+  TYPE output = filter->a0 * input + filter->a1 * history->x1 +     \
+      filter->a2 * history->x2 + filter->b1 * history->y1 +             \
+      filter->b2 * history->y2;                                         \
+  /* update history */                                                  \
+  history->y2 = history->y1;                                            \
+  history->y1 = output;                                                 \
+  history->x2 = history->x1;                                            \
+  history->x1 = input;                                                  \
+                                                                        \
+  return output;                                                        \
+}                                                                       \
+                                                                        \
+static const guint                                                      \
+history_size_ ## TYPE = sizeof (SecondOrderHistory ## TYPE);            \
+                                                                        \
+static void                                                             \
+gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data,       \
+guint size, guint channels)                                             \
+{                                                                       \
+  guint frames = size / channels / sizeof (TYPE);                       \
+  guint i, c, f;                                                        \
+  TYPE cur;                                                         \
+                                                                        \
+  for (i = 0; i < frames; i++) {                                        \
+    for (c = 0; c < channels; c++) {                                    \
+      SecondOrderHistory ## TYPE *history = equ->history;               \
+      cur = *((TYPE *) data);                                           \
+      for (f = 0; f < equ->freq_band_count; f++) {                      \
+        GstIirEqualizerBand *filter = equ->bands[f];                    \
+                                                                        \
+        cur = one_step_ ## TYPE (filter, history, cur);                 \
+        history++;                                                      \
+      }                                                                 \
+      *((TYPE *) data) = (TYPE) cur;                                    \
+      data += sizeof (TYPE);                                            \
+    }                                                                   \
+  }                                                                     \
+}
+
+CREATE_OPTIMIZED_FUNCTIONS_INT (gint16, gint32, -32768, 32767);
+CREATE_OPTIMIZED_FUNCTIONS (gfloat);
+CREATE_OPTIMIZED_FUNCTIONS (gdouble);
+
+static GstFlowReturn
+gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
+{
+  GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
+
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans);
+
+  GstClockTime timestamp;
+
+  if (G_UNLIKELY (filter->format.channels < 1 || equ->process == NULL))
+    return GST_FLOW_NOT_NEGOTIATED;
+
+  if (equ->need_new_coefficients) {
+    update_coefficients (equ);
+    set_passthrough (equ);
+  }
+
+  if (gst_base_transform_is_passthrough (btrans))
+    return GST_FLOW_OK;
+
+  timestamp = GST_BUFFER_TIMESTAMP (buf);
+  timestamp =
+      gst_segment_to_stream_time (&btrans->segment, GST_FORMAT_TIME, timestamp);
+
+  if (GST_CLOCK_TIME_IS_VALID (timestamp))
+    gst_object_sync_values (G_OBJECT (equ), timestamp);
+
+  equ->process (equ, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
+      filter->format.channels);
+
+  return GST_FLOW_OK;
+}
+
+static gboolean
+gst_iir_equalizer_setup (GstAudioFilter * audio, GstRingBufferSpec * fmt)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio);
+
+  switch (fmt->type) {
+    case GST_BUFTYPE_LINEAR:
+      switch (fmt->width) {
+        case 16:
+          equ->history_size = history_size_gint16;
+          equ->process = gst_iir_equ_process_gint16;
+          break;
+        default:
+          return FALSE;
+      }
+      break;
+    case GST_BUFTYPE_FLOAT:
+      switch (fmt->width) {
+        case 32:
+          equ->history_size = history_size_gfloat;
+          equ->process = gst_iir_equ_process_gfloat;
+          break;
+        case 64:
+          equ->history_size = history_size_gdouble;
+          equ->process = gst_iir_equ_process_gdouble;
+          break;
+        default:
+          return FALSE;
+      }
+      break;
+    default:
+      return FALSE;
+  }
+
+  gst_iir_equalizer_compute_frequencies (equ, equ->freq_band_count);
+  return TRUE;
+}
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (equalizer_debug, "equalizer", 0, "equalizer");
+
+  if (!(gst_element_register (plugin, "equalizer-10bands", GST_RANK_NONE,
+              GST_TYPE_IIR_EQUALIZER_10BANDS)))
+    return FALSE;
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    "equalizer",
+    "GStreamer audio equalizers",
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

Added: trunk/banshee/gstreamer/equalizer/gstiirequalizer.h
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/gstiirequalizer.h	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,77 @@
+/* GStreamer IIR equalizer
+ * Copyright (C) <2004> Benjamin Otte <otte gnome org>
+ *               <2007> Stefan Kost <ensonic users sf net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 __GST_IIR_EQUALIZER__
+#define __GST_IIR_EQUALIZER__
+
+#include <gst/audio/gstaudiofilter.h>
+#include <gst/audio/gstringbuffer.h>
+#include <gst/controller/gstcontroller.h>
+
+typedef struct _GstIirEqualizer GstIirEqualizer;
+typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
+typedef struct _GstIirEqualizerBand GstIirEqualizerBand;
+
+#define GST_TYPE_IIR_EQUALIZER \
+  (gst_iir_equalizer_get_type())
+#define GST_IIR_EQUALIZER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER,GstIirEqualizer))
+#define GST_IIR_EQUALIZER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER,GstIirEqualizerClass))
+#define GST_IS_IIR_EQUALIZER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER))
+#define GST_IS_IIR_EQUALIZER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER))
+
+#define LOWEST_FREQ (20.0)
+#define HIGHEST_FREQ (20000.0)
+
+typedef void (*ProcessFunc) (GstIirEqualizer * eq, guint8 * data, guint size,
+    guint channels);
+
+struct _GstIirEqualizer
+{
+  GstAudioFilter audiofilter;
+
+  /*< private >*/
+
+  GstIirEqualizerBand **bands;
+
+  /* properties */
+  guint freq_band_count;
+  /* for each band and channel */
+  gpointer history;
+  guint history_size;
+
+  gboolean need_new_coefficients;
+
+  ProcessFunc process;
+};
+
+struct _GstIirEqualizerClass
+{
+  GstAudioFilterClass audiofilter_class;
+};
+
+extern void gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count);
+
+extern GType gst_iir_equalizer_get_type(void);
+
+#endif /* __GST_IIR_EQUALIZER__ */

Added: trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.c
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.c	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,230 @@
+/* GStreamer
+ * Copyright (C) <2007> Stefan Kost <ensonic users sf net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+/**
+ * SECTION:element-equalizer-10bands
+ * @short_description: 10-band equalizer
+ *
+ * <refsect2>
+ * <para>
+ * The 10 band equalizer element allows to change the gain of 10 equally distributed
+ * frequency bands between 30 Hz and 15 kHz.
+ * </para>
+ * <title>Example launch line</title>
+ * <para>
+ * <programlisting>
+ * gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-10bands band2=3.0 ! alsasink
+ * </programlisting>
+ * This raises the volume of the 3rd band which is at 119 Hz by 3 db.
+ * </para>
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstiirequalizer.h"
+#include "gstiirequalizer10bands.h"
+
+
+enum
+{
+  ARG_BAND0 = 1,
+  ARG_BAND1,
+  ARG_BAND2,
+  ARG_BAND3,
+  ARG_BAND4,
+  ARG_BAND5,
+  ARG_BAND6,
+  ARG_BAND7,
+  ARG_BAND8,
+  ARG_BAND9,
+};
+
+static void gst_iir_equalizer_10bands_set_property (GObject * object,
+    guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_iir_equalizer_10bands_get_property (GObject * object,
+    guint prop_id, GValue * value, GParamSpec * pspec);
+
+GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
+#define GST_CAT_DEFAULT equalizer_debug
+
+GST_BOILERPLATE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
+    GstIirEqualizer, GST_TYPE_IIR_EQUALIZER);
+
+/* equalizer implementation */
+
+static void
+gst_iir_equalizer_10bands_base_init (gpointer g_class)
+{
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  const GstElementDetails iir_equalizer_details =
+      GST_ELEMENT_DETAILS ("10 Band Equalizer",
+      "Filter/Effect/Audio",
+      "Direct Form 10 band IIR equalizer",
+      "Stefan Kost <ensonic users sf net>");
+
+  gst_element_class_set_details (element_class, &iir_equalizer_details);
+}
+
+static void
+gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+
+  gobject_class->set_property = gst_iir_equalizer_10bands_set_property;
+  gobject_class->get_property = gst_iir_equalizer_10bands_get_property;
+
+  g_object_class_install_property (gobject_class, ARG_BAND0,
+      g_param_spec_double ("band0", "29 Hz",
+          "gain for the frequency band 29 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND1,
+      g_param_spec_double ("band1", "59 Hz",
+          "gain for the frequency band 59 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND2,
+      g_param_spec_double ("band2", "119 Hz",
+          "gain for the frequency band 119 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND3,
+      g_param_spec_double ("band3", "227 Hz",
+          "gain for the frequency band 227 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND4,
+      g_param_spec_double ("band4", "474 Hz",
+          "gain for the frequency band 474 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND5,
+      g_param_spec_double ("band5", "947 Hz",
+          "gain for the frequency band 947 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND6,
+      g_param_spec_double ("band6", "1889 Hz",
+          "gain for the frequency band 1889 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND7,
+      g_param_spec_double ("band7", "3770 Hz",
+          "gain for the frequency band 3770 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND8,
+      g_param_spec_double ("band8", "7523 Hz",
+          "gain for the frequency band 7523 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+  g_object_class_install_property (gobject_class, ARG_BAND9,
+      g_param_spec_double ("band9", "15011 Hz",
+          "gain for the frequency band 15011 Hz, ranging from -24 dB to +12 dB",
+          -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+}
+
+static void
+gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n,
+    GstIirEqualizer10BandsClass * g_class)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
+
+  gst_iir_equalizer_compute_frequencies (equ, 10);
+}
+
+static void
+gst_iir_equalizer_10bands_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
+
+  switch (prop_id) {
+    case ARG_BAND0:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band0::gain", value);
+      break;
+    case ARG_BAND1:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band1::gain", value);
+      break;
+    case ARG_BAND2:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band2::gain", value);
+      break;
+    case ARG_BAND3:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band3::gain", value);
+      break;
+    case ARG_BAND4:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band4::gain", value);
+      break;
+    case ARG_BAND5:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band5::gain", value);
+      break;
+    case ARG_BAND6:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band6::gain", value);
+      break;
+    case ARG_BAND7:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band7::gain", value);
+      break;
+    case ARG_BAND8:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band8::gain", value);
+      break;
+    case ARG_BAND9:
+      gst_child_proxy_set_property (GST_OBJECT (equ), "band9::gain", value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_iir_equalizer_10bands_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
+
+  switch (prop_id) {
+    case ARG_BAND0:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band0::gain", value);
+      break;
+    case ARG_BAND1:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band1::gain", value);
+      break;
+    case ARG_BAND2:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band2::gain", value);
+      break;
+    case ARG_BAND3:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band3::gain", value);
+      break;
+    case ARG_BAND4:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band4::gain", value);
+      break;
+    case ARG_BAND5:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band5::gain", value);
+      break;
+    case ARG_BAND6:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band6::gain", value);
+      break;
+    case ARG_BAND7:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band7::gain", value);
+      break;
+    case ARG_BAND8:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band8::gain", value);
+      break;
+    case ARG_BAND9:
+      gst_child_proxy_get_property (GST_OBJECT (equ), "band9::gain", value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}

Added: trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.h
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/gstiirequalizer10bands.h	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,51 @@
+/* GStreamer
+ * Copyright (C) <2007> Stefan Kost <ensonic users sf net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 __GST_IIR_EQUALIZER_10BANDS__
+#define __GST_IIR_EQUALIZER_10BANDS__
+
+#include "gstiirequalizer.h"
+
+typedef struct _GstIirEqualizer10Bands GstIirEqualizer10Bands;
+typedef struct _GstIirEqualizer10BandsClass GstIirEqualizer10BandsClass;
+
+#define GST_TYPE_IIR_EQUALIZER_10BANDS \
+  (gst_iir_equalizer_10bands_get_type())
+#define GST_IIR_EQUALIZER_10BANDS(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_10BANDS,GstIirEqualizer10Bands))
+#define GST_IIR_EQUALIZER_10BANDS_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_10BANDS,GstIirEqualizer10BandsClass))
+#define GST_IS_IIR_EQUALIZER_10BANDS(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_10BANDS))
+#define GST_IS_IIR_EQUALIZER_10BANDS_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_10BANDS))
+
+struct _GstIirEqualizer10Bands
+{
+  GstIirEqualizer equalizer;
+};
+
+struct _GstIirEqualizer10BandsClass
+{
+  GstIirEqualizer equalizer_class;
+};
+
+extern GType gst_iir_equalizer_10bands_get_type(void);
+
+#endif /* __GST_IIR_EQUALIZER_10BANDS__ */

Added: trunk/banshee/gstreamer/equalizer/remove-n-and-3-bands.diff
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/equalizer/remove-n-and-3-bands.diff	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,26 @@
+--- gstiirequalizer.c.orig	2008-06-18 17:21:37.000000000 -0400
++++ gstiirequalizer.c	2008-06-18 17:20:51.000000000 -0400
+@@ -27,8 +27,6 @@
+ #include <string.h>
+ 
+ #include "gstiirequalizer.h"
+-#include "gstiirequalizernbands.h"
+-#include "gstiirequalizer3bands.h"
+ #include "gstiirequalizer10bands.h"
+ 
+ GST_DEBUG_CATEGORY (equalizer_debug);
+@@ -725,14 +723,6 @@
+ {
+   GST_DEBUG_CATEGORY_INIT (equalizer_debug, "equalizer", 0, "equalizer");
+ 
+-  if (!(gst_element_register (plugin, "equalizer-nbands", GST_RANK_NONE,
+-              GST_TYPE_IIR_EQUALIZER_NBANDS)))
+-    return FALSE;
+-
+-  if (!(gst_element_register (plugin, "equalizer-3bands", GST_RANK_NONE,
+-              GST_TYPE_IIR_EQUALIZER_3BANDS)))
+-    return FALSE;
+-
+   if (!(gst_element_register (plugin, "equalizer-10bands", GST_RANK_NONE,
+               GST_TYPE_IIR_EQUALIZER_10BANDS)))
+     return FALSE;

Added: trunk/banshee/gstreamer/gst-package.mk
==============================================================================
--- (empty file)
+++ trunk/banshee/gstreamer/gst-package.mk	Wed Jun 18 21:27:10 2008
@@ -0,0 +1,5 @@
+GST_INFO_FLAGS = \
+	-DGST_LICENSE=\"LGPL\" \
+	-DGST_PACKAGE_NAME=\"banshee-1\" \
+	-DGST_PACKAGE_ORIGIN=\"gst-plugins-good\"
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]