[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grob-object information
From: |
address@hidden |
Subject: |
Re: grob-object information |
Date: |
Tue, 11 Sep 2012 22:54:30 +0300 |
On 11 sept. 2012, at 22:29, Marc Hohl <address@hidden> wrote:
>>>
>> Are you certain that every vertical axis group will always contain the same
>> number of bar lines? If not, it's possible that the matrix you're talking
>> about may not have complete rows, in which case it's difficult to know how
>> to break it.
> I am not 100% sure – there could be corner cases where a staff line stops
> before the
> volta bracket is closed, but this could lead to an error when compiling the
> .ly file.
What about pieces with different simultaneous time signatures? They'd have
different numbers of bars for a given section.
>>
>> One way to check it is to look at the left or right of the
>> spanned_rank_interval of the grobs (the values will be the same as you're
>> dealing with items which only ever "span" one column). Once it goes
>> backwards, you know that you've skipped to the next row.
> What kind of values does spanned_rank_interval return?
>
The column number of a grob's left and right bound. Columns are linearly
ordered from the beginning of a score to the end, so you can use it to know
when a new staff is beginning in your array. For bar lines, the grob only
spans one column so the left and right values of the returned will be the same
- you can use either one.
In C++, if I had a vector <Grob *> foo that I wanted to sort into vector
<vector <Grob *> > bar, if I understand you correctly, I'd do:
int current_column = INT_MAX;
for (vsize i = 0; i < foo.size (); i++)
{
int column = foo[i]->spanned_rank_interval ()[LEFT];
if (column <= current_column)
bar.push_back (vector<Grob *> ());
bar.back ().push_back (foo[i]);
current_column = column;
}
The same thing is doable in Scheme - I just write pseudo-code faster in C++.
Cheers,
MS
Re: grob-object information, Marc Hohl, 2012/09/14