<?xml version="1.0"?>
<Denemo>
  <merge>
    <title>A Denemo Keymap</title>
    <author>Dan Wilckens, RTS</author>
    <map>
      <row>
        <action>DynamicsDialog</action>
        <scheme>;;;;DynamicsDialog Standalone Dynamics - by Dan Wilckens. Tweaked by RTS
(let ((choice #f)(X 0)  (replace #f) (level "63")(LilyString "")(Graphic "")  (DynamicList "") )
(if (equal? (d-GetType) "LILYDIRECTIVE" ) 
	(if (equal? (d-DirectiveGetTag-standalone) "Dynamic" )
		(set! replace #t )
	)
) 
; format: dynamics, midi volume, image filename
(set! DynamicList '(("fff" "127" "Fortississimo")("ff" "111" "Fortissimo") ("f" "95" "Forte") ("mf" "79" "MezzoForte")("mp" "63" "MezzoPiano") ("p" "47" "Piano") ("pp" "31" "Pianissimo") ("ppp" "15" "Pianississimo") ("More" "60" "") ("ppppp" "5" "ppppp")("pppp" "7" "pppp")("ffff" "127" "ffff") ("fp" "" "fp")
   ("sf" "" "sf") ("sff" "" "sff") ("sp" "" "sp" ) ("spp" "" "spp") ("sfz" "" "sfz") ("rfz" "" "rfz") ("Custom" "" "")))
(set! choice (d-GetOption (string-append "fff" stop "ff" stop "f" stop "mf" stop "mp" stop "p" stop "pp" stop "ppp" stop "More" stop )))

(if (equal? choice "More") 
   (set! choice (d-GetOption (string-append "ppppp" stop "pppp" stop  "ffff" stop "fp" stop "sf" stop  "sff" stop "sp"  stop "spp" stop "sfz" stop "rfz" stop "Custom" stop ) )) )
   (set! LilyString (string-append "s8*0 \\" choice  ))
(set! X (assoc choice DynamicList) )
(set! level (car (cdr X)) )
(set! Graphic (car (cdr (cdr X) ) ) )
(if (equal? choice "Custom" ) (begin 
   	(set! choice (d-GetUserInput "Custom dynamic" "Enter dynamic text:" "" ) ) 
        (set! LilyString (string-append  "s8*0_\\markup  \\bold \\italic { " choice " } " ))	
   	)
)
(if (equal? level "") 
  (begin
   (set! level (d-GetUserInput "Dynamic setting" "Enter loudness level (0-127):" "63" ) ) 
   (let ( (a 0)) 
      (set! a (string-&gt;number level) )
      (if (or (boolean? a) (&gt; a 127) (&lt; a 0) )(set! level #f) )
   )
  )
)
( if (not (boolean? choice) )
    (begin 
    	( if (equal? replace #f ) (d-DirectivePut-standalone "Dynamic" ) )
	(d-DirectivePut-standalone-postfix "Dynamic"  LilyString)
	(if (equal? Graphic "") 
	   (begin
		(d-DirectivePut-standalone-display  "Dynamic" choice)
		(d-DirectivePut-standalone-ty "Dynamic" 70 )
		(d-DirectivePut-standalone-graphic "Dynamic" "")
	   )
	   (begin
	   	(d-DirectivePut-standalone-graphic "Dynamic" Graphic)
	   	(d-DirectivePut-standalone-gy "Dynamic" 70 )
	   	(d-DirectivePut-standalone-gx "Dynamic" 5 )
		(d-DirectivePut-standalone-display  "Dynamic" "&#x25C6;")
		(d-DirectivePut-standalone-ty "Dynamic" 60 )
	   )
	)
        (if (not (boolean? level) ) 
           (begin	(d-DirectivePut-standalone-override "Dynamic" (logior DENEMO_OVERRIDE_STEP DENEMO_OVERRIDE_VOLUME))
	      (d-DirectivePut-standalone-midibytes "Dynamic" level ) ) 
	)
	(d-DirectivePut-standalone-minpixels "Dynamic" 10 )
	(d-RefreshDisplay)
	(d-MoveCursorRight)
    )
 )
 )</scheme>
        <label>Dynamics</label>
        <tooltip>Choose dynamics and midi volume level.</tooltip>
      </row>
    </map>
  </merge>
</Denemo>
