summaryrefslogtreecommitdiffstats
path: root/include/djinterop/performance_data.hpp
blob: 620e6768d4d6e1ea665224acc751781b5c9d2168 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
    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
#ifndef DJINTEROP_PERFORMANCE_DATA_HPP
#define DJINTEROP_PERFORMANCE_DATA_HPP

#if __cplusplus < 201103L && _MSVC_LANG < 201103L
#error This library needs at least a C++11 compliant compiler
#endif

#include <cstdint>
#include <string>

#include <djinterop/pad_color.hpp>


namespace djinterop
{
struct sampling_info
{
    double sample_rate = 0;  // usually 44100.0 or 48000.0
    int64_t sample_count = 0;

    friend bool operator==(
        const sampling_info& first, const sampling_info& second) noexcept
    {
        return first.sample_rate == second.sample_rate &&
               first.sample_count == second.sample_count;
    }
};

struct beatgrid_marker
{
    int32_t index = 0;
    double sample_offset = 0;

    friend bool operator==(
        const beatgrid_marker& first, const beatgrid_marker& second) noexcept
    {
        return first.index == second.index &&
               first.sample_offset == second.sample_offset;
    }
};

struct hot_cue
{
    std::string label;
    double sample_offset = 0;
    pad_color color;

    friend bool operator==(const hot_cue& first, const hot_cue& second) noexcept
    {
        return first.label == second.label &&
               first.sample_offset == second.sample_offset &&
               first.color == second.color;
    }
};

struct loop
{
    std::string label;
    double start_sample_offset = 0;
    double end_sample_offset = 0;
    pad_color color;

    friend bool operator==(const loop& first, const loop& second) noexcept
    {
        return first.label == second.label &&
               first.start_sample_offset == second.start_sample_offset &&
               first.end_sample_offset == second.end_sample_offset &&
               first.color == second.color;
    }
};

struct waveform_point
{
    uint8_t value = 0;
    uint8_t opacity = 255;

    friend bool operator==(
        const waveform_point& first, const waveform_point& second) noexcept
    {
        return first.value == second.value && first.opacity == second.opacity;
    }
};

/**
 * A single high-resolution waveform entry
 *
 * Note that, when rendering the high-resolution waveform, each individual
 * band is scaled so that the largest value across the entire waveform hits the
 * top of the display.  Note also that the mid frequency is always drawn over
 * the low, and the high frequency is always drawn over the low and mid, meaning
 * that very loud high-frequency sounds will hide any low or mid activity on the
 * waveform rendering.
 *
 * A further note is that when the opacity is set to zero, this appears to
 * translate into roughly 50% opacity on a real rendering.
 */
struct waveform_entry
{
    waveform_point low;
    waveform_point mid;
    waveform_point high;

    friend bool operator==(
        const waveform_entry& first, const waveform_entry& second) noexcept
    {
        return first.low == second.low && first.mid == second.mid &&
               first.high == second.high;
    }
};

}  // namespace djinterop

#endif  // DJINTEROP_PERFORMANCE_DATA_HPP