ssb22 / jianpu-ly

Jianpu in Lilypond
http://ssb22.user.srcf.net/mwrhome/jianpu-ly.html
Apache License 2.0
70 stars 18 forks source link

Ties for long notes #53

Closed BertrandSim closed 8 months ago

BertrandSim commented 8 months ago

Hi Silas,

Could I check how to have ties for minims and breves? I tried

1 - - - ~ | 1 - - - |

but this was rendered as

image

Thanks!

ssb22 commented 8 months ago

I think the "proper" way is to just use continuations, not ties:

WithStaff 1 - - - | - - - -

(the tie is automatically added in the 5-line staff, and the note is just continued with dashes in the jianpu)

If we need to do something different, it would help if we could find an example of published jianpu music to confirm what it "should" look like...

BertrandSim commented 8 months ago

I think the "proper" way is to just use continuations.

Got it, thank you.

if we could find an example of published jianpu music to confirm what it "should" look like...

After some searching, here is an example that uses 'numbered notes' at the start of each bar, with the 'numbers' being tied together

image

(Source: https://theocarinanetwork.com/decoding-jianpu-notation-t18028.html)

ssb22 commented 8 months ago

Thanks, ah that makes things complicated.

Lilypond has 3 types of curve to connect notes: tie, slur, and phrase mark. These 3 have slightly different curvatures. The tie is the flattest of the 3, and is supposed to be used only between notes that are right next to each other.

When you say 6 - jianpu-ly actually implements it as 6 ~ 6 but makes the tie invisible and sets the second 6 as a -. That explains why adding a ~ after the - results in a tie starting from the last -.

If we wanted Lilypond to tie from a note at the start of one bar, directly to the note at the start of the next bar, passing over the dashes in between, then we'd probably have to tell Lilypond the true length of the numbered note and add the dashes as fake notes in a separate voice, skipping the non-dash beat in this new voice. That could lead to some quite complex code in jianpu-ly to handle all the cases.

Or you could fake it by using a slur:

2/4 6 ( - | 6 ) -

puts the ends of the curve on the right places, but it does have disadvantages:

  1. the MIDI will sound wrong (because a slur is not really a tie: it will re-sound the note)
  2. if the long notes are already under a slur, then you can't have one slur inside another slur. (You can have a slur inside a phrase mark if you do it that way, but we still have to hope we don't get a case of long notes inside a slur that's already inside a phrase mark. This is rather unlikely though.)
BertrandSim commented 8 months ago

Appreciate the reply, and thanks for the details.

When you say 6 - jianpu-ly actually implements it as 6 ~ 6 but makes the tie invisible and sets the second 6 as a -. That explains why adding a ~ after the - results in a tie starting from the last -.

I see, and now that makes sense.

tell Lilypond the true length of the numbered note and add the dashes as fake notes in a separate voice, ...

Regarding this, what about using fake rests in a separate voice? Feel free to critique.

Rests will probably not affect the midi in anyway, so the implementation may be simpler ( I think). Again, I may have overlooked some complications, so feel free to comment!

ssb22 commented 8 months ago

Hi, well if we're in the jianpu-ly code (not just giving it input), then we don't have to worry about the midi, because we already have a mechanism to say the jianpu, the 5-line and the midi are three different scores at that level i.e. we can do things in jianpu that are different from what was done in midi (that's why there's lines of code that say "if midi or western..." - the whole thing is repeated for each type of output). And I said fake notes instead of fake rests because we already know that notes are easier to work with when we're beaming (although in some cases you can beam across a rest as well).

But it turns out that Lilypond 2.20 and above can do labelled curves which are independent of slurs and phrase marks, so we might as well just use that (most people have 2.20+ these days, and if we still want to support 2.18 we can just detect it and say "your long-note ties are not going to look right unless you upgrade Lilypond to 2.20 or above")

BertrandSim commented 8 months ago

Thanks Silas,

I think using fake rests doesn't concern beaming here (since the note durations are minims and longer), and if we are talking on the code level, either rests or notes is fine.

Either of the approaches in your comment above sounds good :)