File: sound.cpp

package info (click to toggle)
okular 4%3A4.8.4-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,040 kB
  • sloc: cpp: 62,030; ansic: 3,964; xml: 66; sh: 22; makefile: 7
file content (117 lines) | stat: -rw-r--r-- 2,552 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
 *   Copyright (C) 2006 by Pino Toscano <pino@kde.org>                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "sound.h"

#include <QtCore/QVariant>

using namespace Okular;

class Sound::Private
{
    public:
        Private( const QByteArray &data )
            : m_data( QVariant( data ) ),
              m_type( Sound::Embedded )
        {
            init();
        }

        Private( const QString &url )
            : m_data( QVariant( url ) ),
              m_type( Sound::External )
        {
            init();
        }

        void init()
        {
            m_samplingRate = 44100.0;
            m_channels = 1;
            m_bitsPerSample = 8;
            m_soundEncoding = Sound::Raw;
        }

        QVariant m_data;
        Sound::SoundType m_type;
        double m_samplingRate;
        int m_channels;
        int m_bitsPerSample;
        SoundEncoding m_soundEncoding;
};

Sound::Sound( const QByteArray& data )
    : d( new Private( data ) )
{
}

Sound::Sound( const QString& url )
    : d( new Private( url ) )
{
}

Sound::~Sound()
{
    delete d;
}

Sound::SoundType Sound::soundType() const
{
    return d->m_type;
}

QString Sound::url() const
{
    return d->m_type == Sound::External ? d->m_data.toString() : QString();
}

QByteArray Sound::data() const
{
    return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray();
}

double Sound::samplingRate() const
{
    return d->m_samplingRate;
}

void Sound::setSamplingRate( double samplingRate )
{
    d->m_samplingRate = samplingRate;
}

int Sound::channels() const
{
    return d->m_channels;
}

void Sound::setChannels( int channels )
{
    d->m_channels = channels;
}

int Sound::bitsPerSample() const
{
    return d->m_bitsPerSample;
}

void Sound::setBitsPerSample( int bitsPerSample )
{
    d->m_bitsPerSample = bitsPerSample;
}

Sound::SoundEncoding Sound::soundEncoding() const
{
    return d->m_soundEncoding;
}

void Sound::setSoundEncoding( Sound::SoundEncoding soundEncoding )
{
    d->m_soundEncoding = soundEncoding;
}