-
Notifications
You must be signed in to change notification settings - Fork 42
Automation: interpolate dynamics at audio engine level #207
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,18 +59,7 @@ int FluidSequencer::naturalExpressionLevel() const | |
| return NATURAL_EXP_LVL; | ||
| } | ||
|
|
||
| void FluidSequencer::updateOffStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::DynamicLevelLayers& dynamics) | ||
| { | ||
| addPlaybackEvents(m_offStreamEvents, events); | ||
|
|
||
| if (m_useDynamicEvents) { | ||
| addDynamicEvents(m_offStreamEvents, dynamics); | ||
| } | ||
|
|
||
| updateOffSequenceIterator(); | ||
| } | ||
|
|
||
| void FluidSequencer::updateMainStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::DynamicLevelLayers& dynamics) | ||
| void FluidSequencer::updateMainStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::DynamicAutomationLayers& dynamics) | ||
| { | ||
| m_mainStreamEvents.clear(); | ||
|
|
||
|
|
@@ -87,6 +76,12 @@ void FluidSequencer::updateMainStreamEvents(const mpe::PlaybackEventsMap& events | |
| updateMainSequenceIterator(); | ||
| } | ||
|
|
||
| void FluidSequencer::updateOffStreamEvents(const mpe::PlaybackEventsMap& events) | ||
| { | ||
| addPlaybackEvents(m_offStreamEvents, events); | ||
| updateOffSequenceIterator(); | ||
| } | ||
|
|
||
| muse::async::Channel<channel_t, Program> FluidSequencer::channelAdded() const | ||
| { | ||
| return m_channels.channelAdded; | ||
|
|
@@ -119,16 +114,25 @@ void FluidSequencer::addPlaybackEvents(EventSequenceMap& destination, const mpe: | |
| addSostenutoEvents(destination, sostenutoTimeAndDurations); | ||
| } | ||
|
|
||
| void FluidSequencer::addDynamicEvents(EventSequenceMap& destination, const mpe::DynamicLevelLayers& dynamics) | ||
| void FluidSequencer::addDynamicEvents(EventSequenceMap& destination, const mpe::DynamicAutomationLayers& layers) | ||
| { | ||
| for (const auto& layer : dynamics) { | ||
| for (const auto& dynamic : layer.second) { | ||
| midi::Event event(muse::midi::Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10); | ||
| event.setIndex(midi::EXPRESSION_CONTROLLER); | ||
| event.setData(expressionLevel(dynamic.second)); | ||
| constexpr mpe::timestamp_t STEP_INTERVAL_US = 30000; | ||
|
|
||
| destination[dynamic.first].emplace_back(std::move(event)); | ||
| } | ||
| for (const auto& [layerIdx, curve] : layers) { | ||
| std::optional<int> lastLevel; | ||
|
|
||
| mpe::resampleCurve(curve, STEP_INTERVAL_US, [&](mpe::timestamp_t t, muse::real_t normalized) { | ||
| const int level = expressionLevel(mpe::dynamicLevelFromNormalized(normalized)); | ||
| if (lastLevel == level) { | ||
| return; | ||
| } | ||
| lastLevel = level; | ||
|
|
||
| midi::Event event(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10); | ||
| event.setIndex(midi::EXPRESSION_CONTROLLER); | ||
| event.setData(level); | ||
| destination[t].emplace_back(std::move(event)); | ||
|
Comment on lines
+121
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Route expression controls to the note channel. These controller events do not set a channel. The note-on event at Line 161 sets Map each Also applies to: 153-157 🤖 Prompt for AI Agents |
||
| }); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -146,6 +150,13 @@ void FluidSequencer::addNoteEvent(EventSequenceMap& destination, const mpe::Note | |
| m_lastStaff = noteEvent.arrangementCtx().staffLayerIndex; | ||
|
|
||
| if (arrangementCtx.hasStart()) { | ||
| if (m_useDynamicEvents) { | ||
| midi::Event expressionEvent(Event::Opcode::ControlChange, Event::MessageType::ChannelVoice10); | ||
| expressionEvent.setIndex(midi::EXPRESSION_CONTROLLER); | ||
| expressionEvent.setData(expressionLevel(noteEvent.expressionCtx().nominalDynamicLevel)); | ||
| destination[arrangementCtx.actualTimestamp].emplace_back(std::move(expressionEvent)); | ||
| } | ||
|
|
||
| midi::Event noteOn(Event::Opcode::NoteOn, Event::MessageType::ChannelVoice20); | ||
| noteOn.setChannel(channelIdx); | ||
| noteOn.setNote(noteIdx); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.