1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
#include "equalizer.h"
#include "engine.h"
#include <common.h>
#include <dynamicrequest.h>
#include <artsflow.h>
#include <app.h>
#include <player.h>
#include <soundserver.h>
#include <noatunarts.h>
#include <ktempfile.h>
#include <tqdom.h>
#include <kio/netaccess.h>
#include <kstandarddirs.h>
#include <tqtextstream.h>
#include <math.h>
#include <kconfig.h>
#include <klocale.h>
#include "ksaver.h"
#define EQ napp->equalizer()
#define VEQ napp->vequalizer()
struct OldEqCruft
{
VInterpolation *interpolated;
};
static OldEqCruft *eqCruft=0;
Preset::Preset(const TQString &)
{ } // unused
Preset::Preset(VPreset p)
{
VPreset *copy = new VPreset(p);
// isn't this horrible? :)
mFile = TQString::number((unsigned long)copy);
}
Preset::Preset()
{ } // unused
VPreset &Preset::vpreset() const
{
unsigned long addr = mFile.toULong();
return *(VPreset*)addr;
}
TQString Preset::name() const
{
return vpreset().name();
}
bool Preset::setName(const TQString &name)
{
return vpreset().setName(name);
}
bool Preset::save() const
{
vpreset().save();
return true;
}
bool Preset::load()
{
vpreset().load();
return true;
}
void Preset::remove()
{
vpreset().remove();
}
TQString Preset::file() const
{
return vpreset().file();
}
Band::Band(int, int)
{
// Never used
}
Band::Band(int num)
: mNum(num)
{
}
Band::~Band()
{}
int Band::level()
{
return eqCruft->interpolated->band(mNum).level();
}
void Band::setLevel(int l)
{
eqCruft->interpolated->band(mNum).setLevel(l);
}
int Band::start() const
{
return eqCruft->interpolated->band(mNum).start();
}
int Band::end() const
{
return eqCruft->interpolated->band(mNum).end();
}
int Band::center() const
{
return eqCruft->interpolated->band(mNum).center();
}
TQString Band::formatStart(bool withHz) const
{
return eqCruft->interpolated->band(mNum).formatStart(withHz);
}
TQString Band::formatEnd(bool withHz) const
{
return eqCruft->interpolated->band(mNum).formatEnd(withHz);
}
TQString Band::format(bool withHz) const
{
return eqCruft->interpolated->band(mNum).format(withHz);
}
Equalizer::Equalizer()
{
}
Equalizer::~Equalizer()
{
delete eqCruft->interpolated;
delete eqCruft;
// save(napp->dirs()->saveLocation("data", "noatun/") + "equalizer", "auto");
for (Band *i=mBands.first(); i!=0; i=mBands.next())
delete i;
}
void Equalizer::init()
{
// must be called after VEqualizer::init
eqCruft = new OldEqCruft;
eqCruft->interpolated = new VInterpolation(6);
mBands.append(new Band(0));
mBands.append(new Band(1));
mBands.append(new Band(2));
mBands.append(new Band(3));
mBands.append(new Band(4));
mBands.append(new Band(5));
connect(VEQ, TQT_SIGNAL(changed()), TQT_SIGNAL(changed()));
connect(VEQ, TQT_SIGNAL(created(VPreset)), TQT_SLOT(created(VPreset)));
connect(VEQ, TQT_SIGNAL(selected(VPreset)), TQT_SLOT(selected(VPreset)));
connect(VEQ, TQT_SIGNAL(renamed(VPreset)), TQT_SLOT(renamed(VPreset)));
connect(VEQ, TQT_SIGNAL(removed(VPreset)), TQT_SLOT(removed(VPreset)));
connect(VEQ, TQT_SIGNAL(enabled()), TQT_SIGNAL(enabled()));
connect(VEQ, TQT_SIGNAL(disabled()), TQT_SIGNAL(disabled()));
connect(VEQ, TQT_SIGNAL(enabled(bool)), TQT_SIGNAL(enabled(bool)));
connect(VEQ, TQT_SIGNAL(preampChanged(int)), TQT_SIGNAL(preampChanged(int)));
connect(VEQ, TQT_SIGNAL(preampChanged(int)), TQT_SIGNAL(preampChanged(int)));
}
void Equalizer::created(VPreset preset)
{
Preset *p = new Preset(preset);
emit created(p);
delete p;
}
void Equalizer::selected(VPreset preset)
{
Preset *p = new Preset(preset);
emit changed(p);
delete p;
}
void Equalizer::renamed(VPreset preset)
{
Preset *p = new Preset(preset);
emit renamed(p);
delete p;
}
void Equalizer::removed(VPreset preset)
{
Preset *p = new Preset(preset);
emit removed(p);
delete p;
}
TQPtrList<Preset> Equalizer::presets() const
{
TQValueList<VPreset> presets = VEQ->presets();
TQPtrList<Preset> list;
for (
TQValueList<VPreset>::Iterator i(presets.begin());
i != presets.end(); ++i
)
{
list.append(new Preset(*i));
}
return list;
}
Preset *Equalizer::preset(const TQString &file)
{
VPreset p = VEQ->presetByFile(file);
if (!p) return 0;
return new Preset(p);
}
bool Equalizer::presetExists(const TQString &name) const
{
return VEQ->presetExists(name);
}
Preset *Equalizer::createPreset(const TQString &name, bool smart)
{
VPreset p = VEQ->createPreset(name, smart);
if (!p) return 0;
return new Preset(p);
}
const TQPtrList<Band> &Equalizer::bands() const
{
return mBands;
}
Band *Equalizer::band(int num) const
{
// can't use TQPtrList::at since it sets current
TQPtrListIterator<Band> item(mBands);
item+=(unsigned int)num;
return *item;
}
int Equalizer::bandCount() const
{
return 6; // hmm ;)
}
int Equalizer::preamp() const
{
return VEQ->preamp();
}
bool Equalizer::isEnabled() const
{
return VEQ->isEnabled();
}
void Equalizer::setPreamp(int p)
{
VEQ->setPreamp(p);
}
void Equalizer::enable()
{
setEnabled(true);
}
void Equalizer::disable()
{
setEnabled(false);
}
void Equalizer::setEnabled(bool e)
{
VEQ->setEnabled(e);
}
TQString Equalizer::toString(const TQString &name) const
{
return VEQ->toString(name);
}
bool Equalizer::fromString(const TQString &str)
{
return VEQ->fromString(str);
}
bool Equalizer::save(const KURL &filename, const TQString &name) const
{
return VEQ->save(filename, name);
}
bool Equalizer::load(const KURL &filename)
{
return VEQ->load(filename);
}
void Equalizer::add(Band *)
{
// should never be called
}
void Equalizer::remove(Band *)
{
// should never be called
}
void Equalizer::update(bool)
{
// should never be called
}
void Equalizer::enableUpdates(bool)
{
// should never be called
}
#undef EQ
#undef EQBACK
#include "equalizer.moc"
|