Fixed an issue with a range of pedal line controller
This commit is contained in:
parent
234764140e
commit
1e6a1a25a5
4 changed files with 36 additions and 29 deletions
|
@ -24,7 +24,7 @@
|
|||
#define MU_AUDIO_ABSTRACTEVENTSEQUENCER_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "async/asyncable.h"
|
||||
#include "async/channel.h"
|
||||
|
@ -38,7 +38,7 @@ template<class EventType>
|
|||
class AbstractEventSequencer : public async::Asyncable
|
||||
{
|
||||
public:
|
||||
using EventSequence = std::vector<EventType>;
|
||||
using EventSequence = std::set<EventType>;
|
||||
using EventSequenceMap = std::map<msecs_t, EventSequence>;
|
||||
|
||||
typedef typename EventSequenceMap::const_iterator SequenceIterator;
|
||||
|
@ -167,8 +167,7 @@ protected:
|
|||
void handleMainStream(EventSequence& result)
|
||||
{
|
||||
if (m_currentMainSequenceIt->first <= m_playbackPosition) {
|
||||
result.insert(result.cend(),
|
||||
m_currentMainSequenceIt->second.cbegin(),
|
||||
result.insert(m_currentMainSequenceIt->second.cbegin(),
|
||||
m_currentMainSequenceIt->second.cend());
|
||||
|
||||
m_currentMainSequenceIt = std::next(m_currentMainSequenceIt);
|
||||
|
@ -182,8 +181,7 @@ protected:
|
|||
}
|
||||
|
||||
if (m_currentDynamicsIt->first <= m_playbackPosition) {
|
||||
result.insert(result.cend(),
|
||||
m_currentDynamicsIt->second.cbegin(),
|
||||
result.insert(m_currentDynamicsIt->second.cbegin(),
|
||||
m_currentDynamicsIt->second.cend());
|
||||
|
||||
m_currentDynamicsIt = std::next(m_currentDynamicsIt);
|
||||
|
|
|
@ -56,7 +56,7 @@ void FluidSequencer::updateDynamicChanges(const mpe::DynamicLevelMap& changes)
|
|||
event.setIndex(11);
|
||||
event.setData(expressionLevel(pair.second));
|
||||
|
||||
m_dynamicEvents[pair.first].emplace_back(std::move(event));
|
||||
m_dynamicEvents[pair.first].emplace(std::move(event));
|
||||
}
|
||||
|
||||
updateDynamicChangesIterator();
|
||||
|
@ -84,29 +84,24 @@ void FluidSequencer::updatePlaybackEvents(EventSequenceMap& destination, const m
|
|||
noteOn.setNote(noteIdx);
|
||||
noteOn.setVelocity(velocity);
|
||||
|
||||
destination[timestampFrom].emplace_back(std::move(noteOn));
|
||||
destination[timestampFrom].emplace(std::move(noteOn));
|
||||
|
||||
midi::Event noteOff(Event::Opcode::NoteOff, Event::MessageType::ChannelVoice10);
|
||||
noteOff.setChannel(channelIdx);
|
||||
noteOff.setNote(noteIdx);
|
||||
|
||||
destination[timestampTo].emplace_back(std::move(noteOff));
|
||||
destination[timestampTo].emplace(std::move(noteOff));
|
||||
|
||||
appendControlSwitch(destination, noteEvent, PEDAL_CC_SUPPORTED_TYPES, 64, timestampFrom, timestampTo);
|
||||
appendControlSwitch(destination, noteEvent, LEGATO_CC_SUPPORTED_TYPES, 68, timestampFrom, timestampTo);
|
||||
appendControlSwitch(destination, noteEvent, PEDAL_CC_SUPPORTED_TYPES, 64);
|
||||
appendControlSwitch(destination, noteEvent, LEGATO_CC_SUPPORTED_TYPES, 68);
|
||||
appendPitchBend(destination, noteEvent, BEND_SUPPORTED_TYPES, channelIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FluidSequencer::appendControlSwitch(EventSequenceMap& destination, const mpe::NoteEvent& noteEvent,
|
||||
const mpe::ArticulationTypeSet& appliableTypes, const int midiControlIdx,
|
||||
const mpe::timestamp_t timestampFrom,
|
||||
const mpe::timestamp_t timestampTo)
|
||||
const mpe::ArticulationTypeSet& appliableTypes, const int midiControlIdx)
|
||||
{
|
||||
midi::Event cc(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10);
|
||||
cc.setIndex(midiControlIdx);
|
||||
|
||||
mpe::ArticulationType currentType = mpe::ArticulationType::Undefined;
|
||||
|
||||
for (const mpe::ArticulationType type : appliableTypes) {
|
||||
|
@ -118,16 +113,25 @@ void FluidSequencer::appendControlSwitch(EventSequenceMap& destination, const mp
|
|||
|
||||
if (currentType != mpe::ArticulationType::Undefined) {
|
||||
const ArticulationAppliedData& articulationData = noteEvent.expressionCtx().articulations.at(currentType);
|
||||
if (articulationData.occupiedTo == mpe::HUNDRED_PERCENT) {
|
||||
cc.setData(0);
|
||||
destination[timestampTo].emplace_back(std::move(cc));
|
||||
} else {
|
||||
cc.setData(127);
|
||||
destination[timestampFrom].emplace_back(std::move(cc));
|
||||
}
|
||||
const ArticulationMeta& articulationMeta = articulationData.meta;
|
||||
|
||||
midi::Event start(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10);
|
||||
start.setIndex(midiControlIdx);
|
||||
start.setData(127);
|
||||
|
||||
destination[articulationMeta.timestamp].emplace(std::move(start));
|
||||
|
||||
midi::Event end(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10);
|
||||
end.setIndex(midiControlIdx);
|
||||
end.setData(0);
|
||||
|
||||
destination[articulationMeta.timestamp + articulationMeta.overallDuration].emplace(std::move(end));
|
||||
} else {
|
||||
midi::Event cc(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10);
|
||||
cc.setIndex(midiControlIdx);
|
||||
cc.setData(0);
|
||||
destination[timestampFrom].emplace_back(std::move(cc));
|
||||
|
||||
destination[noteEvent.arrangementCtx().actualTimestamp].emplace(std::move(cc));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +160,7 @@ void FluidSequencer::appendPitchBend(EventSequenceMap& destination, const mpe::N
|
|||
|
||||
if (pair.first == HUNDRED_PERCENT) {
|
||||
event.setData(pitchBendValue);
|
||||
destination[currentPoint].emplace_back(std::move(event));
|
||||
destination[currentPoint].emplace(std::move(event));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -167,14 +171,14 @@ void FluidSequencer::appendPitchBend(EventSequenceMap& destination, const mpe::N
|
|||
pitchBendValue = std::clamp(pitchBendValue, 0, 16383);
|
||||
|
||||
event.setData(pitchBendValue);
|
||||
destination[currentPoint].emplace_back(std::move(event));
|
||||
destination[currentPoint].emplace(std::move(event));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
midi::Event event(Event::Opcode::PitchBend, Event::MessageType::ChannelVoice10);
|
||||
event.setChannel(channelIdx);
|
||||
event.setData(8192);
|
||||
destination[timestampFrom].emplace_back(std::move(event));
|
||||
destination[timestampFrom].emplace(std::move(event));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
void updatePlaybackEvents(EventSequenceMap& destination, const mpe::PlaybackEventsMap& changes);
|
||||
|
||||
void appendControlSwitch(EventSequenceMap& destination, const mpe::NoteEvent& noteEvent, const mpe::ArticulationTypeSet& appliableTypes,
|
||||
const int midiControlIdx, const mpe::timestamp_t timestampFrom, const mpe::timestamp_t timestampTo);
|
||||
const int midiControlIdx);
|
||||
|
||||
void appendPitchBend(EventSequenceMap& destination, const mpe::NoteEvent& noteEvent, const mpe::ArticulationTypeSet& appliableTypes,
|
||||
const midi::channel_t channelIdx);
|
||||
|
|
|
@ -147,6 +147,11 @@ struct Event {
|
|||
return operator!=(NOOP()) && isValid();
|
||||
}
|
||||
|
||||
bool operator <(const Event& other) const
|
||||
{
|
||||
return m_data < other.m_data;
|
||||
}
|
||||
|
||||
bool isChannelVoice() const { return messageType() == MessageType::ChannelVoice10 || messageType() == MessageType::ChannelVoice20; }
|
||||
bool isChannelVoice20() const { return messageType() == MessageType::ChannelVoice20; }
|
||||
bool isMessageTypeIn(const std::set<MessageType>& types) const { return types.find(messageType()) != types.end(); }
|
||||
|
|
Loading…
Reference in a new issue