Racket latency with rsound
<p>I wrote this program in Racket which generates 32 random notes from a set of 15 notes and then plays them. The duration of each note should be 0.25 seconds. When I run it gives latency which makes the melody sound off-beat.</p>

<p>How can it run normally?</p>

<p>This is the program:</p>

<pre><code>#lang racket
(provide (all-defined-out))
(require rsound)
(require rsound/piano-tones)


(define-syntax-rule (note y x)
    (begin
       (play (piano-tone y))
       (sleep x)
       (stop)))

(define (random-element list)
  (list-ref list (random (length list))))

(define-syntax-rule (random-note)
  (note (random-element '(40 42 43 45 47 48 50 52 54 55 57 59 60 62 64)) 0.25))


(for ([i 32])
  (random-note))
</code></pre>