Control Surface  1.2.0
MIDI Control Surface library for Arduino
MIDIInputElementChannelPressure.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 
22  : public MIDIInputElement,
23  public DoublyLinkable<MIDIInputElementChannelPressure> {
24  public:
32  elements.append(this);
33  }
34 
41  elements.remove(this);
42  }
43 
44  static void beginAll() {
47  el.begin();
48  }
49 
56  static void resetAll() {
59  el.reset();
60  }
61 
65  static void updateAll() {
68  el.update();
69  }
70 
77  static void updateAllWith(const ChannelMessageMatcher &midimsg) {
79  if (e.updateWith(midimsg)) {
80  e.moveDown();
81  return;
82  }
83  // No mutex required:
84  // e.moveDown may alter the list, but if it does, it always returns,
85  // and we stop iterating, so it doesn't matter.
86  }
87 
88  private:
91  MIDIAddress getTarget(const ChannelMessageMatcher &midimsg) const override {
92  return {
93  0,
94  Channel(midimsg.channel),
95  Cable(midimsg.CN),
96  };
97  }
98 
105  void moveDown() {
107  elements.moveDown(this);
108  }
109 
111 #ifdef ESP32
112  static std::mutex mutex;
113 #endif
114 };
115 
116 #undef GUARD_LIST_LOCK
117 
Channel
A type-safe class for MIDI channels.
Definition: Channel.hpp:13
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDIAddress.hpp:91
Cable
A type-safe class for MIDI USB Cable numbers.
Definition: Cable.hpp:13
MIDIInputElement::address
const MIDIAddress address
Definition: MIDIInputElement.hpp:83
MIDIInputElementChannelPressure::getTarget
MIDIAddress 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:91
ChannelMessageMatcher::CN
uint8_t CN
Definition: ChannelMessageMatcher.hpp:21
MIDIInputElement.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MIDIInputElementChannelPressure::updateAllWith
static void updateAllWith(const ChannelMessageMatcher &midimsg)
Update all MIDIInputElementChannelPressure elements with a new MIDI message.
Definition: MIDIInputElementChannelPressure.hpp:77
ChannelMessageMatcher
Struct for easily matching MIDI messages.
Definition: ChannelMessageMatcher.hpp:10
MIDIInputElementChannelPressure::~MIDIInputElementChannelPressure
virtual ~MIDIInputElementChannelPressure()
Destructor.
Definition: MIDIInputElementChannelPressure.hpp:39
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
LinkedList.hpp
GUARD_LIST_LOCK
#define GUARD_LIST_LOCK
Definition: MIDIInputElementChannelPressure.hpp:10
MIDIInputElementChannelPressure::MIDIInputElementChannelPressure
MIDIInputElementChannelPressure(const MIDIAddress &address)
Constructor.
Definition: MIDIInputElementChannelPressure.hpp:29
MIDIInputElementChannelPressure
Class for objects that listen for incoming MIDI Channel Pressure events.
Definition: MIDIInputElementChannelPressure.hpp:23
DoublyLinkedList::moveDown
void moveDown(Node *node)
Move down the given node in the linked list.
Definition: LinkedList.hpp:230
MIDIInputElementChannelPressure::moveDown
void moveDown()
Move down this element in the linked list of elements.
Definition: MIDIInputElementChannelPressure.hpp:105
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:198
MIDIInputElementChannelPressure::elements
static DoublyLinkedList< MIDIInputElementChannelPressure > elements
Definition: MIDIInputElementChannelPressure.hpp:110
DoublyLinkedList< MIDIInputElementChannelPressure >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:320
MIDIInputElementChannelPressure::resetAll
static void resetAll()
Reset all MIDIInputElementChannelPressure elements to their initial state.
Definition: MIDIInputElementChannelPressure.hpp:56
MIDIInputElementChannelPressure::beginAll
static void beginAll()
Definition: MIDIInputElementChannelPressure.hpp:44
MIDIInputElementChannelPressure::updateAll
static void updateAll()
Update all MIDIInputElementChannelPressure elements.
Definition: MIDIInputElementChannelPressure.hpp:65
ChannelMessageMatcher::channel
Channel channel
Definition: ChannelMessageMatcher.hpp:18
MIDIInputElement
A class for objects that listen for incoming MIDI events.
Definition: MIDIInputElement.hpp:15