;;; -*- Syntax: Common-Lisp; Package: COMMON-MUSIC; Base: 10; Mode: Lisp -*- (in-package :stella) (in-syntax :midi t) ;;; ;;; Some examples from "advanced.lisp" by Rick Taube. ;;; These require a MIDI interface and synthesizer on MIDI ch. 1 ;;; and are played directly (without writing a file) by typing "listen" ;;; At CCRMA, Midi port to open: b ;;; First time it plays the timings are screwy unless you give a time offset ;;; of a few seconds. ;;; ;;; Motives are defined using the named option, and recalled ;;; using the #@ construct ;;; (algorithm a1_motive midi-note (length 40 rhythm .2 duration .5 amplitude .5) (setf note (item (notes c2 [ef5 b] f (notes fs3 a named low) c3 [ef5 b] f #@low c4 [ef5 b] f #@low c5 [ef5 b] f #@low)))) ;;; ;;; envelope control ;;; (algorithm a2_envelope midi-note (length 60 rhythm .075 duration .25 amplitude .5) (vars (env '(0 0 .5 1 1 0)) (frq1 220) (frq2 880)) (setf note (function-value (/ count length) env (- frq2 frq1) frq1))) ;;; ;;; Using loop to create several algorithms ;;; (merge a3_loop () (loop for beg from 0 to 9 by 1.5 for n in '(a3i_1 a3i_2 a3i_3 a3i_4 a3i_5 a3i_6 a3i_7) do (algorithm (name n) midi-note (start beg end 14 note (degree (+ 100.0 (* 100.0 beg))) duration .25) (setf rhythm (+ .05 (random .15))) (setf amplitude (item (amplitudes mp (fff weight .1 max 1) in random))) (setf note (between (- note 2) (+ note 2)))))) (stella:stella)