'String bus_name' Error when connect to electronic drumkit

Hi there!

I'm working on a project in which i visualize music trough musical instruments. Now I have everything set-up and working with audio to midi converters. But with the only full-on midi instrument I get an error...

Can you guys n gals help me out with this?

So when I connect my electronic drumkit to my laptop and open processing I get the following error: (I don't get this error when I connect a guitar with a midi-converter)

The MidiBus Warning: Disabling midiMessage(MidiMessage message, String bus_name) with bus_name because an unkown exception was thrown and caught java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at themidibus.MidiBus.notifyParent(Unknown Source) at themidibus.MidiBus$MReceiver.send(Unknown Source) at com.sun.media.sound.AbstractMidiDevice$TransmitterList.sendMessage(AbstractMidiDevice.java:679) at com.sun.media.sound.MidiInDevice.callbackShortMessage(MidiInDevice.java:172) at com.sun.media.sound.MidiInDevice.nGetMessages(Native Method) at com.sun.media.sound.MidiInDevice.run(MidiInDevice.java:140) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at HiddeDrums.midiMessage(HiddeDrums.java:57) ... 11 more

Answers

  • What is HiddeDrums? Your sketch?

    That bottom line suggests you're trying to access the second of an array that's only got one element (or fewer). Without the code I can't say any more.

  • Hi Koogs,

    This is my sketch, thanks for your time!

    import themidibus.*; 
    import javax.sound.midi.MidiMessage; 
    import processing.video.*;
    MidiBus myBus; 
    Movie currentMovie;
    int currentColor = 255;
    int midiDevice = 0;
    Movie movie;
    
    HashMap<Integer, Movie> movies;
    void setup() {
      size(800, 800);
      smooth();
      MidiBus.list(); 
      myBus = new MidiBus(this, midiDevice, 1); 
      movies = new HashMap<Integer, Movie>();
      movies.put(45, new Movie(this, "patterns/crash.mov"));
      movies.put(46, new Movie(this, "patterns/hihat.mov"));
      movies.put(49, new Movie(this, "patterns/kick.mov"));
      movies.put(48, new Movie(this, "patterns/hihatopen.mov"));
      movies.put(50, new Movie(this, "patterns/ride.mov"));
      movies.put(47, new Movie(this, "patterns/snare.mov"));
      movies.put(51, new Movie(this, "patterns/tom1.mov"));
      movies.put(52, new Movie(this, "patterns/tom2.mov"));
      movies.put(53, new Movie(this, "patterns/tom3.mov"));
    
    }
    void draw() {
      if (currentMovie != null) {
        image(currentMovie, 0, 0);
      }
    }
    
    
    void midiMessage(MidiMessage message, long timestamp, String bus_name) { 
      int note = (int)(message.getMessage()[1] & 0xFF) ;
      int vel = (int)(message.getMessage()[2] & 0xFF);
    
      if (movies.containsKey(note)) {
        currentMovie = movies.get(note);
        image(currentMovie, 0, 0); 
        currentMovie.jump(0);
        currentMovie.play();
        println(note);
      }
    }
    
    void movieEvent(Movie m) {
      m.read();
    }
    
  • edited June 2015

    The error is probably in these lines:

    int note = (int)(message.getMessage()[1] & 0xFF) ;
    int vel = (int)(message.getMessage()[2] & 0xFF);
    

    Try either:

    • check if message.getMessage() is null and/or if message.getMessage().length > 2
    • Wrap the method body in a try/catch statement
Sign In or Register to comment.