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.
IndexProcessing DevelopmentLibraries,  Tool Development › The MidiBus MIDI library
Pages: 1 2 3 4 
The MidiBus MIDI library (Read 35056 times)
Re: The MidiBus MIDI library
Reply #45 - Dec 13th, 2009, 7:40am
 
Sure!  I was trying to make an amalgam of your "Basic" example sketch and a servo control sketch posted on the arduino website under the heading "SingleServoExample". (sorry for not giving link, I'm too new to be allowed to post urls!).

I'm trying to write the velocity from the noteOn method to the serial port:

Quote:
import themidibus.*; //Import midibus library
import processing.serial.*; //Import serial library

Serial port; // The serial port
MidiBus myBus; // The MidiBus

void setup() {
 size(200,200);
 background(255);
 fill(0);
 MidiBus.list(); // List all available Midi devices on STDOUT.

 myBus = new MidiBus(this, 0, 2); // Create a new MidiBus using the device index.

}


void noteOn(int channel, int pitch, int velocity) {
 // Receive a noteOn
 println();
 println("Note On:");
 println("--------");
 println("Channel:"+channel);
 println("Pitch:"+pitch);
 println("Velocity:"+velocity);
 port.write(velocity+"s");
}


thanks for the help!

Patrick
Re: The MidiBus MIDI library
Reply #46 - Dec 13th, 2009, 12:06pm
 
Hey Patrick,

The port object in your code is null because you never set up your serial connection.

Something like this is what you need ...

Code:

import themidibus.*; //Import midibus library
import processing.serial.*; //Import serial library

Serial port; // The serial port
MidiBus myBus; // The MidiBus

void setup() {
size(200,200);
background(255);
fill(0);
MidiBus.list(); // List all available Midi devices on STDOUT.

myBus = new MidiBus(this, 0, 2); // Create a new MidiBus using the device index.
String portName = Serial.list()[0];
port = new Serial(this, portName, 9600);
}


void noteOn(int channel, int pitch, int velocity) {
// Receive a noteOn
println();
println("Note On:");
println("--------");
println("Channel:"+channel);
println("Pitch:"+pitch);
println("Velocity:"+velocity);
port.write(velocity+"s");
}


That error you had was telling you that there was a null pointer exception in your noteOn() method (the fact that you were trying to call write() on port which was null) and the MidiBus had caught that exception and disabled your noteOn() method to avoid having the exception again.

Hopefully that makes sense.

On a side note you make a good point that this kind of error is a little cryptic and seems like it's coming from the MidiBus. I'll try and make some changes in my next update so that theses error messages are more verbose/human friendly.

Keep me posted!

Sparky
Re: The MidiBus MIDI library
Reply #47 - Dec 13th, 2009, 1:14pm
 
Hi Sparky

Thanks very much for the help!  I tried your suggestion but unfortunately got the same error message, HOWEVER I then tried putting the "port.write" instruction in a separate method, and now it's working!!  Delighted  Smiley

the relevant part of the code:

Quote:
void noteOn(int channel, int pitch, int velocity) {
 // Receive a noteOn
 println();
 println("Note On:");
 println("--------");
 println("Channel:"+channel);
 println("Pitch:"+pitch);
 println("Velocity:"+velocity);
 spos=velocity; // transfer velocity to variable initialised at start
 spitch=pitch; // same with pitch info


 // port.write(velocity+"s");
}

void draw(){
 if (spitch==60){
   port.write(spos+"c");
   background (255, 204, 0);
 }
 else {
   background (255);
 }
}



Only checking for Middle C at the moment  cos I only have one servo.  Getting more during the week, will then implement a switch/case loop to play my different servos.

Thanks again for yr kind help and patience!

P
Re: The MidiBus MIDI library
Reply #48 - Dec 13th, 2009, 1:19pm
 
Happy to hear it's working...

You should be able to keep the port.write() inside the noteOn() method, maybe there's something subtle I'm missing ... but either way you seem to be on right track.

Sparky
Re: The MidiBus MIDI library
Reply #49 - Jan 6th, 2010, 9:57pm
 
As mentioned at the end of this topic, there is an outstanding bug between the new apple subsystem and MAX/MSP. It can be reproduced with the following code (and the max/msp runtime open). For the moment I have no solution, but I'm trying to work something out.

Code:
import javax.sound.midi.*;

public class Test {

Test() {

}

public static void main(String[] args) {
MidiDevice.Info[] available_devices = MidiSystem.getMidiDeviceInfo();

}
}
Re: The MidiBus MIDI library
Reply #50 - Jan 24th, 2010, 8:09am
 
Hello guys.
i bought arduino 2 weeks ago.
i'm using it for my thesis project at university.

what i need to do is to Play a note from Ableton Live,
send it to midi_Yoke, and then send it to arduino and blink a Led corrisponding to a particular midi Note.

Anyone has done something like that as a very first attempt?

i would really apreciate an example of that.
anyone could please make a readable pdf or something clear,
like a simple tutorial of that kind?

like
"code for Processing,
explanations,
code for arduino,
explanations.
"

thank you so much for your help,
Giacomo  Roll Eyes
Re: The MidiBus MIDI library
Reply #51 - Apr 11th, 2010, 12:28pm
 
I'm having a very simple problem, but I can't seem to figure it out. I installed themidibus library in the libraries folder in my sketchbook, but for some reason it will not recognize the library. It keeps saying the package does not exist when I try to run any of the examples. Any idea what I might be doing wrong?
Re: The MidiBus MIDI library
Reply #52 - May 21st, 2010, 12:48pm
 
I'm getting this error trying to run theMIDIbus Basic example sketch:
processing.app.debug.RunnerException: ClassCastException:

I am using Processing 1.1 on OSX 10.5.8, I have tried updating to the latest version of MIDIbus (004), removing mmj from java/extensions folder and still not able to get MIDI going with MIDIbus and Promidi... help please.
Re: The MidiBus MIDI library
Reply #53 - Jun 2nd, 2010, 12:42am
 
Hi there Sparky, I have a small doubt regarding receiving some midi data. I've been doing something like a "midi server for flash" so i could get midi signals into flash and manipulate clips and stuff. It's working greatly for notes and cc, using the noteOn/Off and controllerChange methods.

This let me use keys, knobs and the mod wheel my synth has, but i'm not able to receive the pitch bend signals... I've read it uses 2 bytes to send data, so i was wondering if there's any way to get this signal somehow like a controller change.

I've tried with the midiMessage and midiRaw, but nothing... did I mention i'm still a newbie? hehe.. I guess this should be easy, but i can't get it  Undecided

Thanks in advance, and thanks, once again, for writing this LIB!
Pages: 1 2 3 4