Giter VIP home page Giter VIP logo

midicontroller's People

Contributors

joshnishikawa avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

midicontroller's Issues

Encoder buttons

Hi Josh,

I'm building a MIDI controller for personal use and found your library. It works nicely, thank you for your effort! I was wondering if it would be possible to program an encoder to send a note (button) when a knob (encoder) is turned? It could be handy for example programming scrolling or selecting channel in DAW, if needed.

Teensy LC support

Hi, would i be able to use an LC with this lib?

I want to create a usb midi keyboard to midi DIN converter.

'elapsedMillis' does not name a type Error

Greetings,
Have been trying to use this library but haven't able to get any of the examples to compile, I keep getting this error;

``Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino Leonardo"

In file included from C:\Users\user\Documents\Arduino\libraries\Flicker-master/Flicker.h:41:0,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIbutton.h:6,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIcontroller.h:5,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master\examples\afterTouch\afterTouch.ino:1:

C:\Users\user\Documents\Arduino\libraries\Flicker-master/TouchSwitch.h:63:5: error: 'elapsedMillis' does not name a type

 elapsedMillis held_millis = 0;

 ^~~~~~~~~~~~~

In file included from C:\Users\user\Documents\Arduino\libraries\Flicker-master/Flicker.h:43:0,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIbutton.h:6,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIcontroller.h:5,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master\examples\afterTouch\afterTouch.ino:1:

C:\Users\user\Documents\Arduino\libraries\Flicker-master/TouchVelocity.h:66:5: error: 'elapsedMicros' does not name a type

 elapsedMicros timer;

 ^~~~~~~~~~~~~

In file included from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIcontroller.h:9:0,

             from C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master\examples\afterTouch\afterTouch.ino:1:

C:\Users\user\Documents\Arduino\libraries\MIDIcontroller-master/MIDIdrum.h:20:5: error: 'elapsedMillis' does not name a type

 elapsedMillis timer;

 ^~~~~~~~~~~~~``

I'm not sure how to fix it, I have all the appropriate libraries installed?
Any help would be immensely appreciated, this library looks like a lot of fun to play with if I can get it working :)

Regards
-Jim Foster

Encoder count limit?

Forgive the likely noob question, but I'm using your library for a box that controls FX sends.

My misunderstanding of encoders is this. When the encoder is turned past the range of CC (127 in this case), it keeps track of these turns. Oftentimes it means (that many turns beyond 127) counter-clockwise turns are required to start sending negative CC values. Is there a way to stop it from counting beyond the CC range? So it begins counting down immediately from a counter-clockwise turn, and vice versa?

Thanks!

3.1.0 Sensitivity

I've starting working with my multi drum sketch again with Version 3.1.0. When I uploaded the new Library, I got the warning below which looked like i was trying to access a parameter that was private ? ( sensitivity )

``In file included from /Users/chrisryan/Documents/Arduino/libraries/MIDIcontroller/src/MIDIcontroller.h:9:0,
from /Users/chrisryan/Documents/Arduino/de_FSR_USB_Module_Sensi/de_FSR_USB_Module_Sensi.ino:1:
/Users/chrisryan/Documents/Arduino/libraries/MIDIcontroller/src/MIDIdrum.h: In function 'void setup()':
/Users/chrisryan/Documents/Arduino/libraries/MIDIcontroller/src/MIDIdrum.h:12:9: error: 'int MIDIdrum::sensitivity' is private
int sensitivity;
^
/Users/chrisryan/Documents/Arduino/de_FSR_USB_Module_Sensi/de_FSR_USB_Module_Sensi.ino:39:7: error: within this context
Pad0.sensitivity(80);
^
/Users/chrisryan/Documents/Arduino/de_FSR_USB_Module_Sensi/de_FSR_USB_Module_Sensi.ino:39:21: error: expression cannot be used as a function
Pad0.sensitivity(80);
^
Multiple libraries were found for "Bounce2.h"
Used: /Users/chrisryan/Documents/Arduino/libraries/Bounce2
Not used: /Users/chrisryan/Library/Arduino15/packages/teensy/hardware/avr/1.57.2/libraries/Bounce2
Multiple libraries were found for "Encoder.h"
Used: /Users/chrisryan/Documents/Arduino/libraries/Encoder
Not used: /Users/chrisryan/Library/Arduino15/packages/teensy/hardware/avr/1.57.2/libraries/Encoder
exit status 1

