map knobs and buttons from a midi controller to parameters

edited March 2017 in Library Questions

I'm trying to map a midi controller to change parameters in my sketches. I've installed the ControlP5 library. It seems to have everything I need to make gui buttons and knobs, but how do I map midi to those? Do I need to use the midiBus library in conjunction with ControlP5?

Does anyone have a relatively simple example of this implementation?

Tagged:

Answers

  • Answer ✓

    Please check the reference for the following keywords: map() and lerp().

    A simple example. If you midi provides a value, let's say volume (you store the value in a variable call inVol) which is a value from 0 to 100%, then you could use the map function to map the input value to the sketch'es height:

    float minVol=0;
    float maxVol=100;
    float minHeight=height;
    float maxHeight=0;
    posY=map(inVol,minVol,maxVol,minHeight,maxHeight);
    

    Notice that minHeight, the bottom of the screen, is at location Y dictated by height. The top of the sketch is zero. This detail will make sense if you are familiar with processing.

    Kf

Sign In or Register to comment.