The problem here is that the piano notes are not all the same duration. 
Specifically, your chord  (chord 60 64 67) is a bit longer:

(rs-frames (chord 60 64 67)) -> 161634 frames
(rs-frames (piano-tone 72)) -> 144000 frames

There are a lot of ways of solving this, including clipping the two sounds to 
the same length and using the `assemble` function. but here’s one simple way:


(require rsound)
(require rsound/piano-tones)
(define (chord . notes)
  (rs-overlay* (map piano-tone notes)))
(play (rs-append (rs-overlay (chord 60 64 67)
                            (piano-tone 72))
                 (rs-overlay (chord 60 65 69)
                            (piano-tone 72))
                 (rs-overlay (chord 62 67 71)
                            (piano-tone 74))
                 (rs-overlay (chord 64 67 72)
                            (piano-tone 84))))


(that is, put the append on the outside, and the rs-overlays inside it.)

(Also, yes, I made it a little I-IV-V-I instead of the same chord twice.)

John



> On Dec 7, 2019, at 14:39, wanderley.guimar...@gmail.com wrote:
> 
> I started to playing around with rsound while reading its documentation.  I 
> wrote the following code:
> 
>     #lang racket
>     (require rsound)
>     (require rsound/piano-tones)
>     (define (chord . notes)
>       (rs-overlay* (map piano-tone notes)))
>     (play (rs-overlay (rs-append (chord 60 64 67)
>                                  (chord 60 64 67))
>                       (rs-append (piano-tone 72)
>                                  (piano-tone 72))))
> 
> and I was expecting to hear `(piano-tone 72)` on the begin of the two chords. 
>  The second `(piano-tone 72)` starts few milliseconds after the second chord 
> starts.
> 
> Can you help me understand why this is happening?
> 
> Thanks,
> wander
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAAmHZodfci0HM0_b%2BPaEuGBojyJsKwOhDKd-%2Bgi3jJHhaHi7Hg%40mail.gmail.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/30767f0b-2fd3-480f-a350-9b4f32305498%40mtasv.net.

Reply via email to