Finding the First NoteRest in a Tuplet

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

Finding the First NoteRest in a Tuplet

Martin Marris
There is an enormous quantity of sample code relating to tuplets, including
a whole Tuplets plugin folder, but I got more and more confused as I trawled
through it.

I'm doing something simple with tuplets (for once!). All I want to do is
determine the beaming setting for the first note in each tuplet.

Am I right that the only way to get the first NoteRest in a tuplet is to get
the tuplet's position and voice, and then to walk the bar looking for NRs
that share the same position and voice?

This seems to be working fine but it seems convoluted, and I suspect there
are gotchas ... I haven't even started thinking about nested tuplets.



_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding the First NoteRest in a Tuplet

Bob Zawalich
I have never been able to do much with the shipping tuplet routines
unfortunately. They require a lot of study to determine how they work.

If you are starting from a tuplet, about all you can do is look at all the
notes in a bar until you find a note with a tuplet parent that starts at
position 0 in the tuplet. Then you have to determine if the parent tuplet of
the note is the one you have or is the parent or grandparent etc. of the one
you have. There is also no way to test equality of tuplets except by
enumerating their properties.

With nested tuplets, just finding the note in a tuplet is not enough. Say
you have 17 tuplets deep at the start of a tuplet and find the first note,
but you have the topmost tuplet. You have to check the parents of each
tuplet as well until you find one that matches your tuplet.

I probably have code somewhere that does all this. I can have a look later
today, and post something if I find it.

bob

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Monday, October 05, 2015 4:22 AM
To: 'A mailing list for Sibelius plug-in developers'
Subject: [Plugin-dev] Finding the First NoteRest in a Tuplet

There is an enormous quantity of sample code relating to tuplets, including
a whole Tuplets plugin folder, but I got more and more confused as I trawled
through it.

I'm doing something simple with tuplets (for once!). All I want to do is
determine the beaming setting for the first note in each tuplet.

Am I right that the only way to get the first NoteRest in a tuplet is to get
the tuplet's position and voice, and then to walk the bar looking for NRs
that share the same position and voice?

This seems to be working fine but it seems convoluted, and I suspect there
are gotchas ... I haven't even started thinking about nested tuplets.



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

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding the First NoteRest in a Tuplet

Bob Zawalich
In reply to this post by Martin Marris
This routine will return all the nrs in a tuplet inside a sparse array. The
array may be empty if all nrs were deleted, or the first nr may not be at
the start of the ars if there are deleted rests. Test for this is you care.

If you only want the first NoteRest, do not allocate the sparse array. Where
the push is, just return the nr, and return null if it finds none.
The test for ParentTupletIfAny is not needed, so feel free to remove it. I
have it as a security blanket in case things I don't know about come to
light.


**************************************
GetNoteRestsInTuplet "(tup) {

arrSparseNR = CreateSparseArray();
bar = tup.ParentBar;
// an nr that is in the position range of the tuplet in the same voice is a
child.
// if we need more care we can check the parent against tup

// store all the nrs in the tuplet, even if a rest
// caller should check start pos of first note (if any) in ars to be sure it
does not start with deleted rests

for each NoteRest nr in bar
{
        if ((nr.ParentTupletIfAny != null) and (nr.VoiceNumber =
tup.VoiceNumber))
        {
                if ((nr.Position >= tup.Position) and (nr.Position <
(tup.Position + tup.PlayedDuration)))
                {
                        arrSparseNR.Push(nr);
                }
        }
}

return arrSparseNR;}"

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Monday, October 05, 2015 4:22 AM
To: 'A mailing list for Sibelius plug-in developers'
Subject: [Plugin-dev] Finding the First NoteRest in a Tuplet

There is an enormous quantity of sample code relating to tuplets, including
a whole Tuplets plugin folder, but I got more and more confused as I trawled
through it.

I'm doing something simple with tuplets (for once!). All I want to do is
determine the beaming setting for the first note in each tuplet.

Am I right that the only way to get the first NoteRest in a tuplet is to get
the tuplet's position and voice, and then to walk the bar looking for NRs
that share the same position and voice?

This seems to be working fine but it seems convoluted, and I suspect there
are gotchas ... I haven't even started thinking about nested tuplets.



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

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding the First NoteRest in a Tuplet

Alexander Plötz
In reply to this post by Bob Zawalich
Here is a similar routine that I had need for recently. It takes a tuplet and will return all noterests within that tuplet as well as any direct parent tuplets, but not the noterests within those children tuplets nor any tuplets nestled further in. Basically, it gives you the level of a tuplet as if it was a bar, in a way.
 
 
GetTupletContents "(tup) {
 
Start=tup.Position;
End=Start+tup.PlayedDuration;
TupletContents=CreateSparseArray();
 
for each nrt in tup.ParentBar {
 if ((nrt.Type="NoteRest" or nrt.Type="Tuplet")
 and nrt.VoiceNumber=tup.VoiceNumber
 and nrt.Position>=Start
 and (nrt.ParentTupletIfAny.Position=tup.Position
  and nrt.ParentTupletIfAny.PlayedDuration=tup.PlayedDuration)
 ) {
 
  if (nrt.Position>=End) {
   return TupletContents;
  }
  TupletContents.Push(nrt);
 }
}
 
return TupletContents;
}"
 
 


Sent: Monday, October 05, 2015 7:17 PM
Subject: Re: [Plugin-dev] Finding the First NoteRest in a Tuplet

I have never been able to do much with the shipping tuplet routines
unfortunately. They require a lot of study to determine how they work.

If you are starting from a tuplet, about all you can do is look at all the
notes in a bar until you find a note with a tuplet parent that starts at
position 0 in the tuplet. Then you have to determine if the parent tuplet of
the note is the one you have or is the parent or grandparent etc. of the one
you have. There is also no way to test equality of tuplets except by
enumerating their properties.

With nested tuplets, just finding the note in a tuplet is not enough. Say
you have 17 tuplets deep at the start of a tuplet and find the first note,
but you have the topmost tuplet. You have to check the parents of each
tuplet as well until you find one that matches your tuplet.

I probably have code somewhere that does all this. I can have a look later
today, and post something if I find it.

bob

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Monday, October 05, 2015 4:22 AM
To: 'A mailing list for Sibelius plug-in developers'
Subject: [Plugin-dev] Finding the First NoteRest in a Tuplet

There is an enormous quantity of sample code relating to tuplets, including
a whole Tuplets plugin folder, but I got more and more confused as I trawled
through it.

I'm doing something simple with tuplets (for once!). All I want to do is
determine the beaming setting for the first note in each tuplet.

Am I right that the only way to get the first NoteRest in a tuplet is to get
the tuplet's position and voice, and then to walk the bar looking for NRs
that share the same position and voice?

This seems to be working fine but it seems convoluted, and I suspect there
are gotchas ... I haven't even started thinking about nested tuplets.



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

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

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Finding the First NoteRest in a Tuplet

Alexander Plötz
...must read "as well as any direct child tuplets", of course.

 
Sent: Monday, October 05, 2015 10:52 PM
Subject: Re: [Plugin-dev] Finding the First NoteRest in a Tuplet

Here is a similar routine that I had need for recently. It takes a tuplet and will return all noterests within that tuplet as well as any direct parent tuplets, but not the noterests within those children tuplets nor any tuplets nestled further in. Basically, it gives you the level of a tuplet as if it was a bar, in a way.
 
 
GetTupletContents "(tup) {
 
Start=tup.Position;
End=Start+tup.PlayedDuration;
TupletContents=CreateSparseArray();
 
for each nrt in tup.ParentBar {
 if ((nrt.Type="NoteRest" or nrt.Type="Tuplet")
 and nrt.VoiceNumber=tup.VoiceNumber
 and nrt.Position>=Start
 and (nrt.ParentTupletIfAny.Position=tup.Position
  and nrt.ParentTupletIfAny.PlayedDuration=tup.PlayedDuration)
 ) {
 
  if (nrt.Position>=End) {
   return TupletContents;
  }
  TupletContents.Push(nrt);
 }
}
 
return TupletContents;
}"
 
 


Sent: Monday, October 05, 2015 7:17 PM
Subject: Re: [Plugin-dev] Finding the First NoteRest in a Tuplet

I have never been able to do much with the shipping tuplet routines
unfortunately. They require a lot of study to determine how they work.

If you are starting from a tuplet, about all you can do is look at all the
notes in a bar until you find a note with a tuplet parent that starts at
position 0 in the tuplet. Then you have to determine if the parent tuplet of
the note is the one you have or is the parent or grandparent etc. of the one
you have. There is also no way to test equality of tuplets except by
enumerating their properties.

With nested tuplets, just finding the note in a tuplet is not enough. Say
you have 17 tuplets deep at the start of a tuplet and find the first note,
but you have the topmost tuplet. You have to check the parents of each
tuplet as well until you find one that matches your tuplet.

I probably have code somewhere that does all this. I can have a look later
today, and post something if I find it.

bob

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Monday, October 05, 2015 4:22 AM
To: 'A mailing list for Sibelius plug-in developers'
Subject: [Plugin-dev] Finding the First NoteRest in a Tuplet

There is an enormous quantity of sample code relating to tuplets, including
a whole Tuplets plugin folder, but I got more and more confused as I trawled
through it.

I'm doing something simple with tuplets (for once!). All I want to do is
determine the beaming setting for the first note in each tuplet.

Am I right that the only way to get the first NoteRest in a tuplet is to get
the tuplet's position and voice, and then to walk the bar looking for NRs
that share the same position and voice?

This seems to be working fine but it seems convoluted, and I suspect there
are gotchas ... I haven't even started thinking about nested tuplets.



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

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


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

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