Random tracks playing with random intervals

Sorry it took so long to get back to you.

Here’s some Nyquist code that may be run in the Nyquist Prompt effect.
It assumes that we are starting with a mono track containing audio clips from 0 to 2.5 seconds, 2.5 to 5 seconds … 12 to 15 seconds.
Gaps between the clips will be a random value less than 5 seconds.

I tested this code in Audacity 3.0.2, but it should work in any recent version of Audacity. Adapt as necessary.

;; List of audio clips to randomise, formatted as list of
;; start times and end times.
(setf clips '((0 2.5) (2.5 5) (5 10) (10 12) (12 15)))

(setf max-gap 5.0)  ;maximum gap between clips

; Initialise an empty list
(setf randclips ())

;; Populate 'randclips' with randomised copy of 'clips'
;; This allows us to use each clip once, in a random order.
(dotimes (i (length clips))
  (setf clip (nth (random (length clips)) clips))
  (setf clips (delete clip clips :test 'equal))
  (push clip randclips))

;; test
;(print randclips)

;; Assuming mono sounds
(aud-do "NewMonoTrack:")
(setf paste-time 0) ;paste next clip at time position

(dotimes (i (length randclips) "")
  (setf clip (nth i randclips))
  (setf clipdur (- (second clip) (first clip)))
  (setf sildur (* max-gap (rrandom)))
  ;; Copy an audio clip from first track to 2nd track
  (aud-do "SelectTracks:Mode=Set Track=0 TrackCount=1")
  (aud-do-command "SelectTime:" :end (second clip) :start (first clip))
  (aud-do "Copy:")
  (aud-do "SelectTracks:Mode=Set Track=1 TrackCount=1")
  ;; test
  ;(print paste-time)
  (aud-do-command "SelectTime:" :end paste-time :start paste-time)
  (aud-do "Paste:")
  ; Update paste position for next clip
  (setf paste-time (+ paste-time sildur clipdur)))