Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jack-midi support #19246

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cac893c
cleanup namespace playbackcontroller
lyrra Apr 21, 2024
6db155c
fix hardcoded samplerate
lyrra Mar 29, 2024
f24348f
cosmetic variable rename to avoid 'bufferSize'
lyrra Mar 29, 2024
6f0b59e
macos cleanup
lyrra Apr 5, 2024
6d6b861
playbackcontroller remoteSeek/remotePlayOrStop
lyrra Mar 31, 2024
4824f62
mingw dynamic-library
lyrra Apr 3, 2024
50ca690
jack: enable jack (not mingw)
lyrra Mar 7, 2024
936a6a0
audiodrivers cleanup, prepare for jack/alsa
lyrra Mar 30, 2024
b4ba1c4
separate alsa-driver
lyrra Mar 30, 2024
5e5ad73
alsadriver: rename to AlsaDriverState
lyrra Sep 1, 2023
43eb0ac
rearrange linuxaudiodriver with alsa/jack
lyrra Sep 1, 2023
f634d9d
enable linuxaudiodriver runs jack+alsa
lyrra Mar 30, 2024
835156b
enable jack-audio for win too
lyrra Mar 30, 2024
2d63588
jack midi for linux
lyrra Sep 10, 2023
b8a52ee
jack-midi: jack/alsa subdrivers
lyrra Apr 7, 2024
86fae41
jack-midi: midiportstate (separate subdrivers)
lyrra Sep 30, 2023
b519785
WIP: queue midi events towards jackaudiodriver
lyrra Oct 8, 2023
3a39d62
route midi-in-devices from midi-inport to jack-audio
lyrra Oct 24, 2023
ef16f14
register jack midi inport
lyrra Nov 18, 2023
d123134
let audiomodule know about midimodule
lyrra Nov 18, 2023
3b1b4d4
GUI filter musescore-ingress midiport
lyrra Dec 9, 2023
372a357
alsa: report errors + better alsa names
lyrra Mar 7, 2024
0a6d65a
jack: use playbackcontroller remoteSeek/remotePlayOrStop
lyrra Mar 31, 2024
4c5a5cd
cli audioDelayCompensate in frames
lyrra Mar 31, 2024
c27a329
jack-transport: slow-sync client
lyrra Mar 31, 2024
98f2f46
samplerate dropdown
lyrra Mar 29, 2024
9550469
jack: thread usage cleanup
lyrra Apr 11, 2024
bc9d862
(maybe-squash) bugfix linuxdriver open
lyrra Apr 11, 2024
f5a9b2b
TEMP jack logging turnoff
lyrra Apr 11, 2024
668ac42
move complexity from jackdriver to audiomidimanage
lyrra Apr 16, 2024
e343693
LinuxAudioDriver -> AudioMidiManager
lyrra Apr 2, 2024
6082e61
cleanup private member naming
lyrra Apr 27, 2024
8924974
GUI jack-transport enable checkbox
lyrra May 1, 2024
5b5d1fa
(squash) audiomidipreferencesmodel
lyrra Aug 31, 2024
a1e7fcc
(squash) rebase
lyrra Sep 1, 2024
34da2fc
(squash) compile errors
lyrra Sep 1, 2024
a47e555
(squash) api fixes
lyrra Sep 1, 2024
caff8e9
playbackStatus not ONLY_AUDIO_MAIN_THREAD
lyrra Sep 1, 2024
763e8d8
(sqash) code-style
lyrra Sep 1, 2024
1ae4b90
(squash) rebase cleanups
lyrra Sep 1, 2024
00062b4
bugfix: millisecs and secs conflation
lyrra Oct 3, 2024
ad36c85
(squash) wrong membername
lyrra Oct 20, 2024
efd6860
mac-jack: cmake
lyrra Oct 21, 2024
27be4c1
mac-jack: CI install jack
lyrra Oct 21, 2024
3b96d14
(squash) fix compile errors on mac
lyrra Oct 26, 2024
0d5b540
mac-jack: cmake
lyrra Oct 26, 2024
23f4316
fix compiler errors and warnings
lyrra Oct 26, 2024
90b302d
welcome to c++
lyrra Oct 26, 2024
20768ac
audiomidimanager needs audiodeviceslistener
lyrra Oct 26, 2024
759842c
try to download and install jack universal library
lyrra Oct 26, 2024
ba51b17
run installer for jack as root
lyrra Oct 26, 2024
d04f628
(squash) cleanup src/framework/audio/CMakeLists.txt
lyrra Oct 30, 2024
2d8f86b
audiomidimanager osx stubs
lyrra Oct 30, 2024
aeb9ee0
remove midi
lyrra Nov 1, 2024
242a767
(squash) rebase fix
lyrra Feb 10, 2025
66e210f
(squash) audio stub fixes
lyrra Feb 10, 2025
8df6c22
cleanup audiomidimanager
lyrra Feb 12, 2025
be8770a
squash? typo
lyrra Feb 12, 2025
b452954
(squash) move audioConfig from console to gui
lyrra Feb 12, 2025
77ee666
osx no audiodevicelistener
lyrra Feb 12, 2025
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
6 changes: 3 additions & 3 deletions SetupConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ endif()
set(QT_SUPPORT ON)

