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

Multiple simultaneous MIDI outputs #72

Open sargaroth opened 5 years ago

sargaroth commented 5 years ago

Description of the problem or question

Hello!

Thank you for this awesome library! I have a lot of interesting projects that I plan to use it in.

My question is whether it is possible to get both MIDI over USB and from serial pins 0 and 1 simultaneously; I have so far been unsuccessful in this.

Steps to reproduce the problem

See commented out lines in the code.

I've tried remapping the Serial interface to Serial1 and Serial

Hardware

Sparkfun Pro Micro 5V 16MHz, ATMega32u4. Works well with the Arduino Micro preset as well as their own preset for the IDE.

Software versions:

MIDI Controller library :3.0.0 Arduino IDE: 1.8.7
MIDIUSB library: ? 1.0.0

Settings in the IDE

Full code

#include <frequencyToNote.h>
#include <MIDIUSB.h>
#include <pitchToNote.h>
#include <MIDI_Controller.h> // Include the library

/*
  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
*/

//#define serial Serial1
//unsigned long baud = 115200;

/*Tried to use the above two lines to exchange some of the arguments below, without success. I'm not very experienced regarding C++, so I'm taking a class on the side of this Issue submission*/

//USBDebugMIDI_Interface midiInterface(115200);
//HardwareSerialMIDI_Interface midiInterface2(HardwareSerial Serial,unsigned long baud);
//USBMIDI_Interface::setDefault();
//SoftwarSerialDebugMIDI_Interface RS485(SoftwareSerial Serial1, unsigned long baud);//::setDefault();
//SoftwarSerialMIDI_Interface MIDI(SoftwareSerial Serial1, unsigned long baud);

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
const uint8_t D4 = 62;

// 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);
Digital button2(3, D4, 1, velocity);
void setup() {}

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();
}

Steps taken to try to diagnose or solve the problem

Tried to use the serial monitor by linking TX to RX on the board with no success.

The goal of your project and aditional information