Okular

sound.cpp
1 /*
2  SPDX-FileCopyrightText: 2006 Pino Toscano <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "sound.h"
8 
9 #include <QVariant>
10 
11 using namespace Okular;
12 
13 class Sound::Private
14 {
15 public:
16  explicit Private(const QByteArray &data)
17  : m_data(QVariant(data))
18  , m_type(Sound::Embedded)
19  {
20  init();
21  }
22 
23  explicit Private(const QString &url)
24  : m_data(QVariant(url))
25  , m_type(Sound::External)
26  {
27  init();
28  }
29 
30  void init()
31  {
32  m_samplingRate = 44100.0;
33  m_channels = 1;
34  m_bitsPerSample = 8;
35  m_soundEncoding = Sound::Raw;
36  }
37 
38  QVariant m_data;
39  Sound::SoundType m_type;
40  double m_samplingRate;
41  int m_channels;
42  int m_bitsPerSample;
43  SoundEncoding m_soundEncoding;
44 };
45 
47  : d(new Private(data))
48 {
49 }
50 
52  : d(new Private(url))
53 {
54 }
55 
57 {
58  delete d;
59 }
60 
62 {
63  return d->m_type;
64 }
65 
67 {
68  return d->m_type == Sound::External ? d->m_data.toString() : QString();
69 }
70 
72 {
73  return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray();
74 }
75 
76 double Sound::samplingRate() const
77 {
78  return d->m_samplingRate;
79 }
80 
82 {
83  d->m_samplingRate = samplingRate;
84 }
85 
86 int Sound::channels() const
87 {
88  return d->m_channels;
89 }
90 
92 {
93  d->m_channels = channels;
94 }
95 
97 {
98  return d->m_bitsPerSample;
99 }
100 
102 {
103  d->m_bitsPerSample = bitsPerSample;
104 }
105 
107 {
108  return d->m_soundEncoding;
109 }
110 
112 {
113  d->m_soundEncoding = soundEncoding;
114 }
double samplingRate() const
Returns the sampling rate.
Definition: sound.cpp:76
Is not encoded.
Definition: sound.h:38
int channels() const
Returns the number of channels.
Definition: sound.cpp:86
global.h
Definition: action.h:16
SoundEncoding soundEncoding() const
Returns the sound encoding.
Definition: sound.cpp:106
void setSamplingRate(double rate)
Sets the sampling rate.
Definition: sound.cpp:81
QString url() const
Returns the external storage url of the sound data.
Definition: sound.cpp:66
Is stored embedded in the document.
Definition: sound.h:31
~Sound()
Destroys the sound object.
Definition: sound.cpp:56
Contains information about a sound object.
Definition: sound.h:23
void setChannels(int channels)
Sets the number of channels.
Definition: sound.cpp:91
void setSoundEncoding(SoundEncoding encoding)
Sets the type of sound encoding.
Definition: sound.cpp:111
int bitsPerSample() const
Returns the bits per sample rate.
Definition: sound.cpp:96
SoundEncoding
Describes the encoding of the sound data.
Definition: sound.h:37
QCA_EXPORT void init()
Is stored at external resource (e.g. url)
Definition: sound.h:30
SoundType soundType() const
Returns the type of the sound object.
Definition: sound.cpp:61
SoundType
Describes where the sound is stored.
Definition: sound.h:29
QByteArray data() const
Returns the embedded sound data.
Definition: sound.cpp:71
void setBitsPerSample(int bitsPerSample)
Sets the bits per sample bitsPerSample.
Definition: sound.cpp:101
Sound(const QByteArray &data)
Creates a new sound object with the given embedded sound data.
Definition: sound.cpp:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:32:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.