[CM] Beginner's tutorials?

Juan Reyes juanig at ccrma.Stanford.EDU
Tue Jul 7 14:37:08 PDT 2020


> 2. extract mono channel from stereo/multichannel file


Just found code to extract a channel from a soundfile. Hopefully this
would give you a start on Snd's interface.

   --* Juan

;; instrument or function definition on S7 to be loaded on Snd's 
;;;listener::

(definstrument (extract file
		      (start 0.0)
		      (att 1.0)
		      (chan 0))
   ;;
     (let* ((in-file-sr (mus-sound-srate file))
	   (in-file-dur  (/ (frames file) in-file-sr))
	   (out-start-time 0)
	   (out-duration (- in-file-dur start))
	   (readA (make-readin :file file :channel chan))
	   (beg (seconds->samples out-start-time))
	   (end (seconds->samples in-file-dur))
	   )
       (do ((i beg (1+ i)))
	  ((= i end))
	(begin
	  (let* ((sample (readin readA)))
	    (outa i (* att sample)))))
       ))

Once this code has been saved, load it on Snd's listener by typing
something like:

;; (load "extractch.cms")


- Function or instrument call on the listener (in order to get the 
channel extracted):

;;
;; (with-sound () (extract "eight-channels.wav" :chan 2))
;;
;;  This instrument call will open a new window in Snd.!!
;;  and will extract channel 3 from file "eight-channels.wav"
;;






More information about the Cmdist mailing list