tttapa/Control-Surface

Trying to setVelocity for all notebutton values in mux with piezo device

marlow77 opened this issue · 1 comments

Discussed in #959

Originally posted by marlow77 October 9, 2023
Hello,

I'm trying to do what is stated in this discussion:
#283

Specifically, I have a 4067 mux and a TTP223 touch sensor attached to one of the pins and had to invert the pins to read them, but it works great!

But then i wanted to add a piezo device to update the velocity for the mux values to create a midi button controller, but it gives me the following error:

error: request for member 'setVelocity' in 'buttons', which is of non-class type 'CS::Bankable::NoteButton [16]'
buttons.setVelocity(velocityInput.getValue());
^~~~~~~~~~~

exit status 1

Compilation error: request for member 'setVelocity' in 'buttons', which is of non-class type 'CS::Bankable::NoteButton [16]'

I looked in the code and NoteButtons has that setVelocity option, so I don't understand why it isn't working. Any help would be appreciated.

This is the full arduino code I have so far, and works if I remove the velocity section I took from the earlier post I referenced above.

`/**

  • @brief This is an example of the AnalogMultiplex class.
  • Connections

    • 9: CD74HC4067 address pin S0
    • 10: CD74HC4067 address pin S1
    • 11: CD74HC4067 address pin S2
    • 12: CD74HC4067 address pin S3
    • A0: CD74HC4067 signal pin ("common input/output")
  • Optionally you can connect the enable pin as well, this is useful
  • if you want to use multiple multiplexers with the same address
  • lines and the same analog input. Otherwise, just connect the enable
  • pin to ground.
  • If you are using a 3-bit multiplexer, like the CD74HC4051, you can
  • uncomment the code specific to this multiplexer, and only use three
  • address pins.
  • Behavior

  • Connect some potentiometers or other analog sensors to the 16 inputs
  • of the multiplexer, and open the serial monitor (CTRL+SHIFT+M) or the
  • serial plotter (CTRL+SHIFT+L). You should see all 16 signals printed
  • or plotted.
  • Written by Pieter P, 31-01-2019
  • https://github.com/tttapa/Control-Surface
    */

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

// Instantiate a MIDI over HairlessMIDI_Interface.

HairlessMIDI_Interface midi;

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

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

CD74HC4067 mux = {
T0, // analog pin
{19, 23, 18, 5}, // Address pins S0, S1, S2, S3
// 13, // Optionally, specify the enable pin
};

using namespace MIDI_Notes;

Bankable::NoteButton buttons[] = {
{transposer, mux.pin(0), {note(C, 2), CHANNEL_1}},
{transposer, mux.pin(1), {note(Db, 2), CHANNEL_1}},
{transposer, mux.pin(2), {note(D, 2), CHANNEL_1}},
{transposer, mux.pin(3), {note(Eb, 2), CHANNEL_1}},
{transposer, mux.pin(4), {note(E, 2), CHANNEL_1}},
{transposer, mux.pin(5), {note(F_, 2), CHANNEL_1}},
{transposer, mux.pin(6), {note(Gb, 2), CHANNEL_1}},
{transposer, mux.pin(7), {note(G, 2), CHANNEL_1}},
{transposer, mux.pin(8), {note(Ab, 2), CHANNEL_1}},
{transposer, mux.pin(9), {note(A, 2), CHANNEL_1}},
{transposer, mux.pin(10), {note(Bb, 2), CHANNEL_1}},
{transposer, mux.pin(11), {note(B, 2), CHANNEL_1}},
{transposer, mux.pin(12), {note(C, 3), CHANNEL_1}},
{transposer, mux.pin(13), {note(Db, 3), CHANNEL_1}},
{transposer, mux.pin(14), {note(D, 3), CHANNEL_1}},
{transposer, mux.pin(15), {note(Eb, 3), CHANNEL_1}},
};

// 7-bit filtered analog input for velocity control
FilteredAnalog<7> velocityInput = 35;

void setup() {
Serial.begin(115200);
Control_Surface.begin();
mux.begin(); // Initialize multiplexer
for (auto &button : buttons) // for each button in the buttons array
button.invert();
}

void loop() {

if (velocityInput.update())
buttons.setVelocity(velocityInput.getValue());
Control_Surface.loop();
}`

tttapa commented

Answered in #959.