aboutsummaryrefslogtreecommitdiffstats
path: root/core/ambdec.h
blob: 19f68697114c88b1784301df93fe8bbcd6f08409 (plain)
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
#ifndef CORE_AMBDEC_H
#define CORE_AMBDEC_H

#include <array>
#include <memory>
#include <optional>
#include <string>

#include "core/ambidefs.h"

/* Helpers to read .ambdec configuration files. */

enum class AmbDecScale {
    Unset,
    N3D,
    SN3D,
    FuMa,
};
struct AmbDecConf {
    std::string Description;
    int Version{0}; /* Must be 3 */

    unsigned int ChanMask{0u};
    unsigned int FreqBands{0u}; /* Must be 1 or 2 */
    AmbDecScale CoeffScale{AmbDecScale::Unset};

    float XOverFreq{0.0f};
    float XOverRatio{0.0f};

    struct SpeakerConf {
        std::string Name;
        float Distance{0.0f};
        float Azimuth{0.0f};
        float Elevation{0.0f};
        std::string Connection;
    };
    size_t NumSpeakers{0};
    std::unique_ptr<SpeakerConf[]> Speakers;

    using CoeffArray = std::array<float,MaxAmbiChannels>;
    std::unique_ptr<CoeffArray[]> Matrix;

    /* Unused when FreqBands == 1 */
    float LFOrderGain[MaxAmbiOrder+1]{};
    CoeffArray *LFMatrix;

    float HFOrderGain[MaxAmbiOrder+1]{};
    CoeffArray *HFMatrix;

    ~AmbDecConf();

    std::optional<std::string> load(const char *fname) noexcept;
};

#endif /* CORE_AMBDEC_H */