if (MUSE_MODULE_AUDIO_JACK)
if (OS_IS_LIN OR MINGW)
add_compile_definitions(JACK_AUDIO)
else()
if (OS_IS_WIN AND (NOT MINGW))
set(MUSE_MODULE_AUDIO_JACK OFF)
else()
add_compile_definitions(JACK_AUDIO)
endif()
endif()

Expand Down
5 changes: 5 additions & 0 deletions buildscripts/ci/macos/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export MACOSX_DEPLOYMENT_TARGET=10.14
echo "Install build tools"
brew install cmake ninja --formula --quiet

wget -q https://github.com/jackaudio/jack2-releases/releases/download/v1.9.22/jack2-macOS-universal-v1.9.22.tar.gz
tar xvf jack2-macOS-universal-v1.9.22.tar.gz
ls -ltr
sudo installer -pkg ./jack2-osx-1.9.22.pkg -target /

# Download dependencies
echo "Download dependencies"

Expand Down
4 changes: 4 additions & 0 deletions src/app/cmdoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ struct CmdOptions {
std::optional<float> pngDpiResolution;
} exportImage;

struct {
std::optional<int> audioDelayCompensate;
} audio;

struct {
std::optional<int> mp3Bitrate;
} exportAudio;
Expand Down
6 changes: 6 additions & 0 deletions src/app/internal/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void CommandLineParser::init()
"Check an audio plugin for compatibility with the application and register it", "path"));
m_parser.addOption(QCommandLineOption("register-failed-audio-plugin", "Register an incompatible audio plugin", "path"));

m_parser.addOption(QCommandLineOption("audioDelayCompensate", "Compensate for delay in frames caused by MuseScore buffering", "1024"));

// Internal
m_parser.addOption(internalCommandLineOption("score-display-name-override",
"Display name to be shown in splash screen for the score that is being opened", "name"));
Expand Down Expand Up @@ -275,6 +277,10 @@ void CommandLineParser::parse(int argc, char** argv)
m_options.audioPluginRegistration.failCode = !args1.empty() ? args1[0].toInt() : -1;
}

if (m_parser.isSet("audioDelayCompensate")) {
m_options.audio.audioDelayCompensate = intValue("audioDelayCompensate");
}

// Converter mode
if (m_parser.isSet("r")) {
std::optional<float> val = floatValue("r");
Expand Down
2 changes: 2 additions & 0 deletions src/app/internal/guiapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,6 @@ void GuiApp::applyCommandLineOptions(const CmdOptions& options)
if (options.app.loggerLevel) {
m_globalModule.setLoggerLevel(options.app.loggerLevel.value());
}

audioConfiguration()->setAudioDelayCompensate(options.audio.audioDelayCompensate.value_or(1024)); // FIX: equal to buffer-size
}
2 changes: 2 additions & 0 deletions src/app/internal/guiapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "appshell/iappshellconfiguration.h"
#include "appshell/internal/istartupscenario.h"
#include "importexport/guitarpro/iguitarproconfiguration.h"
#include "audio/iaudioconfiguration.h"

namespace mu::app {
class GuiApp : public muse::BaseApplication, public std::enable_shared_from_this<GuiApp>
Expand All @@ -25,6 +26,7 @@ class GuiApp : public muse::BaseApplication, public std::enable_shared_from_this
muse::Inject<appshell::IAppShellConfiguration> appshellConfiguration;
muse::Inject<appshell::IStartupScenario> startupScenario;
muse::Inject<iex::guitarpro::IGuitarProConfiguration> guitarProConfiguration;
muse::Inject<muse::audio::IAudioConfiguration> audioConfiguration;

public:
GuiApp(const CmdOptions& options, const muse::modularity::ContextPtr& ctx);
Expand Down
1 change: 1 addition & 0 deletions src/appshell/appshell.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<file>qml/Preferences/internal/MeiSection.qml</file>
<file>qml/Preferences/internal/PublishMuseScoreComSection.qml</file>
<file>qml/Preferences/internal/MixerSection.qml</file>
<file>qml/Preferences/internal/JackSection.qml</file>
<file>qml/DevTools/Extensions/ExtensionsListView.qml</file>
<file>qml/platform/PlatformMenuBar.qml</file>
<file>qml/Preferences/PercussionPreferencesPage.qml</file>
Expand Down
13 changes: 13 additions & 0 deletions src/appshell/qml/Preferences/AudioMidiPreferencesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ PreferencesPage {

SeparatorLine {}

JackSection {
jackTransportEnable: audioMidiModel.jackTransportEnable

navigation.section: root.navigationSection
navigation.order: root.navigationOrderStart + 3

onJackTransportEnableChangeRequested: function(enable) {
audioMidiModel.jackTransportEnable = enable
}
}

SeparatorLine {}

MixerSection {
muteHiddenInstruments: audioMidiModel.muteHiddenInstruments

Expand Down
50 changes: 50 additions & 0 deletions src/appshell/qml/Preferences/internal/JackSection.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) MuseScore Limited
*
* 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/>.
*/
import QtQuick 2.15

import Muse.Ui 1.0
import Muse.UiComponents 1.0

BaseSection {
id: root

title: qsTrc("appshell/preferences", "Jack")

property alias jackTransportEnable: jackTransportEnableCheckBox.checked

signal jackTransportEnableChangeRequested(bool enable)

CheckBox {
id: jackTransportEnableCheckBox

width: parent.width

text: qsTrc("appshell/preferences", "Enable Jack Transport")

navigation.name: "JackTransportEnableCheckbox"
navigation.panel: root.navigation

onClicked: {
root.jackTransportEnableChangeRequested(!checked)
}
}
}
18 changes: 18 additions & 0 deletions src/appshell/view/preferences/audiomidipreferencesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ void AudioMidiPreferencesModel::init()
playbackConfiguration()->muteHiddenInstrumentsChanged().onReceive(this, [this](bool mute) {
emit muteHiddenInstrumentsChanged(mute);
});

playbackConfiguration()->jackTransportEnableChanged().onReceive(this, [this](bool mute) {
emit jackTransportEnableChanged(mute);
});
}

QStringList AudioMidiPreferencesModel::audioApiList() const
Expand Down Expand Up @@ -188,3 +192,17 @@ void AudioMidiPreferencesModel::setMuteHiddenInstruments(bool mute)

playbackConfiguration()->setMuteHiddenInstruments(mute);
}

bool AudioMidiPreferencesModel::jackTransportEnable() const
{
return playbackConfiguration()->jackTransportEnable();
}

void AudioMidiPreferencesModel::setJackTransportEnable(bool enable)
{
if (enable == jackTransportEnable()) {
return;
}

playbackConfiguration()->setJackTransportEnable(enable);
}
8 changes: 8 additions & 0 deletions src/appshell/view/preferences/audiomidipreferencesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class AudioMidiPreferencesModel : public QObject, public muse::Injectable, publi

Q_PROPERTY(bool muteHiddenInstruments READ muteHiddenInstruments WRITE setMuteHiddenInstruments NOTIFY muteHiddenInstrumentsChanged)

Q_PROPERTY(bool jackTransportEnable READ jackTransportEnable WRITE setJackTransportEnable NOTIFY jackTransportEnableChanged)

muse::Inject<muse::audio::IAudioConfiguration> audioConfiguration = { this };
muse::Inject<muse::midi::IMidiConfiguration> midiConfiguration = { this };
muse::Inject<muse::midi::IMidiOutPort> midiOutPort = { this };
Expand Down Expand Up @@ -81,13 +83,17 @@ class AudioMidiPreferencesModel : public QObject, public muse::Injectable, publi

bool muteHiddenInstruments() const;

bool jackTransportEnable() const;

public slots:
void setCurrentAudioApiIndex(int index);

void setUseMIDI20Output(bool use);

void setMuteHiddenInstruments(bool mute);

void setJackTransportEnable(bool enable);

