PLUGIN-DEV: Combining Voices

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

PLUGIN-DEV: Combining Voices

musictranscriber
Inquiring minds:
     In Sibelius there is an easy way to combine voices 1 and 2, just select the bar or bars you want and hit option/alt 1. This makes both voices combine into voice 1. It seems a bit more difficult to do this in a plugin. 
   The most logical experiment is to go through voice 2 and extract all the note information, clear voice 2 and add the relevant notes to voice 1. Something like this (a piece of code I use often when creating notes from a pseudo-array:

/////////////////////////////////////////

/* Assign notes to pseudo-array */


x = 0;

num = 0;

for each NoteRest nr in Sibelius.ActiveScore.Selection

{

if(nr.NoteCount!=0)

  {

  n = "note" & num;

  @n = nr;

  num = num + 1;

  }

}


NumOfNotes = num;



/* Loop through pseudo and create new notes */


for i = 0 to (num)

{

  n = "note" & i;

  nr = @n;

  

  bar = nr.ParentBar;

  pos = nr.Position;

  duration = nr.Duration;

  NeededPitch1 = basspitch + 7;

  NeededPitch2 = basspitch + 12;

  NeededPitch3 = basspitch + 16;

  voice = nr.VoiceNumber;

  if(nr.Highest.Tied = True)

    {tied = "True";}

  if(nr.Highest.Tied = False)

    {tied = "False";}

  //dpitch = nr.DiatonicPitch;

  //stringnumber = nr.StringNum;

  nr.Delete();

  bar.AddNote(pos,NeededPitch1,duration,tied,voice);     

}


/////////////////////////////////////////


Now if you do this on a complicated enough rhythm, even just half notes in voice 1 and quarter notes in voice 2, you will find that the notes don't exactly combine into one voice like may be expected.


To some of you out there, I am sure the more logical experiment would be not have been adding notes to a bar, but instead adding Notes to NoteRests. To do this you really need to get two pseudo-arrays, one for each voice and then, based on if the note in voice 1 and the note in voice 2 share a position, you would add a note to voice 1 (essentially combining the voice). Here is what a brief work-up of what that might look like:


/////////////////////////


V1Durations = CreateArray();

V1Pitches = CreateArray();

V1Positions = CreateArray();

V2Durations = CreateArray();

V2Pitches = CreateArray();

V2Positions = CreateArray();


a = 0;

b = 0;

for each NoteRest nr in Sibelius.ActiveScore.Selection

{

if(nr.NoteCount!=0)

{

if(nr.VoiceNumber= 1)

     {

     n = "v1note" & a;

     @n = nr;

     V1Durations[a] = nr.Duration;

     V1Pitches[a] = nr.Highest.Pitch;

     V1Positions[a] = nr.Position;

     a = a + 1;

     }

if(nr.VoiceNumber = 2)

     {     

     n = "v2note" & b;

     @n = nr;

     V2Durations[b] = nr.Duration;

     V2Pitches[b] = nr.Highest.Pitch;

     V2Positions[b] = nr.Position;

     b = b + 1;

     }

}

}


for i = 0 to b

{

n = "v2note" & i;

v2nr = @n;


if(utils.IsInArray(V1Positions, v2nr.Position) = True)

   {

   nn = "v1note" & utils.GetArrayIndex(V1Positions, v2nr.Position);

   v1nr = @nn;

   if(v2nr.Duration > v1nr.Duration)

     {tied = "True";}

   else

     {tied = "False";}

   v1nr.AddNote(v2nr.Highest.Pitch, tied);

   v2nr.Delete();

   }

}


/////////////////////////


Now this certainly combines notes, but if there are more notes in voice 2 (so that not every note in voice 2 has an exact position match to a note in voice 1) then there is no NoteRest in voice 1 to add this to. So it seems that combining voices can certainly be done by using a healthy combination of adding Notes to both Bars and to NoteRests. And probably the most efficient but lengthier task is to create an array of all the notes, clear the bars and then add the array of notes to the bar all in one voice. I wonder however, if anyone out there has stumbled across a more direct route to combining voices? Often times I find myself writing lengthy codes to emulate something Sibelius does in one of it's menus yet does not offer in Manuscript. So I thought I would ask if any of you have seen a direct way to combine voices. If not, I'll finish the code for this and share it with anyone who is interested. So, any suggestions or secret manuscript methods I missed would be great, if not, hopefully I can contribute this find. I realize it seems like a silly thing to want to do since Sibelius can already do it, but combining voices behind the scenes is a really powerful plugin technique (if you set Redraw to False and then restore everything before the plugin finishes, no one will ever know how sneaky you are. I did this in a few analysis plugins and it made analysis about 10 times quicker when the voices were combined, but in those cases I dealt with exact rhythms in both voices). Thanks so much, and sorry for the lengthy email. 


Regards,
      The Music Transcriber
      Roman Molino Dunn
      http://musictranscriber.xbuild.com
      610-392-4807

--- On Tue, 7/14/09, Bob Zawalich <[hidden email]> wrote:

From: Bob Zawalich <[hidden email]>
Subject: RE: PLUGIN-DEV: Convert MIDI tempo to Metronome mark
To: [hidden email]
Date: Tuesday, July 14, 2009, 11:24 PM

It sounds to me as if Sibelius *is* converting midi tempo markings to
metronome marks. They just happen to be hidden with leading ~.
(hidden MIDI text objects (with the ~[quarter note]=128.00035)

So you might be able to filter text that starts with ~, or ~q and delete the
~. Then you will have q = 128.00035, which is a fine metronome mark, if a
bit high on the number of digits.

There is a new plugin on the download page called something like Round
metronome Mark, which takes marks like q = 128.00035 and  makes a test
object  that looks like
q=128~q = 128.00035.  So it presents a rounded mm for printing, but plays
back with all the decimal places.

As I recall it will not change already hidden mms so you still have to
unhide them.

bob


________________________________________
From: Majordomo Pseudo User [mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Tuesday, July 14, 2009 6:01 PM
To: [hidden email]
Subject: PLUGIN-DEV: Convert MIDI tempo to Metronome mark

Hey, guru's of Sib plugins:

Is there a plugin for reading the MIDI tempo markings and then converting to
the Sibelius Metronome mark?
I'm importing quite a few MIDI files and although Sib6 is reading tempos
fine all the MIDI tempos are hidden MIDI text objects (with the ~[quarter
note]=128.00035).  I'd like to have metronome marks that I can then
delete/modifiy.

Regards,
--Doug




Reply | Threaded
Open this post in threaded view
|

Re: PLUGIN-DEV: Combining Voices

Hans Höglund

In Sibelius 6 it is very simple:

for each object in selection {
    object.SetVoice(toVoice, true);
}

It does not work for earlier versions I'm afraid, so your solution makes sense.

Best wishes,
//Hans
Reply | Threaded
Open this post in threaded view
|

Re: PLUGIN-DEV: Combining Voices

musictranscriber
In reply to this post by musictranscriber
Hans,
   Much appreciated. Trying this Manuscript improvement out now. Thanks so much.

Regards,
The Music Transcriber
Roman Molino Dunn
http://musictranscriber.xbuild.com
http://www.homosynchrono.com
610-392-4807

--- On Tue, 7/28/09, Hans Höglund <[hidden email]> wrote:

From: Hans Höglund <[hidden email]>
Subject: Re: PLUGIN-DEV: Combining Voices
To: [hidden email]
Date: Tuesday, July 28, 2009, 4:16 AM

In Sibelius 6 it is very simple:

for each object in selection {
    object.SetVoice(toVoice, true);
}

It does not work for earlier versions I'm afraid, so your solution makes sense.

Best wishes,
//Hans

View this message in context: Re: PLUGIN-DEV: Combining Voices
Sent from the Sibelius ManuScript plug-in developers mailing list archive at Nabble.com.