Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
tenor/src/tenor/harmony.clj
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (32 sloc)
1.59 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; tenor/harmony.clj | |
;; Procedures to create harmony from a melody | |
(ns tenor.harmony | |
(:use [overtone.live])) | |
;; --- Construct chords from notes and note positions --- ;; | |
(defn random-chords [position note] | |
"Create a random chord with 'note' as root note." | |
(let [selected-chord (chord (find-note-name note) (rand-nth (keys CHORD)))] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |
(defn major-chords [position note] | |
"Create a major chord with 'note' as root note." | |
(let [selected-chord (chord (find-note-name note) :major)] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |
(defn minor-chords [position note] | |
"Create a minor chord with 'note' as root note." | |
(let [selected-chord (chord (find-note-name note) :minor)] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |
(defn random-chords-octave-down [position note] | |
"Create a random chord with 'note', | |
shifted down by one octave, as root note." | |
(let [selected-chord (chord (find-note-name (- note 12)) (rand-nth (keys CHORD)))] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |
(defn major-chords-octave-down [position note] | |
"Create a major chord with 'note', | |
shifted down by one octave, as root note." | |
(let [selected-chord (chord (find-note-name (- note 12)) :major)] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |
(defn minor-chords-octave-down [position note] | |
"Create a minor chord with 'note', | |
shifted down by one octave, as root note." | |
(let [selected-chord (chord (find-note-name (- note 12)) :minor)] | |
(hash-map :pos position, :note (into [] selected-chord)))) | |