Skip to content

Commit

Permalink
Move MidiController form Channel to ChannelManager and Renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Aug 5, 2023
1 parent 182f841 commit 62b7169
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/core/channels/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Channel::Channel(ChannelType type, ID id, ID columnId, int position, ChannelShar
break;

case ChannelType::MIDI:
midiController.emplace();
midiChannel.emplace();
break;

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

case ChannelType::MIDI:
midiController.emplace();
midiChannel.emplace(p);
break;

Expand Down
6 changes: 2 additions & 4 deletions src/core/channels/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "core/channels/channelShared.h"
#include "core/channels/midiChannel.h"
#include "core/channels/midiController.h"
#include "core/channels/midiLearn.h"
#include "core/channels/midiLightning.h"
#include "core/channels/sampleAdvancer.h"
Expand Down Expand Up @@ -110,9 +109,8 @@ class Channel final
MidiLearn midiLearn;
MidiLightning midiLightning;

std::optional<MidiController> midiController;
std::optional<SampleChannel> sampleChannel;
std::optional<MidiChannel> midiChannel;
std::optional<SampleChannel> sampleChannel;
std::optional<MidiChannel> midiChannel;

private:
bool m_mute;
Expand Down
16 changes: 8 additions & 8 deletions src/core/channels/channelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ void ChannelManager::keyPress(ID channelId, int velocity, bool canRecordActions,
{
Channel& ch = m_model.get().channels.get(channelId);

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

if (ch.midiController)
ch.midiController->keyKill(ch.shared->playStatus);
if (ch.type == ChannelType::MIDI)
m_midiController.keyKill(ch.shared->playStatus);
if (ch.type == ChannelType::MIDI)
m_midiReceiver.stop(ch.shared->midiQueue);
if (ch.type == ChannelType::MIDI && ch.isPlaying() && !ch.isMuted() && ch.midiChannel->outputEnabled)
Expand Down Expand Up @@ -574,8 +574,8 @@ void ChannelManager::stopAll()
{
for (Channel& ch : m_model.get().channels.getAll())
{
if (ch.midiController)
ch.midiController->stop(ch.shared->playStatus);
if (ch.type == ChannelType::MIDI)
m_midiController.stop(ch.shared->playStatus);
if (ch.type == ChannelType::SAMPLE)
m_sampleReactor.stopBySeq(*ch.shared, m_model.get().behaviors.chansStopOnSeqHalt, ch.sampleChannel->isAnyLoopMode());
if (ch.type == ChannelType::MIDI && ch.isPlaying() && !ch.isMuted() && ch.midiChannel->outputEnabled)
Expand All @@ -591,8 +591,8 @@ void ChannelManager::stopAll()
void ChannelManager::rewindAll()
{
for (Channel& ch : m_model.get().channels.getAll())
if (ch.midiController)
ch.midiController->rewind(ch.shared->playStatus);
if (ch.type == ChannelType::MIDI)
m_midiController.rewind(ch.shared->playStatus);
m_model.swap(model::SwapType::SOFT);
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/channels/channelManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define G_CHANNEL_MANAGER_H

#include "core/channels/midiActionRecorder.h"
#include "core/channels/midiController.h"
#include "core/channels/midiLighter.h"
#include "core/channels/midiReceiver.h"
#include "core/channels/midiSender.h"
Expand Down Expand Up @@ -228,6 +229,7 @@ class ChannelManager final
MidiActionRecorder m_midiActionRecorder;
SampleActionRecorder m_sampleActionRecorder;
SampleReactor m_sampleReactor;
MidiController m_midiController;
};
} // namespace giada::m

Expand Down
4 changes: 2 additions & 2 deletions src/core/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ void Renderer::advanceChannel(const Channel& ch, const Sequencer::EventBuffer& e

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

if (ch.type == ChannelType::SAMPLE)
m_sampleAdvancer.advance(ch.id, *ch.shared, e, ch.sampleChannel->mode, ch.sampleChannel->isAnyLoopMode());
Expand Down
2 changes: 2 additions & 0 deletions src/core/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define G_RENDERER_H

#include "core/channels/audioReceiver.h"
#include "core/channels/midiController.h"
#include "core/channels/midiReceiver.h"
#include "core/channels/midiSender.h"
#include "core/channels/sampleAdvancer.h"
Expand Down Expand Up @@ -96,6 +97,7 @@ class Renderer
SampleAdvancer m_sampleAdvancer;
MidiSender m_midiSender;
MidiReceiver m_midiReceiver;
MidiController m_midiController;
};
} // namespace giada::m

Expand Down

0 comments on commit 62b7169

Please sign in to comment.