Control Surface new-input
MIDI Control Surface library for Arduino
BankAddresses.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "BankableAddresses.hpp"
4 
6 
7 namespace Bankable {
8 
10  public:
13 
14  MIDIAddress getBaseAddress() const { return address; }
15 
17  return getBaseAddress() + getAddressOffset();
18  }
19 
20  private:
22 };
23 
24 template <uint8_t N>
26  public:
29  : banks(banks), address(address) {}
30 
31  MIDIAddress getBaseAddress() const { return address; }
32 
34  auto address = getBaseAddress();
35  for (const OutputBankableMIDIAddress &bank : banks)
36  address += bank.getAddressOffset();
37  return address;
38  }
39 
40  void lock() {
41  for (OutputBankableMIDIAddress &bank : banks)
42  bank.lock();
43  }
44 
45  void unlock() {
46  for (OutputBankableMIDIAddress &bank : banks)
47  bank.unlock();
48  }
49 
50  private:
53 };
54 
56  public:
58  const Array<MIDIAddress, 2> &addresses)
59  : OutputBankableMIDIAddress(config), first(addresses[0]),
60  second(addresses[1]) {}
61 
64 
67  }
70  }
71 
72  private:
74 };
75 
76 template <uint8_t NumRows, uint8_t NumCols>
78  public:
84 
85  uint8_t getBaseAddress(uint8_t row, uint8_t col) const {
86  return addresses[row][col];
87  }
88 
89  MIDIAddress getActiveAddress(uint8_t row, uint8_t col) const {
90  MIDIAddress address = {getBaseAddress(row, col), channelCN};
91  return address + getAddressOffset();
92  }
93 
94  private:
97 };
98 
99 namespace ManyAddresses {
100 
105 template <uint8_t NumBanks>
107  public:
119 
121 
122  private:
124 };
125 
130 template <uint8_t NumBanks>
132  public:
134  const Array2D<MIDIAddress, 2, NumBanks> &addresses)
135  : ManyAddresses_Base(bank), first{addresses[0]}, second{addresses[1]} {}
136 
139  return second[getSelection()];
140  }
141 
142  private:
144 };
145 
146 template <uint8_t NumBanks, uint8_t NumRows, uint8_t NumCols>
148  public:
150  const Bank<NumBanks> &bank,
155 
156  MIDIAddress getActiveAddress(uint8_t row, uint8_t col) const {
157  return {addresses[getSelection()][row][col],
159  }
160 
161  private:
164 };
165 
166 } // namespace ManyAddresses
167 } // namespace Bankable
168 
Array2D< uint8_t, NumRows, NumCols > AddressMatrix
Definition: Def.hpp:28
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class that groups Bankable MIDI Output Elements and Bankable MIDI Input Elements,...
Definition: Bank.hpp:91
DualAddresses(BaseOutputBankConfig config, const Array< MIDIAddress, 2 > &addresses)
MIDIAddress getFirstActiveAddress() const
MIDIAddress getSecondBaseAddress() const
MIDIAddress getFirstBaseAddress() const
MIDIAddress getSecondActiveAddress() const
DualManyAddresses(const Bank< NumBanks > &bank, const Array2D< MIDIAddress, 2, NumBanks > &addresses)
Array< MIDIAddress, NumBanks > first
Array< MIDIAddress, NumBanks > second
Array< MIDIAddress, NumBanks > addresses
ManyAddresses(const Bank< NumBanks > &bank, const Array< MIDIAddress, NumBanks > &addresses)
Constructor.
Array< AddressMatrix< NumRows, NumCols >, NumBanks > addresses
ManyMatrixAddresses(const Bank< NumBanks > &bank, const Array< AddressMatrix< NumRows, NumCols >, NumBanks > &addresses, const Array< MIDIChannelCable, NumBanks > &channelCNs)
MIDIAddress getActiveAddress(uint8_t row, uint8_t col) const
Array< MIDIChannelCable, NumBanks > channelCNs
AddressMatrix< NumRows, NumCols > addresses
MIDIAddress getActiveAddress(uint8_t row, uint8_t col) const
uint8_t getBaseAddress(uint8_t row, uint8_t col) const
MIDIChannelCable channelCN
MatrixAddress(BaseOutputBankConfig config, const AddressMatrix< NumRows, NumCols > &addresses, MIDIChannelCable channelCN)
Array< OutputBankableMIDIAddress, N > banks
SingleAddressMultipleBanks(const Array< OutputBankableMIDIAddress, N > &banks, MIDIAddress address)
MIDIAddress getBaseAddress() const
SingleAddress(BaseOutputBankConfig config, MIDIAddress address)
MIDIAddress getActiveAddress() const
A struct for selecting the bank of BankableMIDIOutputs and the bank type.
Definition: BankConfig.hpp:60
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
A class for saving a MIDI channel and cable number.
Definition: MIDIAddress.hpp:24
A base class for all MIDIOutputElements that can have one of many addresses.
setting_t getSelection() const
Get the bank setting.
A base class for all MIDIOutputElements that can be banked.
RelativeMIDIAddress getAddressOffset() const
Get the offset relative to the base address.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
An array wrapper for easy copying, comparing, and iterating.
Definition: Array.hpp:36