no title pasted by anonymous on Wed May 15 20:43:08 2019

(mdalconfig
 version: 2 target: 'spectrum48
 description: "A simple 2 channel pin pulse (PFM) engine in less than 100 bytes.
 By Shiru 2011, 2013."

 commands: (list (command id: 'BPM bits: 16 type: 'uint default: 140)
		 (command id: 'NOTE bits: 0 type: 'ukey
			  tags: '(enable_modifiers use_last_set is_note)
			  map: (make-dividers 118 8 0 -4)
			  default: "rest")
		 (command id: 'DRUM type: 'trigger 'default: #f description:
			  "Trigger a click drum. Replaces note on channel 1."))

 input: (list (ifield from: 'BPM)
	      (igroup id: 'PATTERNS flags: '(ordered)
		      nodes: ((iblock id: 'DRUMS
				      nodes: (list (ifield from: 'DRUM)))
			      (clone 2
				     (block id: 'CH
					    nodes: (list (ifield from:
								 'NOTE)))))))

 output: (list (comment "sequence")
	       (field bytes: 2 compose: (/ 1779661 (? 'BPM)))
	       (field bytes: 2 compose: (- (sym sequence_end) 8))
	       (order from: (out 'PATTERNS)
		      layout: 'matrix base-index: 1)
	       (group id: 'PATTERNS 'from: '(PATTERNS) resize: 8
		      flags: '(numeric_order)
		      nodes:
		      (list (oblock from: '(CH1, DRUMS)
				    nodes:
				    (list (ofield bytes: 1
						  compose:
						  (if (is-set? 'DRUM)
						      #x2c (? 'NOTE1)))))
			    (block from: '(CH2)
				   nodes:
				   (list (ofield bytes: 1
						 compose: (? 'NOTE2))))))))

Example of using apply to manage data from a file added by Kooda on Wed May 15 21:03:33 2019

(define (mdalconfig-proc #!key version target (description "a default description") commands input output)
  (unless (= version 2)
    (error "Version is wrong"))
  (print "target is: " target)
  (print description)
  #;(do-whatever commands input output))

(define data (with-input-from-file "data" read))

;; You can replace this if with a hash-table lookup
;; if you have multiple commands, for example.
(if (and (pair? data)
         (eqv? (car data) 'mdalconfig))
    ;; this is where the magic happens
    (apply mdalconfig-proc (cdr data))
    (error "unknown configuration command"))