Looping Sections of an AudioBuffer

5 views
Skip to first unread message

George

unread,
Dec 6, 2025, 4:45:16 PM (22 hours ago) Dec 6
to Extempore
Andrew
I have not followed up on your suggestion of implementing a version of AudioBuffer_read but I followed your hint that "AudioBuffer_read_interp (and friends) look like they do".
In fact the read-interp version does exactly what I was looking for!
(I'll post the audio file below)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AudioBuffer_read_interp  has looping built-in

;; I opened the file "tmp/Tom&Greg_Devil_Deal.wav" in Audacity.app and found
;; starting points (frames) of 7 phrases
;; Laboriously copied the starting point and the length of each spoken phrase.
;; In xtlang I generated two vectors: one with 7 i64 integer starting points and
;; one with 7 i64 phrase lengths.
;; Then I randomly chose one of these starting points and the corresponding
;; phrase length.
;; Using AudioBuffer_set_loop_start and AudioBuffer_set_loop_frames I could
;; repeatedly play the selected phrase.

;; On re-evaluating the dsp:DSP code a different phrase may be selected and will
;; loop until another re-evaluation

(bind-func dsp:DSP
  (let ((ab dealWthDevl)
        (vStart:|7,i64|* (alloc))    ;; starting points (frames)
        (vFrame:|7,i64|* (alloc))    ;; representing loop-lengths (frames)
        (array-index (imp_rand1_i64 7)))   ;;
    (afill! vStart  24073 332207 505532 852183 1283089 1791028 2019721)
    (afill! vFrame  308134 175732 187769 334614 286468 113043 247951)
    (AudioBuffer_set_phase ab 0.0)
    (lambda (in time chan dat)
      (AudioBuffer_set_loop_start ab (aref vStart array-index)) ; silent pos
      (AudioBuffer_set_loop_frames ab (aref vFrame array-index)) ;; match length
      (AudioBuffer_read_interp ab (* 1.0 261.6) chan))))

(dsp:set! dsp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I have attempted to run a callback loop that re-evaluates the dsp:DSP code at regular intervals without success.
Also attempted to generate the arrays once only outside the dsp:DSP but ran into trouble with bad types.
Would appreciate some help with that.

Regards
George

George

unread,
Dec 6, 2025, 5:14:49 PM (21 hours ago) Dec 6
to Extempore
Andrew
The file is too big to post here.
I'll Try to find another way.
Or I could send it direct if you give me an address.
George

C K Kashyap

unread,
Dec 6, 2025, 8:04:16 PM (18 hours ago) Dec 6
to extemp...@googlegroups.com
To join the meeting on Google Meet, click this link: https://meet.google.com/jfu-hawj-dxm

Or open Meet and enter this code: jfu-hawj-dxm

--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/extemporelang/9381681b-f050-4825-9998-f2d6348e7cebn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages