Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 return scm_from_double (offset + staff_space * shift); | 1306 return scm_from_double (offset + staff_space * shift); |
1307 } | 1307 } |
1308 | 1308 |
1309 /* | 1309 /* |
1310 Estimate the position of a rest under a beam, | 1310 Estimate the position of a rest under a beam, |
1311 as the average position of its neighboring heads. | 1311 as the average position of its neighboring heads. |
1312 */ | 1312 */ |
1313 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, pure_rest_collision_callback, 4, 1, "") ; | 1313 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, pure_rest_collision_callback, 4, 1, "") ; |
1314 SCM | 1314 SCM |
1315 Beam::pure_rest_collision_callback (SCM smob, | 1315 Beam::pure_rest_collision_callback (SCM smob, |
1316 SCM prev_offset, | |
1317 SCM, /* start */ | 1316 SCM, /* start */ |
1318 SCM /* end */) | 1317 SCM, /* end */ |
1319 { | 1318 SCM prev_offset) |
1319 { | |
1320 Real previous = robust_scm2double (prev_offset, 0.0); | |
1321 | |
1320 Grob *me = unsmob_grob (smob); | 1322 Grob *me = unsmob_grob (smob); |
1321 Grob *stem = unsmob_grob (me->get_object ("stem")); | 1323 Grob *stem = unsmob_grob (me->get_object ("stem")); |
1322 if (!stem) | 1324 if (!stem) |
1323 return scm_from_double (0.0); | 1325 return scm_from_double (previous); |
Keith
2012/04/25 06:21:29
I'm confused. There is a remaining problem with d
| |
1324 Grob *beam = unsmob_grob (stem->get_object ("beam")); | 1326 Grob *beam = unsmob_grob (stem->get_object ("beam")); |
1325 if (!beam | 1327 if (!beam |
1326 || !Beam::normal_stem_count (beam) | 1328 || !Beam::normal_stem_count (beam) |
1327 || !is_direction (beam->get_property_data ("direction"))) | 1329 || !is_direction (beam->get_property_data ("direction"))) |
1328 return scm_from_double (0.0); | 1330 return scm_from_double (previous); |
Keith
2012/04/25 06:21:29
It would seem we do not want an early return in th
mike7
2012/04/25 06:29:02
What would the "wrong value" be here?
| |
1329 | 1331 |
1330 Real ss = Staff_symbol_referencer::staff_space (me); | 1332 Real ss = Staff_symbol_referencer::staff_space (me); |
1331 | 1333 |
1332 /* | 1334 /* |
1333 This gives the extrema of rest positions. | 1335 This gives the extrema of rest positions. |
1334 Even with noteheads on ledgers, beams typically remain within the staff, | 1336 Even with noteheads on ledgers, beams typically remain within the staff, |
1335 and push rests at most one staff-space (2 positions) from the staff. | 1337 and push rests at most one staff-space (2 positions) from the staff. |
1336 */ | 1338 */ |
1337 Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); | 1339 Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); |
1338 Interval rest_max_pos = staff ? Staff_symbol::line_span (staff) : Interval (0. 0, 0.0); | 1340 Interval rest_max_pos = staff ? Staff_symbol::line_span (staff) : Interval (0. 0, 0.0); |
(...skipping 11 matching lines...) Expand all Loading... | |
1350 for (vsize i = 0; i < my_stems.size (); i++) | 1352 for (vsize i = 0; i < my_stems.size (); i++) |
1351 if (my_stems[i] == stem) | 1353 if (my_stems[i] == stem) |
1352 { | 1354 { |
1353 idx = i; | 1355 idx = i; |
1354 break; | 1356 break; |
1355 } | 1357 } |
1356 Grob *left; | 1358 Grob *left; |
1357 Grob *right; | 1359 Grob *right; |
1358 | 1360 |
1359 if (idx == (vsize) - 1 || my_stems.size () == 1) | 1361 if (idx == (vsize) - 1 || my_stems.size () == 1) |
1360 return scm_from_double (0.0); | 1362 return scm_from_double (previous); |
1361 else if (idx == 0) | 1363 else if (idx == 0) |
1362 left = right = my_stems[1]; | 1364 left = right = my_stems[1]; |
1363 else if (idx == my_stems.size () - 1) | 1365 else if (idx == my_stems.size () - 1) |
1364 left = right = my_stems[idx - 1]; | 1366 left = right = my_stems[idx - 1]; |
1365 else | 1367 else |
1366 { | 1368 { |
1367 left = my_stems[idx - 1]; | 1369 left = my_stems[idx - 1]; |
1368 right = my_stems[idx + 1]; | 1370 right = my_stems[idx + 1]; |
1369 } | 1371 } |
1370 | 1372 |
1371 /* In stems with several heads, use the one closest to the beam. */ | 1373 /* In stems with several heads, use the one closest to the beam. */ |
1372 Direction beamdir = get_grob_direction (beam); | 1374 Direction beamdir = get_grob_direction (beam); |
1373 Real offset = min (max ( (Stem::head_positions (left)[beamdir] | 1375 Real shift = min (max ( (Stem::head_positions (left)[beamdir] |
1374 + Stem::head_positions (right)[beamdir]) / 2.0, | 1376 + Stem::head_positions (right)[beamdir]) / 2.0, |
1375 rest_max_pos[DOWN]), | 1377 rest_max_pos[DOWN]), |
1376 rest_max_pos[UP] | 1378 rest_max_pos[UP] |
1377 ) * ss / 2.0; | 1379 ) * ss / 2.0 |
1378 | 1380 - previous; |
1379 /* Always move by a whole number of staff spaces */ | 1381 /* Always move by a whole number of staff spaces */ |
1380 Real previous = robust_scm2double (prev_offset, 0.0); | |
1381 Real shift = offset - previous; | |
1382 shift = ceil (fabs (shift / ss)) * ss * sign (shift); | 1382 shift = ceil (fabs (shift / ss)) * ss * sign (shift); |
1383 | 1383 |
1384 return scm_from_double (previous + shift); | 1384 return scm_from_double (previous + shift); |
1385 } | 1385 } |
1386 | 1386 |
1387 bool | 1387 bool |
1388 Beam::is_knee (Grob *me) | 1388 Beam::is_knee (Grob *me) |
1389 { | 1389 { |
1390 SCM k = me->get_property ("knee"); | 1390 SCM k = me->get_property ("knee"); |
1391 if (scm_is_bool (k)) | 1391 if (scm_is_bool (k)) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 "least-squares-dy " | 1512 "least-squares-dy " |
1513 "neutral-direction " | 1513 "neutral-direction " |
1514 "normal-stems " | 1514 "normal-stems " |
1515 "positions " | 1515 "positions " |
1516 "quantized-positions " | 1516 "quantized-positions " |
1517 "shorten " | 1517 "shorten " |
1518 "skip-quanting " | 1518 "skip-quanting " |
1519 "stems " | 1519 "stems " |
1520 "X-positions " | 1520 "X-positions " |
1521 ); | 1521 ); |
LEFT | RIGHT |