We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › proMIDI 2.0: noteOn() is called at note release!
Page Index Toggle Pages: 1
proMIDI 2.0: noteOn() is called at note release! (Read 1808 times)
proMIDI 2.0: noteOn() is called at note release!
Feb 15th, 2008, 8:53pm
 
Hello! I am developing a simple MIDI application to recieve MIDI notes and send values on the serial port accordingly, but I've noticed a strange bug -- the noteOn() method is called at releasing a note, too, just before noteOff() is called.

I've checked with a MIDI monitor (MIDI-OX) and it seems the problem is with my application.

Here's a stripped version of my code showing the essence of the bug:

Code:
import promidi.*;
MidiIO midiIO;

void setup() {
midiIO = MidiIO.getInstance(this);
midiIO.printInputDevices();
midiIO.openInput(1,0);
}

void draw() {
}

void noteOn(Note note, int deviceNumber, int midiChannel) {
println("On");
}

void noteOff(Note note, int deviceNumber, int midiChannel) {
println("Off");
}


Is it just here or is there an extra "On" being sent just before the "Off"? Is there a way to get around it some how?
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #1 - Feb 15th, 2008, 10:22pm
 
The extra noteon should have a velocity of 0, so you can just check for that.  

I think they did it this way, because it can actually be helpful to be able to use the same function for press and release.
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #2 - Feb 16th, 2008, 12:30am
 
Thanks, but that was not the case. It has the same velocity in both calls:

Quote:
import promidi.*;
MidiIO midiIO;

void setup() {
 midiIO = MidiIO.getInstance(this);
 midiIO.printInputDevices();
 midiIO.openInput(1,0);
}

void draw() {
}

void noteOn(Note note, int deviceNumber, int midiChannel) {
 print("On ");
 println(note.getVelocity());
}

void noteOff(Note note, int deviceNumber, int midiChannel) {
 println("Off");
}
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #3 - Feb 16th, 2008, 2:09am
 
Seems to work for me, strange.

Output:

On 62

On 0

Off

(I added a size() call in setup; not sure if that would affect it)
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #4 - Feb 18th, 2008, 4:34pm
 
Hmm, no, the size() did nothing here. Thanks for the help. This will be a nasty one to solve Smiley

What setup are you on by the way? OS, processing version, what software do you use to test the notes.

I am using MIDI Yoke outputs with processing 135 on Windows XP here...
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #5 - Feb 18th, 2008, 9:41pm
 
I'm using Axiom25 controller with Windows XP.  Latest Processing version, of course. Smiley

A good program to view all midi data coming in/out of the system is www.midiox.com

Re: proMIDI 2.0: noteOn() is called at note releas
Reply #6 - Feb 25th, 2008, 9:04pm
 
Ah, it turns out that only the software I sent the MIDI signal with (fruityloops 3, hehe) would have full velocity on the last note on. When I tried with Reaktor 5 it worked like you said it would. Thanks for the help!
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #7 - Mar 22nd, 2008, 8:15pm
 
hello guys,

i´ve seen you are working with midi pro.
i´m having a problem sending a note off. i wonder if one of you could help me.
i´m doing an example using mouse position to generate a midi note. the value is redirected to a virtual instrument (Reason; Fm8) and it plays the mouse position. After a few seconds of playng the note, the midi sound gets stucked and plays constantly. Processing returns the following error:

Exception in thread "Thread-9" java.lang.ArrayIndexOutOfBoundsException: 1
at java.util.AbstractCollection.toArray(AbstractCollection.java:126)
at promidi.MidiOut$NoteBuffer.run(MidiOut.java:263)

can you note what is the problem, the code of the example i´m using is:


import promidi.*;
MidiIO midiIO;
MidiOut midiOut;

void setup() {
 frameRate(25);
 size(320,240);

 midiIO = MidiIO.getInstance(this);
 midiIO.printDevices();

 Note note;
}

void draw(){
  int   Note;
  Note  note;

rect (40, 40, 80, 80);

  if ( (mouseX > 40 & mouseX < 120) & (mouseY > 40 & mouseY < 120) ) {
   
    midiOut = midiIO.getMidiOut(0,0);
    int n = (int)round(map(mouseX,40, 80, 67, 70));
    //float n = map(mouseY,40, 80, 90, 100);
    note = new Note(n ,60, 50);
 
    midiOut.sendNote(note);
   
  }
}


thanks for any help.

bosch

Re: proMIDI 2.0: noteOn() is called at note releas
Reply #8 - Apr 18th, 2008, 8:36pm
 
Bosch, im getting that exact same error too. notes being locked on. I think it might happen when you try to send too much midi information at once. After that error it will send send midi notes and continue to function just certain notes are locked on.
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #9 - Jun 17th, 2008, 4:57pm
 
I'm still having problems with this, and now I'm pretty sure it's a bug in proMIDI. Different controllers behave differently on when a note is released - a noteOn() is always called and some have a velocity of 0 (reaktor 5), some have velocity 64 (microkorg), and some have the same velocity as when you hit the note (fruityloops 3).

Using monophonic MIDI output in reaktor 5 only produces one noteOn() once all keys are released no matter how many "real" notes you've pressed, and I'm sure other programs behave in different manners.

I'm far from a good Java programmer, but I'll have a look at the sources tonight and see if I can't fix it somehow.

EDIT: I tried a different approach by plug()ing a method with a Note parameter, but it behaves in a similar fashion - once i release a key, the method I plugged is called twice (when it should really happen only once on a note on and once on a note off).
Re: proMIDI 2.0: noteOn() is called at note releas
Reply #10 - Nov 10th, 2008, 8:14pm
 
This appears to still be a bug, I can't seem to find where in the code the Note is distinguished (144 for Note On 128 for Note Off).

If you put a breakpoint in either method the NoteOff() method or the NoteOn() method you'll see that both notes on and off pass to both functions. A rather lame workaround until this gets fixed is just to add:

if (note.getCommand() != 128) return;

as the first line of the noteOff() method in your sketch, or:

if (note.getCommand() != 144) return;

as the first line of you noteOn() method.

Looks like the crux of the problem is the Note object is really geared more towards sending notes to other devices, and is set by default to NOTE_ON. Maybe I'm wrong, but this works around it, its just not good form.
Page Index Toggle Pages: 1