Noatun API Documentation

vequalizer.h

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 
00051 class VBandsInterface
00052 {
00053         friend class VBand;
00054 
00055 public:
00056         VBandsInterface();
00057         virtual ~VBandsInterface();
00058 
00059         virtual int bands() const=0;
00060         virtual VBand band(int num)=0;
00064         VBand operator [] (int num);
00065 
00066 private:
00067         virtual int level(int index) const=0;
00068         virtual void setLevel(int index, int level)=0;
00069 };
00070 
00071 
00072 class VInterpolation;
00073 class VEqualizer;
00074 
00079 class VBand
00080 {
00081         friend class VInterpolation;
00082         friend class VEqualizer;
00083 
00084         struct Private;
00085         VBand::Private *d;
00086 
00087 private:
00088         VBand(VBandsInterface *bands, int index, int start, int end);
00089 
00090 public:
00091         ~VBand();
00092 
00093         VBand(const VBand &copy);
00094         VBand & operator =(const VBand &copy);
00095 
00103         int level() const;
00104         void setLevel(int l);
00105 
00106         int start() const;
00107         int end() const;
00108 
00112         int center() const;
00113 
00114         QString formatStart(bool withHz=true) const;
00115         QString formatEnd(bool withHz=true) const;
00119         QString format(bool withHz=true) const;
00120 };
00121 
00122 
00137 class VInterpolation : public QObject, public VBandsInterface
00138 {
00139         Q_OBJECT
00140         struct Private;
00141         Private *d;
00142         friend class VBand;
00143 
00144 public:
00149         VInterpolation(int bands);
00150         virtual ~VInterpolation();
00151 
00152         virtual int bands() const;
00153         virtual VBand band(int num);
00154         virtual int level(int index) const;
00155         virtual void setLevel(int index, int level);
00156 
00157 signals:
00158         void changed();
00159 
00160 private:
00161         void refresh();
00162         void getFrequencies(int num, int *high, int *low) const;
00167         double onSpline(int bandNum) const;
00168 };
00169 
00170 class VPreset;
00171 
00176 class VEqualizer : public QObject, public VBandsInterface
00177 {
00178         Q_OBJECT
00179         friend class VBand;
00180         friend class VPreset;
00181         friend class Engine;
00182         friend class NoatunApp;
00183         friend class VInterpolation;
00184 
00185         struct Private;
00186         Private *d;
00187 
00188         VEqualizer();
00189         ~VEqualizer();
00190         void init();
00191 
00192 public:
00193 
00200         static QValueList<int> frequencies(int num);
00201 
00207         int bands() const;
00208 
00214         static int start();
00218         static int end();
00219 
00223         int maxBands() const;
00224 
00228         int minBands() const;
00229 
00230         VBand band(int num);
00231 
00232         bool isEnabled() const;
00233 
00237         int preamp() const;
00238 
00239 public: // serialization
00246         bool save(const KURL &file, const QString &friendly) const;
00247 
00251         bool load(const KURL &file);
00252 
00259         QString toString(const QString &name="stored") const;
00260 
00266         bool fromString(const QString &str);
00267 
00268 public: // presets
00277         VPreset createPreset(const QString &name, bool smart=true);
00278 
00283         QValueList<VPreset> presets() const;
00284 
00289         VPreset presetByName(const QString &name);
00290 
00295         VPreset presetByFile(const QString &file);
00296 
00301         bool presetExists(const QString &name) const;
00302 
00303 signals:
00308         void changedBands();
00309 
00314         void changed();
00320         void modified();
00321 
00322         void preampChanged();
00323         void preampChanged(int);
00324 
00325         void enabled();
00326         void disabled();
00327 
00328         void enabled(bool e);
00329 
00333         void created(VPreset preset);
00334 
00339         void selected(VPreset preset);
00340 
00344         void renamed(VPreset preset);
00345 
00349         void removed(VPreset preset);
00350 public slots:
00358         void setPreamp(int p);
00362         void enable();
00366         void disable();
00370         void setEnabled(bool e);
00371         void setBands(int bands);
00372         void setBands(int bands, bool interpolate);
00373 
00374 private:
00375         virtual int level(int index) const;
00376         virtual void setLevel(int index, int level);
00377         void setLevels(const QValueList<int> &levels);
00378 
00379 private:
00386         void update(bool full=false);
00387 };
00388 
00400 class VPreset
00401 {
00402         friend class VEqualizer;
00403 
00404         struct Private;
00405         Private *d;
00406 
00407         void *_bc;
00408         VPreset(const QString &file);
00409 public:
00410         VPreset();
00411         VPreset(const VPreset &copy);
00412         VPreset & operator=(const VPreset &copy);
00413         ~VPreset();
00414         bool operator ==(const VPreset &other) const;
00415 
00419         QString name() const;
00428         bool setName(const QString &name);
00429 
00433         QString file() const;
00434 
00435         bool isValid() const;
00436         bool isNull() const { return !isValid(); }
00437         operator bool() const { return isValid(); }
00438 
00442         void save();
00443 
00447         void load() const;
00448 
00452         void remove();
00453 };
00454 
00455 #endif
KDE Logo
This file is part of the documentation for Noatun 2.6.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 23:49:45 2004 by doxygen 1.3.8-20040913 written by Dimitri van Heesch, © 1997-2003