File: SampleFormat.h

package info (click to toggle)
kwave 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,272 kB
  • sloc: cpp: 56,173; xml: 817; perl: 688; sh: 57; makefile: 11
file content (103 lines) | stat: -rw-r--r-- 3,427 bytes parent folder | download
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
/***************************************************************************
        SampleFormat.h  -  Map for all known sample formats
                             -------------------
    begin                : Sun Jul 28 2002
    copyright            : (C) 2002 by Thomas Eschenbacher
    email                : Thomas.Eschenbacher@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SAMPLE_FORMAT_H
#define SAMPLE_FORMAT_H

#include "config.h"
#include "libkwave_export.h"

#include <QtGlobal>

#include "libkwave/TypesMap.h"

namespace Kwave
{

    class LIBKWAVE_EXPORT SampleFormat
    {
    public:
        /**
         * numeric representation of a sample format
         * @note for compatibility with older settings these values are
         *       the same as defined in audiofile.h.
         */
        typedef enum {
            Unknown  =  -1, /**< unknown/invalid format */
            Signed   = 401, /**< signed integer         */
            Unsigned = 402, /**< unsigned integer       */
            Float    = 403, /**< 32 bit floating point  */
            Double   = 404  /**< 64 bit floating point  */
        } Format;

        /** Default constructor */
        SampleFormat() { assign(Unknown); }

        /** Constructor, from SampleFormat::xxx */
        explicit SampleFormat(const Format x) { assign(x); }

        /** Copy constructor */
        SampleFormat(const SampleFormat &f) { assign(f); }

        /** Destructor */
        virtual ~SampleFormat() {}

        /** conversion operator to Format */
        inline operator Format() const { return m_format; }

        /** assignment operator from Format */
        inline void assign(Format f) { m_format = f; }

        /** compare operator */
        inline bool operator == (const Format &f) const {
            return (f == m_format);
        }

        /** conversion to int (e.g. for use in plugin parameters) */
        inline int toInt() const { return static_cast<int>(m_format); }

        /** conversion from int  (e.g. for use in plugin parameters) */
        void fromInt(int i);

    private:

        /** internal storage of the sample format, see Format */
        Format m_format;

    public:

        /** map for translating between index, sample format and name */
        class LIBKWAVE_EXPORT Map: public Kwave::TypesMap<int, Format>
        {
        public:
            /** Constructor */
            explicit Map();

            /** Destructor */
            ~Map() override;

            /** fills the list */
            void fill() override;
        };

    };
}

#endif /* SAMPLE_FORMAT_H */

//***************************************************************************
//***************************************************************************