This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
MIDIInputElementNote.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "MIDIInputElement.hpp"
4 #include <Helpers/LinkedList.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 
MIDIInputElementNote::MIDIInputElementNote
MIDIInputElementNote(const MIDICNChannelAddress &address)
Constructor.
Definition: MIDIInputElementNote.hpp:27
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
DoublyLinkedList::append
void append(Node *node)
Append a node to a linked list.
Definition: LinkedList.hpp:113
MIDIInputElement.hpp
ChannelMessageMatcher
Struct for easily matching MIDI messages.
Definition: ChannelMessageMatcher.hpp:10
LinkedList.hpp
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:196
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
MIDIInputElementNote::elements
static DoublyLinkedList< MIDIInputElementNote > elements
Definition: MIDIInputElementNote.hpp:105
MIDIInputElementNote::moveDown
void moveDown()
Move down this element in the linked list of elements.
Definition: MIDIInputElementNote.hpp:100
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
MIDIInputElementNote::updateAll
static void updateAll()
Update all MIDIInputElementNote elements.
Definition: MIDIInputElementNote.hpp:59
DoublyLinkedList< MIDIInputElementNote >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:298
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
DoublyLinkedList::moveDown
void moveDown(Node *node)
Move down the given node in the linked list.
Definition: LinkedList.hpp:228
MIDIInputElement
A class for objects that listen for incoming MIDI events.
Definition: MIDIInputElement.hpp:15
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