[CM] [SND] Explicit access to find-channel in reverse

Bill Schottstaedt bil@ccrma.Stanford.EDU
Tue, 3 Apr 2007 04:50:01 -0700


> How, in Snd, is it possible to do the equivalent of C-r, i.e. do backward searches in the channel using 
> Scheme? Do I set up a sample-reader, or... 

Here's one way:

(define* (find-channel-in-reverse proc :optional beg snd chn edpos)
  (let* ((sample (or beg (1- (frames snd chn)))) ; or cursor?
         (reader (make-sample-reader sample snd chn -1 edpos))
         (result #f))
    (do ((i sample (1- i)))
        ((or result (< i 0)) 
         (and result
             (list result i)))
      (set! result (proc (reader))))))