Library for super EASY Teensy MIDI programming

Home :: Reviews of DJ equipment :: Library for super EASY Teensy MIDI programmingReply
Library for super EASY Teensy MIDI programming
Posted on: 08.03.2013 by Brendan Andrascik
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
Weldon Dilg
11.03.2013
Originally Posted by ghztomash
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.
Brendan Andrascik
09.03.2013
Originally Posted by mdcdesign
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
Doreen Schurle
08.03.2013
Originally Posted by ghztomash
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 :-\
Brendan Andrascik
08.03.2013
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
Brendan Andrascik
12.03.2013
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.
Weldon Dilg
11.03.2013
Originally Posted by ghztomash
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.
Brendan Andrascik
09.03.2013
Originally Posted by mdcdesign
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
Doreen Schurle
08.03.2013
Originally Posted by ghztomash
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 :-\

<< Back to Reviews of DJ equipment Reply

Copyright 2012-2023
DJRANKINGS.ORG n.g.o.
Chuo-ku, Osaka, Japan

Created by Ajaxel CMS

Terms & Privacy