Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 51

Thread: Does MIDI Library 2.6 work with Teensy3.0?

  1. #1

    Does MIDI Library 2.6 work with Teensy3.0?

    Does anyone know if MIDI library 3.2 is necessary for Teensy 3.0 or should 2.6 work just fine? The reason I ask is because I am having errors compiling with 3.2 (even when I comment out the line that deals with "word")

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,176
    3.2 compiled for me once I had commented the line with word. This is with Arduino 1.0.4.
    I can't try it out right now though.

    Pete

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,792
    Quote Originally Posted by foam_FORM View Post
    The reason I ask is because I am having errors compiling with 3.2 (even when I comment out the line that deals with "word")
    You could include the actual error in your message (use copy and paste) or a screenshot.

    MIDI 2.6 and 3.2 are on my to-do list to test (right now, I'm working on the Time library, which is turning out to be much more difficult than I'd anticipated). It looks like I loaned my MIDI test board to someone and never got it back, so I might have to build another one or hook it up on a breadboard.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,176
    I've done a quick and dirty test of Midi 2.6 and the MIDI_Input_Test_Teensy sketch works most of the time. Midi 3.2 didn't work.
    I can't test the midi output yet - it's getting late. Manaņa.

    Pete

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108

    Works for me

    I can't replicate the "didn't work". On a fresh install of Arduino 1.0.4 plus Teensyduino 1.13 (Win 7 64bit) I moved libraries/MIDI (which is version 2.6) out of the way, then downloaded MIDI 3.2 from sourceforge and put the MIDI folder inside libraries.

    I then edited MIDI.h as follows:
    change Serial to Serial1
    Code:
    #define USE_SERIAL_PORT         Serial1      // Change the number (to Serial1 for example) if you want
                                                // to use a different serial port for MIDI I/O.
    comment out the definition of word
    Code:
    typedef uint8_t byte;
    // typedef uint16_t word;
    Examples > MIDI > MIDI_basic_IO. Select Teensy 3.0 under boards (USB type was keyboard+mouse+joystick). Compile. No errors. Upload. No errors, reboot ok.

    I haven't breadboarded a DIN socket etc to check it actually sends anything,, but it certainly compiles without error.

  6. #6
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    Quote Originally Posted by el_supremo View Post
    I've done a quick and dirty test of Midi 2.6 and the MIDI_Input_Test_Teensy sketch works most of the time. Midi 3.2 didn't work.
    I don't have a MIDI_Input_Test_Teensy sketch in MIDI 3.2. Where does it come from? Do you have both 2.6 and 3.2 installed at once and if so, how do you know which one is being used?

    3.2 has three examples - MIDI_BASIC_IO, MIDI_Callbacks and MIDI_Input. All three compile correctly with the board set to Teensy 3.0 (or 2.0, just checked that too).

    Edit: OK, found that example in the 2.6 directory I had moved out of the way. Compiled with 3.2. No errors.

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,176
    Quote Originally Posted by Nantonos View Post
    Do you have both 2.6 and 3.2 installed at once?
    Yes. I renamed the directories and files to MIDI_26 and MIDI_32 and changed the include files in each one.

    Pete

  8. #8
    Quote Originally Posted by Nantonos View Post
    I don't have a MIDI_Input_Test_Teensy sketch in MIDI 3.2. Where does it come from? Do you have both 2.6 and 3.2 installed at once and if so, how do you know which one is being used?

    3.2 has three examples - MIDI_BASIC_IO, MIDI_Callbacks and MIDI_Input. All three compile correctly with the board set to Teensy 3.0 (or 2.0, just checked that too).

    Edit: OK, found that example in the 2.6 directory I had moved out of the way. Compiled with 3.2. No errors.
    Yes, I have made sure that I only have one MIDI library in there at once since they both have the same MIDI.h title

    I made the suggested modifications to MIDI.h from Arduino MIDI Library 3.2 (Sourceforge) and am getting the same error message:

    In file included from C:\Users\Spartan's Lounge\Documents\arduino-1.0.3\hardware\teensy\cores\teensy3/WProgram.h:15:0,
    from C:\Users\Spartan's Lounge\Documents\arduino-1.0.3\hardware\teensy\cores\teensy3/Arduino.h:1,
    from simple_midi_sequence___pjrc.ino:3:
    C:\Users\Spartan's Lounge\Documents\arduino-1.0.3\hardware\teensy\cores\teensy3/wiring.h:89:22: error: conflicting declaration 'typedef unsigned int word'
    In file included from simple_midi_sequence___pjrc.ino:1:0:
    C:\Users\Spartan's Lounge\Documents\arduino-1.0.3\libraries\MIDI/MIDI.h:65:18: error: 'word' has a previous declaration as 'typedef uint16_t word'

    I will say that I am using Arduino 1.03 but commenting out that line did allow me to compile once but the uploaded code did not output MIDI. I am not able to repeat even that result currently, however.
    I have been using MIDI as the board type. Did you suggest to use keyboard+mouse+joystick? I am using MIDI for the board type and AVRISP mkII for my programmer. Is that all correct? Also 48hz clock speed...

  9. #9
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,176
    The board type should be serial. The MIDI 2.6 and 3.2 libraries don't use the T3 as a USB MIDI device. They just read/write midi messages on the Serial port.

    Pete

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,792
    Quote Originally Posted by foam_FORM View Post
    .... did not output MIDI.
    You've connected the MIDI OUT jack correctly, using 47 or 56 ohm resistor, right?

    Maybe you could post a photo of the hardware you've connected for your MIDI out?

  11. #11
    I am attempting to use MIDI IN actually to play notes on my laptop software via pushbuttons connected to the Teensy 3.0... I will try serial tonight after work (tomorrow morning) since I have actually been using MIDI as the board type this whole time. I have been using 47ohm resistors on the MIDI jack, but I am connected to VIN, not 3.3V so I have also tried 220ohm resistors. I will post hardware pictures if serial does not work.

  12. #12
    Member
    Join Date
    Dec 2012
    Location
    Adelaide, SA
    Posts
    70
    What VIN are you running? If it's 5V, I would suggest you do not connect your MIDI Out resistors to them. Teensy 3's pins are not 5V tolerant. Make sure they are connected to 3.3V and use 47ohm.

  13. #13
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    Quote Originally Posted by el_supremo View Post
    The board type should be serial. The MIDI 2.6 and 3.2 libraries don't use the T3 as a USB MIDI device. They just read/write midi messages on the Serial port.
    Agreeing with your second sentence and correcting the first, the USB type can be anything, since USB is not being used here. Setting it to Serial means you want a virtual serial-over-USB set up (for example, to display debug messages on the Serial monitor).
    However, remember to edit MIDI.h to change Serial to Serial1 (or Serial2 or Serial3, depending on what pins you are using) since Serial is the Serial-over-USB one.

  14. #14
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    Quote Originally Posted by foam_FORM View Post
    I am attempting to use MIDI IN actually to play notes on my laptop software via pushbuttons connected to the Teensy 3.0.
    That would be MIDI Out, on the Teensy. Which you would connect to MIDI In on your laptop audio interface.
    MIDI In on the Teensy would be the circuit with the optocoupler (which you would connect to MIDI Out on a keyboard or other controller).

    Quote Originally Posted by foam_FORM View Post
    I will try serial tonight after work (tomorrow morning) since I have actually been using MIDI as the board type this whole time.
    The USB type does not matter here, since you are not using USB to connect.

    Quote Originally Posted by foam_FORM View Post
    I have been using 47ohm resistors on the MIDI jack, but I am connected to VIN, not 3.3V so I have also tried 220ohm resistors. I will post hardware pictures if serial does not work.
    I would use the 3V3 pin. Vin is unregulated (and is connected to the USB 5-ish volts, if I recall correctly).

  15. #15
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    I breadboarded a DIN MIDI-Out, with a Teensy 3.0. Not having 50R resistors to hand, I used two 100R in parallel. The circuit was pin1 (Serial1 Tx) to 50R to DIN pin 4; DIN pin5 to 50R to 3V3 on Teensy; DIN pin 2 to GND.

    The following example compiled (with MIDI 3.2), uploaded, and ran correctly. The MIDI Out was connected to the MIDI-I on my audio interface (Presonus AudioBox 44VSL). I checked first with MIDI-OX to see the MIDI stream, then ran it into a software instrument (Kontakt 5.0) to make sure it produced the expected sounds. All worked OK.

    Code:
    /*
    Teensy 3 with MIDI DIN and MIDI library 3.2.
     Edit MIDI.h to send MIDI to Serial1 (pin 1)
     */
    
    #include <MIDI.h>
    #define LED 13               // LED pin on Arduino board
    
    byte note;
    
    void setup() {
      MIDI.begin(1);   // Launch MIDI on channel 1
      pinMode(LED, OUTPUT);
      digitalWrite(LED,LOW);   
      delay(2000);                // Wait for a bit  before starting
    }
    
    void loop() {
      note = random(32,70);
      digitalWrite(LED,HIGH);       // Blink the LED
      MIDI.sendNoteOn(note,92,1);   // Send a Note (pitch random, velo 3/4 on channel 1)
      for (int i=0; i<3000; i+=20) {// MIDI pitch bend range is +- 8k
        MIDI.sendPitchBend(i,1);    // swoop a bit
        delay(12);
      }
      MIDI.sendNoteOff(note,0,1);   // Stop the note
      digitalWrite(LED,LOW);   
      delay(500);                // Wait for a bit between notes    
    }
    Last edited by Nantonos; 03-26-2013 at 06:17 PM.

  16. #16
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    I see that the MIDI library has moved to GitHub, and there is a MIDI 4.0 being prepared for release. There has been some refactoring, so instead of editing MIDI.h there is now a midi_Settings.h Also I see support for Leonardo, with USB being detected (the code assumes that means Leonardo) and MIDI assigned to Serial1. Its also now possible to instantiate multiple MIDI objects (there is an example with a MIDI merger).

    This is the auto serial instantiation (no Teensy support)

    Code:
    // Default serial port configuration (if MIDI_AUTO_INSTANCIATE is set)
    
    
    
    // Set the default port to use for MIDI.
    #if MIDI_AUTO_INSTANCIATE
    #   ifdef ARDUINO
    #       ifdef USBCON
    #           define MIDI_DEFAULT_SERIAL_PORT     Serial1 // For Leonardo
    #       else
    #           define MIDI_DEFAULT_SERIAL_PORT     Serial  // For other Arduinos
    #       endif
    #       define MIDI_DEFAULT_SERIAL_CLASS        HardwareSerial
    #       include "Arduino.h"
    #       include "HardwareSerial.h"
    #   else
    #       error Auto-instanciation disabled. Use MIDI_CREATE_INSTANCE macro.
    #   endif
    #endif

  17. #17
    Quote Originally Posted by Nantonos View Post
    That would be MIDI Out, on the Teensy. Which you would connect to MIDI In on your laptop audio interface.
    MIDI In on the Teensy would be the circuit with the optocoupler (which you would connect to MIDI Out on a keyboard or other controller).


    The USB type does not matter here, since you are not using USB to connect.


    I would use the 3V3 pin. Vin is unregulated (and is connected to the USB 5-ish volts, if I recall correctly).
    Ah..yes. Sorry I meant MIDI OUT. I have been using out so far, not in. I am thinking my problem is the Voltage source. I will try 3.3V here soon but have another project I have to attend to for a day or so. Thanks so much! I will try out your example here soon, but last time I hit compile the same error came up telling be about the previous declaration of word, even though I had commented out the line with word and changed Serial to Serial1. I am using Arduino 1.03.....is it not refreshing/referencing the library correctly?

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,792
    Quote Originally Posted by foam_FORM View Post
    is it not refreshing/referencing the library correctly?
    One simple way to check is to add an intentional syntax error inside the code. Then click Verify.

  19. #19
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    Check the libraries folder inside your sketch folder, as well as the main libraries folder. You might have a copy in there as well, in which case the edits to the one in the main libraries folder will have no effect *cough* happend to a freind of mine *cough*

  20. #20
    Quote Originally Posted by Nantonos View Post
    Check the libraries folder inside your sketch folder, as well as the main libraries folder. You might have a copy in there as well, in which case the edits to the one in the main libraries folder will have no effect *cough* happend to a freind of mine *cough*

    I don't think that is the problem, Nan. When I delete the MIDI library it tells me no such file exists, and there is no other library file in my sketch folder-- so I think that probably means it is referring to the file I am editing, but it doesn't seem to recognize the change when I comment out that line now. I tried //typedef and // typedef --with a space and without....no luck. Maybe it was because it was arduino 1.02 before when it was working but I honestly don't know anymore. I want to try out the 3.3v pin but if I can't get the library to compile there is little use for that. There must be a simple "tweak" I am missing.

  21. #21
    Ok, I will look that up...what would that indicate? I am an extreme novice if you couldn't tell already.

  22. #22
    Quote Originally Posted by Nantonos View Post
    Check the libraries folder inside your sketch folder, as well as the main libraries folder. You might have a copy in there as well, in which case the edits to the one in the main libraries folder will have no effect *cough* happend to a freind of mine *cough*
    Nan, are you sure you are using 3.0 as your board type? I ask because I CAN get MIDI Library 3.2 to compile with 2.0 as the board type but with 3.0 I get the typedef error no matter what I do.

  23. #23
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    Absolutely sure. a) just checked b) am looking at Teensy 3.0 on breadboard hooked up to MIDI socket c) it wouldn't upload correctly, otherwise.

    Can you copy and paste your exact error message? Also, if you go Help > Abou Arduino what is the version number? (I wonder igf you have multiple versions installed and the one you are editing is not the one you are using).

  24. #24
    Quote Originally Posted by Nantonos View Post
    Absolutely sure. a) just checked b) am looking at Teensy 3.0 on breadboard hooked up to MIDI socket c) it wouldn't upload correctly, otherwise.

    Can you copy and paste your exact error message? Also, if you go Help > Abou Arduino what is the version number? (I wonder igf you have multiple versions installed and the one you are editing is not the one you are using).
    Well, if I use 2.0 for my board it does upload the code/library correctly and 3.0 will not...I cannot copy anything from the error message section-- it will only let me copy the code. It is the same error message that came before I commented out typedef like this: ;//typedef uint16_t word; that tells me word has been used in a previous declaration. It seems like the computer is having troubles updating the library changes but I am not sure why.

  25. #25
    Quote Originally Posted by Nantonos View Post
    Absolutely sure. a) just checked b) am looking at Teensy 3.0 on breadboard hooked up to MIDI socket c) it wouldn't upload correctly, otherwise.

    Can you copy and paste your exact error message? Also, if you go Help > Abou Arduino what is the version number? (I wonder igf you have multiple versions installed and the one you are editing is not the one you are using).
    My Arduino version number is 1.04 now. I was using 1.03 at the time of the last post. Teensy 2.0 would compile but no MIDI signals again. I used 2 220ohm resistors and quadruple-checked EVERYTHING as far as hardware/code/libraries/redundancies/settings/etc.,/etc., that I can possibly find and still no MIDI. There has to be something very simple I am overlooking or else my CPU just has a weird bug/incompatibility. I am going to put this aside for a while and move on unless anyone has any final suggestions...I very much appreciate all of your help so far. @PaulStoffregen - please let me know when you have tested MIDI OUT on 3.0! I would be interested to see if you have any success with it.

    @Nantonos: Either we living in parallel universes, am I just that noob, or you are pulling my leg because I am just that noob. I really hope it's not the third because that was a lot of time.

Posting Permissions

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