Copying voice 1 to voice 2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Copying voice 1 to voice 2

nradisch
So I got this working fairly well by using copy/paste tricks. I'm
running into one weird problem. If the notes are part of a tuplet, the
copy in the second voice is missing any associated articulations (they
copy over fine if the notes are not part of a tuplet). Weird thing is,
I've traced through various stages of the code, and after I move the
notes to the second voice, the Articulations field of the notes are
still set, yet none show up on the screen.

In fact, if you comment out all the code after the SetVoice() call
(essentially turning the code into a move-to instead of copy-to) the
same problem still occurs, so it's not the pasting back to the first
voice that's clobbering anything.

Thoughts anyone?

Here's the code


     counter = 0;
     startbar = sel.FirstBarNumber;
     endbar = sel.LastBarNumber;
     startstaff = sel.TopStaff;
     endstaff = sel.BottomStaff;
     startpos = sel.FirstBarSr;
     endpos = sel.LastBarSr;

     // get objects of interest
     for each obj in sel
         {
         if (obj.GetIsInVoice(src))
             {
             name = "obj" & counter;
             @name = obj;
             counter = counter + 1;
             }
         }

     // make a non-passage selection of objects so paste doesn"t clobber
     // all voices in the bar
     sel.Clear();
     for x = 0 to counter
         {
         name = "obj" & x;
         obj = @name;
         obj.Select();
         }
     sel.Copy(1);

     // move objects to destination voice
     x = counter;
     while(x > 0)
         {
         x = x - 1;
         name = "obj" & x;
         obj = @name;
         if (obj.Type != "Text")
             {
             obj.SetVoice(dst);
             }
         }

     // we can"t move notes and text at the same time because tuplets
confuse
     // the text location. The tuplets all have to be in place before we
can align the text
     x = counter;
     while(x > 0)
         {
         x = x - 1;
         name = "obj" & x;
         obj = @name;
         if (obj.Type = "Text")
             {
             obj.SetVoice(dst);
             }
         }

     sel.Clear();
     // paste back original voice
     sel.PasteToPosition(startstaff,startbar,startpos,1,True);
     // restore original selection
     sel.SelectPassage(startbar,endbar,startstaff,endstaff,startpos,endpos);

     // some objects end up in multiple voices, make sure it"s only in
the destination
     for each obj in sel
         {
         if (obj.GetIsInVoice(dst) and obj.GetIsInVoice(src))
             {
             obj.RemoveVoice(src);
             }
         }
_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Copying voice 1 to voice 2

notenlektorat
Hi Neil,

>From doing something similar in the past I remember that "changing the
voice" of a tuplet in Sibelius basically means deleting it and completly
re-entering it in the new voice. Back then I came to the conclusion that
this is even how it works internally, and therefore what happens when you do
it from a plug-in.

What I did, in the end, was to keep track of all relevant properties that
are accessible by ManuScript, and then, in an additional run, to revert any
alterations that might have happened to objects within tuplets. Doing this
comprehensively is nontrivial, but it is possible. However, there are also a
number of properties that are not accessible, and those will be lost
inevitably.

Best,

Alex


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Neil Radisch
Sent: Freitag, 24. Februar 2017 23:13
To: [hidden email]
Subject: [Plugin-dev] Copying voice 1 to voice 2

So I got this working fairly well by using copy/paste tricks. I'm running
into one weird problem. If the notes are part of a tuplet, the copy in the
second voice is missing any associated articulations (they copy over fine if
the notes are not part of a tuplet). Weird thing is, I've traced through
various stages of the code, and after I move the notes to the second voice,
the Articulations field of the notes are still set, yet none show up on the
screen.

In fact, if you comment out all the code after the SetVoice() call
(essentially turning the code into a move-to instead of copy-to) the same
problem still occurs, so it's not the pasting back to the first voice that's
clobbering anything.

Thoughts anyone?

Here's the code


     counter = 0;
     startbar = sel.FirstBarNumber;
     endbar = sel.LastBarNumber;
     startstaff = sel.TopStaff;
     endstaff = sel.BottomStaff;
     startpos = sel.FirstBarSr;
     endpos = sel.LastBarSr;

     // get objects of interest
     for each obj in sel
         {
         if (obj.GetIsInVoice(src))
             {
             name = "obj" & counter;
             @name = obj;
             counter = counter + 1;
             }
         }

     // make a non-passage selection of objects so paste doesn"t clobber
     // all voices in the bar
     sel.Clear();
     for x = 0 to counter
         {
         name = "obj" & x;
         obj = @name;
         obj.Select();
         }
     sel.Copy(1);

     // move objects to destination voice
     x = counter;
     while(x > 0)
         {
         x = x - 1;
         name = "obj" & x;
         obj = @name;
         if (obj.Type != "Text")
             {
             obj.SetVoice(dst);
             }
         }

     // we can"t move notes and text at the same time because tuplets
confuse
     // the text location. The tuplets all have to be in place before we can
align the text
     x = counter;
     while(x > 0)
         {
         x = x - 1;
         name = "obj" & x;
         obj = @name;
         if (obj.Type = "Text")
             {
             obj.SetVoice(dst);
             }
         }

     sel.Clear();
     // paste back original voice
     sel.PasteToPosition(startstaff,startbar,startpos,1,True);
     // restore original selection
     sel.SelectPassage(startbar,endbar,startstaff,endstaff,startpos,endpos);

     // some objects end up in multiple voices, make sure it"s only in the
destination
     for each obj in sel
         {
         if (obj.GetIsInVoice(dst) and obj.GetIsInVoice(src))
             {
             obj.RemoveVoice(src);
             }
         }
_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev

_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev