summaryrefslogtreecommitdiffstats
path: root/src/djinterop/enginelibrary/performance_data_format.hpp
blob: e96fb71f05a3f29bbda3520a0e7acecb0f5bc524 (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
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
/*
    This file is part of libdjinterop.

    libdjinterop is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libdjinterop is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with libdjinterop.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <array>
#include <cstdint>
#include <vector>

#include <boost/optional.hpp>

#include <djinterop/performance_data.hpp>

namespace djinterop
{
enum class musical_key;

namespace enginelibrary
{
struct beat_data
{
    beat_data() noexcept = default;

    boost::optional<sampling_info> sampling;
    std::vector<beatgrid_marker> default_beatgrid;
    std::vector<beatgrid_marker> adjusted_beatgrid;

    std::vector<char> encode() const;
    static beat_data decode(const std::vector<char>& compressed_data);
};

struct high_res_waveform_data
{
    high_res_waveform_data() noexcept = default;

    double samples_per_entry;
    std::vector<waveform_entry> waveform;

    std::vector<char> encode() const;
    static high_res_waveform_data decode(
        const std::vector<char>& compressed_data);
};

struct loops_data
{
    loops_data() = default;

    std::array<boost::optional<loop>, 8> loops;  // Don't use curly braces here!

    std::vector<char> encode() const;
    static loops_data decode(
        const std::vector<char>& raw_data);  // not compressed
};

struct overview_waveform_data
{
    overview_waveform_data() noexcept = default;

    double samples_per_entry;
    std::vector<waveform_entry> waveform;

    std::vector<char> encode() const;
    static overview_waveform_data decode(
        const std::vector<char>& compressed_data);
};

struct quick_cues_data
{
    quick_cues_data() = default;

    std::array<boost::optional<hot_cue>, 8> hot_cues;
    double adjusted_main_cue = 0;
    double default_main_cue = 0;

    std::vector<char> encode() const;

    static quick_cues_data decode(const std::vector<char>& compressed_data);
};

struct track_data
{
    track_data() noexcept = default;

    boost::optional<sampling_info> sampling;
    boost::optional<double> average_loudness;  // range (0, 1]
    boost::optional<musical_key> key;

    std::vector<char> encode() const;

    static track_data decode(const std::vector<char>& compressed_data);
};

}  // namespace enginelibrary
}  // namespace djinterop