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
|
/***************************************************************************
* Copyright (C) 2006 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SOUNDCORE_H
#define SOUNDCORE_H
#include <QObject>
#include "decoder.h"
#include "output.h"
#include "visualization.h"
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
class QIODevice;
class SoundCore : public QObject
{
Q_OBJECT
public:
/*! This enum describes the errors that may be returned by the error() function.
* Available values is:
* \b SoundCore:NoError - no error occurred,
* \b SoundCore:DecoderError - an error occurred when creating decoder,
* \b SoundCore:OutputError - an error occurred when creating output.
*/
enum ErrorType { NoError = 0, DecoderError, OutputError };
SoundCore(QObject *parent = 0);
~SoundCore();
//control
/*!
* This function plays file with given path, returns \b TRUE if all is OK, otherwise \b FALSE
*/
bool play(const QString &source);
/*!
* Returns the playback error status.
* For example, if play() returns false, this function can be called to find out
* the reason why the operation failed.
*/
uint error();
/*!
* Stops playing
*/
void stop();
/*!
* Pauses/resumes playing
*/
void pause();
/*!
*This function sets the current play position to \b pos
*/
void seek(int pos);
// properties
/*!
* Returns length in seconds
*/
int length();
/*!
* Returns \b TRUE if \b play() called successful, otherwise \b FALSE.
*/
bool isReady();
/*!
* Returns \b TRUE if \b play() called successful, otherwise \b FALSE.
* Also this function returns \b FALSE if \b stop() called before
*/
bool isInitialized();
/*!
* Returns \b TRUE if plugins in pause mode, otherwise \b FALSE.
*/
bool isPaused();
//equalizer
/*!
* Sets equalizer settings. Each item of \b bands[] and \b reamp should be
* \b -100..100
*/
void setEQ(int bands[10], const int &preamp);
/*!
* Enables equalizer if on is \b TRUE or disables it if on is \b FALSE
*/
void setEQEnabled(bool on);
//volume
/*!
* Sets volume. \b L - volume of left channel. \b R - volume of right channel.
* \b L and \b R should be 0..100
*/
void setVolume(int L, int R);
//config
/*!
* updates configuration
*/
void updateConfig();
//visualization
/*!
* adds visualization
*/
void addVisualization(Visualization *visual);
signals:
/*!
* This signal is emited when the state of the decoder changes.
* The argument \b state is the new state of the decoder
*/
void decoderStateChanged(const DecoderState& state);
/*!
* This signal is emited when the state of the output changes.
* The argument \b state is the new state of the output
*/
void outputStateChanged(const OutputState& state);
private:
Decoder* m_decoder;
Output* m_output;
QIODevice* m_input;
uint m_error;
bool m_paused;
bool m_useEQ;
bool m_update;
int m_preamp;
int m_bands[10];
Visualization *m_vis;
};
#endif
|