File indexing completed on 2025-02-09 05:31:45
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 #ifndef Phonon_AUDIODATAOUTPUT_H 0023 #define Phonon_AUDIODATAOUTPUT_H 0024 0025 #include "phonon_export.h" 0026 #include "abstractaudiooutput.h" 0027 #include "phonondefs.h" 0028 0029 #ifndef DOXYGEN_SHOULD_SKIP_THIS 0030 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0031 template<typename T> class QVector; 0032 #else 0033 template<typename T> class QList; 0034 #endif 0035 template<typename Key, typename T> class QMap; 0036 #endif 0037 0038 namespace Phonon 0039 { 0040 class AudioDataOutputPrivate; 0041 0042 /** 0043 * \short This class gives you the audio data (for visualizations). 0044 * 0045 * This class implements a special AbstractAudioOutput that gives your 0046 * application the audio data. Don't expect realtime performance. But 0047 * the latencies should be low enough to use the audio data for 0048 * visualizations. You can also use the audio data for further processing 0049 * (e.g. encoding and saving to a file). 0050 * 0051 * \author Matthias Kretz <kretz@kde.org> 0052 */ 0053 class PHONON_EXPORT AudioDataOutput : public AbstractAudioOutput 0054 { 0055 Q_OBJECT 0056 P_DECLARE_PRIVATE(AudioDataOutput) 0057 Q_ENUMS(Channel) 0058 Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize) 0059 PHONON_HEIR(AudioDataOutput) 0060 public: 0061 /** 0062 * Specifies the channel the audio data belongs to. 0063 */ 0064 enum Channel 0065 { 0066 LeftChannel, 0067 RightChannel, 0068 CenterChannel, 0069 LeftSurroundChannel, 0070 RightSurroundChannel, 0071 SubwooferChannel 0072 }; 0073 0074 /** 0075 * Returns the currently used number of samples passed through 0076 * the signal. 0077 * 0078 * \see setDataSize 0079 */ 0080 int dataSize() const; 0081 0082 /** 0083 * Returns the sample rate in Hz. Common sample rates are 44100 Hz 0084 * and 48000 Hz. AudioDataOutput will not do any sample rate 0085 * conversion for you. If you need to convert the sample rate you 0086 * might want to take a look at libsamplerate. For visualizations it 0087 * is often enough to do simple interpolation or even drop/duplicate 0088 * samples. 0089 * 0090 * \return The sample rate as reported by the backend. If the 0091 * backend is unavailable -1 is returned. 0092 */ 0093 int sampleRate() const; 0094 0095 public Q_SLOTS: 0096 /** 0097 * Sets the number of samples to be passed in one signal emission. 0098 * 0099 * Defaults to 512 samples per emitted signal. 0100 * 0101 * \param size the number of samples 0102 */ 0103 void setDataSize(int size); 0104 0105 Q_SIGNALS: 0106 /** 0107 * Emitted whenever another dataSize number of samples are ready. 0108 * 0109 * \param data A mapping of Channel to a vector holding the audio data. 0110 */ 0111 void dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &data); 0112 0113 0114 /** 0115 * This signal is emitted before the last dataReady signal of a 0116 * media is emitted. 0117 * 0118 * If, for example, the playback of a media file has finished and the 0119 * last audio data of that file is going to be passed with the next 0120 * dataReady signal, and only the 28 first samples of the data 0121 * vector are from that media file endOfMedia will be emitted right 0122 * before dataReady with \p remainingSamples = 28. 0123 * 0124 * \param remainingSamples The number of samples in the next 0125 * dataReady vector that belong to the media that was playing to 0126 * this point. 0127 */ 0128 void endOfMedia(int remainingSamples); 0129 }; 0130 } // namespace Phonon 0131 0132 0133 // vim: sw=4 ts=4 tw=80 0134 #endif // Phonon_AUDIODATAOUTPUT_H