| 1 |
/* This file is part of the KDE project |
| 2 |
Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org> |
| 3 |
|
| 4 |
This library is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU Lesser General Public |
| 6 |
License as published by the Free Software Foundation; either |
| 7 |
version 2.1 of the License, or (at your option) version 3, or any |
| 8 |
later version accepted by the membership of KDE e.V. (or its |
| 9 |
successor approved by the membership of KDE e.V.), Nokia Corporation |
| 10 |
(or its successors, if any) and the KDE Free Qt Foundation, which shall |
| 11 |
act as a proxy defined in Section 6 of version 3 of the license. |
| 12 |
|
| 13 |
This library is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
Lesser General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU Lesser General Public |
| 19 |
License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
*/ |
| 22 |
#ifndef Phonon_AUDIODATAOUTPUT_H |
| 23 |
#define Phonon_AUDIODATAOUTPUT_H |
| 24 |
|
| 25 |
#include "phonon_export.h" |
| 26 |
#include "abstractaudiooutput.h" |
| 27 |
#include "phonondefs.h" |
| 28 |
|
| 29 |
QT_BEGIN_HEADER |
| 30 |
QT_BEGIN_NAMESPACE |
| 31 |
|
| 32 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 33 |
template<typename T> class QVector; |
| 34 |
template<typename Key, typename T> class QMap; |
| 35 |
#endif |
| 36 |
|
| 37 |
namespace Phonon |
| 38 |
{ |
| 39 |
class AudioDataOutputPrivate; |
| 40 |
|
| 41 |
/** |
| 42 |
* \short This class gives you the audio data (for visualizations). |
| 43 |
* |
| 44 |
* This class implements a special AbstractAudioOutput that gives your |
| 45 |
* application the audio data. Don't expect realtime performance. But |
| 46 |
* the latencies should be low enough to use the audio data for |
| 47 |
* visualizations. You can also use the audio data for further processing |
| 48 |
* (e.g. encoding and saving to a file). |
| 49 |
* |
| 50 |
* \author Matthias Kretz <kretz@kde.org> |
| 51 |
*/ |
| 52 |
class PHONON_EXPORT AudioDataOutput : public AbstractAudioOutput |
| 53 |
{ |
| 54 |
Q_OBJECT |
| 55 |
K_DECLARE_PRIVATE(AudioDataOutput) |
| 56 |
Q_ENUMS(Channel) |
| 57 |
Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize) |
| 58 |
PHONON_HEIR(AudioDataOutput) |
| 59 |
public: |
| 60 |
/** |
| 61 |
* Specifies the channel the audio data belongs to. |
| 62 |
*/ |
| 63 |
enum Channel |
| 64 |
{ |
| 65 |
LeftChannel, |
| 66 |
RightChannel, |
| 67 |
CenterChannel, |
| 68 |
LeftSurroundChannel, |
| 69 |
RightSurroundChannel, |
| 70 |
SubwooferChannel |
| 71 |
}; |
| 72 |
|
| 73 |
/** |
| 74 |
* Returns the currently used number of samples passed through |
| 75 |
* the signal. |
| 76 |
* |
| 77 |
* \see setDataSize |
| 78 |
*/ |
| 79 |
int dataSize() const; |
| 80 |
|
| 81 |
/** |
| 82 |
* Returns the sample rate in Hz. Common sample rates are 44100 Hz |
| 83 |
* and 48000 Hz. AudioDataOutput will not do any sample rate |
| 84 |
* conversion for you. If you need to convert the sample rate you |
| 85 |
* might want to take a look at libsamplerate. For visualizations it |
| 86 |
* is often enough to do simple interpolation or even drop/duplicate |
| 87 |
* samples. |
| 88 |
* |
| 89 |
* \return The sample rate as reported by the backend. If the |
| 90 |
* backend is unavailable -1 is returned. |
| 91 |
*/ |
| 92 |
int sampleRate() const; |
| 93 |
|
| 94 |
public Q_SLOTS: |
| 95 |
/** |
| 96 |
* Sets the number of samples to be passed in one signal emission. |
| 97 |
* |
| 98 |
* Defaults to 512 samples per emitted signal. |
| 99 |
* |
| 100 |
* \param size the number of samples |
| 101 |
*/ |
| 102 |
void setDataSize(int size); |
| 103 |
|
| 104 |
Q_SIGNALS: |
| 105 |
/** |
| 106 |
* Emitted whenever another dataSize number of samples are ready. |
| 107 |
* |
| 108 |
* \param data A mapping of Channel to a vector holding the audio data. |
| 109 |
*/ |
| 110 |
void dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &data); |
| 111 |
|
| 112 |
|
| 113 |
/** |
| 114 |
* This signal is emitted before the last dataReady signal of a |
| 115 |
* media is emitted. |
| 116 |
* |
| 117 |
* If, for example, the playback of a media file has finished and the |
| 118 |
* last audio data of that file is going to be passed with the next |
| 119 |
* dataReady signal, and only the 28 first samples of the data |
| 120 |
* vector are from that media file endOfMedia will be emitted right |
| 121 |
* before dataReady with \p remainingSamples = 28. |
| 122 |
* |
| 123 |
* \param remainingSamples The number of samples in the next |
| 124 |
* dataReady vector that belong to the media that was playing to |
| 125 |
* this point. |
| 126 |
*/ |
| 127 |
void endOfMedia(int remainingSamples); |
| 128 |
}; |
| 129 |
} // namespace Phonon |
| 130 |
|
| 131 |
QT_END_NAMESPACE |
| 132 |
QT_END_HEADER |
| 133 |
|
| 134 |
// vim: sw=4 ts=4 tw=80 |
| 135 |
#endif // Phonon_AUDIODATAOUTPUT_H |