       (time-signature 0 sig))
     :else sig))
 
+;; --- Beats --- ;;;
+
 (defn segment-beat [note-count note-value
                     & {:keys [sparseness]
                        :or {sparseness 1}}]
+  "Break a beat down into sixteenth-note positions and
+  assign notes and rests to each position by iteration."
   (let [sixteenth-count (* (/ 16 note-value) note-count)
         notes (range 1 (inc sixteenth-count))
         distribution (cons true (repeat sparseness false))]

      (fn [x] (or (= 1 x) (rand-nth distribution)))
      notes)))

(defn segment-measure [measure
                       & {:keys [running-count result note-value sparseness]
                          :or {running-count 0 result '()
                               note-value 16 sparseness 1}}]
  (if (empty? measure)
    result
    (let [result (concat result (map #(+ running-count %)

;; tenor/constructs.clj
;; Primitive components of music theory.

(ns tenor.constructs
  (:use [overtone.live]))


;; --- Notes --- ;;

(defn make-note [notation]
  "Take pitch letter + octave notation
  and generate an overtone note keyword."
  (let [notation-re #"^([A-G])([#b]?)([1-9])$"
        components (re-matches notation-re notation)]
    (if components
      (keyword (reduce str (rest components)))
      (throw (Exception. "Invalid notation")))))

;; --- Time Signature --- ;;

(defn time-signature [note-count & [sig]]
  "Decompose a measure into randomly spaced out beats,
  within the time signature's note count."
  (cond
    (> note-count 3)
    (let [beat (rand-nth [2 3 4])
