Skip to content
Sara Adkins edited this page Jan 19, 2017 · 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 have two different methods we use to send MIDI messages to the orchestra: Processing's MidiBus Library(recommended for windows users) and the Java Sound API(recommended for mac users). Regardless of your computers operating system, it is recommended you set up both methods.

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
  • Download Processing and install it. Processing is a java-based software sketchbook that has many convenient libraries for creating audio and visual art.
  • 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.
  • 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

Java Sound API Setup

  • Download the Java Developers Kit and install it. The JDK includes the Sound API that we will use.
  • Install a Java IDE of your choice. Some commonly used ones are NetBeans, Eclipse and IntelliJ. The IDE is just an environment where you run and edit your Java code, so you can use any program you like.
  • Download Processing and install it.
  • To test you setup, navigate to Examples/Midi_Interface_Test in the Github repo, and open Midi_Interface_Test.pde. The file should open up in Processing.
  • Run the code by pressing the play button. If you are not hearing sound, you may have to alter the deviceIndex variable. Once you run the code, a list of available MIDI Output devices will appear in the console along with their indexes. Alter deviceIndex to test each of these options until you hear sound when the code runs.

Using the MidiBus

This method has known issues for Mac users. Untested on Linux.

###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

Using the Java Sound API

This method works for both Windows and Mac. Untested on Linux.

RobOrchestra MIDI Wrappers

Because writing code using the Java Sound API can get a bit "wordy," RobOrchestra has a library of wrapper classes that can be referenced to substantially simplify your code. These wrapper classes are designed to mimic the flow of working with the MidiBus Library. To use these wrapper classes, copy the files located in the "Java MIDI Wrapper" folder on the github repo into the directory where you are writing your code. This will allow you to reference the classes from your code.

Example

For a simple example of how RobOrchestra uses the Java Sound API wrapper classes, look over the file Examples/Midi_Interface_Test/MidiBus_Interface_Test.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 plugged into your computer. It references the three wrapper classes: DeviceList, Orchestra and NoteMessage. This test code is written in Processing(hence the .pde extension), but can easily be modified to a valid java file by encompassing the example code into its own class.

Documentation and Resources

For information on the RobOrchestra Wrapper classes and their functions, look over the commented source code in the "Java MIDI Wrapper" folder on the Github.

If you are interested in how the wrapper classes are implemented, you can check out the Java Sound Programmer Guide which has documentation for all classes and methods of the Java Sound API.

Clone this wiki locally