[CM] adding an extra channel

e deleflie edeleflie@gmail.com
Fri, 15 Jun 2007 11:58:06 +1000


> Yes, or try this sequence: open the 3 channel input file, use "New"
> in the File menu, or (new-sound "test.snd" :channels 4) to open
> an output file, select the new sound,

Unfortunately, I'm working in a script only environement, my install
of Linux doesn't have a head on it (I'm doing everything by SSH).

Is there a way to 'select' the currently active sound in the script?
I've tried changing the order of opening the source file and creating
the new output file, but to no success.

The following code doesn't work ... I end up with 4 channels of the
right length, but all values are 0. If I create outsound AFTER opening
insound ... then the result has length 0.

theoretically now, the only missing link is working out how to direct
the output of the LADSPA plugin ....

	 	(let ((outsound (new-sound "out.snd" :channels 4)))
                (let ((insound (open-sound fullfilename)))
                        (src-sound (/ (srate insound) 44100) 1.0
insound) ; resample

                        (let ((readers
                                        (list   (make-sample-reader 0 0 0)  ; W
                                                (make-sample-reader 0 0 1)  ; X
                                                (make-sample-reader 0 0 2)  ; Y
                                                (make-sample-reader 0
0 3) ))) ; Z

                        (apply-ladspa readers 	(list "ambisonic1"
"Ambisonics-11-square-decoder" 0 1 1.414 2.0   380 2.5)
                                        	(mus-sound-frames fullfilename)
                                       		"ambisonic file")

                        (for-each (lambda (r) (if r
(free-sample-reader r))) readers))

                        ; now convert the 4 channels into 4 mono wav
files, and write to disk
                        (do ((i 0 (1+ i)))
                                   ((= i 4))
                                        (display (format #f "writing
channel ~D\n" i))
                                (save-sound-as (format #f "~a~a.~a" outpath name
                                                        (case i
                                                                ((0)
"LFront.wav")
                                                                ((1)
"RFront.wav")
                                                                ((2)
"RSurround.wav")
                                                                ((3)
"LSurround.wav")
                                                                (else "lost")
                                                        )
                                                )
                                                outsound
                                                :header-type mus-riff
                                                :data-format mus-l24int
                                                :srate 44100
                                                :channel i)
                        )
                        (close-sound insound)
                )
                (close-sound outsound)
                )

Etienne