Homer Drums

I said I started with the Omg/Moog track, but actually, I already had the homer drums track in mind. The code on the right is EXACTLY Chris's homework 5 scheme code, the non random/quantized version, with only one modification: using the "drummer" patch from STK instead of what was originally there. The midi file is a bassline, but I liked what it did with the drum patch. I simply generated a wave file using Anjuta/Snd and imported that wave file into Ardour. This is the file that determined the tempo of the song (115 bpm).

I actually used two tracks of this. I used the original track, and then I ran that through the aarontrack.pd patch, taking that output to another channel in Ardour. I then faded that channel up from zero at the beginning of the song, and edited them seperately (so that there are some points where there is only the original), and eventually mixed the two together to create one final "homer drums" track.

Homework Five Scheme Example

;; demo of reading in one track of a midi file and sending to Stk patch
;; users need to edit the "cd ~/220a/scm/stk" lines in shell calls below
;; if that's not a directory that they have

(load "/user/c/cc/220a/scm/stk/stk.scm")

;; import events from a .midi file into a CM seq
(define mid (import-events "/user/c/cc/220a/scm/stk/midi/nitefunk.mid"))

;; procedure to extract notes track-by-track from a CM seq
;; seq object -s- should contain seq subobjects, pulled in by track num -tn-
(define (get-track-data s tn) (let ((events '())) 
				(map-subobjects (lambda (x) (push x events)) (list-ref s tn))
				(reverse events)))

;; define an stk instrument and its note parameters
(define (my-stk n d k a)
  (let* ((p 'Drummer) (mytag (tag-me)))
					;  (output (new-event p :type 'ctrl :time n :tag mytag :num 16 :val 1))
    (output (new-event p :type 'on :time n :tag mytag :num k :val a))
    (sprout (new-event p :type 'off  :time (+ n d) :tag mytag :num k :val a ))

(define (stk-ify midi-list tempo)
  (process for i in midi-list
           when (equal? (object-name i) 'midi)
	   do ; construct an stk note from a midi event
	    (* (object-time i) tempo)
	    (* (midi-duration i) tempo)
	    (midi-keynum i) 
	    (* (midi-amplitude i) 127)

(events (list 
;	 (stk-ify (get-track-data mid 1) 1) ; clavinet
	 (stk-ify (get-track-data mid 2) 1) ; slapbass
;	 (stk-ify (get-track-data mid 3) 1) ; grand piano
; etc.

;; compile the synth, compute sound file, convert to stereo, open
(band patches)
(shell "cp /user/c/cc/220a/scm/stk/threebees.cpp /zap")
(shell "cp /user/c/cc/220a/scm/stk/m /zap")
(shell "cd /zap; touch threebees.cpp; ./m")
(shell "/zap/threebees /zap/test.skini")
(shell "sox /zap/test.wav -c 2 /zap/test-stereo.wav")
(open-sound "/zap/test-stereo.wav")

#! misc. hints on how to use midi output instead of stk
(define mag1-seq (new seq :subobjects (get-track-data mag 1)))
(define mag2-seq (new seq :subobjects (get-track-data mag 2)))
(define mag3-seq (new seq :subobjects (get-track-data mag 3)))
(events (list mag1 mag2 mag3) "/zap/test.midi")
;; timidity -Os -s 48000 /user/c/cc/220a/scm/stk/midi/nitefunk.mid
;; timidity -Ow -s 48000 test.midi