Control Surface  1.1.1
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  protected:
30  elements.append(this);
31  }
32 
33  public:
40  elements.remove(this);
41  }
42 
48  static void beginAll() {
51  e.begin();
52  }
53 
59  static void updateAll() {
62  e.update();
63  }
64 
70  static void resetAll() {
73  e.reset();
74  }
75 
82  static void updateAllWith(const ChannelMessageMatcher &midimsg) {
84  if (e.updateWith(midimsg)) {
85  e.moveDown();
86  return;
87  }
88  // No mutex required:
89  // e.moveDown may alter the list, but if it does, it always returns,
90  // and we stop iterating, so it doesn't matter.
91  }
92 
93  private:
100  void moveDown() {
102  elements.moveDown(this);
103  }
104 
106 #ifdef ESP32
107  static std::mutex mutex;
108 #endif
109 };
110 
111 #undef GUARD_LIST_LOCK
112 
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
MIDIInputElementNote
Class for objects that listen for incoming MIDI Note events.
Definition: MIDIInputElementNote.hpp:20
GUARD_LIST_LOCK
#define GUARD_LIST_LOCK
Definition: MIDIInputElementNote.hpp:10
MIDIInputElementNote::beginAll
static void beginAll()
Initialize all MIDIInputElementNote elements.
Definition: MIDIInputElementNote.hpp:48
MIDIInputElementNote::elements
static DoublyLinkedList< MIDIInputElementNote > elements
Definition: MIDIInputElementNote.hpp:105
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:117
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
LinkedList.hpp
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
MIDIInputElementNote::resetAll
static void resetAll()
Reset all MIDIInputElementNote elements to their initial state.
Definition: MIDIInputElementNote.hpp:70
MIDIInputElementNote::~MIDIInputElementNote
virtual ~MIDIInputElementNote()
Destructor.
Definition: MIDIInputElementNote.hpp:38
MIDIInputElementNote::updateAllWith
static void updateAllWith(const ChannelMessageMatcher &midimsg)
Update all MIDIInputElementNote elements with a new MIDI message.
Definition: MIDIInputElementNote.hpp:82
DoublyLinkedList::moveDown
void moveDown(Node *node)
Move down the given node in the linked list.
Definition: LinkedList.hpp:232
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:200
MIDIInputElementNote::moveDown
void moveDown()
Move down this element in the linked list of elements.
Definition: MIDIInputElementNote.hpp:100
DoublyLinkedList< MIDIInputElementNote >
MIDIInputElementNote::MIDIInputElementNote
MIDIInputElementNote(const MIDICNChannelAddress &address)
Constructor.
Definition: MIDIInputElementNote.hpp:27
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:302
MIDIInputElementNote::updateAll
static void updateAll()
Update all MIDIInputElementNote elements.
Definition: MIDIInputElementNote.hpp:59
MIDIInputElement
A class for objects that listen for incoming MIDI events.
Definition: MIDIInputElement.hpp:15