-Simultaneous_music *
-My_lily_parser::get_rest_element (String s, Duration * duration_p)
-{
- Simultaneous_music* velt_p = new Request_chord;
- velt_p->set_spot (here_input());
-
- if (s=="s")
- { /* Space */
- Skip_req * skip_p = new Skip_req;
- skip_p->duration_ = *duration_p;
-
- skip_p->set_spot (here_input());
- velt_p->add_music (skip_p);
- }
- else
- {
- Rest_req * rest_req_p = new Rest_req;
- rest_req_p->duration_ = *duration_p;
- rest_req_p->set_spot (here_input());
-
- velt_p->add_music (rest_req_p);
- }
-
- delete duration_p;
- return velt_p;
-}
-
-Simultaneous_music *
-My_lily_parser::get_chord (Musical_pitch tonic, Array<Musical_pitch>* add_arr_p, Array<Musical_pitch>* sub_arr_p, Duration d)
-{
- Simultaneous_music*v = new Request_chord;
- v->set_spot (here_input ());
-
- Note_req* n = new Note_req;
- n->pitch_ = tonic;
- n->duration_ = d;
- v->add_music (n);
-
- for (int i = 0; i < add_arr_p->size (); i++)
- {
- Musical_pitch p = tonic;
- Musical_pitch q = (*add_arr_p)[i];
- // duh, c7 should mean <c bes>
- if (q.notename_i_ == 6)
- q.accidental_i_--;
- p.transpose (q);
- (*add_arr_p)[i] = p;
- }
- add_arr_p->sort (Musical_pitch::compare);
- for (int i = 0; i < sub_arr_p->size (); i++)
- {
- Musical_pitch p = tonic;
- Musical_pitch q = (*add_arr_p)[i];
- // duh, c7 should mean <c bes>
- if (q.notename_i_ == 6)
- q.accidental_i_--;
- p.transpose (q);
- (*sub_arr_p)[i] = p;
- }
- sub_arr_p->sort (Musical_pitch::compare);
-
- Musical_pitch third (2);
- Musical_pitch mthird (2, -1);
- Musical_pitch missing;
- missing = tonic;
- missing.transpose (third);
-
- Musical_pitch p;
- p = tonic;
- p.transpose (third);
- p.transpose (mthird);
-
- /*
- must have minimum at 5 (3 is added automatically as missing)
- */
- if (!add_arr_p->size ())
- add_arr_p->push (p);
- else if ((add_arr_p->top () < p) && (add_arr_p->top ().notename_i_ != p.notename_i_))
- add_arr_p->push (p);
- add_arr_p->sort (Musical_pitch::compare);
-
- Array<Musical_pitch> triads;
- triads.push (third); // c e
- triads.push (mthird); // d f
- triads.push (mthird); // e g
- triads.push (third); // f a
- triads.push (third); // g b
- triads.push (mthird); // a c
- triads.push (mthird); // b d
-
- /*
- if first addition is 4, assume sus4 and don't add third implicitely
- */
- Musical_pitch sus (3);
- sus.transpose (tonic);
- if (add_arr_p->size ())
- if ((*add_arr_p)[0] == sus)
- missing.transpose (mthird);
-
- /*
- add missing triads
- */
- for (int i = 0; i < add_arr_p->size (); i++)
- {
- Musical_pitch p = (*add_arr_p)[i];
- if (p > missing)
- while (p > missing)
- {
- if (p.notename_i_ != missing.notename_i_)
- {
- if ((missing.notename_i_ - tonic.notename_i_ + 7) % 7 == 6)
- {
- Musical_pitch special_seven = missing;
- Musical_pitch lower (0, -1);
- special_seven.transpose (lower);
- add_arr_p->insert (special_seven, i++);
- }
- else
- add_arr_p->insert (missing, i++);
- }
- missing.transpose (triads[(missing.notename_i_ - tonic.notename_i_ + 7) % 7]);
- }
- else if (p.notename_i_ == missing.notename_i_)
- missing.transpose (triads[(missing.notename_i_ - tonic.notename_i_ + 7) % 7]);
- else
- i++;
- }
-
- /*
- add all that aren't subtracted
- */
- for (int i = 0; i < add_arr_p->size (); i++)
- {
- Musical_pitch p = (*add_arr_p)[i];
- Note_req* n = new Note_req;
- n->pitch_ = p;
- n->duration_ = d;
- for (int j = 0; j < sub_arr_p->size (); j++)
- {
- if (p == (*sub_arr_p)[j])
- {
- delete n;
- n = 0;
- break;
- }
- }
- if (n)
- v->add_music (n);
- }