5 vec_union(svec<Interval> notes)
9 for (int i =0 ; i < notes.sz() ; i++) {
16 default_bounds(Interval t)
21 bounds.add(t.min + dt/2);
26 Rhythmic_grouping::get_bounds()
30 for (int i=0; i < children.sz(); i++) {
31 bounds.add(children[i]->t.min);
36 // bounds.add(t.max );
41 Rhythmic_grouping::last()
47 Rhythmic_grouping::split_grouping(svec<Real> bounds)
50 svec<Rhythmic_grouping*> newgrp;
51 for (int i=0, j = 1; i < children.sz() && j < bounds.sz(); ) {
52 if ( children[i]->t.max < bounds[j]) {
55 } else if (children[i]->t.max > bounds[j]) {
60 assert( children[lasti]->t.min == bounds[j-1] );
61 assert( children[i]->t.max == bounds[j] );
63 Rhythmic_grouping * n = new Rhythmic_grouping(Interval(
64 bounds[j-1], bounds[j]));
65 for (int k = lasti ; k < i; k++)
66 n->children.add(children[k]);
71 if (newgrp.sz() <= 1) {
72 newgrp[0]->children.set_size(0);
80 Rhythmic_grouping::split_half()
82 svec<Real> bounds = default_bounds(t);
84 split_grouping(bounds);
86 for (int i=0; i < children.sz(); i++) {
87 if (children[i]->children.sz())
88 children[i]->split_half();
93 Rhythmic_grouping::sub_grouping(Interval v)
98 Rhythmic_grouping::split_grouping(Rhythmic_grouping &initial_grouping)
100 svec<Rhythmic_grouping*> newgrp;
101 svec<Real> bounds = initial_grouping.get_bounds();
102 bounds.add(initial_grouping.last());
103 split_grouping(bounds);
104 for (int i=0; i < children.sz(); i++) {
105 Interval h = children[i]->t;
106 Rhythmic_grouping*r = initial_grouping.sub_grouping(h);
107 if (children[i]->children.sz()) {
109 children[i]->split_grouping(*r);
111 children[i]->split_half();
116 Rhythmic_grouping::Rhythmic_grouping(Interval i)
121 Rhythmic_grouping::Rhythmic_grouping(svec<Interval> notes,
122 svec<Real> initial_grouping)
124 t = vec_union(notes);
125 for (int i=0; i < notes.sz(); i++) {
126 children.add(new Rhythmic_grouping(notes[i]));
128 split_grouping(initial_grouping);
131 Rhythmic_grouping::~Rhythmic_grouping()
133 for (int i=0; i < children.sz(); i++) {
139 Rhythmic_grouping::print()const
141 mtor << "{ " << t << "\n";
142 for (int i=0; i < children.sz(); i++) {
143 children[i]->print();