Re : duplicate parts



with some effort (missing docs), I have written this solution. Sorry in advance for the identation. 
I've left the loop range idea away and the script only copies the content of a part into another, both parts given in arguments.
I'm not very happy with the constant 2147483647 but I don't know how to say "find for all times".
Also, I think there is a more elegant way to find a part from its name but I can't find out which one.

Can you help me improve this code ?


(bse-script-register 'dub-part
		     ""
                     (N_ "/Song/Dub a part")
		     (N_ "Copies the content of a source part into an existing destination part. "
                         "\n"
                         "Note overlaps can occur if the destination part is not empty. "
                         "\n"
                         "The names for the source and destination parts are the usual ones, "
                         "for instance Part-10.")
		     "Jean Legrand"
		     "GNU General Public License"
		     (bse-param-song (N_ "Song") )
                     (bse-param-string (N_ "Source Part") "")
                     (bse-param-string (N_ "Destination Part") ""))

(define (dub-part song src-name dest-name)
        (let* ((song-name (bse-item-get-name song))
               (project   (bse-item-get-project song ))
               (src       (bse-project-find-item project (string-append (string-append song-name ":") src-name)))
               (test-1    (if (not (bse-is-part src))   (bse-exit-error 'text1 (_ "Wrong name for source part"))))
               (dest      (bse-project-find-item project (string-append (string-append song-name ":") dest-name)))
               (test-2    (if (not (bse-is-part dest))   (bse-exit-error 'text1 (_ "Wrong name for destination part"))))
               (notes     (bse-part-list-notes-crossing src 0 2147483647))
               (copy-note (lambda (note)
                                  (bse-part-insert-note-auto dest
                                                             (bse-rec-get note 'tick)
                                                             (bse-rec-get note 'duration)
                                                             (bse-rec-get note 'note)
                                                             (bse-rec-get note 'fine-tune)
                                                             (bse-rec-get note 'velocity)))))
              (begin
                (bse-item-group-undo song "dubbing-part")
                (for-each copy-note notes)
                (bse-item-ungroup-undo song))))
  
--- En date de : Jeu 8.10.09, jean legrand <kkwweett yahoo fr> a écrit :

> De: jean legrand <kkwweett yahoo fr>
> Objet: duplicate parts
> À: beast gnome org
> Date: Jeudi 8 Octobre 2009, 22h36
> Hi everyone,
> I'm new to Beast 0.7.1 and I'd like to know if the parts in
> a loop range can be 
> duplicated such that the content of the new parts is the
> same but the names of the 
> new parts are different.
> For the moment, when I use Tool/Song/Duplicate parts, the
> new parts are only 
> aliases of the original ones, and when I make a change in
> the new parts, the original 
> ones are changed too (and I don't want that).
> Thanks.
> 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]