Qmmp
soundcore.h
1 /***************************************************************************
2  * Copyright (C) 2006-2020 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 VolumeHandler;
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 = nullptr);
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;
120  const TrackInfo &trackInfo() const;
125  bool nextTrackAccepted() const;
129  static SoundCore* instance();
130 
131 public slots:
137  void setVolume(int left, int right);
142  void setMuted(bool mute);
146  void changeVolume(int delta);
151  void setVolume(int volume);
155  void volumeUp();
159  void volumeDown();
164  void setBalance(int balance);
170  bool play(const QString &source, bool queue = false, qint64 offset = -1);
174  void stop();
178  void pause();
182  void seek(qint64 pos);
186  const QString path() const;
187 
188 signals:
193  void bufferingProgress(int progress);
198  void elapsedChanged(qint64 time);
203  void bitrateChanged(int bitrate);
208  void audioParametersChanged(const AudioParameters &p);
212  void streamInfoChanged();
216  void trackInfoChanged();
220  void stateChanged (Qmmp::State newState);
224  void finished();
230  void volumeChanged(int left, int right);
235  void mutedChanged(bool muted);
240  void volumeChanged(int volume);
245  void balanceChanged(int balance);
249  void eqSettingsChanged();
253  void nextTrackRequest();
254 
255 private slots:
256  void startNextSource();
257  void startNextEngine();
258 
259 private:
260  bool event(QEvent *e) override;
261  enum NextEngineState
262  {
263  NO_ENGINE = 0,
264  SAME_ENGINE,
265  ANOTHER_ENGINE,
266  INVALID_SOURCE
267  };
268  QHash <QString, QString> m_streamInfo;
269  TrackInfo m_info;
270  QString m_path;
271  static SoundCore* m_instance;
272  StateHandler *m_handler;
273  VolumeHandler *m_volumeControl;
274  AbstractEngine *m_engine;
275  QQueue<InputSource *> m_sources;
276  int m_nextState;
277 };
278 
279 #endif
State
Definition: qmmp.h:61
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:73
The TrackInfo class stores metadata and other information about track.
Definition: trackinfo.h:31
The EqSettings class helps to work with equalizer settings.
Definition: eqsettings.h:29
The VolumeHandler class provides volume control access.
Definition: volumehandler.h:37
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