tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.26k stars 140 forks source link

no_channel to stop output doesn't work and reverts to channel 1 on MCU from example One-Pot-Both-PB-and-CC #709

Closed gringow831 closed 2 years ago

gringow831 commented 2 years ago

Hi Pieter, I have used the example of One-Pot-Both-PB-and-CC to try stopping t the output of the channel so the Potentiometer doesn't act but whenever on MCU I can't make that happen... All I have whenever I change to the second address is the potentiometer reverting to Channel 1 for some reason instead of having no output. I can't seem to find the solution to this. The no_address function doesn't work when PBPotentiometer, just the no_channel so can't try using that one as it doesn't compile.

Bank<2> bank2(4);
IncrementSelector<2> bankSelector2 = {bank2, 3};

constexpr auto no_address = [MIDIAddress::invalid];
constexpr auto no_channel = [MIDIChannelCable::invalid];

Bankable::ManyAddresses::PBPotentiometer<2> faders[] {
  {bank, 14, {{{MCU::VOLUME_2, CABLE_2}, {no_channel}, }}},
 {bank, 15, {{{MCU::VOLUME_3, CABLE_2}, {MCU::VOLUME_3, CABLE_1}, }}},
};

The error message when using no_address is this. The error message I have on this Trial :102: error: could not convert '{bank, 14, {{{CS::MCU::VOLUME_2, CS::CABLE_2}, {no_address}}}}' from '' to 'CS::Bankable::ManyAddresses::PBPotentiometer<2u>' }; ^ could not convert '{bank, 14, {{{CS::MCU::VOLUME_2, CS::CABLE_2}, {no_address}}}}' from '' to 'CS::Bankable::ManyAddresses::PBPotentiometer<2u>'

tttapa commented 2 years ago
constexpr auto no_address = [MIDIAddress::invalid];
constexpr auto no_channel = [MIDIChannelCable::invalid];

Why are there square brackets around the right-hand sides?

MIDIAddress::invalid() is a function, you have to call it:

constexpr auto no_address = MIDIAddress::invalid();
gringow831 commented 2 years ago

not what I have on my code. It was a mistake when copying the part from the one-pot-both-pb-and-cc example website

gringow831 commented 2 years ago

I reduced the whole script to the minimum trying to troubleshoot why when no_channel is on PBpotentiometer if on MCU it reverts to VOLUME_1 instead of invalidating the output of that potentiometer. This is the minimum script and still have an output after I change to the second ManyAddresses.

#include <Control_Surface.h>

USBMIDI_Interface midi;

constexpr auto no_address = MIDIAddress::invalid();
constexpr auto no_channel = MIDIChannelCable::invalid();

Bank<2> bank2(1);

IncrementSelector<2> bankSelector2 = {bank2, 3};

Bankable::ManyAddresses::PBPotentiometer<2> faderbanks2plus[] {
  {bank2, 19, {MCU::VOLUME_8, no_channel}},
};

void setup() {
  RelativeCCSender::setMode(MACKIE_CONTROL_RELATIVE);
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

As before, just in case, I tried using the no_address but it doesn't let me compile it. When I use NoteButton it works invalidating the button but not when it's a PBPotentiometer over MCU.

To check the output I use MIDI Monitor

gringow831 commented 2 years ago

Hi Pieter,

I went for a different approach by separating the banks and using a variable in the loop to disable and enable them according to the needs with a button that I already have set.

One more question if you don't mind. I have 4 banks wich they will be indicated by 2 LED to know where I am. All banks going around with just one IncrementSelector Button.

Bank 1 should show LED1 Bank 2 should show LED2 Bank 3 Showing LED1 and LED2 together. Bank 4 turning them off.

Is there a way to approach this? At first I used Custom-Selector-Callback but it doesn't seem I can use it for this. I looked into #364, #367, #268 and #136 although not being a programmer not sure how I can show 2 LEDs "HIGH" for Bank3.

Can you point me in the right direction?