Composing Counterpoint Music With Variable Neighbourhood Search

download Composing Counterpoint Music With Variable Neighbourhood Search

of 24

  • date post

  • Category


  • view

  • download


Embed Size (px)


Presentation Bridges conference, Seoul.

Transcript of Composing Counterpoint Music With Variable Neighbourhood Search

  • Composing Counterpoint Music WithVariable Neighbourhood Search

    D. Herremans & K. Sorensen

    Bridges, August 14-19, 2014, Seoul

    University of Antwerp

    Operations Research Group


  • Overview

    Computer aided composing (CAC)

    Variable Neigbourhood Search

    Experiments & Results



  • Computer aided composing (CAC)

    Composing music = combinatorial optimization problem

    I Music combination of notesI Good music fits a style as well as possibleI Formalized and quantified rules of a style objective


  • Counterpoint

    I Polyphonic classical music

    I Inspired Bach, Haydn,. . .

    I One of the most formally defined musical styles Rules written by Fux in 1725

  • 1st species counterpoint

    I Counterpoint & Cantus firmus

    44 44

    I Represented as 2 vectors with midi values[ 60 65 64 62 60 64 65 67 67 69 62 64 64 60 59 60 ]

  • 5th species counterpoint

    I Counterpoint & Cantus firmus


    I Represented as a vector of note objects, each with:I Pitch: midi valueI DurationI Beat numberI Measure numberI Tied?

  • Quantifying musical quality

    Examples of rules:

    I Each large leap should be followed by stepwise motion in theopposite direction

    I Half notes should always be consonant on the first beat, unlessthey are suspended and continued stepwise and downward

    I All perfect intervals should be approached by contrary oroblique motion

    19 vertical and 19 horizontal subscores between 0 and 1

  • Quantifying musical quality

    I Eight notes (8ths) must move in step.

    subscoreH1 (s) =#8ths not preceded by step + 8ths not left by step

    #8ths 2(1)

    I Whole notes should always be vertically consonant.

    subscoreV1 (s) =#dissonant whole notes

    #whole notes(2)

  • Quantifying musical quality

    fcf (s) =


    ai.subscore cfHi (s)

    horizontal aspect


    fcp(s) =


    ai.subscore cpHi (s)

    horizontal aspect



    bj .subscoreVj (s)

    vertical aspect


    f(s) = fcf (s) + fcp(s) (5)

  • Quantifying musical quality

    I Weights ai and bjI Specified at input

    I Emphasize subscore from start

    I Adaptive weights mechanismI Increase weight of subscore with highest valueI Keeps the search in the right direction

  • Variable Neigbourhood Search

    I Local search with 3 neighbourhoodsI Selection

    I Steepest descentI Based on adaptive score fa(s)

    Ni Name Description

    Nsw Swap Swap two notesNc1 Change1 Change one noteNc2 Change2 Change two notes

  • Variable Neigbourhood Search

    I Excluded framentsI Tabu listI Infeasible

    I PerturbationI Change r% of the notes randomly

    I Adaptive weights mechanism

    I Update best solution sbest, based on original score f(sbest)

  • LS Swap NH

    LS Change1 NH

    LS Change2 NH

    Current s <

    s at A?

    Change r% of notes randomly

    Yes No

    Update s best

    Generate random s


    Max itersreached?

    Update adaptive weights

    Iters ++







  • Experiments & Results

    I Full factorial experiment, n=2304

    Parameter Values Nr. of levelsNsw - Swap on with ttsw=0, ttsw=

    116 , ttsw=

    18 , off 4

    Nc1 - Change1 on with ttc1=0, ttc1=116 , ttc1=

    18 , off 4

    Nc2 - Change2 on with ttc2=0, ttc2=116 , ttc2=

    18 , off 4

    Random move 14 changed,18 changed, off 3

    Adaptive weights on, off 2Max. iterations 5, 20, 50 3Length of music 16, 32 measures 2

  • Experiments & ResultsI Multi-Way ANOVA model with interaction effects, using RI R2 = 0.98

    Parameter Df F value Prob (> F )Nc1 1 9886.2323 < 2.2e


    Nc2 1 15690.7234 < 2.2e16

    Nsw 1 3909.2959 < 2.2e16

    randsize 2 1110.1724 < 2.2e16

    maxiters 2 322.6488 < 2.2e16

    length 1 165.6053 < 2.2e16

    adj. weights 1 4.0298 0.0448367ttc1 2 2.2575 0.1048791ttc2 2 8.271 0.0002646ttsw 2 3.2447 0.0391833

  • Experiments & Results

    I Mean plot for the size of the random jump

    0 10 200.6




    Random size (in %)



    0 10 20






  • Optimal parameter settings

    Parameter Value

    Nsw on with ttsw =116

    Nc1 on with ttc1 =116

    Nc2 on with ttc2 =116

    Random move 18 changedAdaptive weights onMax. number of iterations 50

  • Implementation

    I C++ VNSI JavaScript using the QtScript engine MuseScore pluginI Input:

    I Key (i.e., G# minor)I Weights for each subscoresI VNS parameters

    I Result: MusicXML

  • Implementation

  • ResultsI Example of a generated fragment with score 0.556776.



  • Expansions - Composer-specific music

    I Classifications models from corpus

    I Implemented as Android app

    I Continuously generated

  • Expansions - Learned objective function

    I Markov Model learned from a corpus

    I Techniques for using a MM in the objective function

    I High-probability sequencesI Minimize distance between transisiton matrices corpus &

    generated musicI Delta cross-entropyI UnwordsI Information contour

    1st species counterpoint bagana music uplifting trance (transformations)

  • Conclusion

    The fifth species counterpoint rules have been quantified and anefficient algorithm has been implemented to compose this style ofmusic. This algorithm is later combined with an objective functionlearned from a corpus.

    Future research:I More complex music:

    I Different stylesI More partsI Semiotic structure

  • Composing Counterpoint Music WithVariable Neighbourhood Search

    D. Herremans & K. Sorensen

    Bridges, August 14-19, 2014, Seoul

    University of Antwerp

    Operations Research Group


    Computer aided composing (CAC)Variable Neigbourhood SearchExperiments & ResultsImplementationConclusion