Skip to content

Commit

Permalink
Merge pull request #26741 from RomanPudashkin/reload_playback_cache_o…
Browse files Browse the repository at this point in the history
…ption

Added ability to reload playback cache
  • Loading branch information
RomanPudashkin authored Feb 26, 2025
2 parents 1bbc56b + a289698 commit 6d5490f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ MenuItem* AppMenuModel::makeDiagnosticsMenu()

MenuItemList items {
makeMenuItem("diagnostic-save-diagnostic-files"),
makeMenuItem("playback-reload-cache"),
makeMenu(TranslatableString("appshell/menu/diagnostics", "&System"), systemItems, "menu-system")
};

Expand Down
1 change: 1 addition & 0 deletions src/notation/inotationplayback.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class INotationPlayback
virtual ~INotationPlayback() = default;

virtual void init() = 0;
virtual void reload() = 0;

virtual const engraving::InstrumentTrackId& metronomeTrackId() const = 0;
virtual engraving::InstrumentTrackId chordSymbolsTrackId(const muse::ID& partId) const = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/notation/internal/notationplayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ void NotationPlayback::init()
});
}

void NotationPlayback::reload()
{
m_playbackModel.reload();
}

const engraving::InstrumentTrackId& NotationPlayback::metronomeTrackId() const
{
return m_playbackModel.metronomeTrackId();
Expand Down
1 change: 1 addition & 0 deletions src/notation/internal/notationplayback.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NotationPlayback : public INotationPlayback, public muse::async::Asyncable
NotationPlayback(IGetScore* getScore, muse::async::Notification notationChanged, const muse::modularity::ContextPtr& iocCtx);

void init() override;
void reload() override;

const engraving::InstrumentTrackId& metronomeTrackId() const override;
engraving::InstrumentTrackId chordSymbolsTrackId(const muse::ID& partId) const override;
Expand Down
4 changes: 4 additions & 0 deletions src/notation/internal/notationplaybackstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ void NotationPlaybackStub::init()
{
}

void NotationPlaybackStub::reload()
{
}

const engraving::InstrumentTrackId& NotationPlaybackStub::metronomeTrackId() const
{
static const engraving::InstrumentTrackId dummy;
Expand Down
1 change: 1 addition & 0 deletions src/notation/internal/notationplaybackstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class NotationPlaybackStub : public INotationPlayback
NotationPlaybackStub();

void init() override;
void reload() override;

const engraving::InstrumentTrackId& metronomeTrackId() const override;
engraving::InstrumentTrackId chordSymbolsTrackId(const muse::ID& partId) const override;
Expand Down
9 changes: 9 additions & 0 deletions src/playback/internal/playbackcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void PlaybackController::init()
dispatcher()->reg(this, COUNT_IN_CODE, this, &PlaybackController::toggleCountIn);
dispatcher()->reg(this, PLAYBACK_SETUP, this, &PlaybackController::openPlaybackSetupDialog);
dispatcher()->reg(this, TOGGLE_HEAR_PLAYBACK_WHEN_EDITING_CODE, this, &PlaybackController::toggleHearPlaybackWhenEditing);
dispatcher()->reg(this, "playback-reload-cache", this, &PlaybackController::reloadPlaybackCache);

globalContext()->currentNotationChanged().onNotify(this, [this]() {
onNotationChanged();
Expand Down Expand Up @@ -824,6 +825,14 @@ void PlaybackController::toggleHearPlaybackWhenEditing()
configuration()->setPlayNotesWhenEditing(!wasPlayNotesWhenEditing);
}

void PlaybackController::reloadPlaybackCache()
{
INotationPlaybackPtr playback = notationPlayback();
if (playback) {
playback->reload();
}
}

void PlaybackController::openPlaybackSetupDialog()
{
interactive()->open("musescore://playback/soundprofilesdialog");
Expand Down
2 changes: 2 additions & 0 deletions src/playback/internal/playbackcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class PlaybackController : public IPlaybackController, public muse::actions::Act
void toggleLoopPlayback();
void toggleHearPlaybackWhenEditing();

void reloadPlaybackCache();

void openPlaybackSetupDialog();

void addLoopBoundary(notation::LoopBoundaryType type);
Expand Down
9 changes: 9 additions & 0 deletions src/playback/internal/playbackuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ const UiActionList PlaybackUiActions::m_loopBoundaryActions = {
),
};

const UiActionList PlaybackUiActions::m_diagnosticActions = {
UiAction("playback-reload-cache",
mu::context::UiCtxAny,
mu::context::CTX_ANY,
TranslatableString("action", "Reload playback cache")
)
};

PlaybackUiActions::PlaybackUiActions(std::shared_ptr<PlaybackController> controller)
: m_controller(controller)
{
Expand Down Expand Up @@ -199,6 +207,7 @@ const UiActionList& PlaybackUiActions::actionsList() const
alist.insert(alist.end(), m_midiInputPitchActions.cbegin(), m_midiInputPitchActions.cend());
alist.insert(alist.end(), m_settingsActions.cbegin(), m_settingsActions.cend());
alist.insert(alist.end(), m_loopBoundaryActions.cbegin(), m_loopBoundaryActions.cend());
alist.insert(alist.end(), m_diagnosticActions.cbegin(), m_diagnosticActions.cend());
}
return alist;
}
Expand Down
1 change: 1 addition & 0 deletions src/playback/internal/playbackuiactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class PlaybackUiActions : public muse::ui::IUiActionsModule, public muse::async:
static const muse::ui::UiActionList m_midiInputPitchActions;
static const muse::ui::UiActionList m_settingsActions;
static const muse::ui::UiActionList m_loopBoundaryActions;
static const muse::ui::UiActionList m_diagnosticActions;

std::shared_ptr<PlaybackController> m_controller;
muse::async::Channel<muse::actions::ActionCodeList> m_actionEnabledChanged;
Expand Down

0 comments on commit 6d5490f

Please sign in to comment.