diff --git a/mscore/exportaudio.cpp b/mscore/exportaudio.cpp index 1a0e4e689c052..90896d8c6bf08 100644 --- a/mscore/exportaudio.cpp +++ b/mscore/exportaudio.cpp @@ -33,9 +33,9 @@ namespace Ms { /// /// \brief Function to synthesize audio and output it into a generic QIODevice -/// \param The score to output -/// \param The output device -/// \param An optional callback function that will be notified with the progress in range [0, 1] +/// \param score The score to output +/// \param device The output device +/// \param updateProgress An optional callback function that will be notified with the progress in range [0, 1] /// \return True on success, false otherwise. /// /// If the callback function is non zero an returns false the export will be canceled. @@ -53,9 +53,15 @@ bool MuseScore::saveAudio(Score* score, QIODevice *device, std::functionrenderMidi(&events, synthesizerState()); - if(events.size() == 0) - return false; + // In non-GUI mode current synthesizer settings won't + // allow single note dynamics. See issue #289947. + const bool useCurrentSynthesizerState = !MScore::noGui; + + if (useCurrentSynthesizerState) { + score->renderMidi(&events, synthesizerState()); + if (events.empty()) + return false; + } MasterSynthesizer* synth = synthesizerFactory(); synth->init(); @@ -72,6 +78,16 @@ bool MuseScore::saveAudio(Score* score, QIODevice *device, std::functioninit(); } + if (!useCurrentSynthesizerState) { + score->masterScore()->rebuildAndUpdateExpressive(synth->synthesizer("Fluid")); + score->renderMidi(&events, score->synthesizerState()); + if (synti) + score->masterScore()->rebuildAndUpdateExpressive(synti->synthesizer("Fluid")); + + if (events.empty()) + return false; + } + int oldSampleRate = MScore::sampleRate; MScore::sampleRate = sampleRate; diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 7215b476cf825..a809cc40dd065 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -6881,9 +6881,15 @@ bool MuseScore::saveMp3(Score* score, QIODevice* device, bool& wasCanceled) return false; #else EventMap events; - score->renderMidi(&events, synthesizerState()); - if(events.size() == 0) - return false; + // In non-GUI mode current synthesizer settings won't + // allow single note dynamics. See issue #289947. + const bool useCurrentSynthesizerState = !MScore::noGui; + + if (useCurrentSynthesizerState) { + score->renderMidi(&events, synthesizerState()); + if (events.empty()) + return false; + } MP3Exporter exporter; if (!exporter.loadLibrary(MP3Exporter::AskUser::MAYBE)) { @@ -6955,6 +6961,16 @@ bool MuseScore::saveMp3(Score* score, QIODevice* device, bool& wasCanceled) MScore::sampleRate = sampleRate; + if (!useCurrentSynthesizerState) { + score->masterScore()->rebuildAndUpdateExpressive(synth->synthesizer("Fluid")); + score->renderMidi(&events, score->synthesizerState()); + if (synti) + score->masterScore()->rebuildAndUpdateExpressive(synti->synthesizer("Fluid")); + + if (events.empty()) + return false; + } + QProgressDialog progress(this); progress.setWindowFlags(Qt::WindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowTitleHint)); progress.setWindowModality(Qt::ApplicationModal);