Skip to content

Instantly share code, notes, and snippets.

@extratone
Created July 2, 2025 20:20
Show Gist options
  • Save extratone/5acb61370a18d8a5d4ca5c75d0941a6d to your computer and use it in GitHub Desktop.
Save extratone/5acb61370a18d8a5d4ca5c75d0941a6d to your computer and use it in GitHub Desktop.
;nyquist plug-in
;version 4
;type tool ;;; CHANGED: from "process" to "tool" for modifying track properties.
;name "Sequential Pan Selected Tracks..."
;action "Panning tracks..."
;control count "Number of tracks" int "" (length *selection*) 0 0
;;; Sequential Pan by David Blue's Gemini Assistant (v2)
;;; This script pans the selected tracks sequentially from -100% (left) for the top track
;;; to +100% (right) for the bottom track.
(let* ((total-tracks (length *selection*)))
(if (> total-tracks 1)
;; If multiple tracks are selected, loop through them.
(dotimes (i total-tracks)
;; 'i' is the current track index, from 0 to (total-tracks - 1)
;;
;;; CHANGED: Corrected the panning formula to go from Left (-1.0) to Right (+1.0)
;;
;; The formula maps the index 'i' over the range [0, total-tracks-1]
;; to the pan value range [-1.0, 1.0].
(let* ((pan-value (+ -1.0 (/ (* (float i) 2.0) (1- (float total-tracks)))))
(current-track (nth i *selection*)))
(setf (get 'pan current-track) pan-value)))
;; If only one track is selected, just center it.
(if (= total-tracks 1)
(setf (get 'pan (nth 0 *selection*)) 0.0)))
;; Return an empty string because a "tool" type plugin does not need to return audio.
"")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment