-(define dynamic-default-volume 0.71)
-
-;; Count number of sharps minus number of flats
-(define (accidentals-in-key pitch-list)
- (apply + (map cdr pitch-list)))
-
-;; Characterise the key as major if the alteration of the
-;; third scale note is the same as that of the main note.
-;; Note: MIDI cannot handle other tonalities than major/minor.
-(define (major-key pitch-list)
- ;; This charactersition is only true for a scale that starts at `c'.
- (if (not (equal? (car pitch-list) '(0 . 0)))
- (begin
- (ly-warn "Attempt to determine tonality of transposed scale")
- #t)
- (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6)))))
+(define-public dynamic-default-volume 0.71)
+
+(define-public (alterations-in-key pitch-list)
+ "Count number of sharps minus number of flats"
+
+ (* (apply + (map cdr pitch-list)) 2))
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+
+(define-public (write-performances-midis performances basename)
+ (let
+ loop
+ ((perfs performances)
+ (count 0))
+
+
+ (if (pair? perfs)
+ (begin
+ (ly:performance-write
+ (car perfs)
+ (if (> count 0)
+ (format #f "~a-~a.midi" basename count)
+ (format #f "~a.midi" basename)))
+ (loop (cdr perfs) (1+ count))))))