A Categorial Grammar For Music And Its Use In Automatic .

2y ago
30 Views
3 Downloads
997.66 KB
9 Pages
Last View : 30d ago
Last Download : 3m ago
Upload by : Albert Barnett
Transcription

A Categorial Grammar for Music and Its Use in AutomaticMelody GenerationHalley YoungUniversity of PennsylvaniaUnited Stateshalleyy@seas.upenn.eduAbstractLike natural language, music can be described as being composedof various parts, which combine together to form a set-theoreticor logical entity. The conceptualized parts are more basic thanthe music seen on a page; they are the musical objects subject tomusic-theoretic analysis, and can be described using the languageof functional programming and lambda calculus. This paper introduces the types of musical objects seen in tonal and modern music,as well as the combinators that allow them to combine to createother musical objects. We propose a method for automatically generating melodies by searching for combinations of musical objectswhich together produce a valid program corresponding to a melodyor set of melodies.Figure 1. An excerpt from “The Girl with the Flaxen Hair”operator applied to an even shorter snippet of music.2 The phrasecontains many [0.5, 0.25, 0.25] rhythmic patterns. Except for theend, it appears to be metrical.All of the above properties are assumed to be important tounderstanding the piece as it is performed. However, simply listingthe properties of a piece as above can make the properties describedseem arbitrary and disconnected. This is patently not the case, asthey clearly are all derived from the musical surface of the piece(the actual notes), and thus must all combine in some way to createthose notes. In addition, some properties seem to be dependent onothers - the prominence of the note D is related to the use of the Dpentatonic scale. Unfortunately, without knowing the relationshipbetween a property and other properties or the musical surface, itis difficult to understand how and why a given property contributesto the piece.In this paper, we propose a formal method for characterizingmusical properties based on the linguistic concept of categorialgrammars. Categorial grammars describe how “objects” (computational expressions) of various types combine to form larger expressions. After a basic overview of the usage of categorial grammarsin linguistics, we turn to their usage in music, showing that theycan express the relationship between different musical properties,which can be thought of as computational objects. We show howlarger pieces of music can be built from the interaction of musicalobjects with other objects representing shorter pieces of music,and discuss how this method relates to a model of the process ofmusical analysis.While it is clearly possible to use categorial grammars for thepurpose of musical analysis, this paper will focus on their application to music generation. Categorial grammars lend themselves toautomatic generation of music. Combinators can be used to derivenew musical objects, including melodies, from pre-existing musicalobjects. There are a set of valid musical objects and functions, andCCS Concepts Theory of computation Grammars andcontext-free languages; Applied computing Sound andmusic computing;Keywords Categorial grammar, music generation, automated musicACM Reference format:Halley Young. 2017. A Categorial Grammar for Music and Its Use in Automatic Melody Generation. In Proceedings of 5th ACM SIGPLAN InternationalWorkshop on Functional Art, Music, Modeling and Design, Oxford, UK, September 9, 2017 (FARM’17), 9 oductionMusic theorists have developed rigorous systems for describingmusic in ways that go beyond the individual note values. Considerthe beginning of Claude Debussy’s piano prelude “The Girl with theFlaxen Hair”, shown in figure 1. One can describe the “surface” ofthis short phrase of music - the actual notes seen on the page.1 However, one can also discuss properties of the music that contribute tothat surface: The phrase uses a pentatonic scale centered around thepitch-class D. The beginning contains two nearly repetitive motifs,with the first note being slightly shortened in the second repetition.Each of these motifs itself consists of a transposition and inversion1 Here I am borrowing terminology from David Temperley, who distinguishes the“surface” of the music (what is seen on the page) from its underlying structure. [1]Permission to make digital or hard copies of all or part of this work for personal orclassroom use is granted without fee provided that copies are not made or distributedfor profit or commercial advantage and that copies bear this notice and the full citationon the first page. Copyrights for components of this work owned by others than ACMmust be honored. Abstracting with credit is permitted. To copy otherwise, or republish,to post on servers or to redistribute to lists, requires prior specific permission and/ora fee. Request permissions from permissions@acm.org.FARM’17, September 9, 2017, Oxford, UK 2017 Association for Computing Machinery.ACM ISBN 978-1-4503-5180-5/17/09. . . 15.00https://doi.org/10.1145/3122938.31229392 Transpositionand inversion are two operators applied to musical motifs. Transposition moves the motif up or down on the musical staff, while inversion reverses thedirection of the motif.1

FARM’17, September 9, 2017, Oxford, UKHalley Youngthey can be put together in such a way as to result in an expression that is a melody. By automatically generating valid lambdaexpressions, we generate small musical pieces.2Together, these words express a logical premise (that Kim walkedand fed the dog), which can be true or false. Alternatively, onecan interpret the words in the sentence as well as the resultingexpression set-theoretically - it describes a set of situations in whichKim walked and fed the dog. This model is technically a grammar, asthere are proof mechanisms to show a certain collection of tokens isa valid sentence [8], one can assign parts of speech according to thetypes of the words, and it can be used to show how individual partsmake up a greater whole. However, it is more commonly studiedby semanticists than syntacticians, and is the foundation of muchresearch in natural language meaning.Music and LanguageFor at least 2500 years, music has been described as “soundingnumber,” or something inherently mathematical [2]. At the sametime, at least since the Renaissance, music has also been seen assomething akin to language, with syntax and semantics [3]. Recently, developments in the field of linguistics have shown thatanalysis of music as natural language and as mathematical systemare not orthogonal to each other, but rather complementary; naturallanguage can be explored in precise ways by using areas of mathas diverse as category theory and statistics [4] [5]. Therefore, it islogical that pursuing the “music as language” metaphor could beuseful not only for philosophical purposes, but also for the purposeof computational analysis and generation of music - assuming thatsome of the same formalisms used to describe natural language alsoapply to music. In fact, certain linguistic formalisms, particularlycontext free grammars, have already been applied to music generation [6]. Categorial grammars are another linguistic formalism thathave proved useful to the study of music.44.1Categorial Grammars in MusicPrevious ResearchIn his 2013 thesis, Wilding develops a categorial grammar for musical harmony [9]. According to Wilding, harmonic progressionscan be described in terms of series of functions. He refers to onecommon function, which takes a chord and outputs that chordconnected with the chord transposed up by 7 semitones, as leftonto(he considers dominant motion as leftward motion). For example,he shows how a D-G-C harmony can be described as(λx .leftonto(x ))(λx .leftonto(x ))(0)3Categorial Grammars in Languagewhere 0 represents the pitch-class C. He goes on to provide a wayof parsing tonal harmonies and describing them as repeated applications of leftonto and rightonto operations, as well as a few morebasic operations.In 1935, semanticist Kazimierz Ajdukiewicz introduced the conceptof categorial grammars in natural language - a concept which became well-known in the linguistics community after the publishingof Richard Montague’s paper “Universal Grammar” in 1970 [7]. Categorial grammars are different than the Chomsky-style generativegrammars more well-known to computer scientists in that theydo not only describe the syntax of a sentence, but also how themeanings of the individual words combine to create the meaningof the entire sentence. The meaning of the sentence is assumed tobe a predicate logic statement. This predicate logic statement isarrived at through reductions of an expression in a typed lambdacalculus. The typed lambda calculus only has two primitive types:entity (typically used to describe nouns such as a person or anitem), and truth value. A full expression in the typed lambda calculus corresponding to a sentence, which reduces to a predicate logicstatement, is created by concatenating the computational meaningsof each word in the sentence. Each word has an associated type(shown here in Haskell notation).For example, “Kim walked and fed the dog” is composed of thefollowing words:4.2Current ResearchIn this paper, we suggest a method for using categorial grammarsto describe not just the harmony but also the surface of a piece ofmusic. This is accomplished by drawing a close analogy betweenwords and sentences and all types of musical objects and the musicalsurface. One could argue that individual measures of music shouldbe given the same status in the categorial grammar as words, andthe piece as a whole (or a musical phrase within the piece) shouldbe given the same status as a sentence. However, such an explanation doesn’t allow for the sort of combination of words into ameaningful whole that we see in Montague’s grammar for naturallanguage, and thus renders the use of categorial grammars fairlymeaningless. To describe the relationship between two measuresof music computationally (and thus to benefit from the use of categorial grammars), it is necessary to look beneath the surface of apiece of music at the musical objects from which it is composed.Kim k :: entitywalked λx[W alked (x )] :: entity truthand λx, y, z[x (z) y(z)] :: (entity truth) (entity truth) entity truthfed λx, y[Fed (y, x )] :: entity entity truththe λx[x] :: entity entitydog d :: entity5Musical ObjectsThere are a rich variety of musical semantic objects, or propertiesthat contribute to the identity of the music, that may be discussedwhen describing a piece of music. Some examples include the following: The basic parameters of music: duration (a decimal number), octave (an integer), pitch class (an integer), and timbre(which can be simply described as an enum of instruments) Product types: Examples include a pitch, which can be described as a tuple of (octave, pitch class). For musical analyses where pitch including octave is important, see [10]. Lists of musical objects, which includePutting it all together, we getlambda x, y, z[x (z) y(z)](λx[W alked (x )])(λx, y[Fed (y, x )](λx[x](d )))(k ) W alked (k ) Fed (k, d )2

