Clojure Artificial Intelligence music
Need help with musical-creativity?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


Models of Musical Creativity (in Clojure)

126 Stars 6 Forks 644 Commits 0 Opened issues

Services available

Need anything else?

Computer models of musical creativity

Experiments with models for computers generating music.


(require '[musical-creativity.musician :as musician] :reload)
(use '[musical-creativity.instruments] :reload)

;Cosine (require '[musical-creativity.composers.cosine :as cosine] :reload) (musician/play (cosine/compose) piano)

;Cellular automata (require '[musical-creativity.composers.cellular-automata :as ca] :reload) (musician/play (ca/compose) organ) (musician/play (ca/compose ca/rule-22) sawish)

;Sonify data (require '[musical-creativity.composers.sonify-data :as sonify-data] :reload) (musician/play (sonify-data/compose) piano)

;Sonify text (require '[musical-creativity.composers.sonify-words :as sonify-words] :reload) (musician/play (sonify-words/compose "Strange Loop Strange Loop") piano) (musician/play (sonify-words/compose "potato potato") ping)

;Network (Using adaptive resonance theory) (require '[ :as network] :reload) (musician/play (network/compose) piano)

;Markov chains (require '[musical-creativity.composers.markov :as markov] :reload) (musician/play (markov/compose) piano) (musician/play (markov/compose) ping)

(musician/play (markov/compose data.bach/bach1 [57 60 69] 1 50) piano)

;with phrase mapping (musician/play (markov/compose data.bach/bach1 [57] 16 (* 5 16)) piano)

;with naive voice extraction and phrase mapping (require '[musical-creativity.analyzer :as analyzer] :reload) ; first extracted voice only and phrase mapping (musician/play (markov/compose (first (-> data.bach/bach1 analyzer/group-by-time analyzer/extract-voices-min-distance)) [57] 16 (* 16 5)) piano) ; all voices added to model separately and phrase mapping (musician/play (markov/compose (flatten (-> data.bach/bach1 analyzer/group-by-time analyzer/extract-voices-min-distance)) [57] 16 (* 16 5)) piano)

;multiple markov models (let [lead-voice 1 standard-prep #(-> % analyzer/group-by-time analyzer/extract-voices-min-distance) dur-prep #(->> % analyzer/group-by-time analyzer/extract-durations (map (fn [d] {:duration d})) vector)] (markov/compose-multi-model data.bach/bach1 50 :pitch (markov/transition-source standard-prep 1 8 1 lead-voice) :voices (markov/transition-source #(-> % analyzer/group-by-time vector) 1 4 1 0) :harmonics (markov/harmonic-source standard-prep lead-voice [0 2 3]) :duration (markov/transition-source dur-prep 1 4 4 :all) :velocity (markov/constant-source 128)))

;Fuzzy (require '[musical-creativity.composers.fuzzy :as fuzzy] :reload) (musician/play (fuzzy/compose) piano)

;Improvise ;(very experimental) (require '[musical-creativity.composers.improvise :as improvise] :reload) (musician/play (improvise/compose) piano)

(require '[ :as band] :reload) (band/play (improvise/compose))

;Recombinance (Based on Bach Choral no. 140) (require '[musical-creativity.composers.recombinance :as recombinance] :reload) (require '[data.bach :as bach] :reload) (recombinance/create-database-from bach/chorale-140-data) (musician/play (recombinance/compose) organ) (musician/play (recombinance/compose) piano) (musician/play (recombinance/compose) slow-piano)

(musician/play (recombinance/compose-original) piano)

;Gradus (with each run Gradus learns how to better compose) (require '[musical-creativity.composers.gradus :as gradus] :reload)

(musician/play (gradus/compose) piano)

(musician/play (gradus/compose-canon) piano)

(musician/play (gradus/compose-canon data.gradus/cantus-firmus-1) piano) (musician/play (gradus/compose-canon data.gradus/cantus-firmus-2) piano) (musician/play (gradus/compose-canon data.gradus/cantus-firmus-7) piano)

(musician/play (gradus/compose-contemporary) piano)

Association Network (Apprentice)

(require '[musical-creativity.composers.apprentice :as apprentice] :reload)
(require '[musical-creativity.composers.apprentice.player :refer :all] :reload)

(apprentice/apprentice play-all)

An example musical conversion:

user> ceg!
user> gbd?
alice> ceg!
user> ceg fac gbd?
alice> fac ceg ceg!
user> ceg fac gbd ceg!
alice> gbd?
user> ceg!
alice> gbd?
user> gbd?
alice> ceg!



A non musical dialog example:

user> hello!
Alice> your what your is name?
user> my name is joseph!
Alice> name?
user> your name is computer!
Alice> name?
user> what is my name?
Alice> joseph!
user> what is your name?
Alice> computer!
user> no*
user> what is your name?
Alice> joseph!


(musical-creativity.musician/play (map data.bach.chorale-140/b11606b) piano)

(require '[musical-creativity.composers.recombinance :as recombinance] :reload) (require '[data.bach :as bach] :reload) (recombinance/create-database-from bach/chorale-140-data)

(musical-creativity.musician/play (map ('b11606b-22 @beats-store)))


Based on exercises from:

Computer Models of Musical Creativity

Computer Models of Musical Creativity

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.