Skip to content

Programming 4.1 breakout with Visual Studio / PlatformIO possible, error message.... #8

Description

@Keeze

Hi Andrei,

I try to create a project in Visual Studio with platformIO. Created a new preject and pasted alterd code for my need.

Problem is that I get the followong message. By the way, code compiles (not tested yet on the Teensy).

no instance of overloaded function "midi::MidiInterface<Transport, _Settings, _Platform>::send [with Transport=midi::SerialMIDI<HardwareSerial, midi::DefaultSerialSettings>, _Settings=midi::DefaultSettings, _Platform=midi::DefaultPlatform]" matches the argument list -- argument types are: (byte, byte, byte, byte) -- object type is: midi::MidiInterface<midi::SerialMIDI<HardwareSerial, midi::DefaultSerialSettings>, midi::DefaultSettings, midi::DefaultPlatform>

Do you have experience with coding in Visual Studio Code and can you see whats wrong?

Code:

/* Create a "class compliant " USB to 8 MIDI IN and 8 MIDI OUT interface.

   MIDI receive (6N138 optocoupler) input circuit and series resistor
   outputs need to be connected to Serial1, Serial2 and Serial3.

   You must select MIDIx4 from the "Tools > USB Type" menu

   This example code is in the public domain.
*/

#include <Arduino.h>

#include <MIDI.h>
#include <MIDI.hpp>
#include <usb_midi.h>
#include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port)

// Create the Serial MIDI ports
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI1);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI2);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial3, MIDI3);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial4, MIDI4);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial5, MIDI5);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial6, MIDI6);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial7, MIDI7);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial8, MIDI8);


// Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs)
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBHub hub3(myusb);
USBHub hub4(myusb);
MIDIDevice midi01(myusb);
MIDIDevice midi02(myusb);
MIDIDevice midi03(myusb);
MIDIDevice midi04(myusb);
MIDIDevice midi05(myusb);
MIDIDevice midi06(myusb);
MIDIDevice midi07(myusb);
MIDIDevice midi08(myusb);
MIDIDevice * midilist[8] = {
  &midi01, &midi02, &midi03, &midi04, &midi05, &midi06, &midi07, &midi08,
};

// A variable to know how long the LED has been turned on
elapsedMillis ledOnMillis;

void setup() {
  Serial.begin(115200);
  pinMode(13, OUTPUT); // LED pin
  MIDI1.begin(MIDI_CHANNEL_OMNI);
  MIDI2.begin(MIDI_CHANNEL_OMNI);
  MIDI3.begin(MIDI_CHANNEL_OMNI);
  MIDI4.begin(MIDI_CHANNEL_OMNI);
  MIDI5.begin(MIDI_CHANNEL_OMNI);
  MIDI6.begin(MIDI_CHANNEL_OMNI);
  MIDI7.begin(MIDI_CHANNEL_OMNI);
  MIDI8.begin(MIDI_CHANNEL_OMNI);  
  MIDI1.turnThruOff();
  MIDI2.turnThruOff();
  MIDI3.turnThruOff();
  MIDI4.turnThruOff();
  MIDI5.turnThruOff();
  MIDI6.turnThruOff();
  MIDI7.turnThruOff();
  MIDI8.turnThruOff();
  
    digitalWriteFast(13, HIGH); // LED on
    delay(500);
    digitalWriteFast(13, LOW);

  myusb.begin();
  
}

void loop() {
  bool activity = false;

  if (MIDI1.read()) {
    // get a MIDI IN1 (Serial) message
    byte type = MIDI1.getType();
    byte channel = MIDI1.getChannel();
    byte data1 = MIDI1.getData1();
    byte data2 = MIDI1.getData2();

    if (channel == 1) {
      MIDI1.send(type, data1, data2, channel);
      activity = true;
    }

    if (channel == 2) {
      MIDI1.send(type, data1, data2, channel);
      activity = true;
    }

    if (channel == 16) {
      MIDI1.send(type, data1, data2, channel);
      activity = true;
    }

    if (channel == 4) {
      MIDI2.send(type, data1, data2, 1);
      activity = true;
    }

    if (channel == 5) {
      MIDI3.send(type, data1, data2, 1);
      activity = true;
    }

    if (channel == 6) {
      MIDI4.send(type, data1, data2, 1);
      activity = true;
    }
  }
  if (MIDI2.read()) {
    // get a MIDI IN2 (Serial) message
    byte type = MIDI2.getType();
    byte channel = MIDI2.getChannel();
    byte data1 = MIDI2.getData1();
    byte data2 = MIDI2.getData2();

    if (channel == 10) {
      MIDI5.send(type, data1, data2, 10);
      activity = true;
    }

    if (channel == 1) {
      MIDI6.send(type, data1, data2, 1);
      activity = true;
    }

    if (channel == 2) {
      MIDI7.send(type, data1, data2, 1);
      activity = true;
    }

    if (channel == 3) {
      MIDI8.send(type, data1, data2, 1);
      activity = true;
    }
  }
  // blink the LED when any activity has happened
  if (activity) {
    digitalWriteFast(13, HIGH); // LED on
    ledOnMillis = 0;
  }
  if (ledOnMillis > 15) {
    digitalWriteFast(13, LOW);  // LED off
  }

}

Cheers,
Kees

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions