Skip to content
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

Blank staff in wizard (fix #1139) #1605

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Nodd
Copy link

@Nodd Nodd commented May 13, 2023

Hi,
This PR adds a new option in the score wizard to create blank staff with the given configuration.

Fixes #1139

It generates this kind of code :

flute = \relative do'' {
  \global
  % Music follows here.
  
  \repeat unfold 7 { s1 \break }
  
}

image

Comment on lines 135 to 137
num = self.scoreProperties.blankStaff.value()
if num:
ly.dom.Text(r"\repeat unfold {num} {{ s1 \break }}".format(num=num), s)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not proud of this part... If there is a better way to do it, please enlighten me !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't python-ly have dom elements for repeats and such? (I didn't look into this yet.)

The s1 needs to depend on the time signature...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the time signature and \partial into account. I did not find anything in the dom code about repeats. Nothing about rests either.

@jeanas
Copy link
Member

jeanas commented May 13, 2023

Is the purpose to get a blank staff as final score (e.g., to print staves to handwrite on), or to start with a score that already has some staves to get a first idea of the layout?

If the latter, perhaps spelling out s<duration> \break s<duration> \break ... is more convenient for later editing than \repeat unfold?

@Nodd
Copy link
Author

Nodd commented May 13, 2023

To be honest I just picked an issue with a beginner label to get into the code base, so your guess is as good as mine! #1139 seemed to be the former (to print staves to handwrite on).

If it's the second one, I think the biggest problem is the \break when there are multiple instruments and multiple lines. As long as one of the instruments is not modified, each bar will be on one line. So I think that the current version is easier to work with because you can delete one line of code more easily than dozens of s<duration> \break.

@Nodd
Copy link
Author

Nodd commented May 13, 2023

I just noticed that it doesn't work well with the Preview functionality, the notes are added to the end after the blank lines. I think that if blank lines are configured, no note should be added so that you can see exactly what you'll get.


# Partial makes its own line
if self.scoreProperties.pickup.currentIndex() > 0:
partial_dur, partial_dots = scoreproperties.partialDurations[self.scoreProperties.pickup.currentIndex() - 1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a cleaner way to get this value, or is it fine like this ?


if num_blank:
# Compute duration for whole measure
sig = self.scoreProperties.timeSignature.currentText().strip()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, is there a cleaner way to get this value, or is it fine like this ?

partial_dur, partial_dots = scoreproperties.partialDurations[self.scoreProperties.pickup.currentIndex() - 1]
num_blank -= 1
duration_ly = ly.duration.tostring(partial_dur, partial_dots)
ly.dom.Text("s{duration}".format(duration=duration_ly), s)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found nothing about rests in ly.dom

factor = duration_frac.numerator
duration_ly = ly.duration.tostring(int(math.log2(duration)), dots, factor)

ly.dom.Text(r"\repeat unfold {num} {{ s{duration} \break }}".format(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found nothing about rests nor repeat in ly.dom

@jeanas
Copy link
Member

jeanas commented Jun 10, 2023

I skimmed this patch and found no obvious issues, although I don't feel very competent on this. Maybe @PeterBjuhr or @dliessi wants to comment?

preview.examplify(doc)
if not builder.scoreProperties.blankStaff.value():
# Add some music when blank staff are not configured
preview.examplify(doc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: isn't it possible to exemplify a blank staff?

@@ -290,6 +293,26 @@ def lySimpleMidiTempo(self, node):
val = self.metronomeValue.currentText() or '60'
return ly.dom.Tempo(dur, val, node)

# Blank staff
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Since blank staff is included in the function names the comment is unneeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to create blank staff paper (Score Wizard)
3 participants