Compilation error: within this context``

I've also included my sketch for you review ... It shows my new numbers since changing to a 1K resistor from a 10K
I believe you may have mentioned that I should not use the array in the beginning of the sketch ?
The sensitivity is pretty important for the kick as it starts to play strangely without it (80)

``#include "MIDIcontroller.h"

// digitalelements FSR USB Module 8

byte MIDIchannel = 10;

const int pressPin [10] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9}; // ANALOG pin

// Pin & Note number
MIDIdrum Pad0(A0, 36);
MIDIdrum Pad1(A1, 38);
MIDIdrum Pad2(A2, 69);
MIDIdrum Pad3(A3, 65);
MIDIdrum Pad4(A4, 69);
MIDIdrum Pad5(A5, 67);
MIDIdrum Pad6(A6, 65);
MIDIdrum Pad7(A7, 96);
MIDIdrum Pad8(A8, 101);
MIDIdrum Pad9(A9, 75);

void setup(){

// Input Range

Pad0.inputRange(20, 380);
Pad1.inputRange(20, 720);
Pad2.inputRange(120, 860);
Pad3.inputRange(120, 860);
Pad4.inputRange(20, 720);
Pad5.inputRange(20, 720);
Pad6.inputRange(20, 720);
Pad7.inputRange(20, 720);
Pad8.inputRange(20, 720);
Pad9.inputRange(20, 720);

// Sensitivity

//Pad0.sensitivity(80);
// Pad1.sensitivity(99);
// Pad2.sensitivity(99);
// Pad3.sensitivity(99);
// Pad4.sensitivity(99);
// Pad5.sensitivity(99);
// Pad6.sensitivity(99);
// Pad7.sensitivity(99);
// Pad8.sensitivity(99);
// Pad9.sensitivity(99);

// Velocity Output

Pad0.outputRange(1,127);
Pad1.outputRange(1,127);
Pad2.outputRange(1,127);
Pad3.outputRange(1,127);
Pad4.outputRange(1,127);
Pad5.outputRange(1,127);
Pad6.outputRange(1,127);
Pad7.outputRange(1,127);
Pad8.outputRange(1,127);
Pad9.outputRange(1,127);

//WaitTime

Pad0.setWaitTime(40);
Pad1.setWaitTime(8);
Pad2.setWaitTime(30);
Pad3.setWaitTime(30);
Pad4.setWaitTime(30);
Pad5.setWaitTime(30);
Pad6.setWaitTime(30);
Pad7.setWaitTime(30);
Pad8.setWaitTime(30);
Pad9.setWaitTime(30);

}

void loop(){
Pad0.send();
Pad1.send();
Pad2.send();
Pad3.send();
Pad4.send();
Pad5.send();
Pad6.send();
Pad7.send();
Pad8.send();
Pad9.send();

// Crash Protection
while(usbMIDI.read()){}

}
``

Teensy 4 and Touch

Hi Josh
I'm building a midi controller with encoders and buttons. I'm attempting to use a Teensy 4 along with your library. I can compile the sketch in Arduino IDE for Pots and Encoders, but the button example gives me this error with the Teensy 4 (it compiles fine for Teensy 3.6):

Arduino: 1.8.11 (Mac OS X), TD: 1.51, Board: "Teensy 4.0, MIDI, 600 MHz, Faster, US English

/var/folders/j0/v7q8w86j5lqfx_ph7blxdf600000gn/T/arduino_build_188966/libraries/Flicker-master/TouchSwitch.cpp.o: In function TouchSwitch::trigger()': Documents/Arduino/libraries/Flicker-master/TouchSwitch.cpp:88: undefined reference to touchRead'
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 4.0.

