okular
sound.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2006 by Pino Toscano <pino@kde.org> * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 ***************************************************************************/ 00009 00010 #include "sound.h" 00011 00012 #include <QtCore/QVariant> 00013 00014 using namespace Okular; 00015 00016 class Sound::Private 00017 { 00018 public: 00019 Private( const QByteArray &data ) 00020 : m_data( QVariant( data ) ), 00021 m_type( Sound::Embedded ) 00022 { 00023 init(); 00024 } 00025 00026 Private( const QString &url ) 00027 : m_data( QVariant( url ) ), 00028 m_type( Sound::External ) 00029 { 00030 init(); 00031 } 00032 00033 void init() 00034 { 00035 m_samplingRate = 44100.0; 00036 m_channels = 1; 00037 m_bitsPerSample = 8; 00038 m_soundEncoding = Sound::Raw; 00039 } 00040 00041 QVariant m_data; 00042 Sound::SoundType m_type; 00043 double m_samplingRate; 00044 int m_channels; 00045 int m_bitsPerSample; 00046 SoundEncoding m_soundEncoding; 00047 }; 00048 00049 Sound::Sound( const QByteArray& data ) 00050 : d( new Private( data ) ) 00051 { 00052 } 00053 00054 Sound::Sound( const QString& url ) 00055 : d( new Private( url ) ) 00056 { 00057 } 00058 00059 Sound::~Sound() 00060 { 00061 delete d; 00062 } 00063 00064 Sound::SoundType Sound::soundType() const 00065 { 00066 return d->m_type; 00067 } 00068 00069 QString Sound::url() const 00070 { 00071 return d->m_type == Sound::External ? d->m_data.toString() : QString(); 00072 } 00073 00074 QByteArray Sound::data() const 00075 { 00076 return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray(); 00077 } 00078 00079 double Sound::samplingRate() const 00080 { 00081 return d->m_samplingRate; 00082 } 00083 00084 void Sound::setSamplingRate( double samplingRate ) 00085 { 00086 d->m_samplingRate = samplingRate; 00087 } 00088 00089 int Sound::channels() const 00090 { 00091 return d->m_channels; 00092 } 00093 00094 void Sound::setChannels( int channels ) 00095 { 00096 d->m_channels = channels; 00097 } 00098 00099 int Sound::bitsPerSample() const 00100 { 00101 return d->m_bitsPerSample; 00102 } 00103 00104 void Sound::setBitsPerSample( int bitsPerSample ) 00105 { 00106 d->m_bitsPerSample = bitsPerSample; 00107 } 00108 00109 Sound::SoundEncoding Sound::soundEncoding() const 00110 { 00111 return d->m_soundEncoding; 00112 } 00113 00114 void Sound::setSoundEncoding( Sound::SoundEncoding soundEncoding ) 00115 { 00116 d->m_soundEncoding = soundEncoding; 00117 }
KDE 4.0 API Reference