Skip to content

Commit

Permalink
moved audio plugin code to audioplugin module
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor authored and igorkorsukov committed Aug 9, 2024
1 parent dc48bea commit c11d863
Show file tree
Hide file tree
Showing 55 changed files with 461 additions and 364 deletions.
5 changes: 4 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ set(LINK_LIB
muse::workspace
workspacescene
muse::audio
muse::audioplugins
muse::mpe
muse::midi
muse::learn
Expand All @@ -162,6 +161,10 @@ if (MUSE_MODULE_UI)
list(APPEND LINK_LIB muse::dockwindow)
endif()

if (MUSE_MODULE_AUDIOPLUGINS)
list(APPEND LINK_LIB muse::audioplugins)
endif()

if (MUE_BUILD_CONVERTER_MODULE)
list(APPEND LINK_LIB converter)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/app/internal/consoleapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "converter/iconvertercontroller.h"
#include "engraving/devtools/drawdata/idiagnosticdrawprovider.h"
#include "autobot/iautobot.h"
#include "audio/iregisteraudiopluginsscenario.h"
#include "audioplugins/iregisteraudiopluginsscenario.h"
#include "multiinstances/imultiinstancesprovider.h"

#include "ui/iuiconfiguration.h"
Expand All @@ -60,7 +60,7 @@ class ConsoleApp : public muse::BaseApplication, public std::enable_shared_from_
muse::Inject<converter::IConverterController> converter;
muse::Inject<engraving::IDiagnosticDrawProvider> diagnosticDrawProvider;
muse::Inject<muse::autobot::IAutobot> autobot;
muse::Inject<muse::audio::IRegisterAudioPluginsScenario> registerAudioPluginsScenario;
muse::Inject<muse::audioplugins::IRegisterAudioPluginsScenario> registerAudioPluginsScenario;
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider;
muse::Inject<muse::ui::IUiConfiguration> uiConfiguration;
muse::Inject<appshell::IAppShellConfiguration> appshellConfiguration;
Expand Down
18 changes: 1 addition & 17 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/iplayback.h
${CMAKE_CURRENT_LIST_DIR}/isoundfontrepository.h
${CMAKE_CURRENT_LIST_DIR}/isynthesizer.h
${CMAKE_CURRENT_LIST_DIR}/iknownaudiopluginsregister.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginsscanner.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginsscannerregister.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginmetareader.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginmetareaderregister.h
${CMAKE_CURRENT_LIST_DIR}/iregisteraudiopluginsscenario.h
${CMAKE_CURRENT_LIST_DIR}/devtools/inputlag.h

# Common internal
Expand All @@ -126,16 +120,6 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/abstractsynthesizer.h
${CMAKE_CURRENT_LIST_DIR}/internal/abstracteventsequencer.h

# Plugins
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/knownaudiopluginsregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/knownaudiopluginsregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/audiopluginsscannerregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/audiopluginsscannerregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/audiopluginmetareaderregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/audiopluginmetareaderregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/registeraudiopluginsscenario.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/plugins/registeraudiopluginsscenario.h

# Driver
${DRIVER_SRC}

Expand Down Expand Up @@ -337,5 +321,5 @@ set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml)
setup_module()

if (MUSE_MODULE_AUDIO_TESTS)
add_subdirectory(tests)
#add_subdirectory(tests) no tests
endif()
21 changes: 0 additions & 21 deletions src/framework/audio/audiomodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
#include "internal/audiothreadsecurer.h"
#include "internal/audiooutputdevicecontroller.h"

#include "internal/plugins/knownaudiopluginsregister.h"
#include "internal/plugins/audiopluginsscannerregister.h"
#include "internal/plugins/audiopluginmetareaderregister.h"
#include "internal/plugins/registeraudiopluginsscenario.h"

#include "internal/worker/audioengine.h"
#include "internal/worker/playback.h"

Expand Down Expand Up @@ -124,7 +119,6 @@ void AudioModule::registerExports()
m_synthResolver = std::make_shared<SynthResolver>();
m_playbackFacade = std::make_shared<Playback>(iocContext());
m_soundFontRepository = std::make_shared<SoundFontRepository>();
m_registerAudioPluginsScenario = std::make_shared<RegisterAudioPluginsScenario>();

#if defined(MUSE_MODULE_AUDIO_JACK)
m_audioDriver = std::shared_ptr<IAudioDriver>(new JackAudioDriver());
Expand Down Expand Up @@ -160,11 +154,6 @@ void AudioModule::registerExports()
ioc()->registerExport<IFxResolver>(moduleName(), m_fxResolver);

ioc()->registerExport<ISoundFontRepository>(moduleName(), m_soundFontRepository);

ioc()->registerExport<IKnownAudioPluginsRegister>(moduleName(), std::make_shared<KnownAudioPluginsRegister>());
ioc()->registerExport<IAudioPluginsScannerRegister>(moduleName(), std::make_shared<AudioPluginsScannerRegister>());
ioc()->registerExport<IAudioPluginMetaReaderRegister>(moduleName(), std::make_shared<AudioPluginMetaReaderRegister>());
ioc()->registerExport<IRegisterAudioPluginsScenario>(moduleName(), m_registerAudioPluginsScenario);
}

void AudioModule::registerResources()
Expand Down Expand Up @@ -216,7 +205,6 @@ void AudioModule::onInit(const IApplication::RunMode& mode)

// Init configuration
m_configuration->init();
m_registerAudioPluginsScenario->init();

