Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 38 of 38

Thread: Teensy 3.1 Midi - USB Interface: 1 in+2 Out/Thru (split) + Midi Controller

  1. #26
    Ha ha ha!
    Yeah - I live in Oslo now but coming back home for some Sunshine in Feb/March!
    MSC could be very useful if syncing transport controls is required?
    Good Work man, I included a Teensy 3.2 in my order ;-)

  2. #27
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    I'm not sure about MSC for ongoing sync. I think MTC is more usual, or maybe extracting position data from asio audio driver, even???

    Anyway, good news ...I think I've cracked the 2 x 2 interface part, software wise atm, here. Have do do real hardware testing.

    The weather over here has been fantastic ... hope it holds for you.

  3. #28
    Thanks man,
    Thats great news!
    I'm still waiting for parts sigh... How did your hardware tests go?

  4. #29
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    i've tested everything apart from the 2 x 2 midi interface bit ...I'll get to it this weekend. The code looks good, and I found my breadboard with a midi in circuit on it still! incl optocoupler ... I 'll just check it over and do an output circuit ... then fire it up maybe even tomorrow.

  5. #30
    Just realised I left off the 280 Ohm resister from my parts order. Dammit. I'll have to use something else while I order them.

  6. #31
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Hello!!

    I finally got round to testing out the midithru hardware functionality ... I made a 1 x 1 midi hardware interface, and attached in and out to different serial ports ... so I sent midi in one serial port and out the other ! Plus ... up the teensy USB...

    Also, it worked really well as a thru ..in the serial port and out ..etc. It worked with the interrupt-driven main controller program (I've re-written the whole thing as a library, too!!) ...

    All that remains is a proper test of 'everything together' ...I need to build another hardware interface, so its 2 x 2 + USB, and stress test it, along with the rest of the controller program ... I noticed a slight bit of latencyusing 1 x 1, but really minimal!! surprised me how good in fact.... better than 50% of the data out had the same timestamp on the way back in!! Totally awesome! That's fast.

    Anyway, here is the documentation, in an example.... note it uses MIDI 4.2, and if you want MAME functionality (i.e. USB keyboard), you need a custom USB type.

    Happy to share the actual library (cpp and h) ... I'll finish up assembling the hardware, do a stress test, and tidy up soon ...

    Promise.
    Code:
    //1 Rotary encoder, 1 Motorised fader (using native FaderPort protocol "FPP"), 1 Joystick (4 switches) and 9 other switches / buttons, and a 2 x 2 USB Midi interface, merger and splitter!
    //3 different modes choosable on startup by button press. MODE1.MidiController MODE2.Faderport clone MODE3.MAME controller. Because MAME uses keystrokes, a cutom usb type of keyboard/midi is needed
    //Obviously if you want to ditch MAME, you won't need a custom usb type
    //Also MIDI 4.2 library is required.
    
    #include <usb_midi.h>
    #include <MIDI.h>
    #include "myController13.h"
    
    #define NUM_INPUT_SWITCHES 13// Number of digital switches you are using, 13 or less ... 
    // The digital pins used are, in order, 2, 14, 7, 8, 15, 22, 23, 18, 3, 4, 5, 11, 6.
    // SO ... if you want 4 digital pins, use 2, 14, 7, and 8 (the first 4).
    // The rotary encoder is on digital 16 and 17 ...
    // The fader wiper in is pin A14, and the touch line is pin 19.  See below for more on the fader MOTOR
    /*
    
    Switches        2       14      7       8      15      22     23     18     3      4      5     11     6
    
    mode 1 USB      MMC     MMC     MMC     MMC    MMC     MMC    MMC    Note70 71     72     73    74     Note75
                    STOP    PLAY    FFWD    RWD    PCHIN   PCHOUT PAUSE
           midi1       ""                  ""           ""               Note70         """"               Note75
           midi2       ""                  ""           ""               Note70         """"               Note75
    
    
    mode 2 USB      AfterT  AfterT  AfterT  AfterT
                    FPP     FPP     FPP     FPP    ...........                      ............           FPP
                    bankL   bankR   ChL     ChR    PLAY    PCH    STOP   RW     FF     REC    TCH   WRTE   SHIFT
           midi1    N/A                                     ...                                            N/A
           midi2    N/A                                     ...                                            N/A
    
    
    mode 3 USB      DOWN    UP      LEFT    RIGHT   A       B      C      D     E
           midi1    N/A                                     ...                                            N/A
           midi2    N/A                                     ...                                            N/A
    
    
    Encoder   L         R
    
    mode 1    CH 16-1   CH 1-16 (for swiches send)
    mode 2    FPP       FPP
              PANL      PANR
    mode 3    LEFT      RIGHT
    
    
    Fader
    
    mode 1     10 bit messages MSB CC 00 (3bits) LSB CC 32 (7bits)
    mode 2     10 bit messages MSB CC 00 (3bits) LSB CC 32 (7bits)
    mode 3     N/A
    
    
    MIDI RX1 TX1 RX2 TX2
    Midimerger / split / thru incl USB (but USB in /out has no thru...)
    
    RX1 to TX1, TX2, and USB
    RX2 to TX1, TX2, and USB
    USB to TX1 and TX2
    */
    
    #define MOTOR
    //Comment out '#define MOTOR' above if you DO NOT want to use the fader MOTOR on mode 1 and 2.
    //If using the MOTOR, the pwm / speed pin is 20, and the direction pin is 21.
    //The fader wiper in is pin A14, and the capacative touch line is pin 19.
    
    #define TOUCHTHRESH 2000     // Threshold for fader capacitive touch ... the fader is assumed to have capacative touch even if the MOTOR is not used. 
    #define HYST 2               // Amount of hysteresis jitter suppresion for the fader. A capacitor across wiper and ground is otherwise needed.
    
    /*In your setup, call ...
    myController13.Mode (mode1 pin, mode2 pin, mode3 pin)
    substituting your own pin numbers for the relevant mode
    3 modes ...1.MidiController 2.Faderport clone 3.MAME controller
    So ...
    myController13.Mode (4,5,11)
    makes pin 4 the switch for mode 1, pin 5 for mode 2, pin 11 for mode 3
    Once a selection is made via the switches, there is no way to change it unless you power cycle... after selection the pins have their 'usual functions' (above)
    */
    
    //Finally, in your loop, call myController13.Loop();
    
    void setup()
    {
      myController13.Mode(4, 5, 11);
    }
    
    void loop()
    {
      myController13.Loop();
    }
    The only outstanding thing is feedback for the channel selection rotary .... I'm thinking an oled and a teensy lc (controlled by sysex of course).
    Last edited by adrian; 01-30-2016 at 05:55 AM.

  7. #32
    Hey Bro,
    Just finished the Festival - life has been on hold the last 6 weeks!
    I have all the bits with me but no time to build, will have to drag it back to Norway with me to complete. Still haven't found any 280 ohm resistors - where did you get yours from? I've tried Jaycar and Surplustronics in Auckland but no joy :-(
    I will try and get to Wellington sometime next week - I am in Masterton at the mo. If I get near I'll buzz you for a coffee/beer!

  8. #33
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Dude! If you make it over the hill to Wellington, it would be fun to say hi!

    I was hoping to finish off my 2 x 2 / usb midi interface over easter ...I've got to mount it / connect it, and test the software yet .. here is a picture of the perf board etc. Of course I also want to get into the studio to finish a song idea I started last week ... and work is just so busy at the moment... sheesh. AND there is a cool new teensy library 'Talkie' I want to play with... hmm

    Click image for larger version. 

Name:	WP_20160326_006[1].jpg 
Views:	458 
Size:	107.5 KB 
ID:	6846

    I have exactly 2 x 270 ohm resistors!! You can have them if you like..... but they are like 2 cents or something from farnell / element 14 online... jay car can be a bit variable as to parts, but the wellington one is surprisingly good. Anyway, rock on, bro.
    Last edited by adrian; 03-25-2016 at 11:34 PM.

  9. #34
    Cool man, I'll keep you posted, I may be able to catch up wednesday night... We'll see how it plays out.
    I have 270 Ohm resistors, but the spec asks for 280... Am I being pedantic? Maybe a 270 is best used in parallel with a 10 ohm resistor also?

  10. #35
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Keep in touch, dude.

    The schematic I use says 270Ohm. And 270 vs 280 just doesn't matter, in my view ... think about using 5% tolerance parts, and well,.... for a MIDI circuit I'm sure it makes no difference....

  11. #36

    Simplified midithru

    HI guys, for a simple midithru (serial<->usb), do I need the whole midithru() function posted in this thread or can be semplified ? A very simple "pass everything as is".

    Thanks,
    Daniele.

  12. #37
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Hi

    midi serial to midi usb requires repackaging, transcoding if you like. here is a thread with working code etc etc. for a 2 x 2 interface post 14 / 16

  13. #38
    Quote Originally Posted by adrian View Post
    Hi

    midi serial to midi usb requires repackaging, transcoding if you like. here is a thread with working code etc etc. for a 2 x 2 interface post 14 / 16
    Ah ok, thanks !

    Daniele.

Posting Permissions

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