Skip to content

Commit 62b7169

Browse files
committed
Move MidiController form Channel to ChannelManager and Renderer
1 parent 182f841 commit 62b7169

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/core/channels/channel.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ Channel::Channel(ChannelType type, ID id, ID columnId, int position, ChannelShar
6363
break;
6464

6565
case ChannelType::MIDI:
66-
midiController.emplace();
6766
midiChannel.emplace();
6867
break;
6968

@@ -108,7 +107,6 @@ Channel::Channel(const Patch::Channel& p, ChannelShared& s, float samplerateRati
108107
break;
109108

110109
case ChannelType::MIDI:
111-
midiController.emplace();
112110
midiChannel.emplace(p);
113111
break;
114112

src/core/channels/channel.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include "core/channels/channelShared.h"
3131
#include "core/channels/midiChannel.h"
32-
#include "core/channels/midiController.h"
3332
#include "core/channels/midiLearn.h"
3433
#include "core/channels/midiLightning.h"
3534
#include "core/channels/sampleAdvancer.h"
@@ -110,9 +109,8 @@ class Channel final
110109
MidiLearn midiLearn;
111110
MidiLightning midiLightning;
112111

113-
std::optional<MidiController> midiController;
114-
std::optional<SampleChannel> sampleChannel;
115-
std::optional<MidiChannel> midiChannel;
112+
std::optional<SampleChannel> sampleChannel;
113+
std::optional<MidiChannel> midiChannel;
116114

117115
private:
118116
bool m_mute;

src/core/channels/channelManager.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ void ChannelManager::keyPress(ID channelId, int velocity, bool canRecordActions,
327327
{
328328
Channel& ch = m_model.get().channels.get(channelId);
329329

330-
if (ch.midiController)
331-
ch.midiController->keyPress(ch.shared->playStatus);
330+
if (ch.type == ChannelType::MIDI)
331+
m_midiController.keyPress(ch.shared->playStatus);
332332
if (ch.type == ChannelType::SAMPLE && ch.hasWave() && canRecordActions && !ch.sampleChannel->isAnyLoopMode())
333333
m_sampleActionRecorder.keyPress(channelId, *ch.shared, currentFrameQuantized, ch.sampleChannel->mode, ch.hasActions);
334334
if (ch.type == ChannelType::SAMPLE && ch.hasWave())
@@ -357,8 +357,8 @@ void ChannelManager::keyKill(ID channelId, bool canRecordActions, Frame currentF
357357
{
358358
Channel& ch = m_model.get().channels.get(channelId);
359359

360-
if (ch.midiController)
361-
ch.midiController->keyKill(ch.shared->playStatus);
360+
if (ch.type == ChannelType::MIDI)
361+
m_midiController.keyKill(ch.shared->playStatus);
362362
if (ch.type == ChannelType::MIDI)
363363
m_midiReceiver.stop(ch.shared->midiQueue);
364364
if (ch.type == ChannelType::MIDI && ch.isPlaying() && !ch.isMuted() && ch.midiChannel->outputEnabled)
@@ -574,8 +574,8 @@ void ChannelManager::stopAll()
574574
{
575575
for (Channel& ch : m_model.get().channels.getAll())
576576
{
577-
if (ch.midiController)
578-
ch.midiController->stop(ch.shared->playStatus);
577+
if (ch.type == ChannelType::MIDI)
578+
m_midiController.stop(ch.shared->playStatus);
579579
if (ch.type == ChannelType::SAMPLE)
580580
m_sampleReactor.stopBySeq(*ch.shared, m_model.get().behaviors.chansStopOnSeqHalt, ch.sampleChannel->isAnyLoopMode());
581581
if (ch.type == ChannelType::MIDI && ch.isPlaying() && !ch.isMuted() && ch.midiChannel->outputEnabled)
@@ -591,8 +591,8 @@ void ChannelManager::stopAll()
591591
void ChannelManager::rewindAll()
592592
{
593593
for (Channel& ch : m_model.get().channels.getAll())
594-
if (ch.midiController)
595-
ch.midiController->rewind(ch.shared->playStatus);
594+
if (ch.type == ChannelType::MIDI)
595+
m_midiController.rewind(ch.shared->playStatus);
596596
m_model.swap(model::SwapType::SOFT);
597597
}
598598

src/core/channels/channelManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define G_CHANNEL_MANAGER_H
2929

3030
#include "core/channels/midiActionRecorder.h"
31+
#include "core/channels/midiController.h"
3132
#include "core/channels/midiLighter.h"
3233
#include "core/channels/midiReceiver.h"
3334
#include "core/channels/midiSender.h"
@@ -228,6 +229,7 @@ class ChannelManager final
228229
MidiActionRecorder m_midiActionRecorder;
229230
SampleActionRecorder m_sampleActionRecorder;
230231
SampleReactor m_sampleReactor;
232+
MidiController m_midiController;
231233
};
232234
} // namespace giada::m
233235

src/core/renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ void Renderer::advanceChannel(const Channel& ch, const Sequencer::EventBuffer& e
163163

164164
for (const Sequencer::Event& e : events)
165165
{
166-
if (ch.midiController)
167-
ch.midiController->advance(ch.shared->playStatus, e);
166+
if (ch.type == ChannelType::MIDI)
167+
m_midiController.advance(ch.shared->playStatus, e);
168168

169169
if (ch.type == ChannelType::SAMPLE)
170170
m_sampleAdvancer.advance(ch.id, *ch.shared, e, ch.sampleChannel->mode, ch.sampleChannel->isAnyLoopMode());

src/core/renderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define G_RENDERER_H
2929

3030
#include "core/channels/audioReceiver.h"
31+
#include "core/channels/midiController.h"
3132
#include "core/channels/midiReceiver.h"
3233
#include "core/channels/midiSender.h"
3334
#include "core/channels/sampleAdvancer.h"
@@ -96,6 +97,7 @@ class Renderer
9697
SampleAdvancer m_sampleAdvancer;
9798
MidiSender m_midiSender;
9899
MidiReceiver m_midiReceiver;
100+
MidiController m_midiController;
99101
};
100102
} // namespace giada::m
101103

0 commit comments

Comments
 (0)