Library for super EASY Teensy MIDI programming
Results 1 to 5 of 5
  1. #1
    Tech Mentor
    Join Date
    Apr 2012
    Location
    Berlin
    Posts
    150

    Default Library for super EASY Teensy MIDI programming

    Do you want to build your dream controller but don't have the know-how or just can't be bothered going through that complex process of programming? Not a problem at all, I have developed a library for Teensy that wraps up and hides the ugly process of reading pins and deciding whether to send MIDI signals or not, into couple of easy to use Classes. Just create an instance for each component of your controller, like Button, Potentiometer, LED etc and just with couple lines of code never bother again about the logic behind it.

    Here is a simple example for a fully functioning one button and fader controller:

    Code:
    boolean debug=false; // print to serial instead of midi
    boolean secondary=true; // enable secondary midi messages
    int midiChannel=1; // midi channel number
     
    // declare all your components here
    Button but(17,midiChannel,1,secondary,debug); // button 1 on pin 17
    Potentiometer pot(45,midiChannel,3,secondary,debug); // knob on pin 45 (A7)
     
    void setup(){
    }
     
    void loop(){
      // add here all the input component reads
      pot.read(); // read knob and send midi messages
      but.read(); // read buttons and send midi messages
    }
    Download: https://github.com/ghztomash/MIDIElements
    Doc: http://tomashg.com/?p=854

  2. #2

    Default

    Quote Originally Posted by ghztomash View Post
    Do you want to build your dream controller but don't have the know-how or just can't be bothered going through that complex process of programming? Not a problem at all, I have developed a library for Teensy that wraps up and hides the ugly process of reading pins and deciding whether to send MIDI signals or not, into couple of easy to use Classes. Just create an instance for each component of your controller, like Button, Potentiometer, LED etc and just with couple lines of code never bother again about the logic behind it.

    Here is a simple example for a fully functioning one button and fader controller:

    Code:
    boolean debug=false; // print to serial instead of midi
    boolean secondary=true; // enable secondary midi messages
    int midiChannel=1; // midi channel number
     
    // declare all your components here
    Button but(17,midiChannel,1,secondary,debug); // button 1 on pin 17
    Potentiometer pot(45,midiChannel,3,secondary,debug); // knob on pin 45 (A7)
     
    void setup(){
    }
     
    void loop(){
      // add here all the input component reads
      pot.read(); // read knob and send midi messages
      but.read(); // read buttons and send midi messages
    }
    Download: https://github.com/ghztomash/MIDIElements
    Doc: http://tomashg.com/?p=854
    The issue I have is the whole multiplexer thing; if I made my own controller, it'd have WAY more controls than the Teensy board can support :-\

  3. #3
    Tech Mentor
    Join Date
    Apr 2012
    Location
    Berlin
    Posts
    150

    Default

    Quote Originally Posted by mdcdesign View Post
    The issue I have is the whole multiplexer thing; if I made my own controller, it'd have WAY more controls than the Teensy board can support :-\
    You could definitely use each class with a multiplexer. Declare an array of Pots for example, all on the same pin. and then while reading through all the elements in a loop update the mux in selector.
    Probably I will add a multiplexer class at some point

  4. #4
    Tech Convert
    Join Date
    Dec 2012
    Posts
    18

    Default

    Quote Originally Posted by ghztomash View Post
    You could definitely use each class with a multiplexer. Declare an array of Pots for example, all on the same pin. and then while reading through all the elements in a loop update the mux in selector.
    Probably I will add a multiplexer class at some point
    Thanks for the sketches but I cant understand how to use them or put them together into a whole. could you do a brief explanation of how they fit together?

    im trying to get 2 pot outputs and 2 button outputs from a gameport joystick.

  5. #5
    Tech Mentor
    Join Date
    Apr 2012
    Location
    Berlin
    Posts
    150

    Default

    Hey, if you open up the examples included with the library there is one empty template you could fill in and a complete working example with comments. Head over to http://tomashg.com/?p=854 for the complete list of functions, classes and their description.

    if you want to read 2 pots and 2 buttons from your teensy, then create two objects of each class, for example
    Potentiometer pot1(the pin number the pot is connected on your teensy, midi channel you want it to send the message on, the control change number you want it to use); same for pot2, and the buttons but with different pin number and cc number,

    then inside void loop call the read function for every instance, pot1.read(); pot2.read(); button1.read(); button2.read(); and that's it!

    also note that you have to set the USB Type to MIDI in the Arduino IDE or else the library will not compile.

Tags for this Thread

Posting Permissions

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