Qmmp
soundcore.h
1 /***************************************************************************
2  * Copyright (C) 2006-2017 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef SOUNDCORE_H
21 #define SOUNDCORE_H
22 
23 #include <QObject>
24 #include <QString>
25 #include <QQueue>
26 #include <QHash>
27 #include "decoder.h"
28 #include "output.h"
29 #include "visual.h"
30 #include "qmmp.h"
31 #include "qmmpsettings.h"
32 #include "audioparameters.h"
33 #include "eqsettings.h"
34 
35 class VolumeControl;
36 class AbstractEngine;
37 class InputSource;
38 class StateHandler;
39 
43 class SoundCore : public QObject
44 {
45  Q_OBJECT
46 public:
51  SoundCore(QObject *parent = 0);
55  ~SoundCore();
59  qint64 totalTime() const;
63  EqSettings eqSettings() const;
67  void setEqSettings(const EqSettings &settings);
71  int leftVolume() const;
75  int rightVolume() const;
79  int volume() const;
83  int balance() const;
87  bool isMuted() const;
91  qint64 elapsed() const;
95  int bitrate() const;
103  Qmmp::State state() const;
107  QMap <Qmmp::MetaData, QString> metaData() const;
111  QString metaData(Qmmp::MetaData key) const;
115  QHash<QString, QString> streamInfo() const;
120  bool nextTrackAccepted() const;
124  static SoundCore* instance();
125 
126 public slots:
132  void setVolume(int left, int right);
137  void setMuted(bool mute);
141  void changeVolume(int delta);
146  void setVolume(int volume);
150  void volumeUp();
154  void volumeDown();
159  void setBalance(int balance);
165  bool play(const QString &source, bool queue = false, qint64 offset = -1);
169  void stop();
173  void pause();
177  void seek(qint64 pos);
181  const QString url() const;
182 
183 signals:
188  void bufferingProgress(int progress);
193  void elapsedChanged(qint64 time);
198  void bitrateChanged(int bitrate);
207  void metaDataChanged ();
211  void streamInfoChanged();
215  void stateChanged (Qmmp::State newState);
219  void finished();
225  void volumeChanged(int left, int right);
230  void mutedChanged(bool muted);
235  void volumeChanged(int volume);
240  void balanceChanged(int balance);
244  void eqSettingsChanged();
248  void nextTrackRequest();
249 
250 private slots:
251  void startNextSource();
252  void startNextEngine();
253 
254 private:
255  bool event(QEvent *e);
256  enum NextEngineState
257  {
258  NO_ENGINE = 0,
259  SAME_ENGINE,
260  ANOTHER_ENGINE,
261  INVALID_SOURCE
262  };
263  QMap <Qmmp::MetaData, QString> m_metaData;
264  QHash <QString, QString> m_streamInfo;
265  QString m_url;
266  static SoundCore* m_instance;
267  StateHandler *m_handler;
268  VolumeControl *m_volumeControl;
269  AbstractEngine *m_engine;
270  QQueue<InputSource *> m_sources;
271  int m_nextState;
272  bool m_muted;
273 };
274 
275 #endif
bool play(const QString &source, bool queue=false, qint64 offset=-1)
void volumeDown()
void metaDataChanged()
void nextTrackRequest()
State
Definition: qmmp.h:51
void setVolume(int left, int right)
int volume() const
void pause()
void stateChanged(Qmmp::State newState)
AudioParameters audioParameters() const
bool isMuted() const
void streamInfoChanged()
The AudioParameters class keeps information about audio settings.
Definition: audioparameters.h:31
EqSettings eqSettings() const
void seek(qint64 pos)
SoundCore(QObject *parent=0)
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:34
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:38
int balance() const
bool nextTrackAccepted() const
void elapsedChanged(qint64 time)
MetaData
Definition: qmmp.h:63
void setMuted(bool mute)
qint64 totalTime() const
int bitrate() const
void finished()
void balanceChanged(int balance)
const QString url() const
The EqSettings class helps to work with equalizer settings.
Definition: eqsettings.h:27
void setEqSettings(const EqSettings &settings)
int rightVolume() const
QMap< Qmmp::MetaData, QString > metaData() const
int leftVolume() const
void audioParametersChanged(const AudioParameters &p)
void volumeChanged(int left, int right)
void mutedChanged(bool muted)
void setBalance(int balance)
void volumeUp()
Qmmp::State state() const
The AbstractEngine class provides the base interface class of audio audio engines.
Definition: abstractengine.h:38
void stop()
void bufferingProgress(int progress)
qint64 elapsed() const
QHash< QString, QString > streamInfo() const
void bitrateChanged(int bitrate)
void changeVolume(int delta)
The SoundCore class provides a simple interface for audio playback.
Definition: soundcore.h:43
void eqSettingsChanged()
static SoundCore * instance()