[CM] adding an extra channel

Kjetil S. Matheussen k.s.matheussen@notam02.no
Tue, 12 Jun 2007 02:09:33 +0200 (CEST)


On Tue, 12 Jun 2007, e deleflie wrote:

> All,
>
> I've got a situation where I read eiether 3 or 4 channel files, then
> pump the channels through a LADSPA plugin.
>
> the LADSPA plugin requires 4 channels. So when I read a 3 channel
> file, I need to create a fourth, empty (no signal) channel.
>
> I cant seem to find the command for creating a new channel.
>
> something like this:
>
> (let ((index (open-sound name)))
>               ((if (= (channels 0) 3) (add-channel 0) ))
>


This is a work-around, but you can use new-sound instead of open-sound, 
and then use insert-sound to insert channels from your file into the 
sound:


(open-sound name)
(if (= (channels) 3)
   (let ((snd (new-sound (string-append name ".4-channels") (header-type) (data-format) (srate) 2)))
     (let loop ((ch 0))
       (insert-sound name 0 ch snd)
       (if (< ch 3)
 	  (loop (1+ ch)))))