A musical system can be seen as a set of musical objects called Instruments that collaborate for a common goal or performance. Therefore, at the first level, the most important objects in this kind of system are the Instruments. Instrument objects are instances of the last level of a class hierarchy that has the abstract Instrument class as the base class that is then specialized into different families of Instruments such as string, percussion or wind. In the last level of the hierarchy we find particular Instruments such as piano or guitar, see Figure 6.1.
An Instrument responds to incoming events by generating music. These events are generated from the interaction of the performers (system actors) on the Instrument interface.
But if we look closer into an Instrument we discover that Instruments are not the atomic physical objects in a musical system. As a matter of fact, an Instrument is in itself a set of more or less independent elements that produce sound by themselves. A clear and extreme example of this are the drums, where a single Instrument is in fact the result of many different possible combinations of individual Instruments.
When focusing on the properties of the internal mechanism, a first classification could divide Instruments into monophonic and polyphonic. In Instruments belonging to the first category it is clear that no more than a single Note can be sounding at the same time. But even polyphonic Instruments have limited amount of voices (simultaneous sounding notes). For instance, in a guitar no more than six simultaneous notes can be produced.
We define a Generator as the atomic entity that can generate a sound by itself. A Generator usually generates sound in response to an incoming control event, therefore Generators must have the ability of receiving and interpreting such events. A Generator is part of an Instrument although there can be Instruments with just a single single Generator (e.g. a flute). An Instrument is therefore a set of Generators that can be controlled independently but always according to the rules dictated by the Instrument definition.
The relation between the Instrument and Generator classes is modeled at an abstract level and must be made concrete when modeling a particular Instrument. If, for example, we have to define a standard acoustic guitar we may describe it as having six Generators, one for each of its six strings.
The guitar Instrument itself is in charge of defining pitch range and other important properties for each of its Generators. On the other hand it may be interesting to define a seventh Generator: the guitar body. The guitar body can indeed be seen as a percussive Generator in itself. This Generator can be controlled independently from the others and responds to completely different behavior rules. Therefore both String and Body would be subclasses of the abstract Generator class.
In a piano it is fairly intuitive to define each key as a different Generator. But one may be tempted to discuss that a piano cannot naturally have all the keys sound at the same time. As a matter of fact the number of simultaneous sounding notes is limited by the number of fingers or hands that are playing. Then, why not say that the actual Generators in a piano are the player's fingers? It is important to remember that according to our object-oriented model Generators are related only to the production mechanism in the system and not to the way controls from the outside actor arrive to them. A piano Generators can be excited by two or four hands but also with a foot or even an automatic mechanism. In other words, all keys in a piano can sound simultaneously and that is enough to prove that each of them is an ``independent'' Generator.
Therefore, an Instrument can be considered as a system made up of almost autonomous units or objects called Generators. The Instrument class is in charge of instantiating each Generator and assigning it a particular behavior which is in fact a subset of the Instrument behavior in itself. But the Instrument also has supra-Generator behavior that can be used, for example, for describing the way that different Generators will interactuate in between them. For instance an Instrument may have a constraint that if Generator N is active, Generator N+1 cannot become active.
From the description given up to now, it is clear that some sort of relation exists between the music model that we are starting to define and the DSPOOM metamodel presented in chapter 4. Figure 6.4 illustrates the interpretation of an Instrument as a particular instance of the DSPOOM metamodel.
The figure illustrates the DSPOOM modeling of a 4-Generator Instrument. Note that we model an Instrument as a DSPOOM Processing Composite (see 4.1.3) because in a general situation we do not need the Instrument definition to be dynamic, in which case we would need a Network. In most implementations we will build the Instrument in configuration time when reading an Instrument definition file (see 6.4.2) that is in fact a DSPOOM configuration. On the other hand, Generators are regular DSPOOM Processing objects.
The Instrument is a DSPOOM Generating Processing object as it has output ports but no input ports. The Instrument responds to incoming controls by producing an output signal through one of its output ports. These Outports correspond directly to the Outports in each of the Generators. In a similar way, there is a direct mapping between the input controls published by the Instrument and those in the Generators.
Note that the Instrument that we have described so far is the simplest one, made of only Generators. Nevertheless, as in a regular DSPOOM model, we could integrate non-generating Processing objects as secondary Generators. Think for instance on an Instrument that adds a filter for each Generator. This way we are able to use the metamodel for constructing a modular synthesizer or similar applications.