MIDI On / Off events and changing things already on canvas

edited April 2015 in Library Questions

I have a small working program that takes MIDI NoteOn events (using theMidiBus library) to simply draw circles on screen (their location in space and their size is determined by which MIDI note and how hard it is pressed). Every 10 seconds, the screen is reseted to a white canvas.

Simple.

I want it to be able to draw a circle with a thick border (perhaps using strokeWeight) and SOMEHOW change the strokeWeight AFTER the note is RELEASED (using the noteOff event). This way, out of all the circles on the screen in any given 10 second chunk, it is obvious which circles correspond to notes that are still pressed down.

It sounds easy but I'm just not familiar enough to understand how a circle previously created can be manipulated easily. Ideas?

Answers

  • Answer ✓

    You can use something like this (adding midi signals):

    int time = 0;
    int start;
    int sw = 2;
    void setup(){
      size(100,100);
    }
    
    void draw(){
      background(100);
      time = millis() - start;
      if(time<10000){
        fill(255);
        strokeWeight(sw);
        ellipse(width/2,height/2,30,30);
      }else { 
        time=millis(); 
      }
      if (mousePressed){
        start = millis();;
      }
      text(time,30,height-10);
    }
    
    void keyPressed (){
      sw+=1;
    }
    
Sign In or Register to comment.