Selecter, Banking and Multiplexers

Hi, while searching for information on Control-Surface.h I came across this sketch

/**
 * Mapping
 * -------
 * 
 * Route the Arduino MIDI port into a synth to play the notes.
 * 
 * Written by PieterP, 2019-10-26  
 * https://github.com/tttapa/Control-Surface
 */

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

// Instantiate four Banks, with twelve tracks per bank (12 semitones = 1 octave).
Bank<2> bank(12);

// Instantiate a Bank selector to control which one of the four Banks is active.
IncrementDecrementSelector<2> bankSelector {bank, {28, 29}, Wrap::Wrap};

// instantiate a transposer that can transpose from one octave down to one
// octave up
Transposer<-2, +2> transposer(12);

// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector {
  transposer,
  {27, 26},
  Wrap::Wrap,
};

// Instantiate an array of Bankable::NoteButton objects
Bankable::NoteButton buttons[] {
  {transposer, 14, MIDI_Notes::C(4)},
  {transposer, 15, MIDI_Notes::Db(4)},
  {transposer, 16, MIDI_Notes::D(4)},
  {transposer, 17, MIDI_Notes::Eb(4)},
  {transposer, 18, MIDI_Notes::E(4)},
  {transposer, 19, MIDI_Notes::F_(4)},
  {transposer, 20, MIDI_Notes::Gb(4)},
  {transposer, 21, MIDI_Notes::G(4)},
  {transposer, 22, MIDI_Notes::Ab(4)},
  {transposer, 23, MIDI_Notes::A(4)},
  {transposer, 24, MIDI_Notes::Bb(4)},
  {transposer, 25, MIDI_Notes::B(4)},
};

using namespace MIDI_Notes;
Bankable::NoteChordButton chordbuttons[] = {
  {bank, 14, {MIDI_Notes::C(4), CHANNEL_1}, Bass::Double + Chords::Major},
  {bank, 16, {MIDI_Notes::D(4), CHANNEL_1}, Bass::Double + Chords::Minor},
  {bank, 18, {MIDI_Notes::E(4), CHANNEL_1}, Bass::Double + Chords::Minor},
  {bank, 19, {MIDI_Notes::F_(4), CHANNEL_1}, Bass::Double + Chords::MajorFirstInv},
  {bank, 21, {MIDI_Notes::G(4), CHANNEL_1}, Bass::Double + Chords::MajorSecondInv},
  {bank, 23, {MIDI_Notes::A(4), CHANNEL_1}, Bass::Double + Chords::MinorSecondInv},
  {bank, 25, {MIDI_Notes::B(4), CHANNEL_1}, Bass::Double + Chords::Diminished},
};


void setup() {
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}

My questions are how can this be adapted to use with the CD74HC4067
multiplexer? And where can I find the documentation on the transposer and banking functions? Is there a tutorial?

Check the library on github.

Instantiate a multiplexer as shown in Control Surface: Getting Started, and then replace the hard-coded pin numbers in the NoteButton initialization by mux.pin(n).

And where can I find the documentation on the transposer and banking functions? Is there a tutorial?

Thank you Peter. I found it quite an ordeal searching the documentation, it is vast. :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.