#| Copyright Tom Collins 10/10/2014.

Script for converting a kern representation of a piece
into point-set and MIDI versions. |#

#| Set some paths. |#
(setq
 *music-data-root*
 (make-pathname
  :directory
  '(:absolute
     "Users" "tomthecollins" "Shizz" "Documents"
     "Homepage" "research" "data")))
(setq
 *path&name*
 (merge-pathnames
  (make-pathname
   :directory
   '(:relative
     "gibbons_orlando" "the_silver_swanne_20141010"))
  *music-data-root*))

(setq *piece-name* "silverswan")

(setq
 kern-source
 (merge-pathnames
  (make-pathname
   :name *piece-name* :type "krn") *path&name*))
(setq
 csv-destination
 (merge-pathnames
  (make-pathname
   :name *piece-name* :type "csv") *path&name*))
(setq
 MIDI-destination
 (merge-pathnames
  (make-pathname
   :name *piece-name* :type "mid") *path&name*))
(setq
 dataset-destination
 (merge-pathnames
  (make-pathname
   :name *piece-name* :type "txt") *path&name*))

(progn
  (setq *scale* 1000 #| Was ??? for tempo ???. |#)
  (setq *channel* "use channel")
  (setq
   dataset
   (kern-transp-file2dataset-by-col kern-source))
  "Yes!"
  (saveit
   MIDI-destination
   (modify-to-check-dataset
    (mapcar
     #'(lambda (x)
         (append
          (list
           (- (first x) (first (first dataset))))
          (rest x))) dataset) *scale* *channel*))
  (write-to-file dataset dataset-destination)
  (dataset2csv dataset-destination csv-destination))
