Introducing Rusty: The Importance of Tradition, and Fuzzy Logic as Musical Judgement Michael Saunders Cardiff University, Department of Physics and Astronomy MichaelSaunders7@hotmail.com Abstract This paper introduces Rusty, a graphical language for writing musical computer programs. It is based on an extensive object-oriented class library (in Java) for representing music and music-theoretical objects. Ethnomusicology and the comparison of differing musical traditions in a search for universal forms are important themes of its design; this is illustrated by an outline of its representation of melodic mode. Also important is its use of fuzzy logic, illustrated by an outline of its chord-voicing algorithm. Keywords fuzzy logic, music, music representation, music theory, object-oriented Introducing Rusty Rusty is a language for writing musical computer programs. It consists of an object-oriented class library (in Java) for representing the objects of music and music theory. Although they can stand on their own, these classes are designed to be used in Ian Taylor's Triana OCL (Taylor 1998), a graphical programming environment. Triana works much like a modular synthesizer-modular subprograms appear as boxes on the screen (each with its own pop-up GUI "control panel"). The users connect their inputs and outputs with virtual "cables". Unlike a modular synthesizer, Triana's cables can carry complex objects. At first, basic modules (such as graphical editors for each Rusty class) will be provided. Eventually, users will write modules of their own, exchange them, and interconnect them to form musical applications. The Rusty classes have several important features: I. They are familiar. They directly represent concepts familiar to musicians, as is reflected by their names, e.g., Scale, Meter, Chord and Rhythm. II. They are extensive. They cover nearly every facet of music and music theory (a notable exception is timbre). The categories of classes include: A. Crisp and fuzzy values B. Time and tempo C. Meter D. Dynamics E. Spectra F. Pitch G. Scale and tuning H. Sounds I. Spatialization J. Musical qualities and indications K. Musical form L. Scores, instruments and conductors M. Melodic mode N. Chords and voicings O. Harmonic mode P. Rhythm and groove Q. Melody R. Harmony S. Mathematical functions T. Markov chains III. They are inclusive. An attempt was made to make each class as general as possible, able to represent objects from all documented traditions, able to represent (hopefully) any instance of the class one might desire. IV. They are serviceable. Wherever some behavior of objects was found to be representable by a parameterized algorithm, this algorithm was incorporated into the class, both to more accurately represent the class's musical concept and to make programming easier (e.g., scales can tune themselves; chords can voice themselves; scores, when sufficiently complete, can perform themselves). Much of this functionality involves fuzzy logic. The Rusty classes have been thoroughly designed (Saunders 1998); they are currently being coded. Adherence to the Forms of Tradition: Mode Tradition has certain forms. That is, traditions, particularly musical traditions, are concerned with certain classes of object and each class has a definite form within which (by means of which) a multitude of particular objects may become manifest. Traditions are significant since each is a valid (and tested) way of understanding. If several (or all) traditions can be served by common forms, we can infer that these forms have a great significance, possibly for perceptual or cognitive reasons, without understanding what those reasons are. In any case, traditions and the forms which can be derived from them have a great utility and should not be ignored. Rusty's classes represent very general forms which are capable of serving many traditions. Such general forms seem to have an archetypal nature. The classes of object dealt with by widely varying music theories (traditions separated historically and geographically) are a remarkably consistent set. Comparing the forms of each of these classes across many traditions reveals less consistency, but points to the general (ideally, universal) forms which Rusty attempts to represent. An interesting example of this is (melodic) mode. Modes are objects directing the generation (perhaps equivalently, explaining the cognition) of melodies. They are ubiquitous, occurring in practically every tradition with a written music theory (they are so basic to music-making that one might expect them to be equally common in oral traditions or (unconsciously) in inarticulate traditions). The forms of mode, however, differ amongst traditions more widely than do those of other classes; yet, common features can be discerned which allow for a general form to be posited. Rusty modes have two components: a set of degrees selected from another object and re-indexed, and a package of "characteristic information". Modal degrees are indexed by the fields: nucleus (a concept from Persian music, but applicable to the system of 24 keys), slope (ascending, harmonic or descending), degree, alteration, octave and instrument (important for linking modes with some types of tuning). Basic selection involves a listing of degrees from a source (a scale or another mode). Different nuclei may have different sources. Provisions are made for modes and sources which are not octave-repeating, for altering the tessitura of the source (i.e., re-indexing its octaves) and for insuring compatibility between selection and source. Selection may also be abstract, using parameters to control the generation of several modes from one source (e.g., as in Western and Chinese music). To do this, circular "templates" of steps (e.g., ...2212221...) are given a starting- point parameter to produce "patterns" of steps (e.g., 2212221, major; 2122122, minor) which, given a source "keynote", defines a complete selection. All characteristic information is optional in Rusty, but most traditions include some, often to distinguish between similar selections (e.g. C major and A minor are distinguished by finalis). It falls into four categories: melodic functions, Markovian constraints, characteristic formulae and general characteristics. The mode class maintains a canonical list of melodic functions (e.g., finalis, agogically strong), a fuzzy suitability for each of which may be indicated for every modal degree; interpretation is left to the client. Conditional probability characteristics are represented by Markov objects-these can resolve together Markov chains of any number of different orders and provide useful features, such as reporting the probability of a given sequence occurring. Modes can maintain any number of collections of stereotypical melodic formulae for characterization. The heading of "general characteristics" allows mode designers to associate other Rusty objects with their modes; e.g., a fuzzy tempo could characterize a mode traditionally described as fast-paced. Rusty also provides a rich set of algorithms by which modes may be compared, melodies and other objects may be recast into new modes, melodies may be written in terms of melodic functions, and so on. Another class represents harmonic modes similarly. Fuzzy Logic as Musical Judgement: Chord Voicing Composition, analysis and performance abound with judgements--- Compromises must be made and balances struck (e.g., between repetition and variety), decisions must be made where rules conflict or data is incomplete (e.g., in the tension between the horizontal and the vertical, between harmonic and melodic concerns). In many cases (e.g., in the tuning of scales or improvisation on a figured bass) judgement is essential to the nature of a process, because it is unreasonable or undesirable to require musicians to make complete, unconflicting specifications. Fuzzy Logic is an excellent technique for representing judgement. Rusty uses it extensively; all units and most parameters may be represented fuzzily. Units are represented as fit-valued (i.e., on [0,1]) functions of value. These are interpreted as "preference curves"; the x-values at which the function reaches unity are the most preferred while those at which the function is zero are effectively forbidden, with intermediate values representing intermediate levels of preference. This allows users to use fuzzy logic easily when writing musical programs (although crisp representations are always available). Many parameters controlling the basic processes involving objects are represented fuzzily (i.e., on [0,1]), allowing a continuum of behaviors between two extremes. Rusty's use of fuzzy logic in tuning has been described elsewhere (Saunders and Greenhough 1998); another example is the voicing of chords. Rusty has classes for chords, voiced chords and voicings. Chords are collections of scale degrees with no octaves indicated (i.e., "pitch classes", e.g., C major has the components {C,E,G}). Voiced chords are collections of scale degrees with octaves indicated. Voicings are represented as collections of rules which Rusty's voicing algorithm uses to produce voiced chords from given chords. The resulting voiced chord may contain several instances (differing in octave) of each component in the original chord. The rules are generally fuzzy and fall into the following rule-types: * Observance rules decide how suggested octaves in the chord are to be interpreted. * Doubling rules assign preferences to the number of octaves in which each chord-component may appear. these may be modified in three high-level ways: * Texture parameters control the total or average most-preferred number of doublings in various ways. * Exaggeration parameters can stretch, contract or reverse the relationships between the doubling rules of different components. * No-omission rules can insure that particular components will be represented. * Arrangement rules relate to the relative arrangement of components in the voiced chord. * Proximity rules affect how closely in pitch or frequency two components may be voiced. * Span rules constrain the total span of the voiced chord or one of its parts ("limbs"). * Limb arrangement rules affect the arrangement of limbs (e.g., triad, extensions, added-tones). * Limb proximity rules control the proximity of limbs in various ways. * Positioning rules can affect the absolute or relative positioning of components and focus them on the pitch continuum in various ways. * Collapsing degeneracy rules decide what to do when two different components have identical instances (i.e., in the same octave). * Lute constraint rules can help to give the characteristic voicings of instruments with fretboards. Parameters include accordatura, position, suitability vs. fret number curves, and whether these rules constrain the voicing (i.e., act as new doubling rules) or adapt the already-voiced chord determined by the other rules. In addition to these, the voicing call may include a preference vs. pitch/frequency curve which can affect the voicing-"filtering" the voiced chord or nudging the choice of component instances according to other, non-vertical, criteria, e.g., to apply voice-leading or melodic concerns. The details of the voicing algorithm are too numerous to give here; what follows is an outline. First, the most extreme possible span of the resulting voiced chord is determined, taking into account the limb arrangement and limb proximity rules. This span is placed on the pitch continuum and a preliminary weighting (preference vs. pitch) is applied across it according to any span rules, limb arrangement/proximity rules, component position rules, spectral focus rules and certain lute constraint rules which exist in the voicing. The next round of weightings highlights desirable patterns, as suggested by the arrangement rules. Interlopers (possible component-instances which interfere with patterns) are discouraged according to several parameters. Further weightings apply proximity rules before the external preference curve argument is applied. Defuzzification is performed in accordance with the doubling rules and certain positioning rules. Finally, the lute constraints are applied, either performing the defuzzification according to their own rules or adapting the already voiced chord. The primary result is a voiced chord, but one may also obtain the calculated "goodnesses" (i.e., pre-defuzzification preferences) for each possible instance of each chord-component, since these might be useful data for users' programs. References Saunders, M. and Greenhough, M. (1998); Pitch, Scale and Tuning in Rusty: A Fuzzy Logic Approach to the Tuning Problem; Xenharmonikôn, Vol. 17 (pp. 116-119) Saunders, M. (1998); A Computer-based Notation for the Process of Musical Composition; Ph.D. thesis, University of Wales, Cardiff (available at http://www.astro.cf.ac.uk/pub/Michael.Saunders/thesis/toc.html) Taylor, I (1998); Triana OCL; http://www.astro.cf.ac.uk/pub/Ian.Taylor/Triana/index.html