Fixed an issue with tremolo duration

This commit is contained in:
vpereverzev 2022-06-15 13:21:01 +02:00 committed by pereverzev+v
parent ae94b9a0ef
commit 8fedab860f
7 changed files with 213 additions and 0 deletions

View file

@ -190,6 +190,11 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/playback/mapping/percussionssetupdataresolver.h
${CMAKE_CURRENT_LIST_DIR}/playback/mapping/voicessetupdataresolver.cpp
${CMAKE_CURRENT_LIST_DIR}/playback/mapping/voicessetupdataresolver.h
${CMAKE_CURRENT_LIST_DIR}/playback/filters/filterbase.h
${CMAKE_CURRENT_LIST_DIR}/playback/filters/chordfilter.cpp
${CMAKE_CURRENT_LIST_DIR}/playback/filters/chordfilter.h
${CMAKE_CURRENT_LIST_DIR}/playback/filters/internal/tremolofilter.cpp
${CMAKE_CURRENT_LIST_DIR}/playback/filters/internal/tremolofilter.h
${CMAKE_CURRENT_LIST_DIR}/playback/utils/pitchutils.h
${CMAKE_CURRENT_LIST_DIR}/playback/utils/expressionutils.h
${CMAKE_CURRENT_LIST_DIR}/playback/utils/arrangementutils.h

View file

@ -0,0 +1,32 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2022 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/>.
*/
#include "chordfilter.h"
#include "internal/tremolofilter.h"
using namespace mu::engraving;
bool ChordFilter::isPlayable(const EngravingItem* item, const RenderingContext& ctx)
{
return TremoloFilter::isItemPlayable(item, ctx);
}

View file

@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2022 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/>.
*/
#ifndef MU_ENGRAVING_CHORDFILTER_H
#define MU_ENGRAVING_CHORDFILTER_H
#include "filterbase.h"
namespace mu::engraving {
class ChordFilter : public FilterBase<ChordFilter>
{
protected:
friend class FilterBase<ChordFilter>;
static bool isPlayable(const EngravingItem* item, const RenderingContext& ctx);
};
}
#endif // MU_ENGRAVING_CHORDFILTER_H

View file

@ -0,0 +1,46 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2022 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/>.
*/
#ifndef MU_ENGRAVING_FILTERBASE_H
#define MU_ENGRAVING_FILTERBASE_H
#include "log.h"
#include "playback/renderingcontext.h"
namespace mu::engraving {
template<class T>
class FilterBase
{
public:
static bool isItemPlayable(const EngravingItem* item, const RenderingContext& ctx)
{
IF_ASSERT_FAILED(item) {
return false;
}
return T::isPlayable(item, ctx);
}
};
}
#endif // MU_ENGRAVING_FILTERBASE_H

View file

@ -0,0 +1,52 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2022 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/>.
*/
#include "tremolofilter.h"
#include "libmscore/chord.h"
#include "libmscore/tremolo.h"
using namespace mu::engraving;
bool TremoloFilter::isPlayable(const EngravingItem* item, const RenderingContext& /*ctx*/)
{
if (!item->isChord() && !item->isNote()) {
return false;
}
if (item->isChord()) {
const Chord* chord = toChord(item);
Tremolo* tremolo = chord->tremolo();
if (!tremolo) {
return true;
}
if (!tremolo->twoNotes()) {
return true;
}
return tremolo->chord1() == chord;
}
return true;
}

View file

@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2022 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/>.
*/
#ifndef MU_ENGRAVING_TREMOLOFILTER_H
#define MU_ENGRAVING_TREMOLOFILTER_H
#include "playback/filters/filterbase.h"
namespace mu::engraving {
class TremoloFilter : public FilterBase<TremoloFilter>
{
protected:
friend class FilterBase<TremoloFilter>;
static bool isPlayable(const EngravingItem* item, const RenderingContext& ctx);
};
}
#endif // MU_ENGRAVING_TREMOLOFILTER_H

View file

@ -35,6 +35,10 @@ void TremoloMetaParser::doParse(const EngravingItem* item, const RenderingContex
const Tremolo* tremolo = toTremolo(item);
if (tremolo->twoNotes() && tremolo->chord2()->tick().ticks() == ctx.nominalPositionStartTick) {
return;
}
mpe::ArticulationType type = mpe::ArticulationType::Undefined;
switch (tremolo->tremoloType()) {