new custom midi controller

Status
Not open for further replies.

charnjit

Active member
Hello sir , i am a musician , i want to ask you that , as in every midi controller the potentiometer are use to increase/decrease value like pitch ,tempo. Can we attach two push button instead of every potentiometer for increase/decrease controller value (pitch,tempo) ? as like we control vol of tv by pressing - and + buttons what is the type of this midi controller? ,,,,,,,,,, please help me if you can
 
That's a fairly modest first project... should be fine.

What you need is a variable to store the last sent value for the controller (CC?) and on reading a button's is pressed add or subtract one from the variable and resend midi at the new level.

Are you looking for DIN out or USB out for the MIDI?

I would start with Paul's example on using bounce
https://www.pjrc.com/teensy/td_libs_Bounce.html#usingBounce
Code:
#include <Bounce.h>

const int buttonPin = 12;
Bounce pushbutton = Bounce(buttonPin, 10);  // 10 ms debounce

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");
}

byte previousState = HIGH;         // what state was the button last time
unsigned int count = 0;            // how many times has it changed to low
unsigned long countAt = 0;         // when count changed
unsigned int countPrinted = 0;     // last count printed

void loop() {
  if (pushbutton.update()) {
    if (pushbutton.fallingEdge()) {
      count = count + 1;
      countAt = millis();
    }
  } else {
    if (count != countPrinted) {
      unsigned long nowMillis = millis();
      if (nowMillis - countAt > 100) {
        Serial.print("count: ");
        Serial.println(count);
        countPrinted = count;
      }
    }
  }
}

There is already a variable keeping track of a count; which is doing what you want your 'plus' button to do.

So the trick is to add a second button that subtracts 1 instead of adds. So you need to change the one buttonPin to two (say by making buttonPinUp and buttonPinDown) and to make two bounce objects (says pushButtonUp and pushButtonDown) and two variables to store the previous state.

Once you can make the variable increment and decrement from two buttons then you can move to sending MIDI.
If you're doing USB this last part will be simple, if you want DIN output then hardware is your biggest obstacle.

Later you could add a feature that if the button is held for some many milliseconds it increments rapidly... and perhaps accelerates based on how long it's been held.

