Skip to content
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

Fixes bug where clicking on the Activity Indicator doesn't play a note #5824

Merged
merged 2 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions include/MidiEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,32 @@
class MidiEvent
{
public:
enum class Source { Internal, External };

MidiEvent(MidiEventTypes type = MidiActiveSensing,
int8_t channel = 0,
int16_t param1 = 0,
int16_t param2 = 0,
const void* sourcePort = nullptr,
bool ignoreOnExport = true) :
Source source = Source::External) :
m_type( type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( channel ),
m_sysExData( NULL ),
m_sourcePort(sourcePort),
m_ignoreOnExport(ignoreOnExport)
m_source(source)
{
m_data.m_param[0] = param1;
m_data.m_param[1] = param2;
}

MidiEvent(MidiEventTypes type, const char* sysExData, int dataLen, bool ignoreOnExport = true) :
MidiEvent(MidiEventTypes type, const char* sysExData, std::size_t dataLen, Source source = Source::External) :
m_type( type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( 0 ),
m_sysExData( sysExData ),
m_sourcePort(nullptr),
m_ignoreOnExport(ignoreOnExport)
m_source(source)
{
m_data.m_sysExDataLen = dataLen;
}
Expand All @@ -68,7 +70,7 @@ class MidiEvent
m_data( other.m_data ),
m_sysExData( other.m_sysExData ),
m_sourcePort(other.m_sourcePort),
m_ignoreOnExport(other.m_ignoreOnExport)
m_source(other.m_source)
{
}

Expand Down Expand Up @@ -194,14 +196,14 @@ class MidiEvent
setParam( 0, pitchBend );
}

bool ignoreOnExport() const
Source source() const
{
return m_ignoreOnExport;
return m_source;
}

void setIgnoreOnExport(bool value)
void setSource(Source value)
{
m_ignoreOnExport = value;
m_source = value;
}


Expand All @@ -212,16 +214,15 @@ class MidiEvent
union
{
int16_t m_param[2]; // first/second parameter (key/velocity)
uint8_t m_bytes[4]; // raw bytes
uint8_t m_bytes[4]; // raw bytes
int32_t m_sysExDataLen; // len of m_sysExData
} m_data;

const char* m_sysExData;
const void* m_sourcePort;

// This helps us ignore MIDI events that shouldn't be processed
// during a project export, like physical controller events.
bool m_ignoreOnExport;
// Stores the source of the MidiEvent: Internal or External (hardware controllers).
Source m_source;
} ;

#endif
6 changes: 3 additions & 3 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,18 @@ void InstrumentTrack::processCCEvent(int controller)
uint16_t cc = static_cast<uint16_t>(controller);
uint16_t value = static_cast<uint16_t>(m_midiCCModel[controller]->value());

// Process the MIDI CC event as an input event but with ignoreOnExport set to false
// Process the MIDI CC event as an input event but with source set to Internal
// so we can know LMMS generated the event, not a controller, and can process it during
// the project export
processInEvent(MidiEvent(MidiControlChange, channel, cc, value, NULL, false));
processInEvent(MidiEvent(MidiControlChange, channel, cc, value, nullptr, MidiEvent::Source::Internal));
}




void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset )
{
if (Engine::getSong()->isExporting() && event.ignoreOnExport())
if (Engine::getSong()->isExporting() && event.source() == MidiEvent::Source::External)
{
return;
}
Expand Down