Trends in Answer-Set-
Programming – Focus: Music

          Erhard Dinhobl
Roadmap
•   Motivation: Why Automatic Composition?
•   Basics in Music
•   ANTON and Music
•   Basics in Answer-Set-Programming
•   ANTON and Answer-Set-Programming

• Conclusion
Why Automatic Composition
• Is it possible? – With ANTON, yes
• melodic and harmonic composition tool
• ANTON uses declarative programming
  language for rules representation
• helps composers to understand and
  detect failures
Basics
Harmony
• „underlying sound“ of a melody –
  functional parameter, the chord
  structure
• define harmonic progress (history, new
  melody) – i.e. cadences
Melody
• progress of notes over time
• „what we sing“
Basics - Genre
• style of music – different rules (added to
  fundamental music)
• characteristics, culture, instruments, way
  we hear
• western tonality – halftone music
interval structure smaller – Arabian-
  classic, quarter-tone, microtonal
• BUT: blues (quint in between #11 and 5)
System ANTON
• minimal set of rules to generate/verify
  music
• adding rules  improvement of quality
• Computer-Aided Composition
• „Background music“ – Elevators, Halls, …
Compositionprocess I
• global structure (AABA, Etude, Minuet,
  …)
• melody (not overall, variations, J.S.Bach
  Invetionen, W.A.Mozart Twinkle Twinkle
  Little Star)
• question: „where is the next note?“
• example: „Musikalisches Würfelspiel“
• approved: mathematic models, fractals,
  chaos processes, Markov-chains
Compostionprocess II
• David Cope „The Algorithmic Composer“
• Iannis Xenakis (example: Modulor)
• my work „Ursprungskunst“ – generate
  music out of architecture and the other
  way
• ornaments (Claude Debussy, Morton
  Feldmann)
Composition III
• alternative: IRCAM (based on
  PWConstraints-addon LISP and graphic
  lang.)
• composition also in „improvisation music“
  (jazz, baroque „figured bass“ notation)
• jazz musicians improvise over accord
  structure „a standard“
• Improvisation system  Composition
  system
Answer-Set-Programming I
• formal defined rules
• r: a1,…, aj ← b1,…, bm, not bm+1,…,
  not bn
• H(r) = „head“, left-hand side
  „consequence“
• B(r) = „body“, right-hand side „condition“
• if B(r) = {}  H(r) = fact, always true
• construction of answer-set in fixpoint
  iterations to truth assignment of atoms
Answer-Set Example
•   a ← b, c
                   Iterations:
•   b←c            T({}) = {c}
•   c←.            T({c}) = {b, c}
•                  T({b, c}) = {a, b, c}
    d←e
                   T({a, b, c}) = {a, b, c}
•   e←d

d & e not contained!
Answer-Set Programming II
• atoms: something about reality
• rules: connection between atoms;
  assignment gets them to true or false 
  atoms (rules fulfilled)
• choice rules: 1 { p, q, r } 2
  describes, that at least 1 atom of p, q, r
  but at most 2 are choosen to be true
• no negation %
Gelfond-Lifschitz-Reduct
• Reduce every „not“ in rules
• result: no negation in rules
• Interpretation, then check if true or false
  (accept as true or delete rule)
• all facts
                             Example:
• all rules without neg.
                             a ← not b      a←.
                             c ← not d      c←.
                             d←b           d←b
                             d ← e, not a   d←e
                             e ← d, not a   e←d
ANTON
• with ASP model is defined due that
  music is harmonic and melodic valid
  (instance of rules  atoms)
• ANTON consists of 191 loc (28 melodic
  and harmonic rules)
• piece with 8 notes: 3.500 atoms; 13.400
  rules
• duet with 16 notes: 11.000 atoms;
  1.350.000 rules
runtime of anton
      piece for 1 voice with _length_ notes




     piece for 2 voices with _length_ notes




clause learning-mechanism  better performance
Twenty Short Pieces (excerpt)
• verification by human
• disadvantage: only quarter notes
• advantage: due declarative prog.
  order of rules processing doesn‘t
  matter and rule base is extendable




… trying to get insight to Anton's
„thinking“…




                                       0:57
Twenty Short Pieces (Harmony)
Some Example in Code
• key-rule: choosenNote(P, T, N)
  „at time T, voice P plays note N“
• discrete time (quarter notes in this
  example)
• may consists of more than one voice
  (polyphonic)
• octave is divided in 12 intervals –
  independent from temper
Example II
keyMode(lydian).
choosenNote(1,1,25).
choosenNote(1,2,24).
choosenNote(1,8,19).
choosenNote(1,9,20).
choosenNote(1,10,24).
choosenNote(1,14,29).
choosenNote(1,15,27).
choosenNote(1,16,25).
#const t=16.
configuration(solo).
part(1).
Some Rules
% every note must be in the scale
#const err nik=„note not in scale".
reason(err nik).
error(P,T,err nik) :- choosenNote(P,T,N), chromatic(N,C), not key(C).

% melodic minor -> last two notes depend on direction of playing
error(P,T + 1,err ism) :- choosenNote(P,T + 1,N), chromatic(N,9),
upAt(P,T), keyMode(minor).
% voices can only meet at one time
haveMet(P,T+1) :- choosenNote(P,T,N), choosenNote(P+1,T,N), not haveMet(P,T), part(P+1).
haveMet(P,T+1) :- haveMet(P,T).
% every note, the next note must be an other (up or down)
1 { stepAt(P,T), leapAt(P,T) } 1 :- T != t.
1 { downAt(P,T), upAt(P,T) } 1 :- T != t.

% if melody does a jump, only harmonic intervals are allowed
1 { leapBy(P,T,LS) : leapSize(LS) : LS > 0 } 1 :- leapUp(P,T).
% if a voice changes of interval I the next note must be I steps
higher/lower
choosenNote(P,T + 1,N + L) :- choosenNote(P,T,N), leapAt(P,T),
leapBy(P,T,L), note(N + L).
ANTON
• „filling“ of bars no problem
• harmonisation no problem
• harmonisation rules (rules may be taken
  from J.S.Bach Choralgesänge –
  consistent rules)
• ANTON produces diff. formats (i.e.
  Csound, Lilypond) and open for further
  ones
Evaluation
         musical                 technical
subjective by human     ~200 loc for a script
(halftone  quartertone ALL libs and so on: ~800
music)                  loc
                        STRASHEELA (UC
                        Belfast): 8000 loc
                        BOL-Proc.-Script: 88000
                        loc
Work on ANTON
•   better runtime performance (Anton 1.5)
•   real time composition  improvisation
•   composing trios and quartets (Anton 1.5)
•   rhythmic composition (Anton 1.5)
•   recognizing and using of global structures
ANTON 1.5 (no yet released)
• runtime for generating pieces for 1/2 voice(s)
  with _length_ notes

            0.22     0.33
            1.01     1.06
            2.27     2.42
            4.62     4.01




            0.77      1.18
            3.73      3.88
           16.84     14.50
           29.63     82.64




        old values
ANTON 1.5
• runtime for generating pieces for 3/4 voice(s)
  with _length_ notes
Example from ANTON 1.5
               code-remarks

               style(quartet).
               part(1..4).
               melodicPart(1).
               lowestPart(4).
               #const quartetBottomNote=1.
               #const quartetTopNote=68.
               % from contra C
               (lowest + 2 octaves 8vb) to
               g’’’ (highest + 2 octaves)



                   4/4 or 6/4 or …??

                        0:26
Verification with lydian chromatic
    concept – George Russel
• method of scale-finding for improvisation
• chord  some lydian scale = parent scale
• chord  lydian scale from note (b7, b9,
  -b5, maj = tonic)
• visualisation-model of Robert M. Weiß
  (worked with George Russel)
• „travelling“ through quint-circle
Verification with lydian chromatic concept –
              George Russel II




       „A Child Is Born“
Conclusion / Future Work
- Anton is some kind of composition
- not the overall solution
- would be useful if it works in realtime


Future work: trying to get a verification
 model through my mathematical
 visualisation of music in architecture
Reductio ad absurdum – but good
               Christmas-Song „Es ist ein Roß entsprungen“ 
 (A)
 ||: Bbmaj Eb7     |    Abmaj F#7b5    | Fm7 Bb7#11 |       Ebmaj Abmaj ||
                  (B)                                 (A)
 |     Gsus       :||   B-7   A-5b13   | E-7          || Bbmaj Eb7       |

 |     Abmaj F#7b5 |    Fm7 Bb7#11     | Ebmaj Abmaj | Gsus              |

 |     Cmaj        ||                                                  0:49


- odd count of bars
- melody  some chords (arbitrary)
- most incorrect cadences

- some correct cadences
- global structure: AABA
Quellen
[1]
Automatic Composition of Melodic and Harmonic Music by Answer Set Programming, Georg Boenn, Martin Brain, Marina De
     Vos, John ffitch, Cardiff School of Creative & Cultural Industries University of Glamorgan UK
[2]
ANTON: Composing Logic and Logic Composing, Georg Boenn, Martin Brain, Marina De Vos, John Ffitch, Cardiff School of
     Creative & Cultural Industries University of Glamorgan UK
[3]
Ursprungskunst, Erhard Dinhobl, BSc-Thesis, 2008, TU Wien
[4]
Persönliche Korrespondenz mit Robert M. Weiss / Lehrgang „Lydian Chromatic Concept“ am Josef M. Hauer Konservatorium
     Wr. Neustadt
[5]
Persönliche Korrespondenz mit Michael Brain, Entwickler ANTON
[6]
Das wohltemperierte Gehirn: Wie Musik im Kopf entsteht und wirkt, Robert Jourdain, Spektrum Verlag, 2001
[7]
Neue Jazz-Harmonielehre, Frank Sikora, SCHOTT, 2003
[8]
The Lydian Chromatic Concept of Tonal Organisation, George Russel, Concept Publishing Co. New York N.Y, 1953 (2001)
[9]
Automatic Composition using Anwer Set Programming, Georg Boenn, Martin Brain, Marina de Vos, John Ffitch, University of
     Glamorgan, UK, 2009
[10]
389 Choralgesänge (für vierstimmigen gemischten Chor), J.S.Bach
[11]
Knowledge, Representation, Reasoning and Declarative Problem solving, Chitta Baral, University of Cambridge, 2003
[12]
Logische Programme und Antwortensemantik II, Prof. Dr. Gabriele Kern-Isberner, Universität Dortmund, 2004
[13]
Persönliche Korrespondenz mit Monika Etzelt

Feel free to contact me: Erhard Dinhobl / er@master-studios.net

Trends in Answer Set-Programming - Focus Musik - Presentation

  • 1.
    Trends in Answer-Set- Programming– Focus: Music Erhard Dinhobl
  • 2.
    Roadmap • Motivation: Why Automatic Composition? • Basics in Music • ANTON and Music • Basics in Answer-Set-Programming • ANTON and Answer-Set-Programming • Conclusion
  • 3.
    Why Automatic Composition •Is it possible? – With ANTON, yes • melodic and harmonic composition tool • ANTON uses declarative programming language for rules representation • helps composers to understand and detect failures
  • 4.
    Basics Harmony • „underlying sound“of a melody – functional parameter, the chord structure • define harmonic progress (history, new melody) – i.e. cadences Melody • progress of notes over time • „what we sing“
  • 5.
    Basics - Genre •style of music – different rules (added to fundamental music) • characteristics, culture, instruments, way we hear • western tonality – halftone music interval structure smaller – Arabian- classic, quarter-tone, microtonal • BUT: blues (quint in between #11 and 5)
  • 6.
    System ANTON • minimalset of rules to generate/verify music • adding rules  improvement of quality • Computer-Aided Composition • „Background music“ – Elevators, Halls, …
  • 7.
    Compositionprocess I • globalstructure (AABA, Etude, Minuet, …) • melody (not overall, variations, J.S.Bach Invetionen, W.A.Mozart Twinkle Twinkle Little Star) • question: „where is the next note?“ • example: „Musikalisches Würfelspiel“ • approved: mathematic models, fractals, chaos processes, Markov-chains
  • 8.
    Compostionprocess II • DavidCope „The Algorithmic Composer“ • Iannis Xenakis (example: Modulor) • my work „Ursprungskunst“ – generate music out of architecture and the other way • ornaments (Claude Debussy, Morton Feldmann)
  • 9.
    Composition III • alternative:IRCAM (based on PWConstraints-addon LISP and graphic lang.) • composition also in „improvisation music“ (jazz, baroque „figured bass“ notation) • jazz musicians improvise over accord structure „a standard“ • Improvisation system  Composition system
  • 10.
    Answer-Set-Programming I • formaldefined rules • r: a1,…, aj ← b1,…, bm, not bm+1,…, not bn • H(r) = „head“, left-hand side „consequence“ • B(r) = „body“, right-hand side „condition“ • if B(r) = {}  H(r) = fact, always true • construction of answer-set in fixpoint iterations to truth assignment of atoms
  • 11.
    Answer-Set Example • a ← b, c Iterations: • b←c T({}) = {c} • c←. T({c}) = {b, c} • T({b, c}) = {a, b, c} d←e T({a, b, c}) = {a, b, c} • e←d d & e not contained!
  • 12.
    Answer-Set Programming II •atoms: something about reality • rules: connection between atoms; assignment gets them to true or false  atoms (rules fulfilled) • choice rules: 1 { p, q, r } 2 describes, that at least 1 atom of p, q, r but at most 2 are choosen to be true • no negation %
  • 13.
    Gelfond-Lifschitz-Reduct • Reduce every„not“ in rules • result: no negation in rules • Interpretation, then check if true or false (accept as true or delete rule) • all facts Example: • all rules without neg. a ← not b a←. c ← not d c←. d←b  d←b d ← e, not a d←e e ← d, not a e←d
  • 14.
    ANTON • with ASPmodel is defined due that music is harmonic and melodic valid (instance of rules  atoms) • ANTON consists of 191 loc (28 melodic and harmonic rules) • piece with 8 notes: 3.500 atoms; 13.400 rules • duet with 16 notes: 11.000 atoms; 1.350.000 rules
  • 15.
    runtime of anton piece for 1 voice with _length_ notes piece for 2 voices with _length_ notes clause learning-mechanism  better performance
  • 16.
    Twenty Short Pieces(excerpt) • verification by human • disadvantage: only quarter notes • advantage: due declarative prog. order of rules processing doesn‘t matter and rule base is extendable … trying to get insight to Anton's „thinking“… 0:57
  • 17.
  • 18.
    Some Example inCode • key-rule: choosenNote(P, T, N) „at time T, voice P plays note N“ • discrete time (quarter notes in this example) • may consists of more than one voice (polyphonic) • octave is divided in 12 intervals – independent from temper
  • 19.
  • 20.
    Some Rules % everynote must be in the scale #const err nik=„note not in scale". reason(err nik). error(P,T,err nik) :- choosenNote(P,T,N), chromatic(N,C), not key(C). % melodic minor -> last two notes depend on direction of playing error(P,T + 1,err ism) :- choosenNote(P,T + 1,N), chromatic(N,9), upAt(P,T), keyMode(minor). % voices can only meet at one time haveMet(P,T+1) :- choosenNote(P,T,N), choosenNote(P+1,T,N), not haveMet(P,T), part(P+1). haveMet(P,T+1) :- haveMet(P,T). % every note, the next note must be an other (up or down) 1 { stepAt(P,T), leapAt(P,T) } 1 :- T != t. 1 { downAt(P,T), upAt(P,T) } 1 :- T != t. % if melody does a jump, only harmonic intervals are allowed 1 { leapBy(P,T,LS) : leapSize(LS) : LS > 0 } 1 :- leapUp(P,T). % if a voice changes of interval I the next note must be I steps higher/lower choosenNote(P,T + 1,N + L) :- choosenNote(P,T,N), leapAt(P,T), leapBy(P,T,L), note(N + L).
  • 21.
    ANTON • „filling“ ofbars no problem • harmonisation no problem • harmonisation rules (rules may be taken from J.S.Bach Choralgesänge – consistent rules) • ANTON produces diff. formats (i.e. Csound, Lilypond) and open for further ones
  • 22.
    Evaluation musical technical subjective by human ~200 loc for a script (halftone  quartertone ALL libs and so on: ~800 music) loc STRASHEELA (UC Belfast): 8000 loc BOL-Proc.-Script: 88000 loc
  • 23.
    Work on ANTON • better runtime performance (Anton 1.5) • real time composition  improvisation • composing trios and quartets (Anton 1.5) • rhythmic composition (Anton 1.5) • recognizing and using of global structures
  • 24.
    ANTON 1.5 (noyet released) • runtime for generating pieces for 1/2 voice(s) with _length_ notes 0.22 0.33 1.01 1.06 2.27 2.42 4.62 4.01 0.77 1.18 3.73 3.88 16.84 14.50 29.63 82.64 old values
  • 25.
    ANTON 1.5 • runtimefor generating pieces for 3/4 voice(s) with _length_ notes
  • 26.
    Example from ANTON1.5 code-remarks style(quartet). part(1..4). melodicPart(1). lowestPart(4). #const quartetBottomNote=1. #const quartetTopNote=68. % from contra C (lowest + 2 octaves 8vb) to g’’’ (highest + 2 octaves) 4/4 or 6/4 or …?? 0:26
  • 27.
    Verification with lydianchromatic concept – George Russel • method of scale-finding for improvisation • chord  some lydian scale = parent scale • chord  lydian scale from note (b7, b9, -b5, maj = tonic) • visualisation-model of Robert M. Weiß (worked with George Russel) • „travelling“ through quint-circle
  • 28.
    Verification with lydianchromatic concept – George Russel II „A Child Is Born“
  • 29.
    Conclusion / FutureWork - Anton is some kind of composition - not the overall solution - would be useful if it works in realtime Future work: trying to get a verification model through my mathematical visualisation of music in architecture
  • 30.
    Reductio ad absurdum– but good Christmas-Song „Es ist ein Roß entsprungen“  (A) ||: Bbmaj Eb7 | Abmaj F#7b5 | Fm7 Bb7#11 | Ebmaj Abmaj || (B) (A) | Gsus :|| B-7 A-5b13 | E-7 || Bbmaj Eb7 | | Abmaj F#7b5 | Fm7 Bb7#11 | Ebmaj Abmaj | Gsus | | Cmaj || 0:49 - odd count of bars - melody  some chords (arbitrary) - most incorrect cadences - some correct cadences - global structure: AABA
  • 31.
    Quellen [1] Automatic Composition ofMelodic and Harmonic Music by Answer Set Programming, Georg Boenn, Martin Brain, Marina De Vos, John ffitch, Cardiff School of Creative & Cultural Industries University of Glamorgan UK [2] ANTON: Composing Logic and Logic Composing, Georg Boenn, Martin Brain, Marina De Vos, John Ffitch, Cardiff School of Creative & Cultural Industries University of Glamorgan UK [3] Ursprungskunst, Erhard Dinhobl, BSc-Thesis, 2008, TU Wien [4] Persönliche Korrespondenz mit Robert M. Weiss / Lehrgang „Lydian Chromatic Concept“ am Josef M. Hauer Konservatorium Wr. Neustadt [5] Persönliche Korrespondenz mit Michael Brain, Entwickler ANTON [6] Das wohltemperierte Gehirn: Wie Musik im Kopf entsteht und wirkt, Robert Jourdain, Spektrum Verlag, 2001 [7] Neue Jazz-Harmonielehre, Frank Sikora, SCHOTT, 2003 [8] The Lydian Chromatic Concept of Tonal Organisation, George Russel, Concept Publishing Co. New York N.Y, 1953 (2001) [9] Automatic Composition using Anwer Set Programming, Georg Boenn, Martin Brain, Marina de Vos, John Ffitch, University of Glamorgan, UK, 2009 [10] 389 Choralgesänge (für vierstimmigen gemischten Chor), J.S.Bach [11] Knowledge, Representation, Reasoning and Declarative Problem solving, Chitta Baral, University of Cambridge, 2003 [12] Logische Programme und Antwortensemantik II, Prof. Dr. Gabriele Kern-Isberner, Universität Dortmund, 2004 [13] Persönliche Korrespondenz mit Monika Etzelt Feel free to contact me: Erhard Dinhobl / er@master-studios.net