[promidi] noteOff problem ?
in
Contributed Library Questions
•
4 months ago
Hi folks !
I'm trying to set midiOut.sendNote in this simple grid pattern sequencer but have some issues (infinite notes) when two notes have to be played 'simultaneously'…
You'll have to use a DAW to receive the midi / play it on a virtual instrument
Can someone help me with that ?
thanks in advance !
I'm trying to set midiOut.sendNote in this simple grid pattern sequencer but have some issues (infinite notes) when two notes have to be played 'simultaneously'…
You'll have to use a DAW to receive the midi / play it on a virtual instrument
Can someone help me with that ?
thanks in advance !
- import promidi.*;
- MidiIO midiIO;
- MidiOut midiOut;
- Note note;
- int minMidi = 44; // midi MIN (21?)
- int scale = 16+1; // midi SCALE
- int maxMidi = minMidi+scale; // midi MAX (108?)
- final int rows = 16;
- final int cols = 16;
- final int s = 25;
- color[][] colors; // tableau double entrée
- boolean[][] isActive;
- boolean[][] notePlayed;
- color inactive_color, accent_color, pressed_color, active_color, tempo_color, played_color;
- int mousePosX, mousePosY;
- float BPM = 80;
- float startTime;
- float currentTime;
- float millisPerBeat = (1000/(BPM/60.0))/4;
- int currentBeat;
- //////////////////////////////////////////////////////////////////////////
- void setup() {
- midiIO = MidiIO.getInstance(this);
- midiIO.printDevices();
- midiOut = midiIO.getMidiOut(0, 0);
- size(rows*s+1, cols*s+1);
- colors = new color[rows][cols];
- inactive_color = color(40);
- accent_color = color(50);
- pressed_color = color(200);
- active_color = color(150, 0, 0);
- tempo_color = color(0, 200, 0);
- played_color = color(255, 0, 0);
- isActive = new boolean[rows][cols];
- notePlayed = new boolean[rows][cols];
- for (int i = 0; i < cols; i++) {
- for (int j = 0; j < rows; j++) {
- isActive[i][j] = false;
- notePlayed[i][j] = false;
- }
- }
- startTime = millis();
- }
- //////////////////////////////////////////////////////////////////////////
- void draw() {
- // increment currentBeat according to BPM value
- currentTime = millis();
- if (currentTime - startTime > millisPerBeat) {
- currentBeat+=1;
- currentBeat = currentBeat%rows;
- startTime = millis();
- for (int i = 0; i < cols; i++) {
- for (int j = 0; j < rows; j++) {
- notePlayed[i][j] = false;
- }
- }
- }
- mousePosX = mouseX/s;
- mousePosY = mouseY/s;
- for (int i = 0; i < cols; i++) {
- for (int j = 0; j < rows; j++) {
- colors[i][j] = inactive_color; // inactive = dark
- colors[currentBeat][j] = tempo_color; // green tempo line
- if (i==0 || i==4 || i==8 || i==12){
- colors[i][j] = accent_color;
- }
- if (isActive[i][j]==true) {
- colors[i][j] = active_color; // active red color
- }
- // if ACTIVE and SCANNED
- if (i == currentBeat && isActive[i][j]==true) {
- colors[i][j] = played_color;
- noteSend(j, i);
- }
- }
- }
- // draw each case with current color
- for (int i = 0; i < cols; i++) {
- for (int j = 0; j < rows; j++) {
- fill(colors[i][j]);
- rect(s*i, s*j, s, s );
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void noteSend(int noteMidi, int curbeat) {
- if (!notePlayed[curbeat][noteMidi]) {
- notePlayed[curbeat][noteMidi] = true;
- float midiNote = map(noteMidi, cols, 0, minMidi, maxMidi); // map on a midi scale
- int finalMidiNote = int(midiNote);
- println("note "+finalMidiNote);
- note = new Note(finalMidiNote, 80, 50);
- midiOut.sendNote(note);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void mouseReleased() {
- for (int i = 0; i < cols; i++) {
- for (int j = 0; j < rows; j++) {
- if (mousePosX==i && mousePosY==j) {
- if (isActive[i][j]==false) isActive[i][j]=true; else if (isActive[i][j]==true) isActive[i][j]=false;
- }
- }
- }
- }
- void keyReleased() {
- }
1