;;; -*- Syntax: Common-Lisp; Package: COMMON-MUSIC; Base: 10; Mode: Lisp -*- ;;; Streaming showing the tendency of the ear to group lines of music by register. ;;; This example plays a monophonic line with notes in alternating register, ;;; first slow then fast. The streaming effect occurs at higher tempos only. ;;; we define a violin player that's going to play our melody. ;;; to communicate with the player we use the following parameters: ;;; start-time -> when in time to start the melody ;;; events -> number of notes we want the player to play ;;; tempo -> the tempo in bps ;;; octaves -> a pattern with the octave offsets (defun one-violin (start-time events tempo octaves) (let* (;; "shadow" the global tempo variable (*tempo* tempo) ;; our pitch stream (pitch (new cycle c3 d e parsing #'hertz)) ;; our rhythm stream (which will double as duration control) (rhythm (new cycle q parsing #'rhythm)) ;; the time counter, starts at "start-time" (time start-time)) (loop ;; we go through the loop "events" times repeat events ;; this is going to be the duration for the current note for dur = (next rhythm) ;; this is going to be the frequency of the note for freq = (* (next pitch)(next octaves)) do (fm-violin time dur freq 0.1) ;; increment out time counter _after_ the note is played ;; as we use the rhytm as duration, notes will be "legato" (incf time dur)))) #| A simple example of streaming... (with-sound() (one-violin 0 15 (* 60 2) (new cycle 2 4)) (one-violin (/ 15 2.0) 60 (* 60 7)(new cycle 2 4))) |#