~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/library/equalizer.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NOATUN_EQUALIZER_H
 
2
#define NOATUN_EQUALIZER_H
 
3
 
 
4
#include <qlist.h>
 
5
#include <qobject.h>
 
6
#include <kurl.h>
 
7
 
 
8
namespace Arts { class StereoEffect; }
 
9
class Engine;
 
10
class Equalizer;
 
11
 
 
12
class Preset
 
13
{
 
14
friend class Equalizer;
 
15
        Preset(const QString &file);
 
16
        Preset();
 
17
public:
 
18
        QString name() const;
 
19
        bool setName(const QString &name);
 
20
        bool save() const;
 
21
        bool load();
 
22
 
 
23
        void remove();
 
24
 
 
25
        QString file() const;
 
26
private:
 
27
        QString mFile;
 
28
};
 
29
 
 
30
class Band
 
31
{
 
32
friend class Equalizer;
 
33
friend class QList<Band>;
 
34
 
 
35
private:
 
36
        Band();
 
37
        Band(int start, int end);
 
38
        virtual ~Band();
 
39
public:
 
40
        /**
 
41
         * the intensity of the change.
 
42
         * it's logarithmic.  0 is no change
 
43
         * negative numbers are loss in intensity
 
44
         * positive numbers are a gain
 
45
         * And +-100 is the most you'd need to go
 
46
         **/
 
47
        int level();
 
48
        void setLevel(int l);
 
49
        
 
50
        int start() const;
 
51
        int end() const;
 
52
 
 
53
        /**
 
54
         * the middle between start and end
 
55
         **/
 
56
        int center() const;
 
57
 
 
58
        QString formatStart(bool withHz=true) const;
 
59
        QString formatEnd(bool withHz=true) const;
 
60
        /**
 
61
         * return the format for center()
 
62
         **/
 
63
        QString format(bool withHz=true) const;
 
64
        
 
65
private:
 
66
        int mLevel;
 
67
        int mStart, mEnd;
 
68
};
 
69
 
 
70
class Equalizer : public QObject
 
71
{
 
72
friend class Band;
 
73
friend class Preset;
 
74
friend class Engine;
 
75
Q_OBJECT
 
76
public:
 
77
        Equalizer();
 
78
        ~Equalizer();
 
79
        
 
80
        const QList<Band> &bands() const;
 
81
        Band *band(int num) const;
 
82
        int bandCount() const;
 
83
 
 
84
        int preamp() const;
 
85
        bool isEnabled() const;
 
86
        
 
87
        void init();
 
88
 
 
89
public slots:
 
90
        /**
 
91
         * set the preamplification
 
92
         * it's logarithmic.  0 is no change
 
93
         * negative numbers are loss in intensity
 
94
         * positive numbers are a gain
 
95
         * And +-100 is the most you'd need to go
 
96
         **/
 
97
        void setPreamp(int p);
 
98
        void enable();
 
99
        void disable();
 
100
        void setEnabled(bool e);
 
101
 
 
102
 
 
103
public:
 
104
// saving eq stuff
 
105
        /**
 
106
         * save the current levels
 
107
         * all noatun equalizer files have the "*.noatunequalizer"
 
108
         * pattern.  Nevertheless, the file can be identified
 
109
         * by magic, so it's not required
 
110
         **/
 
111
        bool save(const KURL &file, const QString &friendly) const;
 
112
 
 
113
        /**
 
114
         * restore the EQ settings from this file
 
115
         **/
 
116
        bool load(const KURL &file);
 
117
 
 
118
        /**
 
119
         * create a preset with such a name
 
120
         * and remember that it'l return zero
 
121
         * if the name already exists
 
122
         *
 
123
         * If smart is true, append a number to the end
 
124
         * of the name, if one already exists by the given
 
125
         **/
 
126
        Preset *createPreset(const QString &name, bool smart=true);
 
127
 
 
128
        /**
 
129
         * return all the presets
 
130
         * remember to setAutoDelete on this
 
131
         **/
 
132
        QList<Preset> presets() const;
 
133
        
 
134
        Preset *preset(const QString &file);
 
135
        bool presetExists(const QString &name) const;
 
136
                
 
137
signals:
 
138
        void changed(Band *band);
 
139
        void changed();
 
140
        void enabled();
 
141
        void disabled();
 
142
        void enabled(bool e);
 
143
 
 
144
        void preampChanged(int p);
 
145
        void preampChanged();
 
146
 
 
147
        /**
 
148
         * the preset with the given name
 
149
         * was selected
 
150
         **/
 
151
        void changed(Preset *);
 
152
 
 
153
        /**
 
154
         * when a new preset has been created
 
155
         **/
 
156
        void created(Preset*);
 
157
 
 
158
        /**
 
159
         * when @p preset has been renamed to @p newname
 
160
         **/ 
 
161
        void renamed(Preset *);
 
162
 
 
163
        /**
 
164
         * the given preset has been removed
 
165
         **/
 
166
        void removed(Preset *);
 
167
        
 
168
private:
 
169
        void add(Band*);
 
170
        void remove(Band*);
 
171
        // apply the data to artsd
 
172
        void enableUpdates(bool on=true);
 
173
        void update(bool full=false);
 
174
        
 
175
private:
 
176
        QList<Band> mBands;
 
177
        bool mUpdates;
 
178
        int mPreamp;
 
179
};
 
180
 
 
181
 
 
182
 
 
183
#endif
 
184