A Categorial Grammar for Music and Its Use in Automatic Melody GenerationFARM’17, September 9, 2017, Oxford, UKdescribes the shape of a melody - it consists of a list of numbersranging from 1 to n, where n the number of notes in the melody,such that the i th pitch is lower than the k th note if the i th elementof the contour is smaller than the k th element of the contour, isequal to the k th note if the i th element of the contour is equal tothe k th element of the contour, and is higher than the k th pitchif the i th element of the contour is greater than the k th elementof the contour).3 There is a set of objects in the musical universewhich has all of these properties. Thus the semantics ofFigure 2. A Whole-Tone Scale1. Unordered lists, such as an unordered list of pitch classeswhich is then permuted in various ways2. Ordered lists, such as a rhythm, or ordered list of durations3. Lists where every element of the list is unique, such asa set class4. Lists where elements can be repeated, such as the pitchclasses in a chord with unison intervals Predicates which may be true of musical objects (such as thepredicate is symmetric rhythm which is true of a rhythmwhose reverse is the same as itself) Functions which transform musical objects, such as a function that takes a melody and an interval and moves themelody up or down that interval Polymorphic functions, including1. Higher order functions, such as a function which takesa list, a function which transforms members of that list,and a number n, and transforms every nt h element ofthe list2. Non-higher order functions, such as functions whichchange the order or number of times a given element isseenAll of these objects are often discussed even in non-mathematicalmusical analyses. However, the use of some of the musical objectstends to be localized in music of a certain repertoire - for instance,set classes (unordered unique lists of pitch classes) are found moreoften in atonal music than in tonal music, while scale degrees (integers corresponding to indices of scales) are not commonly foundin atonal music. Thus, the type of objects being used in an analysisor in a generation procedure are indicative of the style of the piecein question.The musical objects can be part of a categorial grammar in thatthey combine together to form set-theoretic entities or characteristic functions. To build a whole-tone scale (a common structure inImpressionist music), we only need three musical objects: a startingpitch, a transpose function, which takes a pitch and an interval nand shifts the pitch up or down by n, repeatApply that computesλx, y, z.combine(x, y, z)(rhythm, [0.5, 0.5, 1.0])(start pit,(5, 0)),(contour, [1, 3, 2])is the set of all musical objects (which in this case have to bemelodies) which possess those properties (some of which are shownin figure 3).On first inspection, the above formula doesn’t seem nearly asinteresting as the corresponding categorial descriptions of linguistic phrases. The benefit of linguistic categorial grammars is thatfunctions and objects fit together in interesting ways to produce apredicate-logic or set-theoretic entity, and in the above formula itappears as though the individual musical objects are unrelated toeach other. In fact, this is not quite the case. The combine functionhas a specific meaning, which references the properties of the objects it is combining. In particular, this combine function works asfollows:1. Take the cartesian power of all possible pitches with n (lenдth(contour ) 1).2. For every member of the cartesian power set, prepend thepitch start pitch to that member.3. Filter out members of the derived set which do not havethe specified contour - that is, members of the derived set(which are themselves lists) where it is not true for everyn and i that the nth element of the set is larger than thei th element of the set if contour [n] contour [i], the nthelement of the set is smaller than the i th element of theset if contour [n] contour [i], and the nth element of theset equal to the i th element of the set if contour [n] contour [i].4. Every member of this derived set is a list. For each of theselists, pair up the elements of the list with the elements ofthe rhythm, such that you achieve a list[(x[0], rhythm[0]), (x[1], rhythm[1]).(x[n], rhythm[n])] forevery element x of the previously derived set. The result isthe set containing melodies which fit the given constraints,namely having the correct pitch, contour, and rhythm.What is interesting about this combine function is that it containsan implicit description of the semantics of each of the argumentsin terms of their relationship to each other: The start pitch and thecontour are related in that both describe properties of the pitches,and the rhythm is related in that the list product type of pitchesand rhythm is a melody. If one was starting instead with a set ofstart pitches, a set of contours, and a set of rhythms, the same effectcould be achieved by applying the above algorithm to the cartesian[x, f (x ), f ( f (x )).f n (x )]The lambda-expression below computes a whole-tone scale startingon the pitch C5, shown in figure 2.(λi, j.repeatApply(i, j, 6))((λn, x .transpose(x, n)))(2))(((octave, 5), (pitch class, 0)))For a more involved example, consider three musical objects:the rhythm [0.5,0.5,1.0], the starting pitch (5,0) (where 5 is theoctave, and 0 is the pitch class) and a contour [1,3,2] (a contour3 Thus,the contour [1,3,2] implies a list of 3 pitches such that the first is the lowest,the second is the highest, and the third is between the first two.3

FARM’17, September 9, 2017, Oxford, UKHalley YoungTable 1. A Partial List of Combinator FunctionsFigure 3. A subset of the set of melodies with rhythm [0.5,0.5,1.0],start pitch (5,0), and contour [1,3,2]product of all combinations of start pitches, contours, and rhythmsbeing described.It may seem tempting to, instead of giving procedures for acombine function, treat the combine function as simply a logicalAND. In such a case, the combine function would take all possible melodies, and filter out ones which do not solve each of theproperties - namely, having the given contour, the given startingpitch, and the given rhythm. In this case, the contour, pitch, andrhythm variables would have to be fed to functions which returnedlogical predicates, which is not a problem, and which in fact maybe more similar to linguistic categorial methods than the previously proposed approach. The problem with this approach is thatit would require considering all possible melodies and filtering outonly those which satisfy the given conditions. As a thought experiment, consider only melodies made up of 4 beats of sixteenth notes,which only span the range of an octave. There are an enormous1216 possible measures that satisfy these constraints. Now considerall melodies of any reasonable length (which may be conservativelyestimated as 800 beats) of any rhythm, and without the range constraint. There are clearly far more possible melodies than there areatoms in the universe, and so it would not be feasible to producean algorithm that operates only by filtering the set of all possiblepieces of music using logical predicates. Whether this problemseems merely practical or “real” depends on one’s thoughts aboutthe philosophical implications of complexity theory, but it is safeto say that if one wants a computationally tractable grammar, oneshould use a combinator function that redefines the relationshipbetween various musical objects in a computationally tractableway.As there are many types of musical objects, there are manytimes of combinator functions. Not all combinator functions necessarily describe sets of melodies; one can imagine a combinatorwhich takes a total duration and a number of durations, and returnsthe set of all rhythms with the correct total duration and numberof individual durations. In addition, there are combinator functionswhich only describe a single musical object, rather than a set ofmusical objects. For instance, the combinator that takes a list ofpitches and rhythms, and returns a list of notes, only returns asingle melody.6Argument TypesReturn TypeReturns Set ofCharacteristicValues or a SingleValueNumber of NotesInterval VectorLengthPitch, DurationN-tuplets, LengthInterval gleRhythm, Pitch List,Vertical Interval ListRhythm, Start Pitch,Horizontal IntervalList, VerticalIntervals ListHarmony, Generating Larger MusicalObjectsIt is certainly possible to describe a 32-measure piece of music asconsisting of a single contour, rhythm, and starting pitch. However, it is potentially more useful to describe musical objects whichspan large durations as bei

context free grammars, have already been applied to music genera-tion [6]. Categorial grammars are another linguistic formalism that have proved useful to the study of music. 3 Categorial Grammars in Language In 1935, semanticist Kazimierz Ajdukiewicz introduced the concept of categorial gr

Related Documents:

Categorial Grammar (CG) is a lexicalized formal grammar well known for its tied connection between syntax and semantics. ariantsV of it (Combinatory Categorial Grammar, CCG, and Categorial ypeT Logic, CTL) have been used to reach wide coverage grammars for Engli

hybrid logic dependency structures What do the grammar and lexicon look like? Categorial Grammar Categorial grammars are lexicalised grammars a grammar is just a “dictionary” there are no language-specific grammar rules a grammar is a mapping from words to stru

Categorial Grammar The term Categorial Grammar names a group of theories of natural language syntax and semantics in which the main responsibility for defining syntactic form is borne by the lexicon. (M. Steedman) Categorial Grammars (CGs) developed as an alternati

1 IntroductionOn categorial grammars and learnabilityLogical Information Systems (LIS)Categorial grammars and/as LISAnnex Plan 1 Introduction 2 On categorial grammars and learnability 3 Logical Information Systems (LIS) 4 Categorial grammars and/as LIS 5 Annex Annie Foret IRISA & Univ. Ren

From CFG to AB grammars Proposition 2 Every "-free Context-Free Grammar in Greibach normal form is strongly equivalent to an AB categorial grammar. Thus every "-free Context-Free grammar is weakly equivalent to an AB categorial grammar. PROOF:Let us consider the following AB grammar: IIts words are the terminals of the CF

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

This lead to head grammars (Pollard), proven to be weakly equivalent to tree adjoining grammars by Vijay Shankar. Extending the grammar with composition and lift operations was explored extensively in combinatory categorial

Tulang rawan yang paling banyak dijumpai pada orang dewasa. Lokasi : - Ujung ventral iga - Larynx,trachea, bronchus - Permukaan sendi tulang - Pada janin & anak yg sedang tumbuh pada lempeng epifisis Matriks tulang rawan hilain mengandung kolagen tipe II, meskipun terdapat juga sejumlah kecil kolagen tipe IX, X, XI dan tipe lainnya. Proteoglikan mengandung kondroitin 4-sulfat, kondroitin 6 .