Composing Counterpoint Music With Variable Neighbourhood Search

24
Composing Counterpoint Music With Variable Neighbourhood Search D. Herremans & K. S¨ orensen Bridges, August 14-19, 2014, Seoul University of Antwerp Operations Research Group ANT / OR

description

Presentation Bridges conference, Seoul.

Transcript of Composing Counterpoint Music With Variable Neighbourhood Search

Page 1: 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

ANT/OR

Page 2: Composing Counterpoint Music With Variable Neighbourhood Search

Overview

Computer aided composing (CAC)

Variable Neigbourhood Search

Experiments & Results

Implementation

Conclusion

Page 3: Composing Counterpoint Music With Variable Neighbourhood Search

Computer aided composing (CAC)

Composing music = combinatorial optimization problem

I Music → combination of notes

I “Good” music → fits a style as well as possible

I Formalized and quantified “rules” of a style → objectivefunction

Page 4: Composing Counterpoint Music With Variable Neighbourhood Search

Counterpoint

I Polyphonic classical music

I Inspired Bach, Haydn,. . .

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

Page 5: Composing Counterpoint Music With Variable Neighbourhood Search

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 ]

Page 6: Composing Counterpoint Music With Variable Neighbourhood Search

5th species counterpoint

I Counterpoint & Cantus firmus

4444

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

Page 7: Composing Counterpoint Music With Variable Neighbourhood Search

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

Page 8: Composing Counterpoint Music With Variable Neighbourhood Search

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)

Page 9: Composing Counterpoint Music With Variable Neighbourhood Search

Quantifying musical quality

fcf (s) =

19∑i=0

ai.subscore cfHi (s)︸ ︷︷ ︸horizontal aspect

(3)

fcp(s) =

19∑i=0

ai.subscore cpHi (s)︸ ︷︷ ︸

horizontal aspect

+

19∑j=0

bj .subscoreVj (s)︸ ︷︷ ︸vertical aspect

(4)

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

Page 10: Composing Counterpoint Music With Variable Neighbourhood Search

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

Page 11: Composing Counterpoint Music With Variable Neighbourhood Search

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

Page 12: Composing Counterpoint Music With Variable Neighbourhood Search

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)

Page 13: Composing Counterpoint Music With Variable Neighbourhood Search

LS Swap NH

LS Change1 NH

LS Change2 NH

Current s <

s at A?

Change r% of notes randomly

YesNo

Update s best

Generate random s

A

Max itersreached?

Update adaptive weights

Iters ++

No

Exit

Exit

Optimumfound?

yes

Yes

Page 14: Composing Counterpoint Music With Variable Neighbourhood Search

Experiments & Results

I Full factorial experiment, n=2304

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

16 , ttsw= 18 , off 4

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

8 , off 4Nc2 - Change2 on with ttc2=0, ttc2= 1

16 , ttc2= 18 , off 4

Random move 14 changed, 1

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

Page 15: Composing Counterpoint Music With Variable Neighbourhood Search

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−16

Nc2 1 15690.7234 < 2.2e−16

Nsw 1 3909.2959 < 2.2e−16

randsize 2 1110.1724 < 2.2e−16

maxiters 2 322.6488 < 2.2e−16

length 1 165.6053 < 2.2e−16

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

Page 16: Composing Counterpoint Music With Variable Neighbourhood Search

Experiments & Results

I Mean plot for the size of the random jump

0 10 200.6

0.8

1

1.2

Random size (in %)

Sco

re

0 10 20

100

200

Tim

e(s

)

Page 17: Composing Counterpoint Music With Variable Neighbourhood Search

Optimal parameter settings

Parameter Value

Nsw on with ttsw = 116

Nc1 on with ttc1 =116

Nc2 on with ttc2 =116

Random move 18 changed

Adaptive weights onMax. number of iterations 50

Page 18: Composing Counterpoint Music With Variable Neighbourhood Search

Implementation

I C++ → VNS

I JavaScript using the QtScript engine → MuseScore pluginI Input:

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

I Result: MusicXML

Page 19: Composing Counterpoint Music With Variable Neighbourhood Search

Implementation

Page 20: Composing Counterpoint Music With Variable Neighbourhood Search

ResultsI Example of a generated fragment with score 0.556776.

4444

12

Page 21: Composing Counterpoint Music With Variable Neighbourhood Search

Expansions - Composer-specific music

I Classifications models from corpus

I Implemented as Android app

I Continuously generated

Page 22: Composing Counterpoint Music With Variable Neighbourhood Search

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)

Page 23: Composing Counterpoint Music With Variable Neighbourhood Search

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

Page 24: 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

ANT/OR