Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
declare_module(muse_audio)
set(MODULE_ALIAS muse::audio)

set(MODULE_QRC main/audio.qrc)

set(MODULE_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml)

include(GetPlatformInfo)

set(MODULE_LINK )
Expand Down Expand Up @@ -100,13 +105,21 @@ set(MODULE_SRC
${DRIVER_SRC}
)

set(MODULE_QRC main/audio.qrc)
set(MODULE_INCLUDE ${MODULE_INCLUDE}
${AUDIO_DRIVER_INC}
)

set(MODULE_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml)
set(MODULE_LINK ${MODULE_LINK}
${AUDIO_DRIVER_LINK}
)

setup_module()

if (MUSE_MODULE_AUDIO_ASIO)
# see driver\platform\win\asio\asiosdk\CMakeLists.txt
add_definitions(-DUNICODE)
endif()

if (MUSE_MODULE_AUDIO_TESTS)
add_subdirectory(tests)
endif()
33 changes: 33 additions & 0 deletions src/framework/audio/driver/audio_driver.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
include(GetPlatformInfo)

if (OS_IS_WIN)

set(AUDIO_DRIVER_SRC
#${CMAKE_CURRENT_LIST_DIR}/platform/win/winmmdriver.cpp
#${CMAKE_CURRENT_LIST_DIR}/platform/win/winmmdriver.h
Expand All @@ -36,6 +37,38 @@ if (OS_IS_WIN)
${CMAKE_CURRENT_LIST_DIR}/platform/win/wasapiaudiodriver2.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/win/wasapiaudiodriver2.h
)

if (MUSE_MODULE_AUDIO_ASIO)

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/platform/win/asio/asiosdk)

set(AUDIO_ASIODRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/platform/win/asio/asiodiscovery.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/win/asio/asiodiscovery.h
)

set_source_files_properties(
${AUDIO_ASIODRIVER_SRC}
PROPERTIES
SKIP_UNITY_BUILD_INCLUSION ON
SKIP_PRECOMPILE_HEADERS ON
)

set(AUDIO_DRIVER_SRC
${AUDIO_DRIVER_SRC}
${AUDIO_ASIODRIVER_SRC}
)

set(AUDIO_DRIVER_INC
${ASIO_SDK_SRC}
)

set(AUDIO_DRIVER_LINK
asiosdk
)

endif()

