A method for automatic gamelan music composition

Algorithmic composition is an approach to create a music composition automatically using a certain algorithm [1][2]. Algorithmic composition has been developed since 1955 when Hiller and Isaacson used rule systems and Markov chains to design a computer-generated composition called Illiac Suite, and then followed by Xenakis which used stochastic algorithm to generate raw material for music composition [1]. Now algorithmic composition has used a wide variety of algorithmic approaches, such as generative grammars, Genetic Algorithm, cellular automata, neural networks, machine-learning techniques, expert systems, and others [1][3][4].


I. Introduction
Algorithmic composition is an approach to create a music composition automatically using a certain algorithm [1] [2].Algorithmic composition has been developed since 1955 when Hiller and Isaacson used rule systems and Markov chains to design a computer-generated composition called Illiac Suite, and then followed by Xenakis which used stochastic algorithm to generate raw material for music composition [1].Now algorithmic composition has used a wide variety of algorithmic approaches, such as generative grammars, Genetic Algorithm, cellular automata, neural networks, machine-learning techniques, expert systems, and others [1][3] [4].
In this study, algorithmic composition is implemented for traditional music called gamelan.Gamelan is a traditional music ensemble came from the land of Java.Gamelan songs are called gending.The most important in composing a new gending is not to add or subtract something that is not necessary, and it is suggested to analyze existing gendings as references in composing a new gending [5].In fact, arranging notations sequence in gamelan music composition is not as simple as duplicating and modifying existing gending.There is deep philosophy in gamelan music composition.Gamelan melodies are bound by rules and regulations of Java community which is sacred [6].The use of Javanese culture concept must be considered in composing a gending; Gamelan is not only the means of performances, but also is a part of life of the Java community, in which there is the concept of cosmology as well as the other life concepts [7].Based on description above, expert systems are considered as a proper approach to apply algorithmic composition for gamelan music.
Expert systems are a form of knowledge-based systems [8][9] [10].The use of knowledge is an approach in developing knowledge-based systems.Expert system's program can solve complex problems in a particular domain, or can solve problems which cannot be solved by people who do not have knowledge about the problem [9].Expert systems comprise two essential components which are knowledge and inference, knowledge base contains domain knowledge and inference engine consist of algorithm for manipulating the knowledge [11].Rule is a technique to representing knowledge in expert systems [12].CHORAL is a rule-based expert system for harmonizing fourpart chorales in the style of J.S. Bach which uses more than 270 rules produced by multi-view points, such as the chord skeleton, individual melodic lines of each voice and the Schenkerian voice leading within the descant and bass, in order to represent knowledge [13].Another example is McIntyre's work which used rules defined by musical scholars to govern Baroque harmony, and added pre-defined melody to control the search space [14].
Algorithmic composition for gamelan music has been studied in several works.Grammar approach is used by Becker and Becker and Hughes to define rules of gamelan music composition [15] [16].Becker and Becker define rules using linguistic method for a type of gending composition called srepegan [15].Instead of using linguistic method, Hughes uses a frame work of quasilinguistic to describe melodic feature in gending entitled Lampah [16].Another study was conducted by Surjodiningrat et al. [17] which identified the pattern of laras slendro (laras is a musical scale; slendro is a type of laras).Surjodiningrat analyzed the melodic features based on frequent gatra, which is the smallest unit in gamelan music which consists of 4 notations, and resulted data base of frequent gatra as recommendation for composing gamelan music laras slendro [17].In this study, a method based on rule-based expert system is proposed to develop a program of automatic gamelan music composition.The program is designed for non-expert user in order to help them composing gamelan music or analyzing their composition to achieve explanation and recommendation of ideal composition.

II. Gamelan Music
Laras or musical scale in gamelan music consists of slendro and pelog.Notations in laras slendro consists of 1, 2, 3, 5, 6, and laras pelog consists of 1, 2, 3, 4, 5, 6, 7.There are gamelan music orchestras which use both of laras slendro and laras pelog, or one of them.Gending is divided into 7 forms, which are lancaran, gangsaran, ketawang, ladrang, ayak-ayakan, srepegan, and Sampak.The forms of gending is differed by the number of balungan beats in one gong (gong: one of gamelan instrument), and setting of the play of gamelan instruments of kethuk, kempul, kenong, kempyang and gong [18].Fig. 1 shows the different forms of gendings [19].Gamelan music consists of elements: (1) Balungan or skeleton, which is the structure of gending that functions as a reminder to gamelan players when they perform.(2) Gatra, which is the smallest unit in gending containing 4 beats (notations) of balungan.(3) Irama and laya (rhythm and tempo): rhythm controls the stretching and squeezing of gatra, and tempo control the speed of gamelan song [20].
The creative process in composing gamelan music is usually started with humming.The composer hummed to construct the melody, and then it will be completed by performing ricikan balungan, ricikan garap, and ricikan structural.Ricikan balungan is based on balungan or structure of gending; ricikan garap refers to balungan in arranging the gamelan song; Ricikan structural is determined by the structure of gending which constructs the tone and defines the structure of gending [20].The characteristics process in composing gamelan music is different with another type of music.Gamelan composers arrange balungan notations and the song, while rhythm, tempo and structure of the song are interpreted by gamelan players when they perform [21].Fig. 2 shows notations for ricikan balungan arranged by composer, and notations for ricikan garap interpreted by gamelan players referring to ricikan balungan.Fig. 3 shows notations for gending entitled Suwe Ora Jamu in the term of balungan notations (skeleton or structure of gending).

