On Fri, 18 Dec 2009, [email protected] wrote:

>
> Hi,
>
> long time ago I had an audio file, which I think it was
> generate via csound, which plays a tone pitch, which /seems/
> to increase endlessly. It was the audible counterpart of an
> optical illusion.
>
> I like to know, how this "trick" was constructed and how I
> can rebuild the effect ?
>
> Thank you very much in advance for your help!
>

Hi,

The instrument below implements a shephard tone in snd-rt.
(taken from rt-example.scm). I don't really
know very well what I'm doing when it comes
to signal processing, but by tweaking enough I got it to sound
quite nice. Hopefully someone will shout out if there's
something fundamentally wrong with it. :-)

Hopefully the code is somewhat understandable.


(definstrument (risset startpitch endpitch num-oscs loop-duration)
   (define starttime (+ 1 (rte-time))) ;; Ensure all starts simultaniously by 
scheduling one second into the future.
   (for-each (lambda (n)
              (let ((osc (make-oscil #:frequency 0))
                    (e-p (make-env `(0 ,startpitch 1 ,endpitch     ) #:duration 
loop-duration #:base (expt 2 num-oscs)))
                    (e-a (make-env `(0 0           1 0.25       2 0) #:duration 
loop-duration #:base 100)) ;; Linear amplitude-change didn't sound very nice.
                    (start-location (* (/ (* (mus-srate) loop-duration)
                                          num-oscs)
                                       n)))
                (set! (mus-location e-p) start-location)
                (set! (mus-location e-a) start-location)
                (<rt-play-abs> starttime
                               (lambda ()
                                 (if (>= (mus-location e-p) (mus-length e-p))
                                     (begin
                                       (set! (mus-location e-p) 0)
                                       (set! (mus-location e-a) 0)))
                                 (out (* (env e-a)
                                         (oscil osc (hz->radians (env 
e-p)))))))))
            (iota num-oscs)))


_______________________________________________
Cmdist mailing list
[email protected]
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to