Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include <QTime>
26 :
27 : #include "global/containers.h"
28 :
29 : #include "audio/common/audiotypes.h"
30 : #include "engraving/types/types.h"
31 :
32 : namespace mu::playback {
33 : static constexpr muse::audio::aux_channel_idx_t AUX_CHANNEL_NUM = 2;
34 : static constexpr muse::audio::aux_channel_idx_t REVERB_CHANNEL_IDX = 0;
35 :
36 : enum class PlaybackCursorType {
37 : SMOOTH,
38 : STEPPED
39 : };
40 :
41 : enum class MixerSectionType {
42 : Unknown,
43 : Labels,
44 : Sound,
45 : AudioFX,
46 : Balance,
47 : Volume,
48 : Fader,
49 : MuteAndSolo,
50 : Title
51 : };
52 :
53 : static const std::map<MixerSectionType, std::string> MIXER_SECTION_TYPE_STR = {
54 : { MixerSectionType::Unknown, "unknown" },
55 : { MixerSectionType::Labels, "labels" },
56 : { MixerSectionType::Sound, "sound" },
57 : { MixerSectionType::AudioFX, "audio-fx" },
58 : { MixerSectionType::Balance, "balance" },
59 : { MixerSectionType::Volume, "volume" },
60 : { MixerSectionType::Fader, "fader" },
61 : { MixerSectionType::MuteAndSolo, "mute-and-solo" },
62 : { MixerSectionType::Title, "title" }
63 : };
64 :
65 0 : static inline std::string str_conv(MixerSectionType type)
66 : {
67 0 : return muse::value(MIXER_SECTION_TYPE_STR, type);
68 : }
69 :
70 0 : static inline MixerSectionType str_conv(const std::string& str, MixerSectionType def)
71 : {
72 0 : return muse::key(MIXER_SECTION_TYPE_STR, str, def);
73 : }
74 :
75 0 : inline QList<MixerSectionType> allMixerSectionTypes()
76 : {
77 : static const QList<MixerSectionType> sections {
78 : MixerSectionType::Labels,
79 : MixerSectionType::Sound,
80 : MixerSectionType::AudioFX,
81 : MixerSectionType::Balance,
82 : MixerSectionType::Volume,
83 : MixerSectionType::Fader,
84 : MixerSectionType::MuteAndSolo,
85 : MixerSectionType::Title
86 0 : };
87 :
88 0 : return sections;
89 : }
90 :
91 : static const QTime ZERO_TIME(0, 0, 0, 0);
92 :
93 0 : inline QTime timeFromSeconds(muse::audio::secs_t seconds)
94 : {
95 0 : return ZERO_TIME.addMSecs(muse::secs_to_msecs(seconds));
96 : }
97 :
98 0 : inline muse::audio::secs_t timeToSeconds(const QTime& time)
99 : {
100 0 : return muse::msecs_to_secs(ZERO_TIME.msecsTo(time));
101 : }
102 :
103 : enum class SoundProfileType {
104 : Undefined = -1,
105 : Basic,
106 : Muse,
107 : Custom
108 : };
109 :
110 : using SoundProfileName = muse::String;
111 : using SoundProfileData = std::map<muse::mpe::PlaybackSetupData, muse::audio::AudioResourceMeta>;
112 :
113 : struct SoundProfile {
114 : SoundProfileType type = SoundProfileType::Undefined;
115 : SoundProfileName name;
116 :
117 : SoundProfileData data;
118 :
119 0 : const muse::audio::AudioResourceMeta& findResource(const muse::mpe::PlaybackSetupData& key) const
120 : {
121 0 : auto search = data.find(key);
122 0 : if (search != data.cend()) {
123 0 : return search->second;
124 : }
125 :
126 0 : static muse::audio::AudioResourceMeta empty;
127 0 : return empty;
128 : }
129 :
130 0 : bool isEnabled() const
131 : {
132 0 : return !data.empty();
133 : }
134 :
135 0 : bool isValid() const
136 : {
137 0 : return type != SoundProfileType::Undefined
138 0 : && !name.isEmpty()
139 0 : && isEnabled();
140 : }
141 : };
142 :
143 : using SoundProfilesMap = std::map<SoundProfileName, SoundProfile>;
144 :
145 : enum OnlineSoundsShowProgressBarMode {
146 : Always = 0,
147 : DuringPlayback,
148 : Never,
149 : };
150 :
151 : using LoopBoundaryType = mu::engraving::LoopBoundaryType;
152 : }
|