Qmmp
Loading...
Searching...
No Matches
soundcore.h
1/***************************************************************************
2 * Copyright (C) 2006-2022 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
36class VolumeHandler;
37class AbstractEngine;
38class InputSource;
39class StateHandler;
40
44class QMMP_EXPORT SoundCore : public QObject
45{
46 Q_OBJECT
47public:
52 SoundCore(QObject *parent = nullptr);
60 qint64 duration() 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;
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;
130
131public 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();
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
188signals:
193 void bufferingProgress(int progress);
198 void elapsedChanged(qint64 time);
203 void bitrateChanged(int bitrate);
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);
254
255private slots:
256 void startNextSource();
257 void startNextEngine();
258
259private:
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 = nullptr;
275 QQueue<InputSource *> m_sources;
276 NextEngineState m_nextState = NO_ENGINE;
277};
278
279#endif
The AbstractEngine class provides the base interface class of audio audio engines.
Definition abstractengine.h:40
The AudioParameters class keeps information about audio settings.
Definition audioparameters.h:32
The EqSettings class helps to work with equalizer settings.
Definition eqsettings.h:30
The InputSource class provides the base interface class of transports.
Definition inputsource.h:39
State
Definition qmmp.h:62
MetaData
Definition qmmp.h:74
The SoundCore class provides a simple interface for audio playback.
Definition soundcore.h:45
void seek(qint64 pos)
void bitrateChanged(int bitrate)
void volumeChanged(int left, int right)
void stateChanged(Qmmp::State newState)
bool isMuted() const
void mutedChanged(bool muted)
void trackInfoChanged()
QHash< QString, QString > streamInfo() const
void changeVolume(int delta)
QString metaData(Qmmp::MetaData key) const
SoundCore(QObject *parent=nullptr)
void bufferingProgress(int progress)
void balanceChanged(int balance)
static SoundCore * instance()
void volumeChanged(int volume)
Qmmp::State state() const
void setVolume(int volume)
const QMap< Qmmp::MetaData, QString > & metaData() const
void pause()
void setEqSettings(const EqSettings &settings)
int rightVolume() const
int leftVolume() const
void setMuted(bool mute)
const TrackInfo & trackInfo() const
void stop()
int volume() const
bool play(const QString &source, bool queue=false, qint64 offset=-1)
void volumeDown()
void audioParametersChanged(const AudioParameters &p)
int balance() const
void streamInfoChanged()
void eqSettingsChanged()
qint64 elapsed() const
const QString path() const
qint64 duration() const
int bitrate() const
void setBalance(int balance)
void setVolume(int left, int right)
EqSettings eqSettings() const
void elapsedChanged(qint64 time)
void volumeUp()
bool nextTrackAccepted() const
void finished()
AudioParameters audioParameters() const
void nextTrackRequest()
The StateHandler class allows one to track information about playback progress.
Definition statehandler.h:35
The TrackInfo class stores metadata and other information about track.
Definition trackinfo.h:32
The VolumeHandler class provides volume control access.
Definition volumehandler.h:38