Score:Markup in Pitch umwandeln

(Weitergeleitet von Markup in Pitch umwandeln)
Zur Navigation springen Zur Suche springen

{{Score:Markup in Pitch umwandeln}}

Diese Funktion wandelt einen Text (String) in eine Tonhöhe (Pitch) um. Dieses Programm stellt die Umkehrung zu Pitch in Markup umwandeln dar.

Anwendung

mymus =
#(define-music-function (txt)(string?)
   (make-music
    'SequentialMusic
    'elements
    (list (make-music
           'NoteEvent
           'duration
           (ly:make-duration 2)
           'pitch
           (string->pitch txt)))))
\relative c { \mymus "dis" \relative c' \mymus "ges" \relative c' \mymus "fisis" \mymus "eisis" }

String2pitch.png

Scheme-Code

#(define (string->pitch txt)
   (let* ((systr (string->symbol txt))
          (erst  (car (string->list txt)))
          (alttab
           `((c . 0) (ces . ,FLAT) (ceses . ,DOUBLE-FLAT)
              (cis . ,SHARP) (cisis . ,DOUBLE-SHARP)
              (des . ,FLAT) (deses . ,DOUBLE-FLAT)
              (d . 0)
              (dis . ,SHARP) (disis . ,DOUBLE-SHARP)
              (es . ,FLAT) (eses . ,DOUBLE-FLAT) (eeses . ,DOUBLE-FLAT)
              (e . 0) (eisis . ,DOUBLE-SHARP)
              (f . 0) (feses . ,DOUBLE-FLAT)
              (fis . ,SHARP) (fisis . ,DOUBLE-SHARP)
              (ges . ,FLAT) (geses . ,DOUBLE-FLAT)
              (g . 0)
              (gis . ,SHARP) (gisis . ,DOUBLE-SHARP)
              (as . ,FLAT) (ases . ,DOUBLE-FLAT) (aeses . ,DOUBLE-FLAT)
              (a . 0) (aes . ,FLAT)
              (ais . ,SHARP) (aisis . ,DOUBLE-SHARP)
              (b . ,FLAT) (heses . ,DOUBLE-FLAT) (bes . ,FLAT) (beses . ,DOUBLE-FLAT)
              (h . 0) (hisis . ,DOUBLE-SHARP) (his . ,SHARP)
              ))
          (pitab '((c . 0) (d . 1) (e . 2) (f . 3) (g . 4)
                    (a . 5) (h . 6) (b . 6)))
          (ton (assoc-get (string->symbol (string erst)) pitab))
          (alt (assoc-get systr alttab)))
     (if ton
         (ly:make-pitch 0 ton alt)
         (ly:make-pitch 0 0 0))))