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

Linebreak algorithm #27

Closed
barbeque-squared opened this issue Oct 6, 2018 · 4 comments
Closed

Linebreak algorithm #27

barbeque-squared opened this issue Oct 6, 2018 · 4 comments

Comments

@barbeque-squared
Copy link
Member

In #26 I noted that the specific beats at which line breaks occured are (at the time of writing) ignored by the parser. Currently, the song format files have line breaks at specific beats, but other than saving some computation work, is it really that useful? It's probably not hard to add a little algorithm that, given two sentences A and B, computes the optimal line break beat.

Here's some pseudo algorithm, I've explicitly used the notes for start/endbeat here, there's a convenience method on the Sentence object as well which will do just that (the important thing to remember is that a Sentence doesn't have any "padding"):

  • If (A.lastnote.endbeat >= B.firstnote.startbeat) return A.lastnote.endbeat
    (we can't really do anything useful in this situation)
  • Else:
    • compute the midway (or 2/3 or something else) point between A.lastnote.endbeat and B.firstnote.startbeat, call it C for now. I checked some random songs and most seem to have it at around 60%
    • compute some A.lastnote.endbeat + (x seconds * BPM) and call it D for now. One second is probably fine.
    • If C < D ? return C : return D

Essentially, this will cause two equidistant sentences to always have the same (relative) linebreak beat.

@barbeque-squared
Copy link
Member Author

This can probably be implemented the easiest in the MutableVoice.AddSentence function, by changing the List<Sentence> to List<MutableSentence> so that we can easily change the start of the current sentence and end of the previous sentence when a new one is added?

@basisbit
Copy link
Member

linebreak timings are there for a reason. Sometimes you want a linebreak to happen very late, so the next line is a bit more of a surprise and other times - especially in more fast paced songs, you'll want the line breaks to happen earlier, so one still has enough time to read ahead.
I'd suggest for those files where linebreaks are earlier or later than the previous / next note, your suggested linebreak algorithm should be used whenever the txt file's linebreak information is trash..

@basisbit
Copy link
Member

fyi, if you press t in the USDX editor and then press s to save, it will adjust all linebreaks to be two third between the first and last notes, if possible.

@barbeque-squared
Copy link
Member Author

didn't know about the 't' in the editor, but after playing around with it for a bit, I find that setting them myself works just fine.
I'm also closing this because after some discussion, we decided that people should just fix their txt's instead of us trying to do it for them. The current state of the branch will reject invalid txt's, even if they could be 'fixed' by this feature request.

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

No branches or pull requests

2 participants