[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Change stem direction based on position of note in staff?
From: |
Stefano Antonelli |
Subject: |
Re: Change stem direction based on position of note in staff? |
Date: |
Sun, 1 Sep 2024 20:29:29 +0000 |
User-agent: |
Evolution 3.36.5-0ubuntu1 |
On Sun, 2024-09-01 at 13:44 +0200, Lukas-Fabian Moser wrote:
> So you want to enter (for instance) the Cr part as a separate
> LilyPond voice? In this case something like 1 R1 1 R1 or even \breve
> \breve? (The point being is that you want to enter durations and
> rests, even though they are in some sense arbitrary?)
Yes they are in some sense arbitrary due to the nature of drums.
What I'd like to see is a syntax like this:
\beatOne = \drummy {
{hihat},
{snare}.
{bass drum},
}
Which can then be combined with:
\beatTwo = \drummy {
{hihat},
{high tom},
{low tom},
{snare},
{bass drum},
{pedal hihat},
}
When \beatOne and \beatTwo are combined in the score, some "code"
should put those different and uniquely identifiable notes into the
required voices. If it helps, they can be sorted into voices by the
note's staff position. That was my earlier thought.
But I see a problem with it. Any bar check errors probably won't tell
you where the real problem is (ie. what line). So it's probably best
to find a way to use << {...} \\ {...} >> (ie. separate voices) and
somehow reduce and combine those voices into just one or two at the
appropriate point in time. I don't know if that's feasible.
> > It's not just that. It's interweaving the kick and combined kicks
> > with
> > the other instruments grouped within that same voice.
> I disagree insofar that I think that this isn't actually a
> complication.
I think I've been confusing your use of kick = event, to my use of kick
= bass drum. I'll stop using kick for bass drum. And I understood
everything that you wrote.
> This is a very general problem - algorithmically converting a
> sequence of points in musical time into a sequence of notes
> (/rests/ties). There are certainly lots of possible styles, depending
> on musical genre, time signature, instruments etc., but it's a
> problem that might be interesting to tackle. One just should think
> carefuly about the desired degree of configurability etc.
It sounds like lilypond already has this facility of "converting a
sequence of points in musical time into a sequence of notes
(/rests/ties)."
If lilypond could understand something like <a4 b8 c16> then maybe it
would be easier? In that case, it should reduce to a chord of the
smallest note value so <a b c>16 and carry the remaining duration as a
rest (r8.). It would probably need to understand rest chords (as silly
as that sounds) as well.
Here's a trivial example of what combining lines (or independent
voices) might look like:
{ r1 }
{ r4 sn4 r4 sn4 }
1. <r1 r4> = <r4 r4> , r2.
2. <r2. sn4> = <r4 sn4> , r2
3. <r2 r4> = <r4 r4> , r4
4. <r4 sn4>
The output of that would be:
6. <r4 r4> <r4 sn4> <r4 r4> <r4 sn4>
Which reduces to:
7. r4 sn4 r4 sn4
And here's another:
{ r2 tomh8 tomh8 tomh8 tomh8 }
{ r4 sn4 r4 sn4 }
1. <r2 r4> = <r4 r4> , r4
2. <r4 sn4> = <r4 sn4> ,
3. <tomh8 r4> = <tomh8 r8> , r8
4. <r8 tomh8> = <tomh8 r8> ,
5. <tomh8 sn4> = <tomh8 sn8> , r8
6. <r8 tomh8> = <tomh8 r8> ,
7. <r4 r4> <r4 sn4> <tomh8 r8> <tomh8 r8> <tomh8 sn8> <tomh8 r8>
8. r4 sn4 tomh8 tomh8 <tomh8 sn8> tomh8
The smallest subdivision was always used for simultaneous notes. The
extra duration became a rest. In none of those cases did an extended
note consume a following rest. I'm not sure what that looks like, but
it would need to be done after everything has been combined.
If the notes were entered with
beatOne = \drummode {
<< {...} \\ {...} \\ {...} \\ {...} >>
}
where any note could appear in any voice, and it was possible to
\drumcombine { \beatOne \beatTwo ... \beatLast }
into two voices with some way to define the combination, that would be
as close to perfect as it could get. I think.
I'll have to look into how \partcombine is implemented. It might be
the right place to start.
In some cases I might use a silent rest rather than a rest. I don't
know how that should be handled automatically.
There's also the issue of how \parenthesize, \accent and others
propagate.
> > https://github.com/Whatang/DrumBurp/blob/1.1.2/src/Notation/lilypond.py
> Thanks for the links, I hope I'll have time to dive into the source
> soon.
From what I understand, drumburp puts the note into either \voiceOne or
\voiceTwo depending on the stem direction. There is a drum kit editor
dialog (which was hard to find) where you can set the stem direction of
each note. If you change all the stem directions for each notehead
(tedious), then you can get cymbals and drums, hands and feet, or all
stems up.
The all stems up is broken though. The stems start as up, but in the
2nd bar it becomes stems down for the rest of the piece. I can fix it
with:
sed -i s'\\new DrumVoice {'\\new DrumVoice { \\stemUp'g db.ly
and then all the stems are up.
lilypond.py just generates text which it writes as a valid lilypond
file using the internal tab data. It knows where on the beat grid the
note falls. The beat grid can be any kind of subdivision.
So basically, it calculates the duration between notes in "beat time"
and converts it to a note duration and/or rest.
The important bit is probably makeLilyDuration(beat, ticks, tickNum):
<
https://github.com/Whatang/DrumBurp/blob/db58c18d7a539a64910dc11a30a2174dba233d40/src/Notation/lilypond.py#L120
>
There's some special handling of tuplets elsewhere though. But you
probably don't need to bother looking at any of it.
> In the example you posted, they seem not to do anything. But from
> reading the source, I think they are supposed to act in situations
> where LilyPond would create two simultaneous rests, in order to
> decide which one to keep.
A workaround then for when the python code creates something ambiguous?
Or is it handling the case where a rest occurs in both voices at the
same time?