This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
MIDIInputElementChannelPressure.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 
16  : public MIDIInputElement,
17  public DoublyLinkable<MIDIInputElementChannelPressure> {
18  public:
26  elements.append(this);
27  }
28 
35  elements.remove(this);
36  }
37 
38  static void beginAll() {
41  el.begin();
42  }
43 
50  static void resetAll() {
53  el.reset();
54  }
55 
59  static void updateAll() {
62  el.update();
63  }
64 
71  static void updateAllWith(const ChannelMessageMatcher &midimsg) {
73  if (e.updateWith(midimsg)) {
74  e.moveDown();
75  return;
76  }
77  // No mutex required:
78  // e.moveDown may alter the list, but if it does, it always returns,
79  // and we stop iterating, so it doesn't matter.
80  }
81 
82  private:
86  getTarget(const ChannelMessageMatcher &midimsg) const override {
87  return {0, Channel(midimsg.channel), midimsg.CN};
88  }
89 
96  void moveDown() {
98  elements.moveDown(this);
99  }
100 
102 #ifdef ESP32
103  static std::mutex mutex;
104 #endif
105 };
106 
107 #undef GUARD_LIST_LOCK
108 
ChannelMessageMatcher::CN
uint8_t CN
Definition: ChannelMessageMatcher.hpp:22
MIDIInputElementChannelPressure::resetAll
static void resetAll()
Reset all MIDIInputElementChannelPressure elements to their initial state.
Definition: MIDIInputElementChannelPressure.hpp:50
Channel
A type-safe class for MIDI channels.
Definition: Channel.hpp:13
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
GUARD_LIST_LOCK
#define GUARD_LIST_LOCK
Definition: MIDIInputElementChannelPressure.hpp:10
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
MIDIInputElementChannelPressure::MIDIInputElementChannelPressure
MIDIInputElementChannelPressure(const MIDICNChannelAddress &address)
Constructor.
Definition: MIDIInputElementChannelPressure.hpp:23
MIDIInputElementChannelPressure
Definition: MIDIInputElementChannelPressure.hpp:15
MIDIInputElementChannelPressure::moveDown
void moveDown()
Move down this element in the linked list of elements.
Definition: MIDIInputElementChannelPressure.hpp:96
MIDIInputElementChannelPressure::getTarget
MIDICNChannelAddress getTarget(const ChannelMessageMatcher &midimsg) const override
Channel Pressure doesn't have an address, so the target consists of just the channel and the cable nu...
Definition: MIDIInputElementChannelPressure.hpp:86
MIDIInputElementChannelPressure::elements
static DoublyLinkedList< MIDIInputElementChannelPressure > elements
Definition: MIDIInputElementChannelPressure.hpp:101
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
ChannelMessageMatcher::channel
uint8_t channel
Definition: ChannelMessageMatcher.hpp:19
MIDIInputElementChannelPressure::updateAllWith
static void updateAllWith(const ChannelMessageMatcher &midimsg)
Update all MIDIInputElementChannelPressure elements with a new MIDI message.
Definition: MIDIInputElementChannelPressure.hpp:71
DoublyLinkedList< MIDIInputElementChannelPressure >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:298
MIDIInputElementChannelPressure::updateAll
static void updateAll()
Update all MIDIInputElementChannelPressure elements.
Definition: MIDIInputElementChannelPressure.hpp:59
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
MIDIInputElementChannelPressure::~MIDIInputElementChannelPressure
virtual ~MIDIInputElementChannelPressure()
Destructor.
Definition: MIDIInputElementChannelPressure.hpp:33
MIDIInputElementChannelPressure::beginAll
static void beginAll()
Definition: MIDIInputElementChannelPressure.hpp:38
MIDIInputElement
A class for objects that listen for incoming MIDI events.
Definition: MIDIInputElement.hpp:15