-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when attaching bar lines to multiple staves in a score? #1252
Comments
By design. Though keep reading for thoughts about future tightening of the model. Note that LilyPond scopes the context of LilyPond bar lines to the LilyPond score. We see that this is the case if we modify your first example to attach only a single bar line, and then look at the resulting LilyPond output:
The LilyPond Abjad does, in fact, model this:
Then, at attach-time Abjad checks for "contention" between two indicators that happen at the same moment but are "scoped" high enough (like at the level of the score) that they clash. That check that Abjad is making is unmotivated in the example here (because the bar lines both "mean" the same thing: they're double bar lines). But imagine that you tried to attach a double bar in one staff and then a final bar in the other staff (at the same time). Then it's actually quite helpful that Abjad is alerting you to the fact that you're effectively trying to overwrite your own intentions. (Even more so if you imagine setting conflicting metronome mark indicators at the same moment in different staves. Metronome marks are also scoped at the score.) So the check will stay. Your second example is different, however: my intention is to forbid the second example. I just haven't gotten around to it yet. I think the way it will work is this: when you go to attach a bar line to a note, rest, chord Abjad will check and see if the note, rest, chord is (ultimately) enclosed in a score. If yes, you can attach. If no, you'll get an exception. I know on first glance all this might "feel" like restricting user functionality. But think about it for a moment or two and you'll realize the restriction is actually super helpful! While we're at it, there's an analogous behavior with time signatures. I'll point it out here. And time signatures will also be subject to a slight behavior change when I get around to this part of the code. Recall that time signatures are scoped to the staff context in LilyPond. This is also true in Abjad. Now, check out the difference between these two examples. This does what you expect:
This is probably a surprise!
Crazy, huh? This is ancient code I wrote a million years ago. What's going on here is that I'm forbidding the time signature from visibly appearing in LilyPond until the Abjad user encloses the whole thing in an Abjad staff. Notice that now stuff works how you'd expect, with no commented-out time signature:
The behavior's less than ideal because it's too implicit: Abjad users can do all this stuff without realizing what's happening behind the scenes. (Quite possibly being unaware that a time signature won't show up.) Much better is the bar line behavior you stumbled upon: at least the exception trains users into how to work with the system! Finally to note is that there's another very important motivator to all this context-checking at attach-time. When you start using This works exactly as you expect:
But this doesn't:
This is basically Abjad pushing you to make sure there's an explicit When I add the generalized raise-an-exception-at-attach-time code then the behavior will be consistent, and the system will nudge you towards having explicit contexts. |
Hi Trevor, thanks for the reply (super detailed as always), this is really appreciated. I understand the motivations you state, but I hope you won't mind me sharing a couple of thoughts about this.
In my view, the main issue with this is that sometimes you are not overwriting your own intentions, but you are explicitly adding identical bar lines or time signatures to multiple staves, which allows for easier part extraction. The code below is a perfectly valid LilyPond file:
Sure, an user might enter some non-sense and get things overwritten, but is it really the job of Abjad to check for that? LilyPond doesn't even output a warning in the log when these things happen, e.g.:
An Abjad user might try the first Abjad example in my issue, stumbled with that error message, and then assume when they write...:
... that the bar line is added to both staves. Then when this user is ready to export parts, they might fail to notice that the bar line is in fact attached only to the first staff, i.e.:
In the worst case scenario, this user might discover the problem only after shipping parts for the performers.
You might argue that the better approach in these examples would be to have a global variable for common time signatures and bar lines, but a counterargument is that LilyPond allows for this sort of approach I used in my initial example and, by limiting it, you are effectively locking users into a single mode of working. From the user point of view, LilyPond uses this very clear underpinning notion that whatever comes last in a simultaneous situation overwrites the previous entry. This is consistently applied, and makes the behaviour of the software very consistent for users. This is sort of similar with the time signature and voice issue you mentioned. I had already stumbled upon that (I believe I initially reported it as a bug). It's a behaviour that is somewhat cryptic to new users, particularly those who happen to be longer-time LilyPond users and who know that the sort of syntax below, albeit unclear, is perfectly valid once again:
With all that said, would you be able to show me in my simple minimal example below how to adapt the code so that I can have the double bar lines both in the full score as well as when extracting parts with the minimal amount of code?
Many thanks! |
Hi @gilbertohasnofb. There's a What the final example is really wanting to do is to treat bar lines as though they're scoped to the staff instead of the score. You can do that like this:
(I replaced the call to Also, all your ideas here are good ones. Let's save them for a future design discussion! The general concept that we're thinking through here is probably called something like "contexted indicators." I've been looking forward to rethinking the entire concept in Abjad from top to bottom. When the time comes for that then we should remember to come back to these great observations! |
Thanks a lot @trevorbaca, I will use the |
Note for future thought on this issue: it's possible that Abjad should be extended to allow "duplicate" indicators to be attached to different leaves in a new way that Abjad currently forbids. Consider the first note (or rest) of each of the (probably) four voices in a string quartet. These four notes all begin at the same offset (zero), and these four notes all live in different contexts (primary music voices of violin 1, violin 2, viola, cello). When attaching the first Perhaps Abjad should instead allow the first metronome mark of the piece to be attached to as many different leaves at offset zero as the composer would like. This would presumably ease the construction of parts considerably, because metronome mark information could be attached to the first note in each part. The behind-the-scenes code in Abjad that determines effective indicators would have to be taught about this, but it would work. And the only constraint that users would have to follow is that multiple metronome marks attached to different leaves that all start at the same offset must all compare equal: if the starting tempo is q=66 then q=66 can be attached to as many leaves at offset zero as the user likes, but attaching q=44 to the viola would still be disallowed. |
When dealing with multiple staves that belong to an
abjad.Score
, attempting to attach a bar line to more than one stave at a same given bar will result in an exception:The code above produces:
Attaching the barlines to the same positions but before adding the staves to a score will not result in an exception:
Is the first case happening by design or is that a bug? It seems odd that once a staff is part of a score it cannot receive barlines if another staff already has one at that given bar.
The text was updated successfully, but these errors were encountered: