;;; ;;; File: beet.lisp ;;; ;;; Summary: Simple MIDI Note Player (Lisp version) ;;; ;;; Author: Tobias Kunze ;;; e-Mail: tkunze@ccrma.stanford.edu ;;; Org: ;;; ;;; orig-Date: 18-Dec-97 at 18:28:02 ;;; Last-Mod: 22-Oct-98 at 12:38:31 by Tobias Kunze ;;; ;;; Description: Make sure Mi_D has been loaded up front. The exact ;;; procedure herefore depends on your Lisp ;;; implementation. In ACL, evaluate ;;; ;;; (progn ;;; (load "/libmi_d.so") ;;; (load "/include/mi_d.lisp") ;;; (load "/include/mi_dACL.lisp")) ;;; ;;; with appropriate substitutes for the italicized portions ;;; in the pathnames. In MCL, first make sure the shared ;;; library is in the extensions folder inside the system ;;; folder or in the same folder as your Lisp image, then, ;;; similarly, evaluate ;;; ;;; (progn ;;; (load "/include/mi_d.lisp") ;;; (load "/include/mi_dMCL.lisp")) ;;; ;;; Again, with the appropriate pathnames. ;;; ;;; Revision: 1.2 ;;; (defun beet (interface) (let (res (qtr 350) ; quarter note tempo (in ms) (time 0) ; note time stamp dur ; note duration (notes ; the melody '(64 64 65 67 67 65 64 62 60 60 62 64 64 62 62))) ;; Open MIDI for 16 channels, 1 route and connection, 16+1 ;; mapping cells and allocate a small queue of 100 or so events (setf res (mi_d:open-midi "Hello Mi_D" 16 1 1 17 100)) (if (/= res mi_d:+no-err+) (error "Can't open MIDI (~d)" res) (progn ;; use standard channel and route maps (mi_d:standard-maps) ;; connect to the given interface (setf res (mi_d:connect 0 interface :mi_d-output)) (if (/= res mi_d:+no-err+) (error "Can't connect to ~s (~d)" interface res) (progn ;; reset timer (mi_d:set-time 0) ;; play the melody (dotimes (i 15) (setf dur (floor (* qtr (case i (12 1.5) (13 .5) (14 2) (t 1))))) (mi_d:write-note_3c 0 (elt notes i) 64 64 dur time) (incf time dur)))))) (mi_d:close-midi))) #| ;;; ;;; Example Call: (beet "Software Synth") |# ;;; ;;; -*- EOF -*-