changeset 329:f54848e1f74c

Flag use of cents; define diatonic-pitch correctly for cents
author Jeremy Gow <jeremy.gow@gmail.com>
date Mon, 19 Nov 2012 15:11:49 +0000
parents 04940d80aaed
children 2fbff655ba47
files implementations/mtp/methods.lisp
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/implementations/mtp/methods.lisp	Thu Nov 08 09:21:00 2012 +0000
+++ b/implementations/mtp/methods.lisp	Mon Nov 19 15:11:49 2012 +0000
@@ -1,5 +1,9 @@
 (cl:in-package #:amuse-mtp)
 
+;;; Are we using cents to represent chromatc pitch, or MIDI values?
+;;; A hack to allow backwards compatibility with old MIDI value databases.
+(defvar *cpitch-cents* t)
+
 ;;; Compositions 
 
 #.(clsql:locally-enable-sql-reader-syntax)
@@ -278,7 +282,9 @@
 
 (defmethod diatonic-pitch-cp ((e mtp-event))
   ;; MIPS morphetic pitch is relative to An0 while cpitch is relative to Cn2
-  (- (%mtp-cpitch e) 21))
+  ;; Make sure MIDI value is used
+  (- (if  *cpitch-cents* (/ (%mtp-cpitch e) 100) (%mtp-cpitch e))
+     21))
 
 (defmethod diatonic-pitch-mp ((e mtp-event))
   ;; MIPS morphetic pitch is relative to An0 while mpitch is relative to Cn2