Skip to content

Commit

Permalink
Merge pull request musescore#18526 from RomanPudashkin/vst_compat_fix
Browse files Browse the repository at this point in the history
vst_compat_fix
  • Loading branch information
RomanPudashkin authored Jul 11, 2023
2 parents b82986e + 7fa0426 commit e46f075
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/iaudiosource.h
${CMAKE_CURRENT_LIST_DIR}/synthtypes.h
${CMAKE_CURRENT_LIST_DIR}/audiotypes.h
${CMAKE_CURRENT_LIST_DIR}/audioutils.h
${CMAKE_CURRENT_LIST_DIR}/iplayer.h
${CMAKE_CURRENT_LIST_DIR}/itracks.h
${CMAKE_CURRENT_LIST_DIR}/iaudiooutput.h
Expand Down
27 changes: 0 additions & 27 deletions src/framework/audio/audiotypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,6 @@ using AudioResourceMetaSet = std::set<AudioResourceMeta>;

static const AudioResourceId MUSE_REVERB_ID("Muse Reverb");

inline AudioResourceMeta makeReverbMeta()
{
AudioResourceMeta meta;
meta.id = MUSE_REVERB_ID;
meta.type = AudioResourceType::MusePlugin;
meta.vendor = "Muse";
meta.hasNativeEditorSupport = true;

return meta;
}

enum class AudioPluginType {
Undefined = -1,
Instrument,
Expand All @@ -186,22 +175,6 @@ struct AudioPluginInfo {
int errorCode = 0;
};

inline AudioPluginType audioPluginTypeFromCategoriesString(const String& categoriesStr)
{
static const std::map<String, AudioPluginType> STRING_TO_PLUGIN_TYPE_MAP = {
{ u"Fx", AudioPluginType::Fx },
{ u"Instrument", AudioPluginType::Instrument },
};

for (auto it = STRING_TO_PLUGIN_TYPE_MAP.cbegin(); it != STRING_TO_PLUGIN_TYPE_MAP.cend(); ++it) {
if (categoriesStr.contains(it->first)) {
return it->second;
}
}

return AudioPluginType::Undefined;
}

enum class AudioFxType {
Undefined = -1,
VstFx,
Expand Down
57 changes: 57 additions & 0 deletions src/framework/audio/audioutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef MU_AUDIO_AUDIOUTILS_H
#define MU_AUDIO_AUDIOUTILS_H

#include "audiotypes.h"

namespace mu::audio {
inline AudioResourceMeta makeReverbMeta()
{
AudioResourceMeta meta;
meta.id = MUSE_REVERB_ID;
meta.type = AudioResourceType::MusePlugin;
meta.vendor = "Muse";
meta.hasNativeEditorSupport = true;

return meta;
}

inline AudioPluginType audioPluginTypeFromCategoriesString(const String& categoriesStr)
{
static const std::vector<std::pair<String, AudioPluginType> > STRING_TO_PLUGIN_TYPE_LIST = {
{ u"Instrument", AudioPluginType::Instrument },
{ u"Fx", AudioPluginType::Fx },
};

for (auto it = STRING_TO_PLUGIN_TYPE_LIST.cbegin(); it != STRING_TO_PLUGIN_TYPE_LIST.cend(); ++it) {
if (categoriesStr.contains(it->first)) {
return it->second;
}
}

return AudioPluginType::Undefined;
}
}

#endif // MU_AUDIO_AUDIOUTILS_H
2 changes: 1 addition & 1 deletion src/framework/audio/internal/fx/musefxresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "reverb/reverbprocessor.h"

#include "log.h"
#include "audio/audioutils.h"

using namespace mu::audio;
using namespace mu::audio::fx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "knownaudiopluginsregister.h"

#include "audioutils.h"
#include "serialization/json.h"

#include "log.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QApplication>

#include "audioutils.h"
#include "audioerrors.h"
#include "translation.h"
#include "log.h"
Expand Down
1 change: 1 addition & 0 deletions src/framework/audio/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(MODULE_TEST_SRC

${CMAKE_CURRENT_LIST_DIR}/knownaudiopluginsregistertest.cpp
${CMAKE_CURRENT_LIST_DIR}/registeraudiopluginsscenariotest.cpp
${CMAKE_CURRENT_LIST_DIR}/audioutilstest.cpp
)

set(MODULE_TEST_LINK audio)
Expand Down
51 changes: 51 additions & 0 deletions src/framework/audio/tests/audioutilstest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <gtest/gtest.h>

#include "audio/audioutils.h"

using namespace mu::audio;

namespace mu::audio {
class Audio_AudioUtilsTest : public ::testing::Test
{
public:
};
}

TEST_F(Audio_AudioUtilsTest, AudioPluginTypeFromCategoriesString)
{
EXPECT_EQ(AudioPluginType::Fx, audioPluginTypeFromCategoriesString(u"Fx|Delay"));
EXPECT_EQ(AudioPluginType::Fx, audioPluginTypeFromCategoriesString(u"Test|Fx"));

EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Instrument|Test"));
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Test|Instrument"));

//! NOTE: "Instrument" has the highest priority for compatibility reasons
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Instrument|Fx|Test"));
EXPECT_EQ(AudioPluginType::Instrument, audioPluginTypeFromCategoriesString(u"Fx|Instrument|Test"));

EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"Test"));
EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"FX|Test"));
EXPECT_EQ(AudioPluginType::Undefined, audioPluginTypeFromCategoriesString(u"INSTRUMENT|Test"));
}
1 change: 1 addition & 0 deletions src/playback/internal/playbackcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "playbacktypes.h"

#include "audio/audioutils.h"
#include "containers.h"
#include "defer.h"
#include "log.h"
Expand Down

0 comments on commit e46f075

Please sign in to comment.