将MIDI从Ableton发送到Processing,但无法可视化接收到的数据

时间:2019-06-22 09:50:50

标签: processing midi ableton-live

我无法使用通过MidiBus接收的MIDI数据。问题是我无法使用收到的数据;例如创建形状。我得到的只是一个仅显示一次的正方形,仅此而已。

import themidibus.*;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.SysexMessage;
import javax.sound.midi.ShortMessage;

MidiBus myBus;

int pitch;
int velocity;
int place; //ignore this
int channel;
int p1; //serves as temp pitch
int v1; //serves as temp velocity

void setup() {
  size(480, 108);
  smooth();
  MidiBus.list();
  frameRate(60);
  ellipseMode(CENTER);
  myBus = new MidiBus(this, 2, 0);
}

void draw () {
  noStroke();
  fill(70, 10);
  rectMode(CORNER);
  rect(0, 0, width, height);

  if (pitch == 46) {
    fill(255);
    ellipse(width/2, height/2, p1, p1);
  } else if (pitch == 42) {
    fill(255, 0, 0);
    rectMode(CENTER);
    rect(width/2, height/2, p1, p1);
  } else if (p1 == 39) {
    fill (0, 150, 190);
    rectMode(CENTER);
    rect(width/2, height/2, p1, p1);
  } else if (p1 == 36) {
    fill(0, 0, 255);
    rectMode(CENTER);
    rect(width/2, height/2, p1, p1);
  }

  if (v1 == 127) {
    for (int i=0; i<5; i++) {
      place = (width/4) *i;
      if (i==4) {
        i=0;
      }
    }
  }
  strokeWeight(5);
  strokeCap(ROUND);
  line(place, 0+height/10, place, height-height/10);


  myBus.sendNoteOn(channel, pitch, velocity);
}


void noteOn(int channel, int pitch, int velocity) {
  p1=pitch;
  v1=velocity;
  println("pitch : "+pitch);
  println("velocity : "+velocity);
}

我希望可以在形状参数中使用MIDI数据值来绘制形状。

0 个答案:

没有答案