Qmmp
Loading...
Searching...
No Matches
soundcore.h
1/***************************************************************************
2 * Copyright (C) 2006-2025 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;
104 Qmmp::State state() const;
108 const QMap<Qmmp::MetaData, QString> &metaData() const;
112 QString metaData(Qmmp::MetaData key) const;
116 const QHash<QString, QString> &streamInfo() const;
120 const TrackInfo &trackInfo() const;
125 bool nextTrackAccepted() const;
129 const QString path() const;
134
135public slots:
141 void setVolumePerChannel(int left, int right);
146 void setMuted(bool mute);
150 void changeVolume(int delta);
155 void setVolume(int volume);
159 void volumeUp();
174 bool play(const QString &source, bool queue = false, qint64 offset = -1);
178 void stop();
182 void pause();
186 void seek(qint64 pos);
187
188signals:
193 void bufferingProgress(int progress);
198 void elapsedChanged(qint64 time);
220 void stateChanged(Qmmp::State newState);
224 void finished();
229 void mutedChanged(bool muted);
248
249private slots:
250 void startNextSource();
251 void startNextEngine();
252
253private:
254 bool event(QEvent *e) override;
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 VolumeHandler *m_volumeControl;
268 AbstractEngine *m_engine = nullptr;
269 QQueue<InputSource *> m_sources;
270 NextEngineState m_nextState = NO_ENGINE;
271};
272
273#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
The SoundCore class provides a simple interface for audio playback.
Definition soundcore.h:45
const QHash< QString, QString > & streamInfo() const
void seek(qint64 pos)
void bitrateChanged(int bitrate)
void stateChanged(Qmmp::State newState)
bool isMuted() const
void mutedChanged(bool muted)
void trackInfoChanged()
void changeVolume(int delta)
void setVolumePerChannel(int left, int right)
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)
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