paulrosen / abcjs

javascript for rendering abc music notation
Other
1.94k stars 285 forks source link

%%printtempo 0 doesn't consistently suppress tempo drawing #1027

Open seisiuneer opened 4 months ago

seisiuneer commented 4 months ago

User reported that on both my tool and drawthedots that when setting

%%printtempo 0

there are cases where the tempo still gets drawn

The expectation is that once you set

%%printtempo 0

that no tempo marks would be drawn until a

%%printtempo 1

is encountered, and this should allow selective showing or hiding of tempo marks.

For example this ABC does hide the single Q: tag in the header:

X: 1 T: Cooley's C: Traditional R: Reel M: 4/4 L: 1/8 %%printtempo 0 Q: 1/4=90 K: Edor |:"Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF| "Em"EBBA B2 EB|B2 AB defg|"D"afge dBAF|1 DEFD "Em"E3D:|2 DEFD "Em"E2gf||

This one hides the header Q: but shows the one in the body:

X: 1 T: Cooley's C: Traditional R: Reel M: 4/4 L: 1/8 %%printtempo 0 Q: 1/4=90 K: Edor |:"Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF| Q: 1/2=90 "Em"EBBA B2 EB|B2 AB defg|"D"afge dBAF|1 DEFD "Em"E3D:|2 DEFD "Em"E2gf||

This one doesn't suppress them properly in the header:

X: 1 T: Cooley's C: Traditional R: Reel M: 4/4 L: 1/8 %%printtempo 0 Q: "FOO" Q: 1/4=90 K: Edor |:"Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF| "Em"EBBA B2 EB|B2 AB defg|"D"afge dBAF|1 DEFD "Em"E3D:|2 DEFD "Em"E2gf||

This one hides the numeric Q: but draws the text one:

X: 1 T: Cooley's C: Traditional R: Reel M: 4/4 L: 1/8 %%printtempo 0 Q: 1/4=90 Q: "FOO" K: Edor |:"Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF| "Em"EBBA B2 EB|B2 AB defg|"D"afge dBAF|1 DEFD "Em"E3D:|2 DEFD "Em"E2gf||

And this one draws all of them:

X: 1 T: Cooley's C: Traditional R: Reel M: 4/4 L: 1/8 %%printtempo 0 Q: "FOO" Q: 1/4=90 K: Edor |:"Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF| Q: 1/2=90 "Em"EBBA B2 EB|B2 AB defg|"D"afge dBAF|1 DEFD "Em"E3D:|2 DEFD "Em"E2gf||

Walking the code, I can see that there is some handling for the header with the tempo and tempo.suppress based on the multilinevars, but that Q: tags later encountered are drawn no matter what directly as a result of encountering a tempo element with no filtering.

In the header handling, not sure why having a text Q: tag before the numeric one causes both to get drawn, but reversing the order causes the numeric one to be hidden, but the text one to be drawn.

I couldn't see a clean way to get the parser tempo.suppress info down to the music engraver for the body cases.

seisiuneer commented 4 months ago

Here's the specific use case from S. Wascher on the abcusers board that drove the request:

"I am cooperating with an archive whose database uses abcjs as abc-notation display tool. In the archives materials often there are music notations containing a verbose tempo indication. On playback, the tempo choosen by abcjs often seems not to meet the tempo expected by the archive people. So they had the idea to add another, "proper", tempo indication aka Q:1/4=100 or alike. Now they want to hide the visibility of 1/4=100 while still displaying the "Verbose" indication.

I thought that could be done using:

X:1 K:C %%printtempo 1 Q:"Verbose" %%printtempo 0 Q:1/4=100 CCCCCCC

seisiuneer commented 4 months ago

For now, suggesting they use another tag, like R: or P: to convey the verbose tempo string on the left side while still hiding the numeric tempo:

S. Wascher, I know this is a sub-optimal workaround, but something like this could be done to hide the tempos while still providing the verbose tempo info in an R: tag, for example:

X: 1 T: Cooley's C: Traditional R: Verbose M: 4/4 L: 1/8 %%printtempo 0 Q: 1/2=90 K: Edor "Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF|

If an R: tag won't work, P: tag also draws on the left side:

X: 1 T: Cooley's C: Traditional P: Verbose M: 4/4 L: 1/8 %%printtempo 0 Q: 1/2=90 K: Edor "Em"EBBA B2 EB|B2 AB dBAG|"D"F/E/D AD BDAD|F/E/D AD BAGF|