A metronome object for Impromptu


Metronome: a device used by musicians that marks time at a selected rate by giving a regular tick. If you ever felt that you missed a metronome in Impromptu, here is a little scheme object that can do that job for you.

Function: make-metroclick

The make-metroclick function returns a closure that can be called with a specific time in beats, so that it plays a sound for each beat and marks the downbeat using a different sound.

Possibly useful in order to keep track of the downbeats while you compose, or just to experiment a little with some rhythmic figures before composing a more complex drum kit section.

Here's a short example of how to use it:

Make-metronome relies on the standard libraries that come with Impromptu, in particular make-metro, which is described in this tutoriale and on this video. Essentially, it requires you to define a metro object first, e.g. (define *metro* (make-metro 120)).

Here's the source code:

;; Metronome object for Impromptu
; UTIL: cl:ratio_is_perfect
;; convoluted way to check if a ratio is a perfect integer
(define cl:ratio_is_perfect
(lambda (f)
(equal? 0 (string->number (cadr (string-split (number->string (rational->real f)) "." ))))))
;;; METROTICK object - relies on a metronome instance being previously defined
; Usage:
; (define *metro* (make-metro 120))
; (define metroclick (mu:make-metrotick *metro*))
; (metroclick 4) ;; start beating a 4/4
; (metroclick 'stop)
(define mu:make-metrotick
(lambda (start-metro)
(let* ((*loopruns* #f)
(*beats* 1)
(*vol* 60)
(metro start-metro)
(musicloop
(lambda (beat)
(let* ((mod (modulo beat *beats*)))
;(print mod)
(if (= 0 mod)
(play dls *gm:hi-bongo* *vol* 1/8 9)
(if (cl:ratio_is_perfect mod)
(begin (play dls *gm:low-bongo* *vol* 1/8 9)) ;;(print 'here mod)
)) ;;(print mod)
(if *loopruns*
(callback (metro (+ beat 1/16)) musicloop (+ beat 1/8)))))))
(lambda (sym . args)
(cond ((number? sym)
(print (string-append "Metronome: started with " (number->string sym) "/4 (use 'stop to end)"))
(set! *beats* sym)
(when (not *loopruns*)
(set! *loopruns* #t)
(musicloop (metro 'get-beat 1))))
((equal? sym 'stop)
(print "Metronome stopped")
(set! *loopruns* #f))
(else 'bad-method-name))))))
view raw metronome.scm hosted with ❤ by GitHub

Cite this blog post:


Michele Pasin. A metronome object for Impromptu. Blog post on www.michelepasin.org. Published on Feb. 20, 2013.

Comments via Github:


See also: