Skip to content

Commit

Permalink
Deprecate more all-caps constants/enums
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Oct 14, 2023
1 parent 5acdb1c commit 9c4cdd4
Show file tree
Hide file tree
Showing 57 changed files with 842 additions and 832 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const int speedMultiplier = 1;
Bank<2> bank(4); // A bank with four channels, and 2 bank settings

Bankable::CCPotentiometer faders[] {
{{bank, BankType::CHANGE_CHANNEL}, A0, {MIDI_CC::Channel_Volume, Channel_1}},
{{bank, BankType::CHANGE_CHANNEL}, A1, {MIDI_CC::Channel_Volume, Channel_2}},
{{bank, BankType::CHANGE_CHANNEL}, A2, {MIDI_CC::Channel_Volume, Channel_3}},
{{bank, BankType::CHANGE_CHANNEL}, A3, {MIDI_CC::Channel_Volume, Channel_4}},
{{bank, BankType::ChangeChannel}, A0, {MIDI_CC::Channel_Volume, Channel_1}},
{{bank, BankType::ChangeChannel}, A1, {MIDI_CC::Channel_Volume, Channel_2}},
{{bank, BankType::ChangeChannel}, A2, {MIDI_CC::Channel_Volume, Channel_3}},
{{bank, BankType::ChangeChannel}, A3, {MIDI_CC::Channel_Volume, Channel_4}},
};