III. Discussion
Rule-based expert system is used as an approach for automatic gamelan music composition in this method.The system is designed to have knowledge of gamelan music, and the knowledge is represented by rules.Interaction between user and program allows user creating or analyzing balungan notation composition.Fig. 4 shows the schematic diagram between the user and the system.Knowledge base and inference engine are the main components implemented in this system.The knowledge base creation is divided into 3 phases which are knowledge acquisition, knowledge base and production rules.The inference engine development contains implementation of chosen algorithm for generating notation sequence and user interface design.The system is designed to allow user creating or analyzing balungan notation composition through user interface.The inference engine in the system has to manage the user's request by using knowledge base, so the system can give explanation to user.
There are 2 types of knowledge used in this system, which are basic knowledge and melodic knowledge.Basic knowledge contains rules that control the structure of gending, such as type of laras, gending, gatra, and many others.In gamelan music, those rules are known as pakem, and a gamelan expert must understand pakem.Basic knowledge is pakem which contains variables with quantitative value, such as laras slendro consists of notations 1, 2, 3, 5, 6 and laras pelog consists of notations 1, 2, 3, 4, 5, 6, 7. The acquisition process uses gamelan music expert and literatures as the experts.The knowledge collected from the experts, and then it is formulated into data base containing variables that represent pakem of gamelan music composition.Melodic knowledge represents dynamic data.Data base of gendings are used as the expert and analyzed based on notation pattern recognition in order to identify the frequent pattern of attribute similarities among notation sequence.

A. Basic Knowledge Base Creation
Basic knowledge is defined based on pakem, which is a basic rules in gamelan music with quantitative value.Below are the examples of pakem of gending lancaran: • Gending lancaran has 16 beats (notations) which are divided into 4 groups called gatra.
• One row or one gong consists of 4 gatra.
• The first and third beats are ricikan kethuk.
• The second of even beat is ricikan kempul.
• The fourth beat of last gatra in each row is ricikan gong.All the information and fact of pakem can be analyzed by consultation and explanation from gamelan music experts and literatures.Basic knowledge is represented with data base containing pakem's variables.Table 1 shows examples of gamelan music basic knowledge base, where types of gamelan music are denoted as J: lancaran (J1), gangsaran (J2), ketawang (J3), ladrang (J4), ayakayakan (J5), srepegan (J6), sampak (J7).

B. Melodic Knowledge Base Creation
Melodic knowledge is focused on the ability of systems in choosing and arranging notations that fit the characteristic sound of gamelan melody.Notation pattern recognition technique is used to identify the notation pattern of gending based on frequent attribute similarities among notation sequences.Balungan notations which are collected from a number of gendings sample are analyzed to identify the melodic features of gending.There are 2 types of the analysis, which are construction analysis and correlation analysis.Construction analysis focuses on identifying of notation construction in a gending, such as total number of gatra, notation variant, notation variant composition, notation variant distribution, identical notation pairs and identical gatras.Construction analysis results knowledge of notations construction for composing or analyzing gendings.Correlation analysis deals with identifying of attribute similarities between notations to identify the ideal arrangement of notations sequence in composition.The analysis consists of inter-notations correlation, inter-groups correlation and inter-gatras correlation.
• Notations variant: the analysis is to identify the frequent use of notations variant in gending composition.
• Notations variant composition: the analysis is to identify the frequent use of notations variant composition in gending composition.
• Variant notations distribution: the analysis is to identify the frequent use of notations variant distribution in gending composition.
• Identical notations pairs: the analysis is to identify the frequent use of identical notations pairs in gending composition.
• Identical gatras: the analysis is to identify the frequent use of identical gatras in gending composition.

2) Correlation Analysis
A correlation between notations is analyzed to identify ideal pattern in arranging notations.The analysis uses term of frequent antecedent and consequent to define ideal notation sequence.The correlation analysis is divided into inter-notations, inter-groups and inter-gatras analysis.

a) Inter-Notations Analysis
Inter-notations correlation analysis is to identify attribute similarities between 2 notations in sequences.The fitness is measured by determining frequent value of previous and following notations pattern.The fitness is used to provide weighting in dominant value scale as recommendation of ideal notation sequence.A number of gendings are collected as data set, and then the procedures of analysis are implemented to each gending.The analysis begins with arranging gending notations into sequence data.Fig. 7 shows an illustration of arranging gending notations entitled Suwe Ora Jamu into sequence data.The sequence data which contains gending notations is extracted into partition, which each partition consists of 2 notations based on odd and even sequences.Odd sequence is determined by position of the first notation which starts from odd order, while even sequence has first notation which starts from even order.With P represents odd sequence, W represents even sequence and s represents a notation, then P1 = <s1, s2>, P2= <s3, s4>, and so on; W1 = <s2, s3>, W2= <s4, s5>, and Wend = <send, s1>.Fig. 8 shows the illustration of odd and even sequences.Result of internotations analysis of gending Suwe Ora Jamu is data base of odd and even notations sequences.The odd and even sequences are used as item set, and then the procedure of fitness measurement based on frequent value is implemented to all item set.The procedures of inter-notations analysis are implemented to all data set separately, and then the result is accumulated in order to collect frequent notation pattern based on odd and even sequences.Table 2 shows the example of odd and even sequences of gending Suwe Ora Jamu.Inter-groups analysis is to identify attribute similarities between groups of notation, where each group contains 2 notations sequence.The fitness is measured by determining frequent value of previous and following groups pattern.The fitness is used to provide weighting in dominant value scale as recommendation of ideal group sequence.A number of gendings are collected as data set, and then the procedures of analysis are implemented to each gending.The analysis begins with arranging gending notations into sequence data, and then notations are grouped by multiple of two notations.Fig. 9 shows groups of notations sequence of gending Suwe Ora Jamu.The array of groups of notations then is extracted into sequences containing two notations based on odd and even group sequences.The procedure of data extraction into odd and even sequences is implemented in this analysis.With PP represents odd group sequence, PW represents even group sequence, and s represents a notation, then PP1 = <<s1, s2>, <s3, s4>>, PP2= <<s5, s6>, <s7, s8>>, and so on; PW1 = <<s2, s3>, <s4, s5>>, PW2= <<s6, s7>, <s8, s9>>, and PWend= <<send-1, send>, <s1, s1>>.Fig. 10 shows the illustration of odd and even group sequences.Result of inter-group analysis of gending Suwe Ora Jamu is data base of odd and even group sequences.The odd and even group sequences are used as item set, and then the procedure of fitness measurement based on frequent value is implemented to all item set.The procedures of inter-groups analysis are implemented to all data set separately, and then the result is accumulated in order to collect frequent notation group pattern based on odd and even sequences.Table 3 shows the example of odd and even group sequences of gending Suwe Ora jamu.Inter-gatras analysis is to identify attribute similarities between particular notations in 2 connected gatras.The fitness is measured by determining frequent value of previous and following gatras pattern.The fitness is used to provide weighting in dominant value scale as recommendation of ideal connected gatras.A number of gendings are collected as data set, and then the procedures of analysis are implemented to each gending.The analysis begins with arranging gending notations based on its gatra.With GP represents odd gatra sequence, GW represents even gatra sequence, and s represents a notation, then GP1a = <s1, s5>, GP2a= <s5, s9>, GP3a= <s9, s13> and GPaend= <s13, s1>; GP1b = <s3, s7>, GP2b= <s7, s11>, GP3b= <s11, s15> and GPbend= <s15, s3>; GW1a = <s2, s6>, GW2a= <s6, s10>, GW3a= <s10, s14> and GWaend= <s14, s2>; GW1b= <s4, s8>, GW2b= <s8, s12>, GW3b= <s12, s16>, and GWbend= <s16, s4>.Fig. 11 shows the illustration of odd and even inter-gatras correleation.Result of inter-gatras analysis of gending Suwe Ora Jamu is data base of odd and even gatras sequences.The odd and even inter-gatras sequences are used as item set, and then the procedure of fitness measurement based on frequent value is implemented to all item set.The procedures of inter-gatras analysis are implemented to all data set separately, and then the result is accumulated in order to collect frequent notation group pattern based on odd and even sequences.Table 4 shows the example of odd and even inter-gatras sequences of gending Suwe Ora jamu.

Odd Inter-gatras Sequences (GP)
Even Inter-gatras Sequences (GW) C. Production Rules There are three types of production rules that used as described below.

1) Rules for Identifying Type of Laras
Laras slendro notations contain combination of 1, 2, 3, 5, or 6, and laras pelog notations contain combination of 1, 2, 3, 4, 5, 6, 7. Basically, if notation 4 or 7 is in a composition, then type of the composition can be identified that the laras is pelog, but if a composition contains combination of 1, 2, 3, 5, 6, then the type of laras can be both of slendro or pelog; therefore the system needs to search more by matching the composition notations with data in notations construction data base, thus the rules of determining type of laras can be defined as follows:

2) Rules for Identifying Type of Gending
Types of gending consist of lancaran, gangsaran, ketawang, ladrang, ayak-ayakan, srepegan, and sampak.There are two techniques in determining type of gending, by using basic knowledge or melodic knowledge.Type of gending is differed by beats of instrument of kenong, kethuk and gong.Basic knowledge of data base contain beat symbols of those instruments, so type of gending can be determined by comparing beat symbols in composition with those in basic knowledge data base.The second technique which is using melodic knowledge is conducted if beat symbols in composition cannot be identified accurately.In these circumstances, the notations construction of composition can be compared with melodic knowledge data base for notations construction

3) Rules for Arranging Notations
Melodic knowledge data base which contains of frequent inter-notations data base, frequent inter-groups data base and frequent inter-gatras data base is used to arrange notations sequences that fit with sound characteristics of gamelan music.Rules defined based on melodic knowledge controls the creation of notations sequence and connected gatras.Below are rules of arranging notations, where a1, b1, c1, d1, a2, b2, c2, d2 stand for notations sequences.

4) Rules for Composing
Composing a gending is started by defining type of laras and gending, then followed by determining the number of gatra.The number of gatra for composition can be defined using data of frequent gatra stored in basic knowledge data base.The next step is determining notations variant, notations variant composition, notations variant distributions, so the population of notations for composition is created.Further, notation sequence generating process can be implemented.Below are the rules for composing gamelan music.IF laras has been defined.AND gending has been defined.AND number of gatra has been defined.AND notations variant has been defined.AND notations variant composition has been defined.THEN define notations variant distribution based on data of frequent notations variant distribution in basic knowledge data base.
IF laras has been defined.AND gending has been defined.AND number of gatra has been defined.AND notations variant has been defined.AND notations variant composition has been defined.AND notations variant distribution has been defined.THEN notations population has been created.
IF notations population has been created.THEN choose for using identical notations pairs or identical gatras, and save the setting in working memory.
IF notations population has been created.AND identical notations pair and identical gatras have defined.THEN start generating notations sequence for composition.
IF pattern in notations sequence is match with those in melodic knowledge database.THEN set notations sequence as composition.

D. Inference Engine
Generate and test method (GAT) is used to inference engine in composing a gending.After notations population is created, system starts to generate notations sequence using random technique, and then test the result.Composition is stated succeed when notations sequence fit with basic and melodic rules, otherwise the system will randomize the notations population again, until composition is created.
Analyzing a composition can be conducted using backward chaining method.Notations in a composition are extracted based on inter-notations correlation, inter-groups correlation and intergatras correlation, and then the procedures of notation pattern recognition is used to match the notations pattern in the composition with those in basic and melodic knowledge base.Result of the analysis can be a recommendation of changing some notations in the composition, or explanation of gending types.

Fig. 6 .
Fig. 6.Identical gatras in gending Kebo Giro Construction analysis is conducted to identify element features of notations construction in gending based on type of laras.There are 2 types of laras which are pelog and slendro.The data base for laras pelog and laras slendro is created separately, and each data base is represented by analyzing a number of gending collected from 7 type of gendings.The construction analysis results 14 data base of notations construction based on type of laras and gending.The construction analysis then is conducted by identifying notations construction as follows:

Fig. 8 .
Fig. 8. Illustration of odd and even sequences

Fig. 10 .
Fig. 10.Illustration of odd and even group sequences

IF
beat symbols in composition are match with those in basic knowledge data base.THEN set type of gending.ELSE start notation pattern recognition.IF beat symbols in composition are match with those in melodic knowledge data base.THEN set type of gending.

Table 1 .
Examples of basic kKnowledge base

Table 2 .
Database of odd and even sequences
IF laras is slendro.THEN available notations are 1, 2, 3, 5, 6.IF laras is pelog.THEN available notations are 1, 2, 3, 4, 5, 6, and 7.IF laras has been defined.AND gending has been defined.AND number of gatra has been defined.AND notations variant has been defined.THEN define notations variant composition based on data of frequent notations variant composition in basic knowledge data base.