]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/drums.scm
*** empty log message ***
[lilypond.git] / scm / drums.scm
index 9162e6821fe9457b1f43e2f5687c9db23cce033b..b6beb241b52eeb99868131e5033031a5a2421fb1 100644 (file)
@@ -3,6 +3,8 @@
 
 ;;;; changed eval to primitive-eval for guile 1.4/1.4.1 compatibility --jcn
 
+;; TODO: the design of this hack should be rethought.
+
 
 ;; ugh. Should make separate module?
 (define-public drum-pitch-names `(
        (fivedown         de    ,(ly:make-pitch -1 2 0))
 ))
 
-(define-public drums `(
-       (acousticbassdrum default       #f        ,(ly:make-pitch -1 4 0))
+;;
+;; all settings for percussive instruments.
+;; public so people can add their own stuff.
+;;
+
+(define-public
+  percussive-instrument-init-settings
+  `((drums
+    . (
+       (acousticbassdrum default       #f        ,(ly:make-pitch -1 4 0))
        (bassdrum         default       #f        ,(ly:make-pitch -1 4 0))
        (sidestick        cross         #f        ,(ly:make-pitch 0 1 0))
        (acousticsnare    default       #f        ,(ly:make-pitch 0 1 0))
        (crashcymbalb     cross         #f        ,(ly:make-pitch 0 5 0))
        (vibraslap        diamond       #f        ,(ly:make-pitch 0 4 0))
        (ridecymbalb      cross         #f        ,(ly:make-pitch 0 5 0))
- ))
     ))
 
-(define-public timbales `(
+  (timbales
+   . (
        (losidestick      cross         #f        ,(ly:make-pitch -1 6 0))
        (lotimbale        default       #f        ,(ly:make-pitch -1 6 0))
        (cowbell          triangle      #f        ,(ly:make-pitch 0 2 0))
        (hisidestick      cross         #f        ,(ly:make-pitch 0 1 0))
        (hitimbale        default       #f        ,(ly:make-pitch 0 1 0))
- ))
     ))
 
-(define-public congas `(
+  (congas
+   . (
        (losidestick      cross         #f        ,(ly:make-pitch -1 6 0))
        (loconga          default       #f        ,(ly:make-pitch -1 6 0))
        (openloconga      default       "open"    ,(ly:make-pitch -1 6 0))
        (hisidestick      cross         #f        ,(ly:make-pitch 0 1 0))
        (hiconga          default       #f        ,(ly:make-pitch 0 1 0))
        (openhiconga      default       "open"    ,(ly:make-pitch 0 1 0))
-        (mutehiconga      default       "stopped" ,(ly:make-pitch 0 1 0))
-  
- ))
+       (mutehiconga      default       "stopped" ,(ly:make-pitch 0 1 0))
+      ))
 
-(define-public bongos `(
-       (losidestick      cross         #f        ,(ly:make-pitch -1 6 0))
+  (bongos
+    . (
+       (losidestick      cross         #f        ,(ly:make-pitch -1 6 0))
        (lobongo          default       #f        ,(ly:make-pitch -1 6 0))
        (openlobongo      default       "open"    ,(ly:make-pitch -1 6 0))
        (mutelobongo      default       "stopped" ,(ly:make-pitch -1 6 0))
        (hibongo          default       #f        ,(ly:make-pitch 0 1 0))
        (openhibongo      default       "open"    ,(ly:make-pitch 0 1 0))
        (mutehibongo      default       "stopped" ,(ly:make-pitch 0 1 0))
- ))
     ))
 
 
-(define-public percussion `(
+  (percussion
+   . (
        (opentriangle     cross         "open"    ,(ly:make-pitch 0 0 0))
        (mutetriangle     cross         "stopped" ,(ly:make-pitch 0 0 0))
        (triangle         cross         #f        ,(ly:make-pitch 0 0 0))
        (cabasa           cross         #f        ,(ly:make-pitch 0 0 0))
        (maracas          default       #f        ,(ly:make-pitch 0 0 0))
        (handclap         default       #f        ,(ly:make-pitch 0 0 0))
- ))
+      ))
+  ))
+
+
+(define percussive-instrument-settings percussive-instrument-init-settings)
+
+;; don't use assoc-set!, since this will overwrite Scheme defaults, and leak
+;; into other files.
+(define-public (set-drum-kit kit value)
+  (set! percussive-instrument-settings
+       (acons kit value  percussive-instrument-settings)))
+
+(define-public (reset-drum-kit)
+  (set! percussive-instrument-settings percussive-instrument-init-settings))
+
+(define-public (get-drum-kit kit)
+  (assoc-get-default kit percussive-instrument-settings '()))
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
  )
 
 (define (make-head-type-elem t)
-   (let* ( (m (make-music-by-name 'Music)))
+   (let* ( (m (make-music-by-name 'OverrideProperty)))
      (set-mus-properties!
       m
-      `((iterator-ctor . ,Push_property_iterator::constructor)
-       (symbol . NoteHead)
+      `((symbol . NoteHead)
        (grob-property . style)
        (grob-value . ,t)
        (pop-first  . #t)))
  )
 
 (define (make-head-type t)
-  (context-spec-music (make-head-type-elem t) "Thread"))
+  (context-spec-music (make-head-type-elem t) 'Thread))
 
 (define (make-thread-context thread-name element)
-  (context-spec-music element "Thread" thread-name))
+  (context-spec-music element 'Thread thread-name))
 
 ;; makes a sequential-music of thread-context, head-change and note
 (define (make-drum-head kit req-ch )
              )
          (add-articulation-script req-ch script)
          (ly:set-mus-property! fe 'pitch pitch)
-         (set! req-ch (make-thread-context style seq))
+         (set! req-ch (make-thread-context (symbol->string style) seq))
         req-ch
        )
       )
              (begin
               (display p) ;; UGH. FIXME. pitch->string ???
               (ly:warn " unknown drumpitch.")
-              (cdar (primitive-eval kit))
+              (cdar (get-drum-kit kit))
           ))
          ((eq? p (caddr (car pitches))) ((name->paper kit) (caar pitches)) )
         (else                          (p2p (cdr pitches) ) )
      )
    )
  )
+
 (define ((name->paper kit) n)
-   (let n2p ((pitches (primitive-eval kit)))
+   (let n2p ((pitches (get-drum-kit kit)))
      (cond ((eq? pitches '())
              (begin
               (ly:warn (string-append "Kit `" (symbol->string kit) "' doesn't contain drum `" n
                                       "'\nSee ly/drumpitch-init.ly for supported drums."))
-              (cdar (primitive-eval kit))
+              (cdar (get-drum-kit kit))
             ))
            ((eq? n (caar pitches))  (cdar pitches) )
           (else                    (n2p (cdr pitches) ) )
    )
  )
 
-
+;;
 ;; converts a midi-pitched (ly/drumpitch.ly) file to paper output.
+;;
 (define-public ((drums->paper kit) music)
   (begin
    (if (equal? (ly:get-mus-property music 'name) 'EventChord)
           (ly:set-mus-property!
            music 'element
            ((drums->paper kit) e))
-        )
-      )
-    )
-   )
+        ))))
    music
-  )
- )
+  ))
+
+