OLD | NEW |
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) 2010--2014 Neil Puttock <n.puttock@gmail.com> | 4 Copyright (C) 2010--2014 Neil Puttock <n.puttock@gmail.com> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual void process (Moment); | 34 virtual void process (Moment); |
35 }; | 35 }; |
36 | 36 |
37 void | 37 void |
38 Partial_iterator::process (Moment m) | 38 Partial_iterator::process (Moment m) |
39 { | 39 { |
40 if (Duration * dur | 40 if (Duration * dur |
41 = Duration::unsmob (get_music ()->get_property ("duration"))) | 41 = Duration::unsmob (get_music ()->get_property ("duration"))) |
42 { | 42 { |
43 Moment length = Moment (dur->get_length ()); | 43 Moment length = Moment (dur->get_length ()); |
44 if (get_outlet ()->now_mom () > 0) | 44 |
| 45 // Partial_iterator is an iterator rather than an engraver, |
| 46 // so the active context it is getting called in does not |
| 47 // depend on which context definition the engraver might be |
| 48 // defined. |
| 49 // |
| 50 // Using where_defined to find the context where |
| 51 // measurePosition should be overwritten does not actually |
| 52 // work since the Timing_translator does not set |
| 53 // measurePosition when initializing. |
| 54 |
| 55 Context *timing = Context::unsmob |
| 56 (scm_call_2 (ly_lily_module_constant ("ly:context-find")
, |
| 57 get_outlet ()->self_scm (), |
| 58 ly_symbol2scm ("Timing"))); |
| 59 |
| 60 if (!timing) |
| 61 programming_error ("missing Timing in \\partial"); |
| 62 else if (get_outlet ()->now_mom () > 0) |
45 { | 63 { |
| 64 timing->set_property ("partialBusy", ly_bool2scm (true)); |
46 Global_context *tg = get_outlet ()->get_global_context (); | 65 Global_context *tg = get_outlet ()->get_global_context (); |
47 tg->add_finalization (scm_list_3 (finalization_proc, | 66 tg->add_finalization (scm_list_3 (finalization_proc, |
48 get_outlet ()->self_scm (), | 67 get_outlet ()->self_scm (), |
49 length.smobbed_copy ())); | 68 length.smobbed_copy ())); |
50 } | 69 } |
51 else | 70 else |
52 { | 71 { |
53 // Partial_iterator is an iterator rather than an engraver, | 72 Moment mp = robust_scm2moment |
54 // so the active context it is getting called in does not | 73 (timing->get_property ("measurePosition"), |
55 // depend on which context definition the engraver might be | 74 Rational (0)); |
56 // defined. | 75 mp.main_part_ = 0; |
57 // | 76 timing->set_property |
58 // Using where_defined to find the context where | 77 ("measurePosition", (mp - length).smobbed_copy ()); |
59 // measurePosition should be overwritten does not actually | |
60 // work since the Timing_translator does not set | |
61 // measurePosition when initializing. | |
62 | |
63 Context *timing = Context::unsmob | |
64 (scm_call_2 (ly_lily_module_constant ("ly:context-find"), | |
65 get_outlet ()->self_scm (), | |
66 ly_symbol2scm ("Timing"))); | |
67 if (!timing) | |
68 programming_error ("missing Timing in \\partial"); | |
69 else | |
70 { | |
71 Moment mp = robust_scm2moment | |
72 (timing->get_property ("measurePosition"), | |
73 Rational (0)); | |
74 mp.main_part_ = 0; | |
75 timing->set_property | |
76 ("measurePosition", (mp - length).smobbed_copy ()); | |
77 } | |
78 } | 78 } |
79 } | 79 } |
80 else | 80 else |
81 programming_error ("invalid duration in \\partial"); | 81 programming_error ("invalid duration in \\partial"); |
82 | 82 |
83 Simple_music_iterator::process (m); | 83 Simple_music_iterator::process (m); |
84 } | 84 } |
85 | 85 |
86 IMPLEMENT_CTOR_CALLBACK (Partial_iterator); | 86 IMPLEMENT_CTOR_CALLBACK (Partial_iterator); |
87 | 87 |
88 MAKE_SCHEME_CALLBACK (Partial_iterator, finalization, 2); | 88 MAKE_SCHEME_CALLBACK (Partial_iterator, finalization, 2); |
89 SCM | 89 SCM |
90 Partial_iterator::finalization (SCM ctx, SCM length) | 90 Partial_iterator::finalization (SCM ctx, SCM length) |
91 { | 91 { |
92 LY_ASSERT_SMOB (Context, ctx, 1); | 92 LY_ASSERT_SMOB (Context, ctx, 1); |
93 LY_ASSERT_SMOB (Moment, length, 2); | 93 LY_ASSERT_SMOB (Moment, length, 2); |
94 Context *timing = Context::unsmob | 94 Context *timing = Context::unsmob |
95 (scm_call_2 (ly_lily_module_constant ("ly:context-find"), | 95 (scm_call_2 (ly_lily_module_constant ("ly:context-find"), |
96 ctx, | 96 ctx, |
97 ly_symbol2scm ("Timing"))); | 97 ly_symbol2scm ("Timing"))); |
98 if (!timing) { | 98 if (!timing) { |
99 programming_error ("missing Timing in \\partial"); | 99 programming_error ("missing Timing in \\partial"); |
100 return SCM_UNSPECIFIED; | 100 return SCM_UNSPECIFIED; |
101 } | 101 } |
102 Moment mp = robust_scm2moment (timing->get_property ("measurePosition"), | 102 Moment mp = robust_scm2moment (timing->get_property ("measurePosition"), |
103 Rational (0)); | 103 Rational (0)); |
104 mp.main_part_ = measure_length (timing); | 104 mp.main_part_ = measure_length (timing); |
105 timing->set_property ("measurePosition", | 105 timing->set_property ("measurePosition", |
106 (mp - *Moment::unsmob (length)).smobbed_copy ()); | 106 (mp - *Moment::unsmob (length)).smobbed_copy ()); |
| 107 timing->unset_property (ly_symbol2scm ("partialBusy")); |
| 108 |
107 return SCM_UNSPECIFIED; | 109 return SCM_UNSPECIFIED; |
108 } | 110 } |
OLD | NEW |