Noatun API Documentation

vequalizer.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003 Charles Samuels <charles@kde.org>
00003  *
00004  * This file is hereby licensed under the GNU General Public License version
00005  * 2 or later at your option.
00006  *
00007  * This file is licensed under the Qt Public License version 1 with the
00008  * condition that the licensed will be governed under the Laws of California
00009  * (USA) instead of Norway.  Disputes will be settled in Santa Clara county
00010  * courts.
00011  *
00012  * This file is licensed under the following additional license.  Be aware
00013  * that it is identical to the BSD license, except for the added clause 3:
00014 
00015  Redistribution and use in source and binary forms, with or without
00016  modification, are permitted provided that the following conditions
00017  are met:
00018 
00019  1. Redistributions of source code must retain the above copyright
00020     notice, this list of conditions and the following disclaimer.
00021  2. Redistributions in binary form must reproduce the above copyright
00022     notice, this list of conditions and the following disclaimer in the
00023     documentation and/or other materials provided with the distribution.
00024  3. By integrating this software into any other software codebase, you waive
00025     all rights to any patents associated with the stated codebase.
00026 
00027  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00028  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00029  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00030  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00031  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00032  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00033  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00034  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00035  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00036  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 */
00038 
00039 #ifndef NOATUN_VEQUALIZER_H
00040 #define NOATUN_VEQUALIZER_H
00041 
00042 #include <qptrlist.h>
00043 #include <qobject.h>
00044 #include <kurl.h>
00045 
00046 class VBand;
00047 
00048 class VBandsInterface
00049 {
00050         friend class VBand;
00051 
00052 public:
00053         VBandsInterface();
00054         virtual ~VBandsInterface();
00055 
00056         virtual int bands() const=0;
00057         virtual VBand band(int num)=0;
00061         VBand operator [] (int num);
00062 
00063 private:
00064         virtual int level(int index) const=0;
00065         virtual void setLevel(int index, int level)=0;
00066 };
00067 
00068 
00069 class VInterpolation;
00070 class VEqualizer;
00071 
00076 class VBand
00077 {
00078         friend class VInterpolation;
00079         friend class VEqualizer;
00080 
00081         struct Private;
00082         VBand::Private *d;
00083 
00084 private:
00085         VBand(VBandsInterface *bands, int index, int start, int end);
00086 
00087 public:
00088         ~VBand();
00089 
00090         VBand(const VBand &copy);
00091         VBand & operator =(const VBand &copy);
00092 
00100         int level() const;
00101         void setLevel(int l);
00102 
00103         int start() const;
00104         int end() const;
00105 
00109         int center() const;
00110 
00111         QString formatStart(bool withHz=true) const;
00112         QString formatEnd(bool withHz=true) const;
00116         QString format(bool withHz=true) const;
00117 };
00118 
00119 
00135 class VInterpolation : public QObject, public VBandsInterface
00136 {
00137         Q_OBJECT
00138         struct Private;
00139         Private *d;
00140         friend class VBand;
00141 
00142 public:
00147         VInterpolation(int bands);
00148         virtual ~VInterpolation();
00149 
00150         virtual int bands() const;
00151         virtual VBand band(int num);
00152         virtual int level(int index) const;
00153         virtual void setLevel(int index, int level);
00154 
00155 signals:
00156         void changed();
00157 
00158 private:
00159         void refresh();
00160         void getFrequencies(int num, int *high, int *low) const;
00165         double onSpline(int bandNum) const;
00166 };
00167 
00168 class VPreset;
00169 
00174 class VEqualizer : public QObject, public VBandsInterface
00175 {
00176         Q_OBJECT
00177         friend class VBand;
00178         friend class VPreset;
00179         friend class Engine;
00180         friend class NoatunApp;
00181         friend class VInterpolation;
00182 
00183         struct Private;
00184         Private *d;
00185 
00186         VEqualizer();
00187         ~VEqualizer();
00188         void init();
00189 
00190 public:
00191 
00198         static QValueList<int> frequencies(int num);
00199 
00205         int bands() const;
00206 
00212         static int start();
00216         static int end();
00217 
00221         int maxBands() const;
00222 
00226         int minBands() const;
00227 
00228         VBand band(int num);
00229 
00230         bool isEnabled() const;
00231 
00235         int preamp() const;
00236 
00237 public: // serialization
00244         bool save(const KURL &file, const QString &friendly) const;
00245 
00249         bool load(const KURL &file);
00250 
00257         QString toString(const QString &name="stored") const;
00258 
00264         bool fromString(const QString &str);
00265 
00266 public: // presets
00275         VPreset createPreset(const QString &name, bool smart=true);
00276 
00281         QValueList<VPreset> presets() const;
00282 
00287         VPreset presetByName(const QString &name);
00288 
00293         VPreset presetByFile(const QString &file);
00294 
00299         bool presetExists(const QString &name) const;
00300 
00301 signals:
00306         void changedBands();
00307 
00312         void changed();
00318         void modified();
00319 
00320         void preampChanged();
00321         void preampChanged(int);
00322 
00323         void enabled();
00324         void disabled();
00325 
00326         void enabled(bool e);
00327 
00331         void created(VPreset preset);
00332 
00337         void selected(VPreset preset);
00338 
00342         void renamed(VPreset preset);
00343 
00347         void removed(VPreset preset);
00348 public slots:
00356         void setPreamp(int p);
00360         void enable();
00364         void disable();
00368         void setEnabled(bool e);
00369         void setBands(int bands);
00370         void setBands(int bands, bool interpolate);
00371 
00372 private:
00373         virtual int level(int index) const;
00374         virtual void setLevel(int index, int level);
00375         void setLevels(const QValueList<int> &levels);
00376 
00377 private:
00384         void update(bool full=false);
00385 };
00386 
00398 class VPreset
00399 {
00400         friend class VEqualizer;
00401 
00402         struct Private;
00403         Private *d;
00404 
00405         void *_bc;
00406         VPreset(const QString &file);
00407 public:
00408         VPreset();
00409         VPreset(const VPreset &copy);
00410         VPreset & operator=(const VPreset &copy);
00411         ~VPreset();
00412         bool operator ==(const VPreset &other) const;
00413 
00417         QString name() const;
00426         bool setName(const QString &name);
00427 
00431         QString file() const;
00432 
00433         bool isValid() const;
00434         bool isNull() const { return !isValid(); }
00435         operator bool() const { return isValid(); }
00436 
00440         void save();
00441 
00445         void load() const;
00446 
00450         void remove();
00451 };
00452 
00453 
00454 
00455 #endif
00456 
KDE Logo
This file is part of the documentation for Noatun 2.6.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 22 00:20:36 2004 by doxygen 1.3.8-20040913 written by Dimitri van Heesch, © 1997-2003