How can I 'roll my own' slippery chicken?

Using make-slippery-chicken, with the attendant palettes, maps, instruments, etc. is not everyone's cup of tea. I've written several pieces myself where, for example, the pitch selection is not done by slippery chicken but by another procedure altogether (e.g. my hyperboles series). Then there are pieces like don't flinch where slippery-chicken events are generated and rendered into MIDI files, but a slippery-chicken object itself is never instantiated.

There are times however when you'd like to generate events on the fly and incorporate them somehow into a slippery-chicken object in order to take advantage of the score-/MIDI-/sound-file writing capabilities of the slippery-chicken class. The following example should get you started with this.

;;              we'll just select random notes from this set
(let* ((chord '(c1 a1 ds2 cs3 g3 d4 f4 bf4 e5 b5 gs6 fs7))
       (chord-len (length chord))
       ;; generate enough 32nd-note events to fill 16 4/4 bars
       (events (loop repeat (* 16 32) collect
                    (make-event (nth (random chord-len) chord) 32)))
       (bars '())
       (ate 0)
  (loop while events do
     (setq bar (make-rthm-seq-bar '((4 4))) ; make an empty bar
           ;; fill the bar with the events we made. This method will stop once
           ;; the bar is full and will return the number of rhythms/events it
           ;; 'ate'.    
           ate (fill-with-rhythms bar events)
           ;; ate should always be 32 but best to check
           events (when ate (nthcdr ate events)))
       ;; we could reverse this after the loop if order was important
       (push bar bars))
  ;; automatically create a slippery-chicken object with the bars we made
  (setq sc (bars-to-sc bars))
  ;; test midi-output
  (midi-play sc)
  ;; test Lilypond output. We could call auto-beam and/or auto-clefs here also
  (lp-display sc)