CCPotentiometer knobsTop[] {
Expand All @@ -61,17 +61,17 @@ CCPotentiometer knobsTop[] {
};

Bankable::CCPotentiometer knobsSide[] {
{{bank, BankType::CHANGE_CHANNEL}, A8, {MIDI_CC::Pan, Channel_1}},
{{bank, BankType::CHANGE_CHANNEL}, A9, {MIDI_CC::Pan, Channel_2}},
{{bank, BankType::CHANGE_CHANNEL}, A10, {MIDI_CC::Pan, Channel_3}},
{{bank, BankType::CHANGE_CHANNEL}, A11, {MIDI_CC::Pan, Channel_4}},
{{bank, BankType::ChangeChannel}, A8, {MIDI_CC::Pan, Channel_1}},
{{bank, BankType::ChangeChannel}, A9, {MIDI_CC::Pan, Channel_2}},
{{bank, BankType::ChangeChannel}, A10, {MIDI_CC::Pan, Channel_3}},
{{bank, BankType::ChangeChannel}, A11, {MIDI_CC::Pan, Channel_4}},
};

Bankable::NoteButtonLatching switches[] {
{{bank, BankType::CHANGE_ADDRESS}, 2, MCU::MUTE_1},
{{bank, BankType::CHANGE_ADDRESS}, 3, MCU::MUTE_2},
{{bank, BankType::CHANGE_ADDRESS}, 5, MCU::MUTE_3},
{{bank, BankType::CHANGE_ADDRESS}, 7, MCU::MUTE_4},
{{bank, BankType::ChangeAddress}, 2, MCU::MUTE_1},
{{bank, BankType::ChangeAddress}, 3, MCU::MUTE_2},
{{bank, BankType::ChangeAddress}, 5, MCU::MUTE_3},
{{bank, BankType::ChangeAddress}, 7, MCU::MUTE_4},
};

CCRotaryEncoder enc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
* Program Change Channel: 9 Data 1: 0x06
* Channel Pressure Channel: 3 Data 1: 0x40
* Pitch Bend Channel: 3 Data 1: 0x7f Data 2: 0x7f (16383)
* System Common MTC_QUARTER_FRAME Data 1: 0x2f
* System Common SONG_POSITION_POINTER Data 1: 0x10 Data 2: 0x4e (10000)
* System Common SONG_SELECT Data 1: 0x46
* System Common TUNE_REQUEST
* System Common MTCQuarterFrame Data 1: 0x2f
* System Common SongPositionPointer Data 1: 0x10 Data 2: 0x4e (10000)
* System Common SongSelect Data 1: 0x46
* System Common TuneRequest
* System Exclusive [10] F0 00 01 02 03 04 05 06 07 F7
* System Exclusive [6+] F0 10 11 12 13 14
* System Exclusive [6+] 15 16 17 18 19 1A
* System Exclusive [6] 1B 1C 1D 1E 1F F7
* Real-Time TIMING_CLOCK
* Real-Time START
* Real-Time CONTINUE
* Real-Time STOP
* Real-Time ACTIVE_SENSING
* Real-Time SYSTEM_RESET
* Real-Time TimingClock
* Real-Time Start
* Real-Time Continue
* Real-Time Stop
* Real-Time ActiveSensing
* Real-Time SystemReset
* ~~~
*
* @see @ref midi_md-sending "MIDI Tutorial: Sending MIDI messages"
Expand Down
32 changes: 16 additions & 16 deletions examples/5.Banks/Bank/Bank.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,50 +80,50 @@
// Instantiate a MIDI over USB interface
USBMIDI_Interface midi;

// Instantiate four Banks, with two tracks per bank.
// Instantiate four Banks, with two tracks per bank.
// Compare these numbers to the diagram above.
Bank<4> bank(2);
// │ └───── number of tracks per bank
// └───────────── number of banks

// Instantiate a Bank selector to control which one of the four Banks is active.
IncrementDecrementSelector<4> selector {
bank, // Bank to manage
{2, 3}, // push button pins (increment, decrement)
Wrap::Wrap, // Wrap around
bank, // Bank to manage
{2, 3}, // push button pins (increment, decrement)
Wrap::Wrap, // Wrap around
};

// Wrapping around means that if you're in Bank 4 and you press the increment
// Wrapping around means that if you're in Bank 4 and you press the increment
// button, you wrap back around to Bank 1. Similarly, if you're in Bank 1 and
// you press the decrement button, you wrap back around to Bank 4.
// The alternative to Wrap::Wrap is Wrap::Clamp. In that case, pressing the
// increment button when you're in Bank 4 won't do anything, you'll stay in
// Bank 4. If you're in Bank 1 and press the decrement button, you'll stay in
// The alternative to Wrap::Wrap is Wrap::Clamp. In that case, pressing the
// increment button when you're in Bank 4 won't do anything, you'll stay in
// Bank 4. If you're in Bank 1 and press the decrement button, you'll stay in
// Bank 1.

// Instantiate two potentiometers for the volume controls.
Bankable::CCPotentiometer potentiometer1 {
{bank, BankType::CHANGE_CHANNEL}, // bank configuration
{bank, BankType::ChangeChannel}, // bank configuration
A0, // analog pin
{MIDI_CC::Channel_Volume, Channel_1}, // address
};
Bankable::CCPotentiometer potentiometer2 {
{bank, BankType::CHANGE_CHANNEL}, // bank configuration
{bank, BankType::ChangeChannel}, // bank configuration
A1, // analog pin
{MIDI_CC::Channel_Volume, Channel_2}, // address
};

// The addresses specified here are the addresses for the first Bank.
// The addresses used in the other Banks are derived from these base addresses
// by adding the number of tracks of the bank to the base address.
// For example, in Bank 1, the first potentiometer will send on Channel 1,
// in Bank 2, the first potentiometer will send on Channel 1 + 2 = Channel 3,
// For example, in Bank 1, the first potentiometer will send on Channel 1,
// in Bank 2, the first potentiometer will send on Channel 1 + 2 = Channel 3,
// because 2 is the number of tracks in the Bank.
//
//
// The bank setting can affect the Channel (as in this example), the address, or
// the MIDI USB Cable Number. You can change this behavior by changing the
// BankType in the bank configuration above to `BankType::CHANGE_ADDRESS` or
// `BankType::CHANGE_CABLENB`.
// the MIDI USB Cable Number. You can change this behavior by changing the
// BankType in the bank configuration above to `BankType::ChangeAddress` or
// `BankType::ChangeCable`.

void setup() {
Control_Surface.begin(); // Initialize Control Surface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ Bank<4> bank;
IncrementDecrementSelector<4> selector {bank, {2, 3}};

// Handy type alias
using CCSmartPot = Bankable::CCSmartPotentiometer<4>;
using CCSmartPot = Bankable::CCSmartPotentiometer<4>;

// Instantiate a CCPotentiometer object
CCSmartPot potentiometer {
{bank, BankType::CHANGE_CHANNEL}, // Bank configuration
{bank, BankType::ChangeChannel}, // Bank configuration
A0, // Analog pin connected to potentiometer
{MIDI_CC::Channel_Volume, Channel_1}, // Channel volume of channel 1
};
Expand All @@ -70,7 +70,7 @@ CCSmartPot potentiometer {
*
* // Instantiate a CCPotentiometer object
* PBSmartPot potentiometer {
* {bank, BankType::CHANGE_CHANNEL}, // Bank configuration
* {bank, BankType::ChangeChannel}, // Bank configuration
* A0, // Analog pin connected to potentiometer
* Channel_1, // Channel 1
* };
Expand All @@ -88,7 +88,7 @@ void loop() {
// Turn on an LED to indicate that the potentiometer
// value is too low to be active
} else if (potentiometer.getState() == CCSmartPot::Higher) {
// Turn on an LED to indicate that the potentiometer
// Turn on an LED to indicate that the potentiometer
// value is too high to be active
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ IncrementSelector<4> selector {

// Instantiate a MyNoteButton object
MyNoteButton button {
{bank, BankType::CHANGE_ADDRESS}, // bank changes the note number (address)
5, // Push button on pin 5
{MIDI_Notes::C(2), Channel_1}, // Base address: Note C2 on MIDI channel 1
0x7F, // Maximum velocity
{bank, BankType::ChangeAddress}, // bank changes the note number (address)
5, // Push button on pin 5
{MIDI_Notes::C(2), Channel_1}, // Base address: Note C2 on MIDI channel 1
0x7F, // Maximum velocity
};

void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ USBMIDI_Interface midi;

// Custom MIDI Input Element to handle incoming note events and control the LEDs.
template <uint8_t RangeLen>
class CustomNoteLED : public MatchingMIDIInputElement<MIDIMessageType::NOTE_ON,
class CustomNoteLED : public MatchingMIDIInputElement<MIDIMessageType::NoteOn,
TwoByteRangeMIDIMatcher> {
public:
// Constructor
CustomNoteLED(CRGB *ledcolors, MIDIAddress address)
: MatchingMIDIInputElement<MIDIMessageType::NOTE_ON,
: MatchingMIDIInputElement<MIDIMessageType::NoteOn,
TwoByteRangeMIDIMatcher>({address, RangeLen}),
ledcolors(ledcolors) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CustomNoteLED
// you want to listen to MIDI Note events by specifying the MIDI message type,
// and use a simple 2-byte message matcher, since MIDI Note events have two
// data bytes.
: public MatchingMIDIInputElement<MIDIMessageType::NOTE_ON,
: public MatchingMIDIInputElement<MIDIMessageType::NoteOn,
TwoByteMIDIMatcher> {
public:
// Constructor
Expand Down Expand Up @@ -80,9 +80,9 @@ class CustomNoteLED

// Instantiate the LED that will light up when middle C is playing.
CustomNoteLED led {
3, // Pin with the LED connected (PWM capable)
3, // Pin with the LED connected (PWM capable)
{MIDI_Notes::C(4), Channel_1}, // Note C4 on MIDI channel 1
10, // Intensity when off
10, // Intensity when off
};

void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ void loop() {
static Timer<millis> timer {1000};
if (timer)
// As an example, send a MIDI timing clock message every second.
Control_Surface.sendRealTime(MIDIMessageType::TIMING_CLOCK);
Control_Surface.sendRealTime(MIDIMessageType::TimingClock);
Control_Surface.loop();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ EncoderSelector<120> selector {
// The potentiometer that sends MIDI messages
// the address (controller number) depends on the bank setting
Bankable::CCPotentiometer potentiometer {
{bank, BankType::CHANGE_ADDRESS}, // Bank configuration
A0, // Analog pin for potentiometer
{0x00, Channel_1}, // Base CC address
{bank, BankType::ChangeAddress}, // Bank configuration
A0, // Analog pin for potentiometer
{0x00, Channel_1}, // Base CC address
};

void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ IncrementDecrementSelectorLEDs<4> bankSelector {

using namespace MIDI_CC;
Bankable::CCPotentiometer potentiometers[] {
{{bank, BankType::CHANGE_CHANNEL}, A0, {Channel_Volume, Channel_1}},
{{bank, BankType::CHANGE_CHANNEL}, A1, {Channel_Volume, Channel_2}},
{{bank, BankType::CHANGE_CHANNEL}, A2, {Sound_Controller_3, Channel_3}},
{{bank, BankType::CHANGE_CHANNEL}, A3, {Sound_Controller_4, Channel_4}},
{{bank, BankType::CHANGE_CHANNEL}, A4, {Sound_Controller_5, Channel_5}},
{{bank, BankType::CHANGE_CHANNEL}, A5, {Sound_Controller_6, Channel_6}},
{{bank, BankType::CHANGE_CHANNEL}, A6, {Effects_1, Channel_7}},
{{bank, BankType::CHANGE_CHANNEL}, A7, {Effects_2, Channel_8}},
{{bank, BankType::CHANGE_CHANNEL}, A8, {Effects_3, Channel_9}},
{{bank, BankType::CHANGE_CHANNEL}, A9, {Effects_4, Channel_10}},
{{bank, BankType::CHANGE_CHANNEL}, A10, {Effect_Control_1, Channel_11}},
{{bank, BankType::CHANGE_CHANNEL}, A11, {Effect_Control_2, Channel_12}},
{{bank, BankType::ChangeChannel}, A0, {Channel_Volume, Channel_1}},
{{bank, BankType::ChangeChannel}, A1, {Channel_Volume, Channel_2}},
{{bank, BankType::ChangeChannel}, A2, {Sound_Controller_3, Channel_3}},
{{bank, BankType::ChangeChannel}, A3, {Sound_Controller_4, Channel_4}},
{{bank, BankType::ChangeChannel}, A4, {Sound_Controller_5, Channel_5}},
{{bank, BankType::ChangeChannel}, A5, {Sound_Controller_6, Channel_6}},
{{bank, BankType::ChangeChannel}, A6, {Effects_1, Channel_7}},
{{bank, BankType::ChangeChannel}, A7, {Effects_2, Channel_8}},
{{bank, BankType::ChangeChannel}, A8, {Effects_3, Channel_9}},
{{bank, BankType::ChangeChannel}, A9, {Effects_4, Channel_10}},
{{bank, BankType::ChangeChannel}, A10, {Effect_Control_1, Channel_11}},
{{bank, BankType::ChangeChannel}, A11, {Effect_Control_2, Channel_12}},
};

Bankable::NoteButton muteButtons[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ USBMIDI_Interface midi;

bool channelMessageCallback(ChannelMessage cm) {
MIDIMessageType type = cm.getMessageType();
if (type == MIDIMessageType::NOTE_ON || type == MIDIMessageType::NOTE_OFF) {
if (type == MIDIMessageType::NoteOn || type == MIDIMessageType::NoteOff) {
Serial << hex << cm.header << ' ' << cm.data1 << ' ' << cm.data2 << dec
<< "\t(" << MCU::getMCUNameFromNoteNumber(cm.data1) << ")"
<< F(" on cable ") << cm.cable.getOneBased() << endl;
Expand Down
13 changes: 8 additions & 5 deletions src/Banks/BankConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ enum BankType {
* @brief Change the offset of the address (i.e. Controller number or
* Note number) of the element.
*/
CHANGE_ADDRESS = 0,
ChangeAddress = 0,
CHANGE_ADDRESS CS_DEPREC("Use ChangeAddress instead") = ChangeAddress,
/**
* @brief Change the offset of the channel number of the element.
*/
CHANGE_CHANNEL = 1,
ChangeChannel = 1,
CHANGE_CHANNEL CS_DEPREC("Use ChangeChannel instead") = ChangeChannel,
/**
* @brief Change the offset of the cable number of the element.
*/
CHANGE_CABLENB = 2,
ChangeCable = 2,
CHANGE_CABLENB CS_DEPREC("Use ChangeCable instead") = ChangeCable,
};

template <setting_t NumBanks>
Expand All @@ -47,7 +50,7 @@ class BaseBankConfig {
};

/// @copydoc BaseBankConfig
template <setting_t N, BankType DefaultBankType = BankType::CHANGE_ADDRESS>
template <setting_t N, BankType DefaultBankType = BankType::ChangeAddress>
struct BankConfig : BaseBankConfig<N> {
BankConfig(Bank<N> &bank, BankType type = DefaultBankType)
: BaseBankConfig<N>(bank, type) {}
Expand All @@ -72,7 +75,7 @@ class BaseOutputBankConfig {
};

/// @copydoc BaseOutputBankConfig
template <BankType DefaultBankType = BankType::CHANGE_ADDRESS>
template <BankType DefaultBankType = BankType::ChangeAddress>
struct OutputBankConfig : BaseOutputBankConfig {
OutputBankConfig(OutputBank &bank, BankType type = DefaultBankType)
: BaseOutputBankConfig(bank, type) {}
Expand Down
16 changes: 8 additions & 8 deletions src/Banks/BankableAddresses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OutputBankableMIDIAddress_Base {
* is returned.
*/
setting_t getSelection() const {
return lockedSetting == UNLOCKED ? getRawBankSetting() : lockedSetting;
return lockedSetting == Unlocked ? getRawBankSetting() : lockedSetting;
}

/**
Expand All @@ -46,7 +46,7 @@ class OutputBankableMIDIAddress_Base {
* independent from the actual bank setting.
*/
void lock() {
if (lockedSetting == UNLOCKED)
if (lockedSetting == Unlocked)
lockedSetting = getRawBankSetting();
}

Expand All @@ -56,14 +56,14 @@ class OutputBankableMIDIAddress_Base {
* After unlocking, @ref getSelection will return the actual bank setting
* again.
*/
void unlock() { lockedSetting = UNLOCKED; }
void unlock() { lockedSetting = Unlocked; }

protected:
const OutputBank &bank;

private:
constexpr static setting_t UNLOCKED = NO_SETTING;
setting_t lockedSetting = UNLOCKED;
constexpr static setting_t Unlocked = NoSetting;
setting_t lockedSetting = Unlocked;
};

/**
Expand Down Expand Up @@ -112,9 +112,9 @@ class OutputBankableMIDIAddress : public OutputBankableMIDIAddress_Base {
RelativeMIDIAddress getAddressOffset(setting_t bankindex) const {
int8_t offset = bank.getOffsetOfSetting(bankindex);
switch (type) {
case CHANGE_ADDRESS: return {offset, 0, 0};
case CHANGE_CHANNEL: return {0, offset, 0};
case CHANGE_CABLENB: return {0, 0, offset};
case ChangeAddress: return {offset, 0, 0};
case ChangeChannel: return {0, offset, 0};
case ChangeCable: return {0, 0, offset};
default: return {};
}
}
Expand Down
Loading

0 comments on commit 9c4cdd4

Please sign in to comment.