I've been trying to take the touch functions out of the library and button files as I don't need them for this project. I feel I've been getting close, but no success so far. Can you help at all with how I can modify the button.h and button.cpp files? Thank you.

Malfunctioning usbMIDI.setHandleSystemExclusive(mySystemExclusive) on Teensy 2.0 returns wrong size!

Hi,

I have the following function:

	void BoxMidi::mySystemExclusive (unsigned char *array, unsigned int size) {
		if (sysex_load == on && handlerSysEx != nullptr) {
			handlerSysEx(array, size);
		} else if (interfacesAreRouted()) {
			MIDI.sendSysEx(size, array);
			usbMIDI.sendSysEx(size, array);
		}
	}

And it is handled to the midi serial and usb functions this way:

		MIDI.setHandleSystemExclusive(mySystemExclusive);
		usbMIDI.setHandleSystemExclusive(mySystemExclusive);

However, when sending a file with 64 bytes on each line, while the serial midi returns the right size of the stream, 64, the usb version returns a different value, 60! Is this a bug or I'm using your library (usb) wrongly?

Thanks

Found now that for 48 bytes per stream instead of 64 it works fine.

MIDIpot doesn't work with Teensy3.2

At compiling the IDE fails to run the program.
Would be too good to be true. The library would save me a lot of work.

I attach the error statement here:

`Arduino: 1.8.13 (Mac OS X), TD: 1.53, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

/Applications/Teensyduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Teensyduino.app/Contents/Java/hardware -hardware /Users/philiphaas/Library/Arduino15/packages -tools /Applications/Teensyduino.app/Contents/Java/tools-builder -tools /Applications/Teensyduino.app/Contents/Java/hardware/tools/avr -tools /Users/philiphaas/Library/Arduino15/packages -built-in-libraries /Applications/Teensyduino.app/Contents/Java/libraries -libraries /Users/philiphaas/Documents/PCB/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=96,opt=o2std,keys=en-us -ide-version=10813 -build-path /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_build_382262 -warnings=none -build-cache /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_cache_115385 -verbose /Users/philiphaas/Documents/PCB/Arduino/Projekte/Teensy/MIDIpot/MIDIpot.ino
/Applications/Teensyduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Teensyduino.app/Contents/Java/hardware -hardware /Users/philiphaas/Library/Arduino15/packages -tools /Applications/Teensyduino.app/Contents/Java/tools-builder -tools /Applications/Teensyduino.app/Contents/Java/hardware/tools/avr -tools /Users/philiphaas/Library/Arduino15/packages -built-in-libraries /Applications/Teensyduino.app/Contents/Java/libraries -libraries /Users/philiphaas/Documents/PCB/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=96,opt=o2std,keys=en-us -ide-version=10813 -build-path /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_build_382262 -warnings=none -build-cache /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_cache_115385 -verbose /Users/philiphaas/Documents/PCB/Arduino/Projekte/Teensy/MIDIpot/MIDIpot.ino
Using board 'teensy31' from platform in folder: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr
Using core 'teensy3' from platform in folder: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr
Detecting libraries used...
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY32 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_build_382262/sketch/MIDIpot.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for MIDIcontroller.h: [MIDIcontroller]
ResolveLibrary(MIDIcontroller.h)
-> candidates: [MIDIcontroller]
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY32 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 -I/Users/philiphaas/Documents/PCB/Arduino/libraries/MIDIcontroller /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_build_382262/sketch/MIDIpot.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Bounce.h: [Bounce]
ResolveLibrary(Bounce.h)
-> candidates: [Bounce]
/Applications/Teensyduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY32 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 -I/Users/philiphaas/Documents/PCB/Arduino/libraries/MIDIcontroller -I/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Bounce /var/folders/9x/73_mykmd6l9ftyg780_8g4k40000gn/T/arduino_build_382262/sketch/MIDIpot.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Flicker.h: []
ResolveLibrary(Flicker.h)
In file included from /Users/philiphaas/Documents/PCB/Arduino/libraries/MIDIcontroller/MIDIcontroller.h:5:0, -> candidates: []

             from /Users/philiphaas/Documents/PCB/Arduino/Projekte/Teensy/MIDIpot/MIDIpot.ino:1:

/Users/philiphaas/Documents/PCB/Arduino/libraries/MIDIcontroller/MIDIbutton.h:6:21: fatal error: Flicker.h: No such file or directory
compilation terminated.
Bibliothek MIDIcontroller im Ordner: /Users/philiphaas/Documents/PCB/Arduino/libraries/MIDIcontroller (legacy) wird verwendet
Bibliothek Bounce im Ordner: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Bounce (legacy) wird verwendet
Fehler beim Kompilieren für das Board Teensy 3.2 / 3.1.
`

Compatibility with other boards

Congrats for your work. Sorry if this not the right place for asking this, but would it work with another board such as esp32 or Arduino?
Thank you once again

Teensy4 support?

I know "MIDI Controller" not support Teensy4 / 4.1 now.
Will be support?

MIDIswitch.ino example has error status 1

Hello Josh,
I recently installed the MIDIcontroller library and tried compiling the MIDIswitch.ino example code. I made no changes to the code. Unfortunately I've run into a strange error message:

MIDIswitchErrorMessage.txt

Certainly appreciate any help you could provide.

Kind regards,
Gerry

Use usbHost on Teensy 4.1?

This looks really promising for my application (I am building a multi-pad controller from scratch)!
I was wondering if and how it could be possible to use the USB host port on the Teensy 4.1 with the MIDIcontroller lib? I would like to keep the base USB port for debugging etc.

Threshold Adjustment for MIDIswitch

Is it possible to bring the setThreshold forward into my sketch ?
I'm attempting to use one of my FSR pads as the switch. The behavior works great when I press my FSR but it will not respond to a strike from a drum stick.( my FSR is covered with a 6mm silicone layer) I'm using the FSR straight in to a digital pin ( 10 which is in the example sketch). I have not included a 10K resistor or 3.3v from the Teensy. I'm only guessing that it would take a threshold adjustment to make this work.

Thanks!

How to use MidiOff

Hello, thank you very much for sharing your work. Question, how to use MidiOff with an FSR or Piezo sensor? Thank you very much

enable to have a initiale value of MIDIPot

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

Feature Request (Seeeduino Xiao)

Hi Josh,

Is there any chance that the MIDIcontroller library might be able to be compatible with a board such as the Seeeduino Xiao ?
I have attempted using some of my previous sketches (for Teensy) and, MIDIdrum_FSR examples but I get a compilation error which references the old bounce.h. This board is much more readily available than say Teensy and much more cost effective for some of my super small drum projects.

Regards,

Chris

                 from /private/var/folders/15/sz8y5tds6jg4lswv01_rv99w0000gn/T/.arduinoIDE-unsaved20221026-15329-j1uvv6.6hidc/MIDIdrum_FSR/MIDIdrum_FSR.ino:1:
/Users/chrisryan/Documents/Arduino/libraries/MIDIcontroller/src/MIDIswitch.h:5:10: fatal error: Bounce.h: No such file or directory
 #include "Bounce.h"
          ^~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

no such as directory

MIDIbutton.h
#include "Flicker.h"
no such as directory...

it works
#include "Flicker/Flicker.h"

Simple question about having multiple instances of Pots

Hello, I am quite new to teensy in general...
so my issue might be somewhat "noob"
I tried different ways to add multiple instances of pots using your library
And I can't seem to find the exact syntax for it
here's what I got, it's compiling but only one out of the 4 pots are reacting:

#include "MIDIcontroller.h"

byte MIDIchannel = 5;
const int potPin = A0; // Change this to the ANALOG pin you want to use
const int potPin1 = A1;
const int potPin2 = A2; 
const int potPin3 = A3; 
// Pot parameters are: pin, CC number, KILL switch enabled
// When KILL is enabled, separate CC messages (with a different number) will be sent
// when you turn the pot all the way down and when you start turning it up again.
// Simply omit the "KILL" argument if you don't want that.
MIDIpot myPot(potPin, 22, KILL);
MIDIpot myPot1(potPin1, 23, KILL);
MIDIpot myPot2(potPin2, 24, KILL);
MIDIpot myPot3(potPin3, 25, KILL);

// OPTIONAL: use outputRange() to limit the min/max MIDI output values
//  myPot.outputRange(0, 127);

void setup(){
}

void loop(){
  myPot.send();


// This prevents crashes that happen when incoming usbMIDI is ignored.
  while(usbMIDI.read()){}

// Also uncomment this if compiling for standard MIDI
//  while(MIDI.read()){}
}

Any help would be greatly appreciated as it seems that your library is giving me excellent analog read for my pots, I have been struggling to find a library that effectively reduces the noise enough so that the pots aren't "giggly"

Inout Range & Threshold

Hi Josh,

I'm trying to confirm that since the input range parameters have been implemented, I not longer need the threshold in my sketches ? It's been a while since I've looked at things and the threshold doesn't appear to have any effect at the moment.

Pad0.setThreshold(960);

Pad0.inputRange(400, 850);

Kind Regards,

Chris

MIDIcontroller- Seeeduino Xiao SAMD21 support

Hey Josh,

I'd like to make a request for adding Seeeduino Xiao to the list of compatible MCUs for your MIDIcontroller library.
A bonus may be that the Xiao SAMD21 supports touch pins as well.

Screen Shot 2024-06-10 at 1 20 12 PM

Regards,

Chris

Undefined reference to MIDIchannel

I'm not sure if I'm doing something wrong and this could absolutely be down to IDE setup or my knowledge of C, but I've created basically the exact same code as the "MIDIpot" example and I'm getting "undefined reference to MIDIchannel"

image

it obviously knows that MIDIcontroller.h references MIDIpot.h, otherwise I think I'd get worse errors. And anyway, it's there, on line 11 of MIDIpot.h:
extern byte MIDIchannel;

What could be happening here?

Using a 4051 Multiplexer??

Is it possible to compliment your library to the usage of a 4051 chip?

For example the potentiometers:

You use <<MIDIpot myPot(potPin, 22);>> . But when I am using a 4051, 8 analogInputs will come via just one analog Input, due to the 4051. How will my PC Programm (Im working on a DJ Controller) distinguish between my 16 Potentiometers, so that every single potentiometer gets his own "mark"(?). Now, all Potentiometers connected to one 4051, will control all the same parameter in my PC Programm, right?

start value of RotaryEncoder

Hello,

thanks for this fabulous lib that simplifying greatly dev on midi custom device (i'm not a great fan of C and arduino IDE but teensy is great for midi device playground)

This not realy an issue, i suppose there is a simple solution.
The encoder value start at 0; and conterclockwise turns do not send update value until there is enough turn clockwise.
is there a way to offset the start value to 64, to be able to detect counterclockwise turn at start?

regards

This lib doesn't do Program Change messages

Program Change is on the TODO list. Meanwhile, it's fairly easy to implement using read() functions. Update to version 2.6.6 and give some of the ideas in this sketch a shot.

#include "MIDIcontroller.h"

byte MIDIchannel = 0;
const byte switchPin = 19;
const byte encoderPinA = 18;
const byte encoderPinB = 17; 
const byte padPin = 14;
int programNumber = 0;

MIDIdrum myPad(padPin, 37);
MIDIenc myEnc(encoderPinA, encoderPinB, 36, PER_DETENT);
MIDIswitch mySwitch(switchPin, 35, TRIGGER);

void setup() {
  pinMode(switchPin, INPUT_PULLUP);
  myPad.inputRange(12, 720);
  myPad.sensitivity(99); // This is still experimental!
}

void loop() {
  int encValue = myEnc.read();
  int switchValue = mySwitch.read();
  int padValue = myPad.read();
  
  if ( encValue >= 0 ){
    programNumber = encValue;
    usbMIDI.sendProgramChange(programNumber, MIDIchannel);
  }

  if ( switchValue > 0 ){
    programNumber = min(127, programNumber + 1);
    myEnc.write(programNumber); // keep the encoder up-to-date
    usbMIDI.sendProgramChange(programNumber, MIDIchannel);
  }

  // whether myPad increments or decrements
  // depents on the state of the footswitch
  if ( padValue > 0 ){ // only inc/dec on rising edge
    if ( digitalRead(switchPin) == LOW ){
      programNumber = max(0, programNumber - 1);
    } else {
      programNumber = min(127, programNumber + 1);
    }

    myEnc.write(programNumber); // keep the encoder up-to-date
    usbMIDI.sendProgramChange(programNumber, MIDIchannel);
  }
}

Originally posted by @joshnishikawa in #27 (comment)

MIDI Pot smooth does not work at all.

See comments in code:

int MIDIpot::smooth(int val, int NR){
buffer = 0; // set to zero so any memory gone.
balancedValue = 0; // this is set to 0 here so any memory is gone
difference = val - balancedValue; // now difference is equal to val - 0 which is val
// if val is 0 then buffer = buffer/2, which is 0 which is val
// if val is not 0 then buffer = buffer + difference which is 0 + val which is val.
// from this you can see that in all cases buffer == val
buffer = val == balancedValue ? buffer/2 : buffer+difference;

// if the square of the buffer which is the square of val is greater than the square of NR
// then you return val
// you return 0 however for any value of val which is less than the sqrt of NR.

if (bufferbuffer > NRNR){ // This works better than abs(buffer) for me.
balancedValue = val;
buffer = 0;
}
return balancedValue;
};

the only use of the smooth member function is like this:
this->smooth(analogRead(pin), 100);
so smooth does nothing except clamp all values less than 100 to zero with no actual smoothing.

MIDI stops when/if the max value setting of the new inputRange is exceeded

The new inputRange allows us to adjust the (min & max) of analog input to optimize the dynamic range.
By lowering the Max input it is easier to reach the top dynamic and send MIDI values at or near 127.
If the analog signal exceeds the max value. no MIDI gets sent or a note with (low) MIDI velocity of 1-5.

It would be ideal to have a Max velocity (127) sent if the analog signal exceeds the inputRange max value.

I've tested with a wide range of waitTime and Threshold settings. It appears these have no bearing on the
issues and are not a secondary trigger event.

I'm Using Teensy 4 with the latest MIDIcontroller library and a variety of FSR sensors wired as suggested
in the example sketches. I'm also playing with drumsticks and using an assortment of materials on top
of the FSR for protection and playability.

I've added code to allow me to watch the Serial plotter as I'm playing for testing.

Cannot run MIDIswitch_toggle

Hi Josh,

First of all thanks for sharing this library, the MIDIpot example worked for me without a doubt.

Unfortunately I get error messages with the MIDIswitch_toggle example, below you can see the error code. I use Arduiono IDE 2.2.1 and a Teensy 4.0 board with board manager https://www.pjrc.com/teensy/package_teensy_index.json.

Can you help me solve this?

c:/users/hans/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Hans\AppData\Local\Temp\arduino\sketches\E4A21663C7284F73A7198036F2335F2C\libraries\Flicker\TouchSwitch.cpp.o: in function `TouchSwitch::setThreshold()':
c:\Users\Hans\Documents\Arduino\libraries\Flicker\src/TouchSwitch.cpp:29: undefined reference to `touchRead'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "Bounce2.h"
  Used: C:\Users\Hans\Documents\Arduino\libraries\Bounce2
  Not used: C:\Users\Hans\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\Bounce2
exit status 1

Compilation error: exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.