signals:
void currentAudioApiIndexChanged(int index);
void midiInputDeviceIdChanged();
Expand All @@ -100,6 +106,8 @@ public slots:

void muteHiddenInstrumentsChanged(bool mute);

void jackTransportEnableChanged(bool enable);

private:
muse::midi::MidiDeviceID midiInputDeviceId(int index) const;
muse::midi::MidiDeviceID midiOutputDeviceId(int index) const;
Expand Down
72 changes: 37 additions & 35 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ set(MODULE_ALIAS muse::audio)

include(GetPlatformInfo)

if (OS_IS_WIN)
set(JACK_SRC "")
if (MUSE_MODULE_AUDIO_JACK)
set(JACK_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.h
)
endif(MUSE_MODULE_AUDIO_JACK)

if (OS_IS_WIN AND (NOT MINGW))
set(DRIVER_SRC
#${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/winmmdriver.cpp
#${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/winmmdriver.h
Expand All @@ -37,28 +45,23 @@ if (OS_IS_WIN)
${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/audiodeviceslistener.h
)
elseif(OS_IS_LIN OR OS_IS_FBSD)
if (MUSE_MODULE_AUDIO_JACK)
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/audiodeviceslistener.h
)
else()
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.h
)
endif()
elseif(OS_IS_LIN OR OS_IS_FBSD OR MINGW)
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/audiomidimanager.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/audiomidimanager.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/alsa/alsaaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/alsa/alsaaudiodriver.h
${JACK_SRC}
)
elseif(OS_IS_MAC)
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/audiomidimanager.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/audiomidimanager.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/osx/osxaudiodriver.mm
${CMAKE_CURRENT_LIST_DIR}/internal/platform/osx/osxaudiodriver.h
${JACK_SRC}
)

set_source_files_properties(
Expand Down Expand Up @@ -277,23 +280,22 @@ endif()

if (MUSE_MODULE_AUDIO_JACK)
find_package(Jack REQUIRED)
set(MODULE_INCLUDE_PRIVATE ${MODULE_INCLUDE_PRIVATE} ${JACK_INCLUDE_DIRS} )
set(MODULE_LINK ${MODULE_LINK} ${JACK_LIBRARIES} pthread )
set(MODULE_INCLUDE_PRIVATE ${MODULE_INCLUDE_PRIVATE} ${JACK_INCLUDE_DIRS})
set(MODULE_LINK ${MODULE_LINK} ${JACK_LDFLAGS} pthread)
endif()

if (OS_IS_MAC)
find_library(AudioToolbox NAMES AudioToolbox)
find_library(CoreAudio NAMES CoreAudio)
set(MODULE_LINK ${MODULE_LINK} ${AudioToolbox} ${CoreAudio})
elseif (OS_IS_WIN AND (NOT (MINGW)))
set(MODULE_LINK ${MODULE_LINK} winmm mmdevapi mfplat)
elseif (OS_IS_LIN)
find_package(ALSA REQUIRED)
set(MODULE_INCLUDE_PRIVATE ${MODULE_INCLUDE_PRIVATE} ${ALSA_INCLUDE_DIRS} )
set(MODULE_LINK ${MODULE_LINK} ${ALSA_LIBRARIES} pthread )
else ()
if (OS_IS_MAC)
find_library(AudioToolbox NAMES AudioToolbox)
find_library(CoreAudio NAMES CoreAudio)
set(MODULE_LINK ${MODULE_LINK} ${AudioToolbox} ${CoreAudio})
elseif (OS_IS_WIN)
set(MODULE_LINK ${MODULE_LINK} winmm mmdevapi mfplat)
elseif (OS_IS_LIN)
find_package(ALSA REQUIRED)
set(MODULE_INCLUDE_PRIVATE ${MODULE_INCLUDE_PRIVATE} ${ALSA_INCLUDE_DIRS} )
set(MODULE_LINK ${MODULE_LINK} ${ALSA_LIBRARIES} pthread )
endif()
set(MODULE_INCLUDE_PRIVATE ${MODULE_INCLUDE_PRIVATE} ${ALSA_INCLUDE_DIRS})
set(MODULE_LINK ${MODULE_LINK} ${ALSA_LIBRARIES} pthread)
elseif (MINGW)
set(MODULE_LINK ${MODULE_LINK} winmm mmdevapi mfplat)
endif()

set(MODULE_QRC audio.qrc)
Expand Down
Loading
Loading