Topics:
Debounce a switch (needed to read the state of your button because swtich contacts 'bounce' when first engaged.
https://www.pjrc.com/teensy/td_libs_Bounce.html
usbMIDI - if you are looking to send midi through USB:
https://www.pjrc.com/teensy/td_midi.html
MIDI - if you are looking to connect thru standard MIDI DIN connectors:
https://www.pjrc.com/teensy/td_libs_MIDI.html
 
Last edited:
Sir , i am not good in english .please try to understand my request, i am using my laptop to playing rhytm live using software FL Studio . In performing beat ,i can do everything with my usb typing keyboard and usb mouse, but now i need to control tempo BPM ,Master Pitch while playing. So i want usb midi very tinny controller with teensy (which is controlled by push button - and + not potentiometer) i can easily connect any exrernal usb midi controller to assign any target like tempo and Master Pitch .but there is are 2 problems , first is large size which does not fit in my box. Second problem is , every controller comes with knobs and sliders. I want usb midi controller having 6 push button. 2 for control tempo. 2 for control Master pitch. 2 for control option target. So i decide to make my own. I want control tempo and Master Pitch with push buttons . in my fl studio software ,tempo bpm is 10.000 to 522.000 I want tempo should be increase by 1.000 bpm with every (+)press. And tempo should decrease by 1.000 bpm with every (-) press Now about pitch controller pitch is in default to 0 it can be -1200 cent to +1200 cent i want ,Master Pitch should increase by 100 cent(1semitone) with every press of (+) button and Pitch should decrease by 100 cent(1 semitone) with every press of (-) button i want to make this usb midi controller from teensy because i want to fit this controller in box with laptop. I dont have knowledg of electronics. So i am unable to understand technical language .I can solder push button to teensy pinouts with help of wiring diagram. I don't know about programming or coding. But i will do if you tell me step-by-step tutorial please help me making my own . can i get this controller ready-made . please help me thanks in advance to all.........
 
I also don't know which board is suitable for this project .so please tell me in simple language like as step-by-step tutorial
 
I also don't know which board is suitable for this project .so please tell me in simple language like as step-by-step tutorial
Any Teensy will do. The LC is normally the least expensive.

You want to connect your switches with one contact to a data pin and the other to ground.

Teensy supports usbMIDI directly so you don't need special hardware to connect MIDI from Teensy back to your computer.

You need to select 'MIDI' from the USB Type menu item in the Tools menu to activate the usbMIDI library.
 
Here is some code that prints to the serial monitor... just need to change to usb.send of some type like usbMIDI.sendControlChange()

I've avoided data arrays... which makes the code look a bit clunky but might be easier to understand.

Code:
#include <Bounce.h>
// tempo pitch target buttons up and down - assign pins
const int buttonPinTempoUp = 0;
const int buttonPinTempoDown = 1;
const int buttonPinPitchUp = 2;
const int buttonPinPitchDown = 3;
const int buttonPinTargetUp = 4;
const int buttonPinTargetDown = 5;

//initialize bounce objects to debouce switch noise
Bounce tempoUpButton = Bounce(buttonPinTempoUp, 10);  // 10 ms debounce
Bounce tempoDownButton = Bounce(buttonPinTempoDown, 10); 
Bounce pitchUpButton = Bounce(buttonPinPitchUp, 10);  
Bounce pitchDownButton = Bounce(buttonPinPitchDown, 10); 
Bounce targetUpButton = Bounce(buttonPinTargetUp, 10);  
Bounce targetDownButton = Bounce(buttonPinTargetDown, 10); 

void setup() {
  pinMode(buttonPinTempoUp, INPUT_PULLUP);
  pinMode(buttonPinTempoDown, INPUT_PULLUP);
  pinMode(buttonPinPitchUp, INPUT_PULLUP);
  pinMode(buttonPinPitchDown, INPUT_PULLUP);
  pinMode(buttonPinTargetUp, INPUT_PULLUP);
  pinMode(buttonPinTargetDown, INPUT_PULLUP);
  Serial.begin(9600);
}

byte tempoUpButtonPrvState = HIGH;         // what state was the button last time, start with HIGH
byte tempoDownButtonPrvState = HIGH;  
byte pitchUpButtonPrvState = HIGH;  
byte pitchDownButtonPrvState = HIGH;  
byte targetUpButtonPrvState = HIGH;  
byte targetDownButtonPrvState = HIGH;  

unsigned int tempo = 120;            // internal counters for midi values
unsigned int pitch = 0;            
unsigned int target = 0; 
unsigned int tempoLag = 120;            // internal counters for midi values - lagged values
unsigned int pitchLag = 0;            
unsigned int targetLag = 0;            
unsigned long changeTempoAt = 0;         // when tempo changed
unsigned long changePitchAt = 0;         // when pitch changed
unsigned long changeTargetAt = 0;         // when target changed



void loop() {

  // tempo buttons
  if (tempoUpButton.update()) {
    if (tempoUpButton.fallingEdge()) {
      tempo = tempo + 1;
      changeTempoAt = millis();
    }
  }  
  if (tempoDownButton.update()) {
    if (tempoDownButton.fallingEdge()) {
      tempo = tempo - 1;
      changeTempoAt = millis();
    }
  }

  //pitch buttons
  if (pitchUpButton.update()) {
    if (pitchUpButton.fallingEdge()) {
      pitch = pitch + 1;
      changePitchAt = millis();
    }
  }  
  if (pitchDownButton.update()) {
    if (pitchDownButton.fallingEdge()) {
      pitch = pitch - 1;
      changePitchAt = millis();
    }
  }

  //target buttons
  if (targetUpButton.update()) {
    if (targetUpButton.fallingEdge()) {
      target = target + 1;
      changeTargetAt = millis();
    }
  }  
  if (targetDownButton.update()) {
    if (targetDownButton.fallingEdge()) {
      target = target - 1;
      changeTargetAt = millis();
    }
  }

  // print --- change to usb.send midi commands!
  if (tempo != tempoLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTempoAt > 100) {
      Serial.print("tempo: ");
      Serial.println(tempo);
      tempoLag = tempo;
    }
  }
  if (pitch != pitchLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changePitchAt > 100) {
      Serial.print("pitch: ");
      Serial.println(pitch);
      pitchLag = pitch;
    }
  }
  if (target != targetLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTargetAt > 100) {
      Serial.print("target: ");
      Serial.println(target);
      targetLag = target;
    }
  }
}

This is what I was suggesting in my first post but with three parameters and six buttons.
 
Thanks to give me code . please give me wiring diagram push button to pinouts of board . sir , i am carpenter & musician(keyboard) . i did not make any electronic project .please help me in full procedure of making custom midi controller step-by-step , ( purchasing board - to -playing midi controller. As getting start. I shall be highly thankful you
 
... I want control tempo and Master Pitch with push buttons . in my fl studio software ,tempo bpm is 10.000 to 522.000 I want tempo should be increase by 1.000 bpm with every (+)press. And tempo should decrease by 1.000 bpm with every (-) press Now about pitch controller pitch is in default to 0 it can be -1200 cent to +1200 cent i want ,Master Pitch should increase by 100 cent(1semitone) with every press of (+) button and Pitch should decrease by 100 cent(1 semitone) with every press of (-) button i want to make this usb midi controller from teensy because i want to fit this controller in box with laptop. I dont have knowledg of electronics. So i am unable to understand technical language .I can solder push button to teensy pinouts with help of wiring diagram. I don't know about programming or coding. But i will do if you tell me step-by-step tutorial please help me making my own . can i get this controller ready-made . please help me thanks in advance to all.........
I would need someone to be able to tell me exactly what the MIDI messages need to look like...

Its possible you don't need to keep track of the current value if there is an increment/decrement adjustment for each of these. If so then the code will be much simpler.
 
Thanks to give me code . please give me wiring diagram push button to pinouts of board . sir , i am carpenter & musician(keyboard) . i did not make any electronic project .please help me in full procedure of making custom midi controller step-by-step , ( purchasing board - to -playing midi controller. As getting start. I shall be highly thankful you

For each switch one wire goes to its pin and the other goes to ground.
See 'Input with Pullup' section of this page: https://www.pjrc.com/teensy/td_digital.html

Because I do not have FL Studio I don't know how it accepts tempo/pitch/target changes via midi and in the absence of that I don't think I can help.
 
Thank you sir, i understand wiring of buttons with board. Teensy LC will be used. no matter you don't know about fl studio. You gave me code for making usb midi controller . please,----------------------answer---------the----------question--------- --------------------will it controll 3 parameters by pressing push button ? If my software detect as extrnal midi controller , i can assign any controller pair of button to my desired knob in software window. I can also set input rate of parameter. --------------Will this controller control 3 parameter using push button? If yes , i want know abuot , --------------- how to programming & coding? ------------------------Which softwares are needed in complete project. ---------------------Can board be damege during software process with any wrong step or wrong programe?. ,,,,,,,,,,, ,,, please give answer to questions ,,,,,,,,Thank you
 
Thank you sir, i understand wiring of buttons with board. Gnd+0= button 1 ,Gnd+1= button2 , gnd+2=button4......
etc . Teensy LC will be used. no matter you don't know about fl studio. You gave me code for making usb midi controller . please,----------------------answer---------the----------question--------- --------------------will it controll 3 parameters by pressing push button ? If my software detect as extrnal midi controller , i can assign any controller pair of button to my desired knob in software window. I can also set input rate of parameter. --------------Will this controller control 3 parameter using push button? ------------ will (button1 and button 2) act as c1,(button3 and button4) act as c2, (button5 and button6) act as c3. Where c1,c2,c3 are controller. -------------will this project be detected as external midi controller ? If yes , i am right ,,, now i want know abuot , --------------- how to programming & coding? ------------------------Which softwares are needed in complete project. ---------------------Can board be damege during software process with any wrong step or wrong programe?. ,,,,,,,,,,, ,,, please give answer to questions ,,,,,,,,Thank you
 
Yes... it's should be fairly simple to take the code above and have it send MIDI CC messages such that the parameter value increases or decreases by one when one of its button are pushed.

You can select any CC you wish for each pair of buttons but that is the part of the code that needs to be added.

If you select MIDI as the USB output type the Teensy will appear to your computer as a midi controller.

What I don't know is how FL Studio will know how much to map CC values to meaningful changes in tempo or pitch.
And that's the part that could be a major problem.




I think you need to learn a bit yourself about how to program Teensy.

When you buy the board don't try to make this project until you can understand the tutorials.
 
Thank you sir for writing code for me . I read code . I seemed it is correct according to my needs. ..........but I get troubleshooting in programming ...please read here my problem....., I tried program teensy as midi controller ..... Step1- I downloaded & install Arduino 1.6.11 ,teesyduino ,teensy loader. ........step 2- I connect teensy board into any one USB port of laptop .It was running blinking led .i did not install any serial driver because it it was not apeared in device manager. (perhaps ,it is reason of troubling).next I open teensy loaeder & Arduino software on window7. Then i paste code text (written by senior member) in new sketch. I select "teensy LC" from board & "Midi" from usb type. I varified sketch. No error was appear . After this i upload sketch into teensy .after uploading i pushed button on teensy board . Led was not blinking after uploading ........... Step3- I removed board from usb port . Then I tried to test it . I saw that, when board is plugged , my software not open properly & hang some time . If i open music software before connecting board then software detect it as "teensy midi" but not working. There is also a midi meter in my software window in which we can test that our midi controller is working or not .this teensy is not doing any activity in midi meter .In propties this is apeared as Audio device,input .main thing is , my music software does not sound if this teensy board is connected.if this board is connected to PC already , my music software & other audio applications are fails to run..(I have use my synthesizer as midi controller properly. I know how to link external midi controller with music software) .these problems was not happening , when I was use my synthesizer as midi controller .......... I seemed it has not programmed correctly ------------have i programmed it wrong way? - what can I do next? Can i re-program it ? If yes ,please tell how. Please , please, give me any solution ,,,,
 
This is months ago and I hardly remember even writing the above fragment.

The post with the code says it only sends to the serial monitor.
I was expecting you would figure out what midi you want to send and how to send it....
... Because I do not have FL Studio I don't know how it accepts tempo/pitch/target changes via midi and in the absence of that I don't think I can help.

The problem with your host could be from running the above code as if it were already a MIDI controller and it's missing this code:
Code:
  // MIDI Controllers should discard incoming MIDI messages.
  while (usbMIDI.read()) {
  }

My advice from before stands... work through the tutorials... try making a single-button controller and using it to send usbMIDI to your computer by following Paul's usbMIDI page.
 
Ok... the code above but set to send CC messages.

I'm not sure if this will work for the intended use but it does what you originally asked.

Code:
#include <Bounce.h>
// CC messages
const int ccTempo = 1;
const int ccPitch = 2;
const int ccTarget = 3;
const int midiChannel = 0; // MIDI channel, 0 is omni
// tempo pitch target buttons up and down - assign pins
const int buttonPinTempoUp = 0;
const int buttonPinTempoDown = 1;
const int buttonPinPitchUp = 2;
const int buttonPinPitchDown = 3;
const int buttonPinTargetUp = 4;
const int buttonPinTargetDown = 5;

//initialize bounce objects to debouce switch noise
Bounce tempoUpButton = Bounce(buttonPinTempoUp, 10);  // 10 ms debounce
Bounce tempoDownButton = Bounce(buttonPinTempoDown, 10); 
Bounce pitchUpButton = Bounce(buttonPinPitchUp, 10);  
Bounce pitchDownButton = Bounce(buttonPinPitchDown, 10); 
Bounce targetUpButton = Bounce(buttonPinTargetUp, 10);  
Bounce targetDownButton = Bounce(buttonPinTargetDown, 10); 

void setup() {
  pinMode(buttonPinTempoUp, INPUT_PULLUP);
  pinMode(buttonPinTempoDown, INPUT_PULLUP);
  pinMode(buttonPinPitchUp, INPUT_PULLUP);
  pinMode(buttonPinPitchDown, INPUT_PULLUP);
  pinMode(buttonPinTargetUp, INPUT_PULLUP);
  pinMode(buttonPinTargetDown, INPUT_PULLUP);
  Serial.begin(9600);
}

byte tempoUpButtonPrvState = HIGH;         // what state was the button last time, start with HIGH
byte tempoDownButtonPrvState = HIGH;  
byte pitchUpButtonPrvState = HIGH;  
byte pitchDownButtonPrvState = HIGH;  
byte targetUpButtonPrvState = HIGH;  
byte targetDownButtonPrvState = HIGH;  

unsigned int tempo = 120;            // internal counters for midi values
unsigned int pitch = 55;            
unsigned int target = 8; 
unsigned int tempoLag = 120;            // internal counters for midi values - lagged values
unsigned int pitchLag = 0;            
unsigned int targetLag = 0;            
unsigned long changeTempoAt = 0;         // when tempo changed
unsigned long changePitchAt = 0;         // when pitch changed
unsigned long changeTargetAt = 0;         // when target changed



void loop() {

  // tempo buttons
  if (tempoUpButton.update()) {
    if (tempoUpButton.fallingEdge()) {
      tempo = tempo + 1;
      changeTempoAt = millis();
    }
  }  
  if (tempoDownButton.update()) {
    if (tempoDownButton.fallingEdge()) {
      tempo = tempo - 1;
      changeTempoAt = millis();
    }
  }

  //pitch buttons
  if (pitchUpButton.update()) {
    if (pitchUpButton.fallingEdge()) {
      pitch = pitch + 1;
      changePitchAt = millis();
    }
  }  
  if (pitchDownButton.update()) {
    if (pitchDownButton.fallingEdge()) {
      pitch = pitch - 1;
      changePitchAt = millis();
    }
  }

  //target buttons
  if (targetUpButton.update()) {
    if (targetUpButton.fallingEdge()) {
      target = target + 1;
      changeTargetAt = millis();
    }
  }  
  if (targetDownButton.update()) {
    if (targetDownButton.fallingEdge()) {
      target = target - 1;
      changeTargetAt = millis();
    }
  }

  // print --- change to usb.send midi commands!
  if (tempo != tempoLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTempoAt > 100) {
      usbMIDI.sendControlChange(ccTempo , tempo, 0);
      tempoLag = tempo;
    }
  }
  if (pitch != pitchLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changePitchAt > 100) {
      usbMIDI.sendControlChange(ccPitch , pitch, 0);
      pitchLag = pitch;
    }
  }
  if (target != targetLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTargetAt > 100) {
      usbMIDI.sendControlChange(ccTarget, target, 0);
      targetLag = target;
    }
  }

  // MIDI Controllers should discard incoming MIDI messages.
  while (usbMIDI.read()) {
  }
}
 
Last edited:
teensy vs roland.jpg
thank you sir , for a bit look at me. ..No problem if you don't know about FL Studio.My FL Studio has not a special setting for midi interface.There is not a special
midi contoller made for only FL studio. Every Generic controller is working. I had use three words(tempo,pitch,target) to tell you only just three parameter.
We can also use words (Parameter1,Parameter2,Parameter3). My FL Studio does not assign any slider or knob to particular parameter automaticaly. when we
connect any(plug & play)midi contoller to PC. we will enable it in midi menu by name.it will be ready to use. Any activity of midi controller like as moving slider,knob or pressing any button will be show in midi meter(midi meter show us that our midi controller in working or not) in this soft ware.we can assign any parameter to be control from any knob or slider by setup of that parameter manualy .I am using my( Roland xp 30 synthesizer) as midi controller [you are seeing in picture].I enabled it as
generic controller in FL Studio once. Now every time FL studio establish link to it automaticaly if it is connected.No matter if we connect it after opening software
.it begin working like as(usb optical mouse or typing keyboard). I also did not intall any driver for it.It is working as plug&play Device. ,,,,,,,,,,,,,,,,,,,,,,


Now please attention to troubleshooting. ....
Please Note two main problem
(1): this board is also not doing any activity in serial monitor of Arduino .(2) My FL studio is not be open if teensy is connected .if i connect it after opening
FL Studio,it does not responding.I mean teensy is disturbing to my software.
,,,,,you made code to control 3 Parameters. I am going to explain
again that i want to use it in music software as midi controller.it should be only input device. It should control parameter value like( as knob or slider are control value in generic controller )through push buttons.please careful, first parameter(mention as "tempo" in sketch) should be highest by pressing increase button 512 times if we start from lowest .second & third parameter should be lowest to highest by pressing incease button 24 times.highest to lowest should be same way.
you already know which custom code should be upload to teensy for this purpose.I don't know about fuctions of sketch .so if there is need to make fuction
change in sketch, please edit it. and post it .i will copy whole text and paste to arduino New Sketch. ,,,,,,,,,,,,,,,should i re-upload sketch ?
,,,,,,,,,,,,,,,,i have done it without intalling serial drivers(following a tutorial from internet). am i right?
,,,,,,,,,,,,,,,,,,,,,,,,,,,A lot of THANKS you,in advance,,,,,,,,,,,,,,,,,,,,,,,,,,,,,teensy vs roland.jpg
 
Yes there are no drivers to install. Teensy is a USB MIDI complaint device and Windows and Mac should see it as one.

To customize the step size the tempo, pitch, target values would need to have adjustment by a step size value (powers of 2).

Also... the above code does not impose zero minimum or 127 maximums for the incremented/decremented values.


128 steps total is the maximum supported by 7-bit CC messages and to do 512 you would have to send two CCs -- even though you'd only be using 2 of the extra 7 bits.

The number of steps from top to bottom (to be even) must be powers of two, so 24 is out.

This code is close the but max() commands are not working to stop the values going negative.
Code:
#include <Bounce.h>
// CC messages
const int ccTempo = 1;
const int ccPitch = 2;
const int ccTarget = 3;
//step sizes -- must be 2^n to cover range evenly
const int tempoStep = 1;
const int pitchStep = 8;
const int targetStep = 8;
//time allowances
const int DBms = 10; // debounce time
const int MIDIms = 50; // MIDI speed limit
// MIDI channel, 0 is omni
const int midiChannel = 0; 
// tempo pitch target buttons up and down - assign pins
const int buttonPinTempoUp = 0;
const int buttonPinTempoDown = 1;
const int buttonPinPitchUp = 2;
const int buttonPinPitchDown = 3;
const int buttonPinTargetUp = 4;
const int buttonPinTargetDown = 5;

//initialize bounce objects to debouce switch noise
Bounce tempoUpButton = Bounce(buttonPinTempoUp, DBms);  
Bounce tempoDownButton = Bounce(buttonPinTempoDown, DBms); 
Bounce pitchUpButton = Bounce(buttonPinPitchUp, DBms);  
Bounce pitchDownButton = Bounce(buttonPinPitchDown, DBms); 
Bounce targetUpButton = Bounce(buttonPinTargetUp, DBms);  
Bounce targetDownButton = Bounce(buttonPinTargetDown, DBms); 

void setup() {
  pinMode(buttonPinTempoUp, INPUT_PULLUP);
  pinMode(buttonPinTempoDown, INPUT_PULLUP);
  pinMode(buttonPinPitchUp, INPUT_PULLUP);
  pinMode(buttonPinPitchDown, INPUT_PULLUP);
  pinMode(buttonPinTargetUp, INPUT_PULLUP);
  pinMode(buttonPinTargetDown, INPUT_PULLUP);

}

byte tempoUpButtonPrvState = HIGH;         // what state was the button last time, start with HIGH
byte tempoDownButtonPrvState = HIGH;  
byte pitchUpButtonPrvState = HIGH;  
byte pitchDownButtonPrvState = HIGH;  
byte targetUpButtonPrvState = HIGH;  
byte targetDownButtonPrvState = HIGH;  

unsigned int tempo = 63;            // internal counters for midi values
unsigned int pitch = 63;            
unsigned int target = 63; 
unsigned int tempoLag = 0;            // internal counters for midi values - lagged values
unsigned int pitchLag = 0;            
unsigned int targetLag = 0;            
unsigned long changeTempoAt = 0;         // when tempo changed
unsigned long changePitchAt = 0;         // when pitch changed
unsigned long changeTargetAt = 0;         // when target changed



void loop() {

  // tempo buttons
  if (tempoUpButton.update()) {
    if (tempoUpButton.fallingEdge()) {
      tempo = min(tempo + tempoStep,127);
      changeTempoAt = millis();
    }
  }  
  if (tempoDownButton.update()) {
    if (tempoDownButton.fallingEdge()) {
      tempo = max(tempo - tempoStep,0);
      changeTempoAt = millis();
    }
  }

  //pitch buttons
  if (pitchUpButton.update()) {
    if (pitchUpButton.fallingEdge()) {
      pitch = min(pitch + pitchStep,127);
      changePitchAt = millis();
    }
  }  
  if (pitchDownButton.update()) {
    if (pitchDownButton.fallingEdge()) {
      pitch = max(pitch - pitchStep,0);
      changePitchAt = millis();
    }
  }

  //target buttons
  if (targetUpButton.update()) {
    if (targetUpButton.fallingEdge()) {
      target = min(target - targetStep,127);
      changeTargetAt = millis();
    }
  }  
  if (targetDownButton.update()) {
    if (targetDownButton.fallingEdge()) {
      target = max(target - targetStep,0);
      changeTargetAt = millis();
    }
  }
// send CC messaages if value has changed and 100 ms have lasped since last
  if (tempo != tempoLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTempoAt > 100) {
      usbMIDI.sendControlChange(ccTempo , tempo, midiChannel);
      tempoLag = tempo;
    }
  }
  if (pitch != pitchLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changePitchAt > 100) {
      usbMIDI.sendControlChange(ccPitch , pitch, midiChannel);
      pitchLag = pitch;
    }
  }
  if (target != targetLag) {
    unsigned long nowMillis = millis();
    if (nowMillis - changeTargetAt > 100) {
      usbMIDI.sendControlChange(ccTarget, target, midiChannel);
      targetLag = target;
    }
  }

  // MIDI Controllers should discard incoming MIDI messages.
  while (usbMIDI.read()) {
  }
}
 
Last edited:
Thank you a lot ,,,,,,,,,,, congratulation ,,,,,,, I succeed in this project ,,,,I completed my dreamy midi controller,,,,, I love you ,,,,,,,thank very much again,,,,,,,,,,
 
Sir , I am highly thankful to you, you are giving me help in my project.
As i have requested you somethings i my older posts. You should watch my this video before read more below
IMG_0592.jpg

Note: i want to asign first two button for tempo, and second two buttons for Master Pitch in every file.third two buttons
Are extra spare parameter like a EFX.
Now you saw, Teensy is controlling tempo with 4BPM rate per one press . But it works very well only in three condition.
Condition1: if i will working only in current file.Not will open next file.
Condition2: if i will not use usb mouse to ind/dec tempo.
Condition3: if i will not use [Tempo Tap] to change tempo. ([Tempo Tap] is a command to change tempo in desired metronome ,it can not be used every time)
Teensy is working only if i am using only its buttons and working in only current file.
Sir, there are three methods to control tempo in FL Studio using teensy’s button, using usb mouse,using [Tempo Tap].
I want to use all of these three methods.Teensy is creating problem when these methods are use before teensy.
I wants also acess so many rhythm file one by one. Teensy also create problem, when previous file is closed & next file is opened.
When tempo is changed to New Tempo by other methods. Teensy does not care of New Tempo before it is used.
It always does inc/dec in previous tempo which was made by teensy’s button last time. For example i made tempo 40 t o 55 by teensy. Then i changed tempo 55 to 100 by usb mouse. Now teensy will inc/dec in 55 not in 100. here i want it should inc/dec in 100
I wants My Teensy should detect current tempo every time before use of teensy.then it should inc/dec in current tempo.when previous file is closed and next file is opened. It should detect current tempo of new file.And it should inc/dec in current tempo.
Sir , if you have understood this above statement and you want to know more or tell me before doing next step. Please ask me,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,thanks for reading
 
I'm jumping into this late, but it appears from reading the thread from top to bottom and looking at your video that you have built a midi controller using a teensy and can successfully send midi control messages to the software. The first problem I observe related to your current concern is that there is no feedback to the controller, to tell it that you loaded a new file. The Teensy code posted above and the samples discard any incoming messages, so there is no way for your teensy code to get feedback from the software loading files (if indeed there is any). I'm no midi expert or tinkerer, but what I observe of the code that is posted it appears you start with a tempo of 120 and keep track of changes from that number, if you adjust tempo to 160 , reload a file and try to 'decrease tempo' it will be decreasing from 160 , not the original 120, and not whatever tempo the file is playing at on the S/W you are using, as there is no feedback to your teensy to notify it of the change of file or its associated control channels. You could confirm my suspicions by printing tot he serial console all the control messages you are sending and re-do your test / video example.

Cheers and best wishes working through this.
 
First of all , I highly thankful to PJRC senior staff . I specialy thanks to Mr Oddson for help me in my teensy project.
I want to attention you on my teensy Project. And wants to show you what i found last time after uploading above codes to this my Teensy LC.
There is a video of using Teensy Lc(as midi controller). Inwhich you will see how teensy is misbehaving against my desire.


Statement below only for First parameter “Tempo” :-
In this video you saw teensy does not begins inc/dec from current value .It always begins inc/dec from that value which was created by teensy’buttons. There it should be start from current value always.

For example:- if i increased tempo 45 to 90 using teensy’s buttons. After this i increased tempo 90 to 135 by dragging usb mouse . Now if i want to push +button from teensy to increase tempo,then tempo increasing will not be start from current value 135. It will be start from 90. Because of tempo was 90 when teensy was used before use of usb mouse.

Same this way ,,,suppose i increased tempo of current file 90 to 130 using teensy’s buttons. After this i closed this file and opened next file having 75 tempo.now if i want to increase current tempo . then increasing will be stert from 130 instead of current value 75. Because of tempo was 130 when teensy was used for tempo.
Although there are many ways to inc/dec tempo parameter(use of teensy,use of usb mouse.Tap Tempo button) but all of them are compulsory. Because of they have their own importance in my live performance. Any of them can not be left.

Above statment “start controlling parameter from current value” is only for 1st Parameter tempo not for pitch or other. Because i have seen that my synthesizer’tempo was being auto sync with FL Studio’tempo when i was inc/dec tempo of FL studio by usb mouse or Tap Tempo button.


Another changes in code should be done according to below statement:-
1. Using previous codes , tempo is being inc/dec by 4.032 bpm.Here it should be inc/dec by 1.000 bpm.
Now -------------one press of button=4.032 for tempo
But i want-----one press of button= 1.000 for tempo

2. Using previous codes , pitch is being inc/dec by 1.51 cent.Here it should be inc/dec by 1.00 cent.
Now -------------one press of button=1.51 for pitch
But i want-----one press of button= 1.00 for pitch

I request to all of you for help me in this project. I don,t know about programming and midi language. I cannot understand & modify any codes .PJRC.com is the last & best platform for me about this project. So i hardly request you.please .............please.......

Please make changes in codes given in obove previous post having care of 3 points
1. Inc/dec of Tempo should be start from current value every time .(only for tempo not for pitch or other)
2. Tempo should be inc/dec by 1.000 bpm instead of 4.032 with one press of tempo(-.+) button.
3. Pitch should be inc/dec by 1.00 cent instead of 1.51 with press of pitch (-,+) button.
,,,,,,,,,,,,,,,,,,,,,,,THANK YOU,,,,,,,,,,,,,,
 
I don't work for PJRC and they don't do free custom-software development either. ;)

My advice is go to Image-Line's forum and ask for some help to determine which MIDI messages need to be sent to get the behaviour you're looking for (and/or how to map an external controller button to the functionality that already exists in the software!)

If you can't figure out how to send that MIDI from Teensy THEN come back here and ask ... in a new thread... for some help.
 
...
Please make changes in codes given in obove previous post having care of 3 points
1. Inc/dec of Tempo should be start from current value every time .(only for tempo not for pitch or other)
...
By-the-way - I don't think you're going to have much luck with the first one since you've indicated that you mean it should know when the tempo was changed in the host by some other means ... which means you'll have to listen for tempo info coming FROM the host and suddenly you don't have a simple controller any more.
 
There are few that work for PJRC, most of us are users who try to support each other. I like oddson's suggestion in #22. I hope you have success.
 
sorry sir, i am unable to post on image-line's Forum at this time.
please see this pic & read texts . if any solution is possible,,,,,
otherwise i will try again to image-line's Forum
fl scr.jpg
Now ,i am using usb optical mouse for this but i wants to be done it by Teensy's buttons.Because plcacing cursor on pitchslider & Tempo Digits
is very difficult in very quickly,.
tell me (while runnig software) if any software or special procedure to find midi messages need to be sent to fl studio for above operation by teensy without placing cursor in tempo & Pitch Slider .

otherwise i will try again to image-line's forum or any more..... and start new thread,,,
 
Last edited:
Status
Not open for further replies.
Back
Top