Skip to content
neimandavid edited this page Apr 5, 2024 · 20 revisions

The software team of RobOrchestra deals with writing code that controls the performance of the orchestra using timed MIDI messages. We write music generation algorithms that generate unique polyphonic music in real time. Because many of our algorithms are probability based, you will never hear the same piece twice when running our algorithms! We currently use Processing's MidiBus library to send MIDI messages to the orchestra.

Java

The RobOrchestra software team primarily codes in Java. If you are new to Java and object oriented programming, there are many resources online! Some recommended resources:

MidiBus Setup

  • Extra Step for Mac: Download SimpleSynth and install it. This is required because OS X does not have a built in MIDI sequencer like Windows does. THIS PROGRAM MUST BE OPEN WHEN RUNNING YOUR CODE FOR YOU TO HEAR SOUND
    • On Mac with a newer OS, download from the last post in this chain: https://github.com/notahat/simplesynth/issues/4
    • If you get an error about Mac OS not being able to check SimpleSynth for malicious software, go into Applications, right click SimpleSynth, click open, and then you can bypass the error message
  • Download Processing and install it. Processing is a java-based software sketchbook that has many convenient libraries for creating audio and visual art. If running Mac OS Catalina or later, instead use this version.
  • Open Processing. In the toolbar navigate to sketch>import library>add library. In the search bar type in "midi" and the library called "The MidiBus" should come up. Select the library and click install.
  • In the same window type "controlP5" into the search bar and the controlP5 graphics library should come up. Select the library and click install.
  • To test your setup, navigate to Examples/MidiBus_TestCode on the Github repo and open the file MidiBus_TestCode.pde. The file should open in Processing. Press the play button to run the code. If you are not hearing sound, you may have to alter the global "output" variable as follows: Once you run the code, a list of available MIDI Output devices will appear in the console along with their indexes. Alter output to these options until you hear sound when the code runs. Mac users make sure SimpleSynth is running or it will not come up as an output
  • If working with Processing 4 and you get a null pointer exception when trying to create a MidiBus, use the .jar file here instead: https://github.com/micycle1/themidibus/releases/tag/p4
    • To get a library using a .jar file, download the .jar file, then drag and drop it into a Processing code window. This adds the library to that sketch only (creates a code subfolder with the .jar); can copy-paste that code folder into other sketches as needed.

Processing

The MidiBus is a library for Processing that we use to send MIDI signals to either our computer speakers or to the RobOrchestra via USB. Processing is really just a simple IDE for Java, so any java functions or syntax can be used in processing. What separates Processing from Java is that Processing has built in setup() and a draw() functions. This is identical to the setup() and loop() functions in Arduino. The setup() function is run once when the code starts and then the draw function runs and loops until the program is stopped. Also unlike with Java, not everything in Processing has to be encompassed in a class. You can define functions and variables directly, much like you would in Python, which is very convenient.

Example

For a simple example of how RobOrchestra uses the MidiBus library, look over the file Examples/MidiBus_TestCode/MidiBus_TestCode.pde on the Github repo. This program sends the MIDI notes of a chromatic scale to either your computer's speakers, or to Xylobot if it is connected to your computer.

The function MidiBus.list() prints to the console a list of your computers available MIDI ports. When RobOrchestra is plugged in, it will come up in this list as "USB-MIDI-2.0"(or something similar). Referencing the indexes of the outputs listed by the list() function, you can alter the output variable that the MidiBus object takes as an argument to route MIDI messages to different outputs like your computer speakers or the orchestra.

Documentation and Resources

The MidiBus Library Documentation contains information on all MidiBus classes and functions. Of importance to RobOrchestra are the MidiBus class, the Note class, the MidiBus.list() function and the MidiBus.sendNoteOn() function.

If you're interested in learning more about Processing, you can check out the Reference and Example pages on the Processing website