if (mode == IApplication::RunMode::AudioPluginRegistration) {
return;
Expand All @@ -238,15 +226,6 @@ void AudioModule::onInit(const IApplication::RunMode& mode)
for (const io::path_t& p : paths) {
pr->reg("soundfonts", p);
}
pr->reg("known_audio_plugins", m_configuration->knownAudioPluginsFilePath());
}
}

void AudioModule::onDelayedInit()
{
Ret ret = m_registerAudioPluginsScenario->registerNewPlugins();
if (!ret) {
LOGE() << ret.toString();
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/framework/audio/audiomodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class AudioModule : public modularity::IModuleSetup, public async::Asyncable
void registerUiTypes() override;
void resolveImports() override;
void onInit(const IApplication::RunMode& mode) override;
void onDelayedInit() override;
void onDeinit() override;
void onDestroy() override;

Expand All @@ -80,9 +79,6 @@ class AudioModule : public modularity::IModuleSetup, public async::Asyncable

std::shared_ptr<SoundFontRepository> m_soundFontRepository;

std::shared_ptr<KnownAudioPluginsRegister> m_knownAudioPluginsRegister;
std::shared_ptr<RegisterAudioPluginsScenario> m_registerAudioPluginsScenario;

std::shared_ptr<IAudioDriver> m_audioDriver;
};
}
Expand Down
14 changes: 0 additions & 14 deletions src/framework/audio/audiotypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,6 @@ using AudioResourceMetaSet = std::set<AudioResourceMeta>;

static const AudioResourceId MUSE_REVERB_ID("Muse Reverb");

enum class AudioPluginType {
Undefined = -1,
Instrument,
Fx,
};

struct AudioPluginInfo {
AudioPluginType type = AudioPluginType::Undefined;
AudioResourceMeta meta;
io::path_t path;
bool enabled = false;
int errorCode = 0;
};

enum class AudioFxType {
Undefined = -1,
VstFx,
Expand Down
16 changes: 0 additions & 16 deletions src/framework/audio/audioutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ inline AudioResourceMeta makeReverbMeta()
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;
}

inline String audioSourceName(const AudioInputParams& params)
{
if (params.type() == AudioSourceType::MuseSampler) {
Expand Down
2 changes: 0 additions & 2 deletions src/framework/audio/iaudioconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class IAudioConfiguration : MODULE_EXPORT_INTERFACE
virtual void setUserSoundFontDirectories(const io::paths_t& paths) = 0;
virtual async::Channel<io::paths_t> soundFontDirectoriesChanged() const = 0;

virtual io::path_t knownAudioPluginsFilePath() const = 0;

virtual bool shouldMeasureInputLag() const = 0;
};
}
Expand Down
5 changes: 0 additions & 5 deletions src/framework/audio/internal/audioconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ async::Channel<io::paths_t> AudioConfiguration::soundFontDirectoriesChanged() co
return m_soundFontDirsChanged;
}

io::path_t AudioConfiguration::knownAudioPluginsFilePath() const
{
return globalConfiguration()->userAppDataPath() + "/known_audio_plugins.json";
}

bool AudioConfiguration::shouldMeasureInputLag() const
{
return settings()->value(AUDIO_MEASURE_INPUT_LAG).toBool();
Expand Down
2 changes: 0 additions & 2 deletions src/framework/audio/internal/audioconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class AudioConfiguration : public IAudioConfiguration
void setUserSoundFontDirectories(const io::paths_t& paths) override;
async::Channel<io::paths_t> soundFontDirectoriesChanged() const override;

io::path_t knownAudioPluginsFilePath() const override;

bool shouldMeasureInputLag() const override;

private:
Expand Down
74 changes: 0 additions & 74 deletions src/framework/audio/tests/mocks/audioconfigurationmock.h

This file was deleted.

23 changes: 22 additions & 1 deletion src/framework/audioplugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,31 @@ set(MODULE_SRC

${CMAKE_CURRENT_LIST_DIR}/audiopluginsmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/audiopluginsmodule.h
${CMAKE_CURRENT_LIST_DIR}/audiopluginstypes.h
${CMAKE_CURRENT_LIST_DIR}/audiopluginserrors.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginsconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/iknownaudiopluginsregister.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginsscanner.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginsscannerregister.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginmetareader.h
${CMAKE_CURRENT_LIST_DIR}/iaudiopluginmetareaderregister.h
${CMAKE_CURRENT_LIST_DIR}/iregisteraudiopluginsscenario.h

${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginsutils.h
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginsconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginsconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/knownaudiopluginsregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/knownaudiopluginsregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginsscannerregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginsscannerregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginmetareaderregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/audiopluginmetareaderregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/registeraudiopluginsscenario.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/registeraudiopluginsscenario.h
)

setup_module()

if (MUSE_MODULE_AUDIOPLUGINS_TESTS)
#add_subdirectory(tests)
add_subdirectory(tests)
endif()
39 changes: 39 additions & 0 deletions src/framework/audioplugins/audiopluginserrors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 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/>.
*/
#pragma once

#include "global/types/ret.h"

namespace muse::audioplugins {
enum class Err {
Undefined = int(Ret::Code::Undefined),
NoError = int(Ret::Code::Ok),
UnknownError = int(Ret::Code::AudioFirst),

UnknownPluginType = 351,
};

inline Ret make_ret(Err e)
{
return Ret(static_cast<int>(e));
}
}
Loading

0 comments on commit c11d863

Please sign in to comment.