jbclements / RSound

A cross-platform sound library for DrRacket
http://www.brinckerhoff.org/clements
Other
45 stars 11 forks source link

Example program from docs fails #33

Open soegaard opened 6 years ago

soegaard commented 6 years ago

On OS X the example program below from the docs fails. The error message is: s16vector-ref: bad index 88800 for s16vector bounds of 0..88199 DrRacket highlights the form: (rs-ith/left waveform i)

I attempted this on a 6.7 (standard) and 6.90 (racket7 branch).

#lang racket

(require rsound)

(define waveform (synth-waveform "vgame" 4))

; wrap i around when it goes off the end:
(define (maybe-wrap i)
  (cond [(< i 48000) i]
        [else (- i 48000)]))

; a signal that plays from a waveform:
(define loop-sig
  (network (pitch)
    [i = (maybe-wrap (+ (prev i 0) (round pitch)))]
    [out = (rs-ith/left waveform i)]))

(signal-play
 (network ()
   [alternator <= square-wave 2]
   [s <= loop-sig (+ (* 200 (inexact->exact alternator)) 400)]
   [out = (* s 0.1)]))
soegaard commented 2 years ago

Just checked. The same error occurs on 7.5.

The example is in this section:

https://docs.racket-lang.org/rsound/index.html#%28part._.Sample_.Code%29