joshnishikawa / MIDIcontroller

A library for creating Teensy MIDI controllers with support for hold or latch buttons, potentiometers, encoders, capacitive sensors, Piezo transducers and other velocity sensitive inputs with aftertouch.
223 stars 19 forks source link

enable to have a initiale value of MIDIPot #19

Closed mrbbp closed 2 years ago

mrbbp commented 2 years ago

Hello sorry for this certainly basic question.

I try to send the initial value of MIDIPot (without any manipulation) when teensy received a noteOn event

void setup() {
  usbMIDI.setHandleNoteOn(OnNoteOn);
}

void OnNoteOn(byte channel, byte note, byte velocity) {
  digitalWrite(13, HIGH); // Any Note-On turns on LED
  for (int i = 0;  i < ANALOG_PINS_NBR; i++) {
    Pots[i]->send(); // notice the -> operator  
    delay(50);
  }
  digitalWrite(13, LOW); // Any Note-On turns on LED
}

The led HIGH and LOW, but i do not received any value from midi. What i'm doing wrong? Do i have to read value with analogRead(APin)or have you a trick to send value?

Oh and sorry to forget... Great job! thanks

regards

mrbbp commented 2 years ago

I tried with read() and send(), but no more return. if i turn the pot i received value

joshnishikawa commented 2 years ago

I think I understand part of what you want to do...You want to bulk send the values of the pots to the DAW? The library doesn't currently handle that but it needs to. Bulk send really needs to be implemented. Give me a couple of days and I'll push an update.

It's interesting that you want to do the bulk send on Note ON...

mrbbp commented 2 years ago

I do not use it with synth. ;) I use midi controller with Processing.org code, to generate graphics... controlChange or noteOn or noteOff, is the same for me. it's just a Bang. :) I use themidibus lib to play with midi in Processing.org in my mind, use a noteOn/Off is more standard than control

I will be wise and I will wait for the update

joshnishikawa commented 2 years ago

Okay, I just pushed version 2.5.3 which includes an option to pass a boolean to the send function. Now you should be able to use Pots[i]->send(FORCE) to have a controller send its current value programmatically. This will work for MIDIpot, MIDIenc, MIDItouch and MIDIswitch (AKA MIDIbutton) classes. Please let me know if it works for you.

mrbbp commented 2 years ago

Thank you very much.

i love the way you do this. It works like a charm!