File indexing completed on 2024-04-28 04:32:45
0001 /* 0002 SPDX-FileCopyrightText: 2006 Pino Toscano <pino@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "sound.h" 0008 0009 #include <QVariant> 0010 0011 using namespace Okular; 0012 0013 class Sound::Private 0014 { 0015 public: 0016 explicit Private(const QByteArray &data) 0017 : m_data(QVariant(data)) 0018 , m_type(Sound::Embedded) 0019 { 0020 init(); 0021 } 0022 0023 explicit Private(const QString &url) 0024 : m_data(QVariant(url)) 0025 , m_type(Sound::External) 0026 { 0027 init(); 0028 } 0029 0030 void init() 0031 { 0032 m_samplingRate = 44100.0; 0033 m_channels = 1; 0034 m_bitsPerSample = 8; 0035 m_soundEncoding = Sound::Raw; 0036 } 0037 0038 QVariant m_data; 0039 Sound::SoundType m_type; 0040 double m_samplingRate; 0041 int m_channels; 0042 int m_bitsPerSample; 0043 SoundEncoding m_soundEncoding; 0044 }; 0045 0046 Sound::Sound(const QByteArray &data) 0047 : d(new Private(data)) 0048 { 0049 } 0050 0051 Sound::Sound(const QString &url) 0052 : d(new Private(url)) 0053 { 0054 } 0055 0056 Sound::~Sound() 0057 { 0058 delete d; 0059 } 0060 0061 Sound::SoundType Sound::soundType() const 0062 { 0063 return d->m_type; 0064 } 0065 0066 QString Sound::url() const 0067 { 0068 return d->m_type == Sound::External ? d->m_data.toString() : QString(); 0069 } 0070 0071 QByteArray Sound::data() const 0072 { 0073 return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray(); 0074 } 0075 0076 double Sound::samplingRate() const 0077 { 0078 return d->m_samplingRate; 0079 } 0080 0081 void Sound::setSamplingRate(double samplingRate) 0082 { 0083 d->m_samplingRate = samplingRate; 0084 } 0085 0086 int Sound::channels() const 0087 { 0088 return d->m_channels; 0089 } 0090 0091 void Sound::setChannels(int channels) 0092 { 0093 d->m_channels = channels; 0094 } 0095 0096 int Sound::bitsPerSample() const 0097 { 0098 return d->m_bitsPerSample; 0099 } 0100 0101 void Sound::setBitsPerSample(int bitsPerSample) 0102 { 0103 d->m_bitsPerSample = bitsPerSample; 0104 } 0105 0106 Sound::SoundEncoding Sound::soundEncoding() const 0107 { 0108 return d->m_soundEncoding; 0109 } 0110 0111 void Sound::setSoundEncoding(Sound::SoundEncoding soundEncoding) 0112 { 0113 d->m_soundEncoding = soundEncoding; 0114 }