elseif(OS_IS_LIN OR OS_IS_FBSD)
set(AUDIO_DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/platform/lin/alsaaudiodriver.cpp
Expand Down
65 changes: 65 additions & 0 deletions src/framework/audio/driver/platform/win/asio/asiodiscovery.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2025 MuseScore Limited 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 "asiodiscovery.h"

#include "ASIOSDK/host/asiodrivers.h"

#include "log.h"

using namespace muse::audio;

AsioDiscovery::AsioDiscovery()
{
}

std::vector<std::string> AsioDiscovery::driverNameList() const
{
char names[16][32];
char* pointers[16];

for (int i = 0; i < 16; i++) {
pointers[i] = names[i];
}

AsioDrivers asio;
long count = asio.getDriverNames(pointers, 16);

std::vector<std::string> result;
result.reserve(count);
for (long i = 0; i < count; i++) {
result.push_back(names[i]);
}

return result;
}

void AsioDiscovery::dump()
{
std::vector<std::string> names = driverNameList();

std::string dump = "ASIO Drivers: \n";
for (size_t i = 0; i < names.size(); ++i) {
dump += std::to_string(i) + " " + names.at(i) + "\n";
}

LOGI() << dump;
}
37 changes: 37 additions & 0 deletions src/framework/audio/driver/platform/win/asio/asiodiscovery.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2025 MuseScore Limited 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 <string>
#include <vector>

namespace muse::audio {
class AsioDiscovery
{
public:
AsioDiscovery();

std::vector<std::string> driverNameList() const;

void dump();
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

declare_thirdparty_module(asiosdk)

if(MUSE_MODULE_AUDIO_ASIO_SDK_PATH)
set(ASIO_SDK_PATH ${MUSE_MODULE_AUDIO_ASIO_SDK_PATH})
else()

# If not set MUSE_MODULE_AUDIO_ASIO_SDK_PATH
# download asiosdk source

set(REMOTE_ROOT_URL https://raw.githubusercontent.com/musescore/muse_deps/main)
set(remote_url "${REMOTE_ROOT_URL}/asiosdk/ASIO-SDK_2.3.4_2025-10-15")
set(local_path ${PROJECT_BINARY_DIR}/_deps/asiosdk)
if (NOT EXISTS ${local_path}/asiosdk.cmake)
file(MAKE_DIRECTORY ${local_path})
file(DOWNLOAD ${remote_url}/asiosdk.cmake ${local_path}/asiosdk.cmake
HTTPHEADER "Cache-Control: no-cache"
)
endif()

include(${local_path}/asiosdk.cmake)

# func from ${name}.cmake)
cmake_language(CALL asiosdk_Populate ${remote_url} ${local_path} "source" "" "")

set(ASIO_SDK_PATH ${local_path})
message(STATUS "ASIO_SDK_PATH: ${ASIO_SDK_PATH}")

endif()

set(ASIO_SDK_SRC
${ASIO_SDK_PATH}/ASIOSDK/common/asio.cpp
${ASIO_SDK_PATH}/ASIOSDK/common/asio.h
${ASIO_SDK_PATH}/ASIOSDK/host/asiodrivers.cpp
${ASIO_SDK_PATH}/ASIOSDK/host/asiodrivers.h
${ASIO_SDK_PATH}/ASIOSDK/host/pc/asiolist.cpp
${ASIO_SDK_PATH}/ASIOSDK/host/pc/asiolist.h
)

set(MODULE_SRC
${ASIO_SDK_SRC}
)

set(MODULE_INCLUDE
${ASIO_SDK_PATH}
${ASIO_SDK_PATH}/ASIOSDK/common
${ASIO_SDK_PATH}/ASIOSDK/host
${ASIO_SDK_PATH}/ASIOSDK/host/pc
)

set(MODULE_USE_UNITY OFF)

# ASIO SDK is written without UNICODE support (it uses variables like char*).
# Define UNICODE is returned at the end of adding the audio module.
remove_definitions(-DUNICODE)

setup_module()

10 changes: 10 additions & 0 deletions src/framework/audio/main/audiomodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@

#include "diagnostics/idiagnosticspathsregister.h"

#include "muse_framework_config.h"
#ifdef MUSE_MODULE_AUDIO_ASIO
#include "audio/driver/platform/win/asio/asiodiscovery.h"
#endif

#include "log.h"

using namespace muse;
Expand Down Expand Up @@ -150,6 +155,11 @@ void AudioModule::onInit(const IApplication::RunMode& mode)
pr->reg("soundfonts", p);
}
}

#ifdef MUSE_MODULE_AUDIO_ASIO
AsioDiscovery d;
d.dump();
#endif
}

void AudioModule::onDeinit()
Expand Down
2 changes: 2 additions & 0 deletions src/framework/cmake/MuseDeclareOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ declare_muse_module_opt(ACCESSIBILITY ON)
option(MUSE_MODULE_ACCESSIBILITY_TRACE "Enable accessibility logging" OFF)

declare_muse_module_opt(ACTIONS ON)

declare_muse_module_opt(AUDIO ON)
option(MUSE_MODULE_AUDIO_JACK "Enable jack support" OFF)
option(MUSE_MODULE_AUDIO_ASIO "Enable asio support" OFF)
option(MUSE_MODULE_AUDIO_EXPORT "Enable audio export" ON)

# 1 - worker
Expand Down
1 change: 1 addition & 0 deletions src/framework/cmake/muse_framework_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#cmakedefine MUSE_MODULE_AUDIO_TESTS 1
#cmakedefine MUSE_MODULE_AUDIO_API 1
#cmakedefine MUSE_MODULE_AUDIO_JACK 1
#cmakedefine MUSE_MODULE_AUDIO_ASIO 1
#cmakedefine MUSE_MODULE_AUDIO_EXPORT 1

#define MUSE_MODULE_AUDIO_WORKER_MODE 1
Expand Down
Loading