Skip to content

Commit 9b84698

Browse files
Merge pull request #18527 from RomanPudashkin/vst_compat_fix_410
vst_compat_fix_410
2 parents 1889893 + eb9ede0 commit 9b84698

File tree

9 files changed

+114
-28
lines changed

9 files changed

+114
-28
lines changed

src/framework/audio/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ set(MODULE_SRC
8585
${CMAKE_CURRENT_LIST_DIR}/iaudiosource.h
8686
${CMAKE_CURRENT_LIST_DIR}/synthtypes.h
8787
${CMAKE_CURRENT_LIST_DIR}/audiotypes.h
88+
${CMAKE_CURRENT_LIST_DIR}/audioutils.h
8889
${CMAKE_CURRENT_LIST_DIR}/iplayer.h
8990
${CMAKE_CURRENT_LIST_DIR}/itracks.h
9091
${CMAKE_CURRENT_LIST_DIR}/iaudiooutput.h

src/framework/audio/audiotypes.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,6 @@ using AudioResourceMetaSet = std::set<AudioResourceMeta>;
161161

162162
static const AudioResourceId MUSE_REVERB_ID("Muse Reverb");
163163

164-
inline AudioResourceMeta makeReverbMeta()
165-
{
166-
AudioResourceMeta meta;
167-
meta.id = MUSE_REVERB_ID;
168-
meta.type = AudioResourceType::MusePlugin;
169-
meta.vendor = "Muse";
170-
meta.hasNativeEditorSupport = true;
171-
172-
return meta;
173-
}
174-
175164
enum class AudioPluginType {
176165
Undefined = -1,
177166
Instrument,
@@ -186,22 +175,6 @@ struct AudioPluginInfo {
186175
int errorCode = 0;
187176
};
188177

189-
inline AudioPluginType audioPluginTypeFromCategoriesString(const String& categoriesStr)
190-
{
191-
static const std::map<String, AudioPluginType> STRING_TO_PLUGIN_TYPE_MAP = {
192-
{ u"Fx", AudioPluginType::Fx },
193-
{ u"Instrument", AudioPluginType::Instrument },
194-
};
195-
196-
for (auto it = STRING_TO_PLUGIN_TYPE_MAP.cbegin(); it != STRING_TO_PLUGIN_TYPE_MAP.cend(); ++it) {
197-
if (categoriesStr.contains(it->first)) {
198-
return it->second;
199-
}
200-
}
201-
202-
return AudioPluginType::Undefined;
203-
}
204-
205178
enum class AudioFxType {
206179
Undefined = -1,
207180
VstFx,

src/framework/audio/audioutils.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA 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+
#ifndef MU_AUDIO_AUDIOUTILS_H
24+
#define MU_AUDIO_AUDIOUTILS_H
25+
26+
#include "audiotypes.h"
27+
28+
namespace mu::audio {
29+
inline AudioResourceMeta makeReverbMeta()
30+
{
31+
AudioResourceMeta meta;
32+
meta.id = MUSE_REVERB_ID;
33+
meta.type = AudioResourceType::MusePlugin;
34+
meta.vendor = "Muse";
35+
meta.hasNativeEditorSupport = true;
36+
37+
return meta;
38+
}
39+
40+
inline AudioPluginType audioPluginTypeFromCategoriesString(const String& categoriesStr)
41+
{
42+
static const std::vector<std::pair<String, AudioPluginType> > STRING_TO_PLUGIN_TYPE_LIST = {
43+
{ u"Instrument", AudioPluginType::Instrument },
44+
{ u"Fx", AudioPluginType::Fx },
45+
};
46+
47+
for (auto it = STRING_TO_PLUGIN_TYPE_LIST.cbegin(); it != STRING_TO_PLUGIN_TYPE_LIST.cend(); ++it) {
48+
if (categoriesStr.contains(it->first)) {
49+
return it->second;
50+
}
51+
}
52+
53+
return AudioPluginType::Undefined;
54+
}
55+
}
56+
57+
#endif // MU_AUDIO_AUDIOUTILS_H

src/framework/audio/internal/fx/musefxresolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "reverb/reverbprocessor.h"
2626

27-
#include "log.h"
27+
#include "audio/audioutils.h"
2828

2929
using namespace mu::audio;
3030
using namespace mu::audio::fx;

src/framework/audio/internal/plugins/knownaudiopluginsregister.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "knownaudiopluginsregister.h"
2424

25+
#include "audioutils.h"
2526
#include "serialization/json.h"
2627

2728
#include "log.h"

src/framework/audio/internal/plugins/registeraudiopluginsscenario.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <QApplication>
2626

27+
#include "audioutils.h"
2728
#include "audioerrors.h"
2829
#include "translation.h"
2930
#include "log.h"

src/framework/audio/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set(MODULE_TEST_SRC
3232

3333
${CMAKE_CURRENT_LIST_DIR}/knownaudiopluginsregistertest.cpp
3434
${CMAKE_CURRENT_LIST_DIR}/registeraudiopluginsscenariotest.cpp
35+
${CMAKE_CURRENT_LIST_DIR}/audioutilstest.cpp
3536
)
3637

3738
set(MODULE_TEST_LINK audio)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA 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+
#include <gtest/gtest.h>
24+
25+
#include "audio/audioutils.h"
26+
27+
using namespace mu::audio;
28+
29+
namespace mu::audio {
30+
class Audio_AudioUtilsTest : public ::testing::Test
31+
{
32+
public:
33+
};
34+
}
35+
36+
TEST_F(Audio_AudioUtilsTest, AudioPluginTypeFromCategoriesString)
37+
{
38+
EXPECT_EQ(AudioPluginType::Fx, audioPluginTypeFromCategoriesString(u"Fx|Delay"));
39+
EXPECT_EQ(AudioPluginType::Fx, audioPluginTypeFromCategoriesString(u"Test|Fx"));
40+
41+
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Instrument|Test"));
42+
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Test|Instrument"));
43+
44+
//! NOTE: "Instrument" has the highest priority for compatibility reasons
45+
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Instrument|Fx|Test"));
46+
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Fx|Instrument|Test"));
47+
48+
EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"Test"));
49+
EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"FX|Test"));
50+
EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"INSTRUMENT|Test"));
51+
}

src/playback/internal/playbackcontroller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "playbacktypes.h"
2525

26+
#include "audio/audioutils.h"
2627
#include "containers.h"
2728
#include "defer.h"
2829
#include "log.h"

0 commit comments

Comments
 (0)