I’m having weirdness with sc-force-rest2, which throws the error above when I call it from this loop
(loop ;;get instruments for ins in '(p1 p2 p3 p4 p5) ;;different numbers of cycles over activity curve for each part for cycles in '(1 2 13 2 15) ;;get total notes for scaling activity curve for notes = (total-notes (get-data ins (ensemble opus))) do (next-event opus ins t 1);start slurping events (loop for ne = (next-event opus ins t) for i from 1 ;;scaled activity envelope with activity = (make-ale (genal) (floor notes cycles)) while ne do (when (not (active activity)) (sc-force-rest2 opus (bar-num ne) (bar-pos ne) ins)))))
Backtrace:
0: ((:METHOD GET-NTH-EVENT (T RTHM-SEQ-BAR)) -1 ..) [fast-method]
1: ((:METHOD SC-FORCE-REST2 (SLIPPERY-CHICKEN T T T)) ..) [fast-method]
It’s happy enough if I just (force-rest) on the event, btw.
Looks like your (bar-pos ne) hasn’t been initialised correctly. If I do (make-rthm-seq-bar ‘((2 4) q e e)) I can see that the bar-pos slot of the rhythm objects is correct. How about yours (look at a random bar via (get-bar …)? If they’re all -1 does (update-slots +opus+) help?
(let ((b (get-bar +opus+ 2 'p1)))
(loop for i from 0 below (sclist-length b)
do (print (bar-pos (get-nth-event i b)))))
Yields
0
1
2
3
4
5
(It also says caught WARNING: undefined variable: +OPUS+ (when I run this from REPL after building the piece), so I’ve still got something to learn about how global vars are bound…)
Ah, we both should have spotted this: doc to sc-force-rest2: – The event number in the bar (integer, counting from 1)
So you’ll need (1+ (bar-pos ne))
re. warning: that’s just SBCL being paranoid. I’d ignore it in the repl but in your code you can always write (declare (special +whatever+)) at the beginning of a defun or even (proclaim ‘(special …)) at the top of a file which might reference a global in several funs.
Bingo, cheers.