;DeleteMidiAndClickTrack
(let ((pos (GetPosition)))
	(define (remove-trailing-blanks)
		(define (remove-one)
			(if (and (EmptyMeasure?) (> (d-GetMeasuresInStaff) 1))
				(begin
					(while (and (d-MoveToStaffDown)
							(EmptyMeasure?)))
					(if (EmptyMeasure?)
						(or (d-DeleteMeasureAllStaffs) #t)
						#f))
				#f))
		(let loop ()
			(while (d-MoveToStaffUp))
			(d-MoveToEnd)
			(if (remove-one)
				(loop))))	
	(d-DeleteImportedMidi)
	(while (d-MoveToStaffUp))
	(if (equal? DenemoClickTrack (d-StaffProperties "query=denemo_name"))
		(begin
			(d-DeleteStaff)
			(d-StaffSetSpaceAbove 20)))
			(remove-trailing-blanks)
			(d-GoToPosition #f (- (list-ref pos 1) 1) (list-ref pos 2) (list-ref pos 3)))
