Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: Teensy LC and MIDI library: MIDI_CREATE_DEFAULT_INSTANCE() not needed?

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    10

    Teensy LC and MIDI library: MIDI_CREATE_DEFAULT_INSTANCE() not needed?

    When I try the code examples at https://www.pjrc.com/teensy/td_libs_MIDI.html I get this error: "'MIDI' was not declared in this scope". Based on my experience with non-Teensy Arduinos, I added a call to MIDI_CREATE_DEFAULT_INSTANCE() and that error went away (I have other problems, but one step at a time).

    Question: Is MIDI_CREATE_DEFAULT_INSTANCE() supposed to be unnecessary with Teensy MIDI as the examples imply?
    • If so, am I somehow pulling in the wrong MIDI.h?
    • If not, the docs should be corrected.

    2nd question: Is there a way to see the contents of header files in the IDE so I can see exactly what's being #included?

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    You cannot compile the example code unaltered?

    If not post your code please. If so it suggests Teensyduino may not be installed properly since that code has worked for many others.

  3. #3
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    ....hmm seems if I add MIDI_CREATE_DEFAULT_INSTANCE() I cannot get it to compile.

  4. #4
    Junior Member
    Join Date
    Sep 2017
    Posts
    10
    Quote Originally Posted by oddson View Post
    You cannot compile the example code unaltered?

    If not post your code please. If so it suggests Teensyduino may not be installed properly since that code has worked for many others.
    Right, I can't compile this example copied straight from the website:
    Code:
    #include <MIDI.h>
    
    const int channel = 1;
    
    void setup() {
      MIDI.begin();
    }
    
    void loop() {
      int note;
      for (note=10; note <= 127; note++) {
        MIDI.sendNoteOn(note, 100, channel);
        delay(200);
        MIDI.sendNoteOff(note, 100, channel);
      }
      delay(2000);
    }
    I had been using the MIDI library before upgrading to Teensy, so I'm wondering if maybe Teensyduino is pulling in the wrong version somehow? Just guessing.

  5. #5
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    Are you sure you compiling for a Teensy?(and which one?)

  6. #6
    Junior Member
    Join Date
    Sep 2017
    Posts
    10
    Quote Originally Posted by oddson View Post
    Are you sure you compiling for a Teensy?(and which one?)
    Tools menu > Board: "Teensy LC"

    Thanks for engaging on this, btw.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,301
    Quote Originally Posted by mpark View Post
    Right, I can't compile this example copied straight from the website:
    Opps, sorry about that.

    Pretty much all of the web page was written when version 3.2 was the most recent. Looks like the info needs to be updated for the changes in MIDI 4.x. I've put this on my todo list.

    Probably best to use File > Examples > MIDI Library, rather than the older examples from the web page.

  8. #8
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    Is there any chance that the transport options available under 4.x could be extended (one day) so that usbMIDI actually uses the MIDI library directly rather than trying to mimic it's behaviour?

    It would be amazing if MIDI over BLE, MIDI over Ethernet, USB, soft serial and hard serial could all use the same library and features like running status translation and USB-to-serial thru by just setting options rather than having to have calls to different libraries.

  9. #9
    Junior Member
    Join Date
    Sep 2017
    Posts
    10
    Thank you, Paul.

    Quote Originally Posted by PaulStoffregen View Post
    Probably best to use File > Examples > MIDI Library, rather than the older examples from the web page.
    oddson, there's a MidiUSB example that I think demonstrates what you're looking for.

  10. #10
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    Thanks... guess I should update a bit more.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,301
    I've updated the web page for the latest MIDI library (4.3.1).

  12. #12
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    234
    I've started the journey to MIDI over BLE, using Nordic Semiconductor's nRF52... Dev Kit.
    It's daunting.
    I have a model use in a product called FreeDrum at https://www.freedrum.rocks, which attaches a small (Teensy-sized) device to each drumstick, and senses motion... sending MIDI over BLE to GarageBand et al on a phone or tablet. The videos on line are cool. The product itself is pretty cool.

    They use the MIDI-over-BLE connection to:
    - send MIDI drum streams to a midi synth (like GarageBand)
    - configure their device and apply firmware updates from their iOS and android apps (sensorware)

    So, MIDI over BLE would be a create add-on to a Teensy-based device.

    @oddson, are you interested in this?

  13. #13
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    234
    By the way, MIDI over BLE differs from MIDI over USD in that a timecode is needed with each message using BLE. That helps the receiver to attempt to properly space received messages - even in the face of BLE latency.

  14. #14
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,138
    Quote Originally Posted by Davidelvig View Post
    I've started the journey to MIDI over BLE...

    So, MIDI over BLE would be a create add-on to a Teensy-based device.

    @oddson, are you interested in this?
    I'm very interested in this.
    I'm not sure about the existing sieren/blidino parser for Ardunio.
    It doesn't seem an ideal starting place to me.

    Are you using that or building your own?

  15. #15
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    234
    @oddson, the sieren/blidino parser you reference above looks like the right stuff, or related, anyway.

    I'm trying to wrap my head around the nRF52 SOC (the descendant of the vRF51 used in the Red Bear hardware a few links down in your reference... http://redbearlab.com/redbearlab-nrf51822/)

    To do MIDI over BLE cleanly, it looks like one would flash the nRF52 with code that:
    1. - communicates MIDI messages with the Teensy over SPI or I2C
    2. - buffers the outbound MIDI messages from Teensy until a radio connection is on (it will be intermittent)
    3. - sends and receives MIDI over BLE to a connected host.


    I think we could flash the nRF52 from the Teensy at runtime using 4 pins dedicated for flashing, but I don't think that's traditional.
    It seems like the usual path is to embed the BLE-ness of the chip via separate flashing, adding its services and characteristics. Nordic has their own bootloader to facilitate the nRF52 running on its own.

    A Teensy BLE add-on using the nRF52 would be pretty useful - especially if it could be adapted for any BLE service (with flashing, or whatever).

    I have the Nordic nRF52 Dev Kit and have downloaded and have run the demo programs from SES (Segger Embedded Studio - licensed for Nordic chip buyers)
    It's all straightforward for use of the nRF52 as an SOC with BLE. Less clear is the nRF52 as a BLE-only add-on to a separate microprocessor.

    Should we start a new thread around BLE MIDI?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •