Manual: Hierarchy

Minim is set up in such a way that actual functionality (that is, implemented code) that is common between the classes that you will routinely use is placed in two base classes: Controller and AudioSource. Whereas expected functionality is defined in four interfaces: Playable, Effectable, Polyphonic, and Recordable. An interface in Java is defined like a class but contains only function definitions. That is, it defines an expected set of functionality without actually implementing any of it (see: Interfaces and Inheritance).

In JavaSound, when audio is transmitted from the system to your application or from your application to the system, it passes through a Line, which is an interface defined in the JavaSound API. A line can have controls such as pan, volume, and balance. These controls can be manipulated to change the audio as it passes through the line on its way to your application or to the speakers. Access to these controls is provided by the base class Controller. AudioSnippet and AudioSource derive from Controller and therefore inherit the functionality it provides. This functionality will be discussed in the next section.

AudioSource defines three AudioBuffers: left, right, and mix. These three sample buffers (a sample buffer is just a float array) will contain the left channel, the right channel and the mix of the left and right channels, respectively. They are continually updated as audio is either received from the system, read from a file, or generated by an AudioSignal. AudioBuffer will be discussed in more depth later, the thing to know for now is that AudioPlayer, AudioOutput, AudioInput, and AudioSample all derive from AudioSource, which means that they inherit these buffers as data members, which means they all provide access to samples.

AudioSource also implements two of the four interfaces: Recordable and Effectable. Not surprisingly, it is able to implement these two interfaces because it has access to samples. As a result, the same four classes mentioned above that derive from AudioSource are also Recordable and Effectable. This fact will be reiterated in the sections for those classes.

Finally, because inheritance of methods cascades all the way down the class hierarchy, the four classes that inherit from AudioSource also inherit from Controller. Think of it this way, for example: AudioPlayer is an AudioSource and is a Controller. Therefore, everything you can do with an AudioSource or a Controller you can do with an AudioPlayer.

4 thoughts on “Manual: Hierarchy

  1. It might be useful to have a diagram or UML of the hierarchy on this page; a textual description of an inheritance hierarchy can be difficult to visualize.

  2. i’d agree with you, Kevin. but i’d also like to point at the left side of this page, where the ToC is pretty much based on the minim hierarchy. something of visual help..

  3. I agree with Kevin. The list above does not give us a simple outline of the methods and properties of each class (unless I’m overlooking something). Your narrative is helpful, but a quick summary would also be useful.

  4. Probably the best place to get a quick summary of methods available for each Minim class is in the Javadocs: http://code.compartmental.net/minim/javadoc/

    However, through talking with folks, I’m finding that the description of the Hierarchy here is more confusing than anything else and I’m no longer sure it’s really of much use to people new to object-oriented programming and this library. So it will probably go away in a future rev of the manual.