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

[Feature Request] go up/down by one octave #24

Closed suntong closed 1 year ago

suntong commented 1 year ago

Again borrowing from https://alda.io/tutorial/

An interesting thing to note here is the >. This is Alda syntax for “go up to the next octave.” An octave, in scientific pitch notation, starts on a C and goes up to a B. Once you go above that B, the notes start over from C and you are in a new octave. In Alda, each instrument starts in octave 4, and remains in that octave until you tell it to change octaves. You can do that in one of two ways: you can use < and > to go down or up by one octave; or, you can jump to a specific octave using o followed by a number.

I believe that jianpu-ly notation currently support (only) the second method from above, and if we introduce the first method of “going up/down to the next octave” syntax, using > and <, it can simplify music scripting in normal cases.

It's a bit harder than the previous request, thus listed separately, but I think/hope it won't need too many changes.

What do you say?

ssb22 commented 1 year ago

O4 and < and > is taken from SMX code, I did it in Manuscript Writer and you'd be amazed how many times I made the mistake of putting whole sections of music into the wrong octave because I forgot what the current octave is, so when I did jianpu-ly I actually thought "let's not do that again" - I'd rather type ' or , for every note that needs it (yes it's more keystrokes, but at least you don't have to look through the whole piece asking "how did we end up being in the wrong octave so much?")

suntong commented 1 year ago

Hmm... yeah, you have far more first hand experiences for sure.

Just like my previous reply, it's not my intention to break any backward compatibility -- the old way still works (and would still be prefered), and this request only provides people with more choices (I would for just one or two notes use the old way, but when a whole sections of music are in another octave, I'll use switch instead.).

I think the problem eventually bog down to the personal preference, and I can tell that you're strongly prefer against my suggestions, I totally understand it. However, since the author of Alda settled with his personal preference, and he seems to be heavily involved with music composing and note taking, I'd assume that the other way of doing things would be fine too, especially when his approach seems to make things simpler to me. And moreover, correcting the "putting whole sections of music into the wrong octave" problem just need a single change (adding/deleting >/<), whereas otherwise I have to make change to every single note in the whole section. Apparently you think the latter way is simpler, so I think it eventually is a problem of personal preference.

Please consider.

suntong commented 1 year ago

I think the problem eventually bog down to the personal preference

I had been thinking why people would have such drastic differences between their preferences,

since the author of Alda settled with his personal preference, and he seems to be heavily involved with music composing and note taking, I'd assume that the other way of doing things would be fine too

I now consider that the fact that you are visually challenged might have a big impact on your preference that every note should contain every information it should have, while for people who prefer to look at things as a whole, and have no difficulties scan a big chunk of music notes quickly, they may prefer global optimization as to local optimization. Just a thought and wild guess...

suntong commented 1 year ago

Hmm... I gave it a try,

The notes from https://alda.io/tutorial/ are

g a b > c

and the result is

image

This is what I tried:

KeepOctave

2/4

1,, - > 1 - > 1 - > 1 - > 1 - 

and got:

Error: Unrecognised command > in score 1
1,, - > 1 - > 1 - > 1 - > 1 -

What's the correct way to do it, to get 1,, - 1, - 1 - 1' - 1'' -?

thx

ssb22 commented 1 year ago

Ah, in the current jianpu-ly version you can't have > as a word by itself, It has to be part of the same word as a note.

KeepOctave 2/4 1,, - >1 - >1 - >1 - >1 -

or equivalently,

KeepOctave 2/4 1,, - 1' - 1' - 1' - 1' -
suntong commented 1 year ago

Thanks for the reply,

KeepOctave 2/4 1,, - >1 - >1 - >1 - >1 -

When I tried it, I got:

Traceback (most recent call last):
  File "/opt/bin/jianpu-ly.py", line 1184, in <module>
    if __name__=="__main__": main()
  File "/opt/bin/jianpu-ly.py", line 1181, in main
    out = process_input(inDat) # <-- you can also call this if importing as a module
  File "/opt/bin/jianpu-ly.py", line 1118, in process_input
    out,maxBeams,lyrics,headers = getLY(part,headers)
  File "/opt/bin/jianpu-ly.py", line 1039, in getLY
    b4last,aftrlast,this,need_space_for_accidental,nBeams,octave = notehead_markup(figures,nBeams,dot,octave,accidental,tremolo)
  File "/opt/bin/jianpu-ly.py", line 479, in __call__
    if not placeholder_chord=="r": ret += {"":"'","'":"''","''":"'''",",":"",",,":","}[octave] # for MIDI + Western, put it so no-mark starts near middle C
KeyError: "'''"

$ head -5 /opt/bin/jianpu-ly.py
#!/usr/bin/env python
# (can be run with either Python 2 or Python 3)

# Jianpu (numbered musical notaion) for Lilypond
# v1.69 (c) 2012-2023 Silas S. Brown
ssb22 commented 1 year ago

Oh, the code was wrong, sorry I should have tested it some more before committing...

suntong commented 1 year ago

Yep, fixed. thx!

https://github.com/jianpu-ly/jianpu-st/blob/master/demo-octave-smpl.jp