Qmmp
soundcore.h
1 /***************************************************************************
2  * Copyright (C) 2006-2018 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 #include "trackinfo.h"
35 
36 class VolumeControl;
37 class AbstractEngine;
38 class InputSource;
39 class StateHandler;
40 
44 class QMMP_EXPORT SoundCore : public QObject
45 {
46  Q_OBJECT
47 public:
52  SoundCore(QObject *parent = 0);
56  ~SoundCore();
60  qint64 duration() const;
64  EqSettings eqSettings() const;
68  void setEqSettings(const EqSettings &settings);
72  int leftVolume() const;
76  int rightVolume() const;
80  int volume() const;
84  int balance() const;
88  bool isMuted() const;
92  qint64 elapsed() const;
96  int bitrate() const;
100  AudioParameters audioParameters() const;
104  Qmmp::State state() const;
108  const QMap<Qmmp::MetaData, QString> &metaData() const;
112  QString metaData(Qmmp::MetaData key) const;
116  QHash<QString, QString> streamInfo() const;
117  const TrackInfo &trackInfo() const;
122  bool nextTrackAccepted() const;
126  static SoundCore* instance();
127 
128 public slots:
134  void setVolume(int left, int right);
139  void setMuted(bool mute);
143  void changeVolume(int delta);
148  void setVolume(int volume);
152  void volumeUp();
156  void volumeDown();
161  void setBalance(int balance);
167  bool play(const QString &source, bool queue = false, qint64 offset = -1);
171  void stop();
175  void pause();
179  void seek(qint64 pos);
183  const QString path() const;
184 
185 signals:
190  void bufferingProgress(int progress);
195  void elapsedChanged(qint64 time);
200  void bitrateChanged(int bitrate);
205  void audioParametersChanged(const AudioParameters &p);
209  void streamInfoChanged();
210  void trackInfoChanged();
214  void stateChanged (Qmmp::State newState);
218  void finished();
224  void volumeChanged(int left, int right);
229  void mutedChanged(bool muted);
234  void volumeChanged(int volume);
239  void balanceChanged(int balance);
243  void eqSettingsChanged();
247  void nextTrackRequest();
248 
249 private slots:
250  void startNextSource();
251  void startNextEngine();
252 
253 private:
254  bool event(QEvent *e);
255  enum NextEngineState
256  {
257  NO_ENGINE = 0,
258  SAME_ENGINE,
259  ANOTHER_ENGINE,
260  INVALID_SOURCE
261  };
262  QHash <QString, QString> m_streamInfo;
263  TrackInfo m_info;
264  QString m_path;
265  static SoundCore* m_instance;
266  StateHandler *m_handler;
267  VolumeControl *m_volumeControl;
268  AbstractEngine *m_engine;
269  QQueue<InputSource *> m_sources;
270  int m_nextState;
271  bool m_muted;
272 };
273 
274 #endif
State
Definition: qmmp.h:52
The AudioParameters class keeps information about audio settings.
Definition: audioparameters.h:31
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
MetaData
Definition: qmmp.h:64
The EqSettings class helps to work with equalizer settings.
Definition: eqsettings.h:29
The AbstractEngine class provides the base interface class of audio audio engines.
Definition: abstractengine.h:39
The SoundCore class provides a simple interface for audio playback.
Definition: soundcore.h:44