compile
[kdegraphics.git] / okular / core / sound.cpp
blobf1e3b7c5201aa355d3761d6262b98ad0659c65d7
1 /***************************************************************************
2 * Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "sound.h"
12 #include <QtCore/QVariant>
14 using namespace Okular;
16 class Sound::Private
18 public:
19 Private( const QByteArray &data )
20 : m_data( QVariant( data ) ),
21 m_type( Sound::Embedded )
23 init();
26 Private( const QString &url )
27 : m_data( QVariant( url ) ),
28 m_type( Sound::External )
30 init();
33 void init()
35 m_samplingRate = 44100.0;
36 m_channels = 1;
37 m_bitsPerSample = 8;
38 m_soundEncoding = Sound::Raw;
41 QVariant m_data;
42 Sound::SoundType m_type;
43 double m_samplingRate;
44 int m_channels;
45 int m_bitsPerSample;
46 SoundEncoding m_soundEncoding;
49 Sound::Sound( const QByteArray& data )
50 : d( new Private( data ) )
54 Sound::Sound( const QString& url )
55 : d( new Private( url ) )
59 Sound::~Sound()
61 delete d;
64 Sound::SoundType Sound::soundType() const
66 return d->m_type;
69 QString Sound::url() const
71 return d->m_type == Sound::External ? d->m_data.toString() : QString();
74 QByteArray Sound::data() const
76 return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray();
79 double Sound::samplingRate() const
81 return d->m_samplingRate;
84 void Sound::setSamplingRate( double samplingRate )
86 d->m_samplingRate = samplingRate;
89 int Sound::channels() const
91 return d->m_channels;
94 void Sound::setChannels( int channels )
96 d->m_channels = channels;
99 int Sound::bitsPerSample() const
101 return d->m_bitsPerSample;
104 void Sound::setBitsPerSample( int bitsPerSample )
106 d->m_bitsPerSample = bitsPerSample;
109 Sound::SoundEncoding Sound::soundEncoding() const
111 return d->m_soundEncoding;
114 void Sound::setSoundEncoding( Sound::SoundEncoding soundEncoding )
116 d->m_soundEncoding = soundEncoding;