Skip to main content

Grammatical Music Composition with Dissimilarity Driven Hill Climbing

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 9596)


An algorithmic compositional system that uses hill climbing to create short melodies is presented. A context free grammar maps each section of the resultant individual to a musical segment resulting in a series of MIDI notes described by pitch and duration. The dissimilarity between each pair of segments is measured using a metric based on the pitch contour of the segments. Using a GUI, the user decides how many segments to include and how they are to be distanced from each other. The system performs a hill-climbing search using several mutation operators to create a population of segments the desired distances from each other. A number of melodies composed by the system are presented that demonstrate the algorithm’s ability to match the desired targets and the versatility created by the inclusion of the designed grammar.


  • Algorithmic composition
  • Hill-climbing
  • Grammar

This is a preview of subscription content, access via your institution.

Buying options

USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions


  1. 1.

    Note that the NC methods use less as each Copy in each of the 1,000 generations requires one evaluation.


  1. Biles, J.A.: Straight-ahead jazz with GenJam: a quick demonstration. In: MUME 2013 Workshop (2013)

    Google Scholar 

  2. Brabazon, A., O’Neill, M., McGarraghy, S.: Grammatical evolution. In: Brabazon, A., O’Neill, M., McGarraghy, S. (eds.) Natural Computing Algorithms, pp. 357–373. Springer, Heidelberg (2015)

    CrossRef  Google Scholar 

  3. Chen, A.L., Chang, M., Chen, J., Hsu, J.L., Hsu, C.H., Hua, S.: Query by music segments: an efficient approach for song retrieval. In: ICME 2000, vol. 2, pp. 873–876. IEEE (2000)

    Google Scholar 

  4. Dahlstedt, P.: Autonomous evolution of complete piano pieces and performances. In: Proceedings of Music AL Workshop. Citeseer (2007)

    Google Scholar 

  5. Donnelly, P., Sheppard, J.: Evolving four-part harmony using genetic algorithms. In: Di Chio, C., et al. (eds.) EvoApplications 2011, Part II. LNCS, vol. 6625, pp. 273–282. Springer, Heidelberg (2011)

    CrossRef  Google Scholar 

  6. Fernández, J.D., Vico, F.: AI methods in algorithmic composition: a comprehensive survey. J. Artif. Intell. Res. 48, 513–582 (2013)

    MathSciNet  MATH  Google Scholar 

  7. Hargreaves, D.J.: The effects of repetition on liking for music. J. Res. Music Educ. 32(1), 35–47 (1984)

    CrossRef  Google Scholar 

  8. Hu, N., Dannenberg, R.B., Lewis, A.L.: A probabilistic model of melodic similarity. In: International Computer Music Conference (ICMC), Goteborg, Sweden. International Computer Music Society (2002)

    Google Scholar 

  9. Lemström, K., Ukkonen, E.: Including interval encoding into edit distance based music comparison and retrieval. In: Proceedings of the AISB, pp. 53–60 (2000)

    Google Scholar 

  10. Logan, B., Salomon, A.: A music similarity function based on signal analysis. In: ICME, Tokyo, Japan, p. 190. IEEE (2001)

    Google Scholar 

  11. Loughran, R., McDermott, J., O’Neill, M.: Grammatical evolution with Zipf’s law based fitness for melodic composition. In: Sound and Music Computing, Maynooth (2015)

    Google Scholar 

  12. Loughran, R., McDermott, J., O’Neill, M.: Tonality driven piano compositions with grammatical evolution. In: CEC, pp. 2168–2175. IEEE (2015)

    Google Scholar 

  13. Middleton, R.: ‘Play It Again Sam’: some notes on the productivity of repetition in popular music. Popular Music 3, 235–270 (1983)

    CrossRef  Google Scholar 

  14. Mladenović, N., Hansen, P.: Variable neighborhood search. Comput. Oper. Res. 24(11), 1097–1100 (1997)

    CrossRef  MathSciNet  MATH  Google Scholar 

  15. Ockelford, A.: Repetition in Music: Theoretical and Metatheoretical Perspectives. Ashgate, Aldershot (2005)

    Google Scholar 

  16. Reddin, J., McDermott, J., O’Neill, M.: Elevated pitch: automated grammatical evolution of short compositions. In: Giacobini, M., et al. (eds.) EvoWorkshops 2009. LNCS, vol. 5484, pp. 579–584. Springer, Heidelberg (2009)

    CrossRef  Google Scholar 

  17. Shao, J., McDermott, J., O’Neill, M., Brabazon, A.: Jive: a generative, interactive, virtual, evolutionary music system. In: Di Chio, C., et al. (eds.) EvoApplications 2010, Part II. LNCS, vol. 6025, pp. 341–350. Springer, Heidelberg (2010)

    CrossRef  Google Scholar 

  18. Slaney, M., Weinberger, K., White, W.: Learning a metric for music similarity. In: International Symposium on Music Information Retrieval (ISMIR) (2008)

    Google Scholar 

  19. Thywissen, K.: GeNotator: an environment for exploring the application of evolutionary techniques in computer-assisted composition. Organ. Sound 4(2), 127–133 (1999)

    CrossRef  Google Scholar 

Download references


This work is part of the App’Ed (Applications of Evolutionary Design) project funded by Science Foundation Ireland under grant 13/IA/1850.

Author information

Authors and Affiliations


Corresponding author

Correspondence to Róisín Loughran .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Loughran, R., McDermott, J., O’Neill, M. (2016). Grammatical Music Composition with Dissimilarity Driven Hill Climbing. In: Johnson, C., Ciesielski, V., Correia, J., Machado, P. (eds) Evolutionary and Biologically Inspired Music, Sound, Art and Design. EvoMUSART 2016. Lecture Notes in Computer Science(), vol 9596. Springer, Cham.

Download citation

  • DOI:

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-31007-7

  • Online ISBN: 978-3-319-31008-4

  • eBook Packages: Computer ScienceComputer Science (R0)