lathoub / Arduino-USBMIDI

Allows a microcontroller, with native USB capabilities, to appear as a MIDI device over USB to a connected computer
MIT License
159 stars 11 forks source link

Unable to compile for Digispark (ATTiny85) #12

Closed svanimisetti closed 3 years ago

svanimisetti commented 3 years ago

Does this library support the ATTiny85? I tried to compile the same code that runs fine on ATmega32u4, but I get the following error.

In file included from C:\Users\<user>\Documents\Arduino\libraries\USB-MIDI\src/USB-MIDI.h:26:0,
from C:\Users\<user>\Desktop\myMIDI\test_jul09a\test_jul09a.ino:10:
C:\Users\<user>\Documents\Arduino\libraries\MIDIUSB\src/MIDIUSB.h:18:2: error: #error MIDIUSB
can only be used with an USB MCU.
#error MIDIUSB can only be used with an USB MCU.
  ^
In file included from C:\Users\<user>\Documents\Arduino\libraries\USB-MIDI\src/USB-MIDI.h:26:0,
from C:\Users\<user>\Desktop\myMIDI\test_jul09a\test_jul09a.ino:10:
C:\Users\RDCUser\Documents\Arduino\libraries\MIDIUSB\src/MIDIUSB.h:25:26: fatal error: PluggableUSB.h:
No such file or directory
#include "PluggableUSB.h"

I have seen another project (USBMIDI) that seem to emulate MIDI over USB using the V-USB library and works for ATTiny85 and the Digispark boards. If it does not support, is it easy to make modifications to support Digispark? I am not sure if its even worth - if the performance suffers as there will be another layer in between.

lathoub commented 3 years ago

if MIDIUSB does not support the device, then this library will not support it either. (see title section of this repo).

But happy to look at your attempts to put this lib on top of USBMIDI

lathoub commented 3 years ago

I've looked at USBMIDI and create a transport for it (very similar to serial comms) in a // repo: https://github.com/lathoub/Arduino-USBMIDI/tree/using_BlokasLabs_USBMIDI (only added 1 file: MIDI-USB.h)

Can you try the following (I can get to compile, but don't have the hardware to test):

#include <MIDI-USB.h>

// Simple tutorial on how to receive and send MIDI messages.
// Here, when receiving any message on channel 4, the Arduino
// will blink a led and play back a note for 1 second.

USBMIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
    if (MIDI.read())                    // If we have received a message
    {
        digitalWrite(LED_BUILTIN, HIGH);
        MIDI.sendNoteOn(42, 127, 1);    // Send a Note (pitch 42, velo 127 on channel 1)
        delay(1000);                    // Wait for a second
        MIDI.sendNoteOff(42, 0, 1);     // Stop the note
        digitalWrite(LED_BUILTIN, LOW);
    }
}
svanimisetti commented 3 years ago

Apologies for the delay. I updated my local Arduino library with your new branch and tried to compile the example you provided. However, there were numerous errors when I compile for this specific board (Boards Manager - Digistump AVR boards). The board (Digispark) is based on ATtiny85 and runs micronucleus as bootloader - and I believe is different from standard Arduinos. The errors listed are as follows. I can attach a full log of error if you wish.

In file included from C:\Users\RDCUser\Documents\Arduino\libraries\MIDI_Library\src/MIDI.h:30:0,
                 from C:\Users\RDCUser\Documents\Arduino\libraries\Arduino-USBMIDI\src/MIDI-USB.h:25,
                 from C:\Users\RDCUser\Desktop\sketch_jul13b\sketch_jul13b.ino:1:
C:\Users\RDCUser\Documents\Arduino\libraries\MIDI_Library\src/midi_Defs.h:70:7: error: expected nested-name-specifier before 'ErrorCallback'
 using ErrorCallback                = void (*)(int8_t);
       ^
C:\Users\RDCUser\Documents\Arduino\libraries\MIDI_Library\src/midi_Defs.h:70:7: error: 'ErrorCallback' has not been declared
C:\Users\RDCUser\Documents\Arduino\libraries\MIDI_Library\src/midi_Defs.h:70:36: error: expected ';' before '=' token
 using ErrorCallback                = void (*)(int8_t);
lathoub commented 3 years ago

It looks like your compiler doesn't support C++11 type aliases. This has become too specific

svanimisetti commented 3 years ago

I agree. I have changed my approach a little bit for this project - and am trying to use the native library directly for ATtiny85 instead of doing it via Arduino and Arduino-USBMIDI. I think its easier to follow this approach rather than fix the issues with Arduino platform. I will go ahead and close this issue.