Okular

sound.cpp
1/*
2 SPDX-FileCopyrightText: 2006 Pino Toscano <pino@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "sound.h"
8
9#include <QVariant>
10
11using namespace Okular;
12
13class Sound::Private
14{
15public:
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
76double Sound::samplingRate() const
77{
78 return d->m_samplingRate;
79}
80
81void Sound::setSamplingRate(double samplingRate)
82{
83 d->m_samplingRate = samplingRate;
84}
85
86int Sound::channels() const
87{
88 return d->m_channels;
89}
90
91void Sound::setChannels(int channels)
92{
93 d->m_channels = channels;
94}
95
97{
98 return d->m_bitsPerSample;
99}
100
101void Sound::setBitsPerSample(int bitsPerSample)
102{
103 d->m_bitsPerSample = bitsPerSample;
104}
105
107{
108 return d->m_soundEncoding;
109}
110
112{
113 d->m_soundEncoding = soundEncoding;
114}
Contains information about a sound object.
Definition sound.h:24
~Sound()
Destroys the sound object.
Definition sound.cpp:56
QByteArray data() const
Returns the embedded sound data.
Definition sound.cpp:71
SoundEncoding
Describes the encoding of the sound data.
Definition sound.h:37
@ Raw
Is not encoded.
Definition sound.h:38
void setSamplingRate(double rate)
Sets the sampling rate.
Definition sound.cpp:81
SoundType soundType() const
Returns the type of the sound object.
Definition sound.cpp:61
int bitsPerSample() const
Returns the bits per sample rate.
Definition sound.cpp:96
QString url() const
Returns the external storage url of the sound data.
Definition sound.cpp:66
void setBitsPerSample(int bitsPerSample)
Sets the bits per sample bitsPerSample.
Definition sound.cpp:101
int channels() const
Returns the number of channels.
Definition sound.cpp:86
void setChannels(int channels)
Sets the number of channels.
Definition sound.cpp:91
SoundEncoding soundEncoding() const
Returns the sound encoding.
Definition sound.cpp:106
void setSoundEncoding(SoundEncoding encoding)
Sets the type of sound encoding.
Definition sound.cpp:111
SoundType
Describes where the sound is stored.
Definition sound.h:29
@ Embedded
Is stored embedded in the document.
Definition sound.h:31
@ External
Is stored at external resource (e.g. url)
Definition sound.h:30
Sound(const QByteArray &data)
Creates a new sound object with the given embedded sound data.
Definition sound.cpp:46
double samplingRate() const
Returns the sampling rate.
Definition sound.cpp:76
global.h
Definition action.h:17
QByteArray toByteArray() const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:47:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.