<?xml version="1.0"?>
<Denemo>
  <merge>
    <title>A Denemo Keymap</title>
    <author>AT, JRR, RTS</author>
    <map>
      <row>
        <action>StepSkipOrSame</action>
        <scheme>;;;;;;;;;;;;;;;
		;;StepSkipOrSame
;; tests if the note goes higher or lower.
(let (
      (shiftup 0)
      (shiftdown 0)
      (runtest 0)
      (PlaceAnswerStatus 0)
      (userinput #t)
      (stepstring #t)
      (score 0)
      (steps 0)
      (starttime 0)
      (endtime 0)
      (direction 0)
      (span 3) ;; how many steps of the scale to test.
      (num-goes 10) ;; how many notes to present for the whole test
      )
  ;; set the random seed up using time of day
  (let ((time (gettimeofday)))
    (set! *random-state*
	  (seed-&gt;random-state (+ (car time)
				 (cdr time)))))
  (set! shiftup
	(lambda (n)
	  (if (&gt; n 0) (begin
			(d-CursorUp)
			(shiftup (- n 1))))))

  (set! shiftdown
	(lambda (n)
	  (if (&gt; n 0) (begin
			(d-CursorDown)
			(shiftdown (- n 1))))))
  (set! PlaceAnswerStatus
  	(lambda (name gfx)
	  (begin
	    (d-DirectivePut-note-minpixels name 30)
	    (d-DirectivePut-note-gx name -15)
	    (d-DirectivePut-note-gy name 10)
	    (d-DirectivePut-note-graphic name gfx))))
 
;;;;;;;; the main function to run the test
  (set! runtest 
	(lambda (n)
	  (if (&gt; n 0) (begin
			(set! steps (random span))
			(set! direction (random 2))
			
			;;(d-InsertLilyDirective "directive=%Your score so far: ")
			(d-DirectivePut-score-display "StepSkipOrSame" (string-append (string-append  "Score: " (object-&gt;string score)) ". Is this note going up or down?"))
			(if (= direction 0)
			    (begin
			      (shiftdown steps)
                              (d-Insert2)))
                         (if (= direction 1)
                            (begin
			      (shiftup steps)
                              (d-Insert2)))
			     
			(if (= steps 0)
			    (begin
				(set! stepstring "a")))
                        (if (= steps 1)
			    (begin
			 	(set! stepstring "t")))
			(if (= steps 2)
			    (begin
				(set! stepstring "k")))

			(set! userinput  (d-GetChar))

			(if (string? userinput)
			    (begin
			      ;;(d-DeletePreviousObject)
			      (if  (string=? stepstring  userinput)
				   (begin
				     (set! score (+ score 1))
  				     (PlaceAnswerStatus "NoteCorrect" "CheckMark")
				     (d-ChangeNotehead "Diamond"))
				   (begin
				     (set! score (- score 1))
				     (PlaceAnswerStatus "NoteWrong" "CrossSign")
				     (d-ChangeNotehead "Cross"))) 		 
			      (runtest (- n 1))))))))

  (d-PlayMidiKey #xF03001)
  (d-PlayMidiKey #xF02A01)
  (d-PlayMidiKey #xF04001)
  (set! num-goes (d-GetUserInput "Reading Test - Instructions" "For each note, hit *t* if the note is moving by step, *k* for a skip, and *a* if the note stays the same.\nHow many goes do you want?" "8"))
  ;(set! num-goes "8")
  (set! starttime (car (gettimeofday)))
  (d-NewWindow)
  (set! num-goes (string-&gt;number num-goes))
  (if (not (integer? num-goes))
      (set! num-goes 10))
  (shiftup 6)
  (d-Insert2)
  (runtest num-goes)
  (d-DirectivePut-score-display  "StepSkipOrSame"  (string-append  "Final Score: " (object-&gt;string score)))
  (set! endtime (car (gettimeofday))) 
  (display (- endtime starttime))
  (d-RefreshDisplay)
  (d-PlayMidiKey #xF03001)
  (d-PlayMidiKey #xF02A01)
  (d-PlayMidiKey #xF04001)
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;

</scheme>
        <label>Beginner Interval Detection</label>
        <tooltip>%tests your ability to determine if note is moving by a step or skip</tooltip>
      </row>
    </map>
  </merge>
</Denemo>
