Control Surface  1.2.0
MIDI Control Surface library for Arduino
MIDIInputElementNote.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "MIDIInputElement.hpp"
5 
6 #if defined(ESP32)
7 #include <mutex>
8 #define GUARD_LIST_LOCK std::lock_guard<std::mutex> guard_(mutex)
9 #else
10 #define GUARD_LIST_LOCK
11 #endif
12 
14 
21  public DoublyLinkable<MIDIInputElementNote> {
22  // public AH::UpdatableCRTP<MIDIInputElementNote> {
23  protected:
31  elements.append(this);
32  }
33 
34  public:
41  elements.remove(this);
42  }
43 
49  static void beginAll() {
52  e.begin();
53  }
54 
60  static void updateAll() {
63  e.update();
64  }
65 
71  static void resetAll() {
74  e.reset();
75  // MIDIInputElementNote::applyToAll(&MIDIInputElementNote::reset);
76  }
77 
84  static void updateAllWith(const ChannelMessageMatcher &midimsg) {
86  if (e.updateWith(midimsg)) {
87  e.moveDown();
88  return;
89  }
90  // No mutex required:
91  // e.moveDown may alter the list, but if it does, it always returns,
92  // and we stop iterating, so it doesn't matter.
93  }
94 
95  private:
102  void moveDown() {
104  elements.moveDown(this);
105  }
106 
108 #ifdef ESP32
109  static std::mutex mutex;
110 #endif
111 };
112 
113 #undef GUARD_LIST_LOCK
114 
MIDIInputElementNote::MIDIInputElementNote
MIDIInputElementNote(const MIDIAddress &address)
Constructor.
Definition: MIDIInputElementNote.hpp:28
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDIAddress.hpp:91
MIDIInputElementNote
Class for objects that listen for incoming MIDI Note events.
Definition: MIDIInputElementNote.hpp:21
MIDIInputElement::address
const MIDIAddress address
Definition: MIDIInputElement.hpp:83
GUARD_LIST_LOCK
#define GUARD_LIST_LOCK
Definition: MIDIInputElementNote.hpp:10
Updatable.hpp
MIDIInputElementNote::beginAll
static void beginAll()
Initialize all MIDIInputElementNote elements.
Definition: MIDIInputElementNote.hpp:49
MIDIInputElementNote::elements
static DoublyLinkedList< MIDIInputElementNote > elements
Definition: MIDIInputElementNote.hpp:107
MIDIInputElement.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
ChannelMessageMatcher
Struct for easily matching MIDI messages.
Definition: ChannelMessageMatcher.hpp:10
DoublyLinkedList::append
void append(Node *node)
Append a node to a linked list.
Definition: LinkedList.hpp:115
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDIInputElementNote::resetAll
static void resetAll()
Reset all MIDIInputElementNote elements to their initial state.
Definition: MIDIInputElementNote.hpp:71
MIDIInputElementNote::~MIDIInputElementNote
virtual ~MIDIInputElementNote()
Destructor.
Definition: MIDIInputElementNote.hpp:39
MIDIInputElementNote::updateAllWith
static void updateAllWith(const ChannelMessageMatcher &midimsg)
Update all MIDIInputElementNote elements with a new MIDI message.
Definition: MIDIInputElementNote.hpp:84
DoublyLinkedList::moveDown
void moveDown(Node *node)
Move down the given node in the linked list.
Definition: LinkedList.hpp:230
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:198
MIDIInputElementNote::moveDown
void moveDown()
Move down this element in the linked list of elements.
Definition: MIDIInputElementNote.hpp:102
DoublyLinkedList< MIDIInputElementNote >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:320
MIDIInputElementNote::updateAll
static void updateAll()
Update all MIDIInputElementNote elements.
Definition: MIDIInputElementNote.hpp:60
MIDIInputElement
A class for objects that listen for incoming MIDI events.
Definition: MIDIInputElement.hpp:15