forked from GrandOrgue/grandorgue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using GOMidiReceivingSendingObject in GOButtonControl
- Loading branch information
Showing
7 changed files
with
152 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/grandorgue/midi/objects/GOMidiReceivingSendingObject.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2006 Milan Digital Audio LLC | ||
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS) | ||
* License GPL-2.0 or later | ||
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). | ||
*/ | ||
|
||
#include "GOMidiReceivingSendingObject.h" | ||
|
||
#include "model/GOOrganModel.h" | ||
|
||
GOMidiReceivingSendingObject::GOMidiReceivingSendingObject( | ||
GOOrganModel &organModel, | ||
const wxString &midiTypeCode, | ||
const wxString &midiTypeName, | ||
GOMidiSenderType senderType, | ||
GOMidiReceiverType reveiverType, | ||
GOMidiShortcutReceiver *pShortcutReceiver, | ||
GOMidiSender *pDivisionSender) | ||
: GOMidiSendingObject( | ||
organModel, | ||
midiTypeCode, | ||
midiTypeName, | ||
senderType, | ||
&m_receiver, | ||
pShortcutReceiver, | ||
pDivisionSender), | ||
m_receiver(organModel, reveiverType) { | ||
r_OrganModel.RegisterEventHandler(this); | ||
} | ||
|
||
GOMidiReceivingSendingObject::~GOMidiReceivingSendingObject() { | ||
r_OrganModel.UnRegisterEventHandler(this); | ||
} | ||
|
||
void GOMidiReceivingSendingObject::LoadMidiObject( | ||
GOConfigReader &cfg, const wxString &group, GOMidiMap &midiMap) { | ||
GOMidiSendingObject::LoadMidiObject(cfg, group, midiMap); | ||
if (!IsReadOnly()) { | ||
m_receiver.Load(cfg, group, midiMap); | ||
} | ||
} | ||
|
||
void GOMidiReceivingSendingObject::SaveMidiObject( | ||
GOConfigWriter &cfg, const wxString &group, GOMidiMap &midiMap) { | ||
GOMidiSendingObject::SaveMidiObject(cfg, group, midiMap); | ||
if (!IsReadOnly()) { | ||
m_receiver.Save(cfg, group, midiMap); | ||
} | ||
} | ||
|
||
void GOMidiReceivingSendingObject::SetElementId(int id) { | ||
if (!IsReadOnly()) { | ||
m_receiver.SetElementID(id); | ||
GOMidiSendingObject::SetElementId(id); | ||
} | ||
} | ||
|
||
void GOMidiReceivingSendingObject::SetPreconfigIndex(unsigned index) { | ||
m_receiver.SetIndex(index); | ||
} | ||
|
||
void GOMidiReceivingSendingObject::PreparePlayback() { | ||
GOMidiSendingObject::PreparePlayback(); | ||
m_receiver.PreparePlayback(); | ||
} | ||
|
||
void GOMidiReceivingSendingObject::ProcessMidi(const GOMidiEvent &event) { | ||
if (!IsReadOnly()) { | ||
GOMidiMatchType matchType = m_receiver.Match(event); | ||
|
||
if (matchType > MIDI_MATCH_NONE) | ||
OnMatchedMidi(event, matchType); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/grandorgue/midi/objects/GOMidiReceivingSendingObject.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2006 Milan Digital Audio LLC | ||
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS) | ||
* License GPL-2.0 or later | ||
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). | ||
*/ | ||
|
||
#ifndef GOMIDIRECEIVINGSENDINGOBJECT_H | ||
#define GOMIDIRECEIVINGSENDINGOBJECT_H | ||
|
||
#include "midi/GOMidiReceiver.h" | ||
|
||
#include "GOEventHandler.h" | ||
#include "GOMidiSendingObject.h" | ||
|
||
class GOMidiReceivingSendingObject : public GOMidiSendingObject, | ||
private GOEventHandler { | ||
private: | ||
GOMidiReceiver m_receiver; | ||
|
||
protected: | ||
GOMidiReceivingSendingObject( | ||
GOOrganModel &organModel, | ||
const wxString &midiTypeCode, | ||
const wxString &midiTypeName, | ||
GOMidiSenderType senderType, | ||
GOMidiReceiverType reveiverType, | ||
GOMidiShortcutReceiver *pShortcutReceiver = nullptr, | ||
GOMidiSender *pDivisionSender = nullptr); | ||
|
||
~GOMidiReceivingSendingObject(); | ||
|
||
virtual void LoadMidiObject( | ||
GOConfigReader &cfg, const wxString &group, GOMidiMap &midiMap) override; | ||
virtual void SaveMidiObject( | ||
GOConfigWriter &cfg, const wxString &group, GOMidiMap &midiMap) override; | ||
|
||
void PreparePlayback() override; | ||
|
||
void ProcessMidi(const GOMidiEvent &event) override; | ||
|
||
virtual void OnMatchedMidi( | ||
const GOMidiEvent &event, GOMidiMatchType matchType) | ||
= 0; | ||
|
||
public: | ||
virtual void SetElementId(int id) override; | ||
void SetPreconfigIndex(unsigned index); | ||
}; | ||
|
||
#endif /* GOMIDIRECEIVINGSENDINGOBJECT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters