tttapa / MIDI_controller

This is a library for creating a MIDI controller using an Arduino or Teensy board.
GNU General Public License v3.0
404 stars 69 forks source link

Button, potentiometer and rotary encoder gives the same result. #80

Closed guillecip closed 5 years ago

guillecip commented 5 years ago

I´ve tried any example with button, potentiometer or rotary encoder and the midi ox always return the same.

MIDI Ox: TIMESTAMP IN PORT STATUS DATA1 DATA2 CHAN NOTE EVENT
000002D8 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
000002D9 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
000002D9 1 -- C0 66 -- 1 --- PC: FX 7(echoes)
000002D9 1 -- F8 -- -- -- --- Timing Clock
000002DA 1 -- F8 -- -- -- --- Timing Clock
0000034A 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
0000034A 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
0000034A 1 -- C0 66 -- 1 --- PC: FX 7(echoes)
0000034B 1 -- F8 -- -- -- --- Timing Clock
0000034B 1 -- F8 -- -- -- --- Timing Clock
00038812 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
00038812 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
00038813 1 -- C0 66 -- 1 --- PC: FX 7(echoes)
00038813 1 -- F8 -- -- -- --- Timing Clock
00038813 1 -- F8 -- -- -- --- Timing Clock
0003892A 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
0003892A 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano
0003892A 1 -- C0 66 -- 1 --- PC: FX 7(echoes)
0003892A 1 -- F8 -- -- -- --- Timing Clock
0003892B 1 -- F8 -- -- -- --- Timing Clock

The debug of MIDI Hairless gives me these messeges:

+247.062 - Serial In: Ch 1: Program change %2 +247.063 - Serial In: System Message #8 +247.063 - Serial In: System Message #8 +247.341 - Serial In: Ch 1: Program change 0 +247.342 - Serial In: Ch 1: Program change 0 +247.342 - Warning: got a status byte when we were expecting 1 more data bytes, sending possibly incomplete MIDI message 0xc0 +247.342 - Serial In: Ch 1: Program change %2 . . . and repeat

These responses are with button, potentiometer or rotary encoder. With any example I charge in the Arduino board

Hardware

Arduino (chinese clone) UNO CH340 (Chipset Atmel Mega 328P)

Software versions:

MIDI Controller library: 3.1.0
Arduino IDE: 1.8.8
Operating System: Windows
Operating System version: 10

(Encoder library): 1.4.1

Settings in the IDE

Full code

// /*
This is an example of the "Digital" class of the MIDI_controller library.
Connect a push buttons to digital pin 2. Connect the other pin of the button to the ground, 
a pull-up resistor is not necessary, because the internal one will be used. 
This button will play MIDI note C4 when pressed.
Map it in your DAW or DJ software.

Written by tttapa, 08/09/2017
https://github.com/tttapa/MIDI_controller
*/

#include <MIDI_Controller.h> // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C4 = 60;              // Note number 60 is defined as middle C in the MIDI specification

// Create a new instance of the class 'Digital', called 'button', on pin 2, that sends MIDI messages with note 'C4' (60) on channel 1, with velocity 127
Digital button(2, C4, 1, velocity);

void setup() {
  HairlessMIDI_Interface;
  }

void loop() {
  // Refresh the button (check whether the button's state has changed since last time, if so, send it over MIDI)
  MIDI_Controller.refresh();
}

I´m trying to make a midi controller similar to Allen&Heath K2

I was trying to do it with the code of Notes&Volts and it works fine, but doesn´t have Rotary encoders. So, thats why I´m trying to do it with these code.

Thanks in advance

Guille

guillecip commented 5 years ago

Problem solve. I have to put these:

HairlessMIDI_Interface myHairlessMidi;

instead of these in the code:

void setup() { HairlessMIDI_Interface; }