;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; helper:mplayp_play_list_v2
;
; helper used by :steps playpattern function
; modified from the original from Andrew's implementation
; but the channel is taken as 1-based (hence -1 from what is passed)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define helper:mplayp_play_list_v2
(let ((lst_idx (range 0 1000)))
(lambda (beat dur pclas inst vols durs channel lst mod_diff step offset poffset args)
(let ((duration 0) (volume 0)
(phase 0))
(for-each (lambda (x idx t)
(if (symbol? x) (set! x (eval x)))
(if (list? durs)
(if (and (symbol? (car durs))
(defined? (car durs))
(or (closure? (eval (car durs)))
(procedure? (eval (car durs)))
(macro? (eval (car durs)))))
(set! duration durs)
(if (= (length durs) (length lst))
(set! duration (list-ref durs idx))
(set! duration step)))
(set! duration durs))
(if (list? vols)
(if (and (symbol? (car vols))
(defined? (car vols))
(or (closure? (eval (car vols)))
(procedure? (eval (car vols)))
(macro? (eval (car vols)))))
(set! volume vols)
(if (= (length vols) (length lst))
(set! volume (list-ref vols idx))
(set! volume 80)))
(set! volume vols))
(if (list? x)
(helper:mplayp_play_list_v2 beat dur pclas inst volume
duration channel x mod_diff (/ step (length lst)) (+ t offset) poffset args)
(if (> x 0)
(begin
(set! phase (+ mod_diff t offset))
(eval
`(mplay ,phase ;(+ mod_diff t offset)
,inst
,(pc:quantize (+ x poffset) pclas)
,volume
,duration
,(- channel 1) ;; NEW
,@args))))))
lst
lst_idx
(range 0 step (/ step (length lst))))))))