JeremyJStarcher / highlanddots

Automatically exported from code.google.com/p/highlanddots
0 stars 0 forks source link

Finding groups of score elements should be generalized at the level of a Score #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
beamgroup.getNoteGroup should moved to the Score, and should be generalized
to handle note groups and phrase groups. To enable this feature, the
current implementation of beamgroup.getNoteGroup should be moved to
score.getGroup and changed so it no longer checks for score element
type/category, but simply iterates through score elements until the
applicable group pseudo element is found. 
Starting with a group tag where 'endSection == true' 
Untested sample code may be similar to the following:

    Score.prototype.getGroup = function(elem) {
      var mel;
      var nested = 0;
      var grp = [];
      var pos = score.find(mel);

      if (!pos) {
        return;
      }

      while (--pos >= 0) {
        mel = score.get(pos);
        if (mel.type === elem.type) {
          if (mel.sectionStart && nested == 0)
            break;
          if (mel.sectionEnd) {
            nested++;
            continue;
          } else if (mel.sectionStart) {
            nested--;
            continue;
          }
        } else {
          if (nested == 0)
            grp.push(mel);
        }
      }
      grp.reverse();
      return grp;
    }

Original issue reported on code.google.com by pipemakertjm@gmail.com on 30 Apr 2010 at 6:34