                        :note-value note-value
                        :sparseness sparseness))))
 
-(defn string-measures [measures note-count
+(defn string-measures [measures beat-count
                        & {:keys [running-string running-count]
                           :or {running-string '() running-count 0}}]
   "String multiple measures together into a single piece."

  and musical notes as values."
  (map #(hash-map :pos %1, :note %2) entity intervals))

(defn generate-piece [measure-count note-count note-value sparseness]
  "Generate a musical piece with measure-count measures,
  each of time signature with note-count and note-value."
  (let [time-sig (time-signature note-count)
        segmented (segment-measure time-sig note-value sparseness)
        piece (repeat measure-count segmented)]
    (string-measures piece note-count)))

(defn generate-entity-map [construct-melody measure-count note-count
                            & {:keys [note-value sparseness scale]
                               :or {note-value 16
                                    sparseness 1
                                    scale (generate-random-scale)}}]
  "Take a function to construct a melody, measure count, note count and note value,
  and generate a measure map of the melody and rhythm using map-entity."
  (let [piece (generate-piece measure-count note-count note-value sparseness)
        scale-intervals (intervals->notes
                          (generate-intervals construct-melody scale (count piece)) scale)]
  (map-entity piece scale-intervals)))

    (let [running-string (concat
                           running-string
                           (map #(+ running-count %) (first measures)))
          running-count (+ running-count beat-count)]
      (string-measures (rest measures)
                       beat-count
                       :running-string running-string
                       :running-count running-count))))

