<?xml version="1.0"?>
<Denemo>
  <merge>
    <title>A Denemo Keymap</title>
    <author>AT, JRR, RTS</author>
    <map>
      <row>
        <action>CheckPitches</action>
        <scheme>;;;;;;;;;;
;;;CheckPitches
(d-Note)
(d-EditMode)
(if (not (defined? 'CheckPitches::Active))
    (define CheckPitches::Active #f))
(if CheckPitches::Active
    (begin
      (d-PutMidi 0)
      (set! CheckPitches::Active #f))
;;; not active
    (let (
	  (midi 0)
	  (command 0)
	  (note 0)
	  (velocity 0)
	  (loop 0))
      (begin
	(set! CheckPitches::Active #t)
	(d-PlayMidiKey #x202001)
	(d-PlayMidiKey #x202601)
	(d-PlayMidiKey #x202201)
        (d-InputFilterNames "Check Pitches Filter")	
	(set! loop  (lambda ()
			(begin
			  (set! midi (d-GetMidi))
			  (set! velocity (bit-extract midi 16 24))
			  (set! note (bit-extract midi 8 16))
			  (set! command (bit-extract midi 0 8))
                          (if (= command #x80)
				(loop))
			  (if  (= command #x90);; only check on channel 0
			       (begin 				 
				(d-PlayMidiKey midi)
				 
				       (if (= (d-GetNoteAsMidi) note)
				       (begin (d-NextNote)(d-RefreshDisplay))
				       (begin (d-PlayMidiKey #xF06001))
				       )
				       (loop))))))
	(loop))))

(display "End of script")
</scheme>
        <label>Check Note Pitches</label>
        <tooltip>Compares note from MIDI with current note, if equal in pitch, advances to next note, else beeps.</tooltip>
      </row>
    </map>
  </merge>
</Denemo>
