Closed jacekiwaszko1 closed 4 years ago
timebase
is part of the standard Humdrum tools, and they in general do not allow rhythms to cross barlines. The parser in Humextras does not allow it either, but the parser in Humlib does. So re-implementing timebase in humlib is what you want. In addition, that would allow it to be added as a filter in VHV.
One temporary solution to the problem is to make every barline a global comment, since durations can pass through global comments in the Humdrum toolkit tools. Then remove the global comments afterwards. Also note that timebase eats grace notes, so you need to comment these out as well to preserve them when passing the data through timebase. In addition, you need to use the correct minimum time unit (calculated by the humextra minrhy
tool) because an non-minimal timebase will each shorter duration events. In other words, if you timebase -t 16
a score, then all of the 32-note offbeats will be removed. So in its current form, the timebase tool is not a general solution for adding extra spaces to fill in for tremolos. A separate tremolo-expansion tool may be ideal; otherwise, a timebase feature that does not drop sub-timebase events nor graces notes, but allows note durations across barlines is what you want 😜
The partjoin script (part of humextra) preserves grace notes in this manner: http://extras.humdrum.org/scripts/perl/partjoin/partjoin
Before the data is sent to timebase, tokens with q
are prefixed with !QqQ
to make them local comments:
if ($line =~ /q/) {
my @fields = split(/\t/, $line);
for (my $j=0; $j<@fields; $j++) {
$fields[$j] = "!QqQ$fields[$j]";
}
$contents[$i] = join("\t", @fields);
}
Perhaps a global comment would work as well (I was probably being careful about a non-gracenote from being commented, but in theory grace notes and regular notes should never occur on the same line.
The QqQ is a string that is used to mark the comment so that it can be unconverted from a local comment later. In partjoin
I do it the hard way, but in general:
$line =~ s/\!QqQ//g;
Should work to remove the embedded grace notes.
Also remember alt-shift-D which adds empty data lines above the current line:
The pressing alt-shift-D twice:
And alt-shift-I adds an empty interpretation line and alt-shift-L adds an empty local comment line.
VHV (and humlib) have an initial implementation of a tremolo tool.
Example input:
**kern **kern **kern
*M4/4 *M4/4 *M4/4
=1 =1 =1
1c@8@ 4e 2g
* *^ *
. 4f@8@ 2.d@16@ .
. 4g@16@ . 4.g
. 4a@32@ . .
. . . 8g
* *v *v *
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f 4.g 4.b
. . 8g 8b
=3|| =3|| =3||
1c@16@ 2e 2g
. 2e@8@ 4.g
. . 8g
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f@32@ 4.g 4.b
. . 8g 8b
= = =
*- *- *-
The way it will work is that you add the tremolo duration after the token in the form @#@
where #
is the rhythmic value of the tremolo. For example @8@
means the tremolo is 8th notes. And 1c@8@
menas a whole note which has 8 8th notes in a tremolo.
Here is the current output, which adds lines for the notes that will be filled in with the next version of the tool:
**kern **kern **kern
*M4/4 *M4/4 *M4/4
=1 =1 =1
1c@8@ 4e 2g
. . .
* *^ *
. 4f@8@ 2.d@16@ .
. . . .
. . . .
. . . .
. 4g@16@ . 4.g
. . . .
. . . .
. . . .
. 4a@32@ . .
. . . .
. . . .
. . . .
. . . 8g
. . . .
. . . .
. . . .
* *v *v *
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f 4.g 4.b
. . 8g 8b
=3|| =3|| =3||
1c@16@ 2e 2g
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. 2e@8@ 4.g
. . .
. . .
. . .
. . .
. . .
. . 8g
. . .
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f@32@ 4.g 4.b
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . 8g 8b
. . .
. . .
. . .
= = =
*- *- *-
After filling in the tremolo notes, the @#@
marker will be removed (it is otherwise illegal **kern
data).
This initial version of the tremolo tool will be somewhat equivalent to what you had in mind for using timebase and can already speed up entry of tremolo notes. After finishing the tool, I will add it to musicxml2hum to automatically convert tremolos from MusicXML to Humdrum which will make tremolo note entry unnecessary. Probably *tremolo
markers may still need to be added (I can think about that later).
The second step in the tremolo tool is implemented: adding the individual notes of the tremolos. Here is a demo:
(1) Add special markup, such as @16@
to notes/chords to indicate 16th note tremolos:
The notation is displayed correctly because I put the tremolo rhythm after the note rhythm.
Tremolos inside of beams are not currently allowed. Tremolos with tuplets are not currently allowed.
(2) Adding the tremolo
filter expands the note to the individual tremolo notes:
I will probably add *tremolo
marks: maybe just before the first tremolo in each spine, and *Xtremolo
after the last tremolo in a spine. This might mean that intermediary repeated-note groupings would need to be adjusted by breaking up the tremolo interpretation into smaller units.
(3) Here is a manual addition of *tremolo
for now:
(4) compiling the tremolo filter to see the processed data (which will typically be done when using the filter to edit a piece, and this will be done automatically by the musicxml2hum converter in the next step of implementation:
New text data, which includes a slur (the slur needs is handled correctly by the tremolo filter, but the conversion from Humdrum-to-MEI needs to be adjusted to handle it properly as well.
Test data:
**kern **kern **kern
*M4/4 *M4/4 *M4/4
=1 =1 =1
*tremolo *tremolo *
1c@8@ 4e 2g
* *^ *
. (4f@8@ 2.d@16@ .
. 4g@16@ . 4.g
. 4a@32@) . .
. . . 8g
* *v *v *
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f 4.g 4.b
. . 8g 8b
=3|| =3|| =3||
1c@16@ 2e 2g
. 2e@8@ 4.g
. . 8g
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f@32@ 4.g 4.b
. . 8g 8b
= = =
*- *- *-
!!!filter: tremolo
the musicxml2hum
tool now can convert tremolos. Here is a demo:
Source data in MuseScore:
Converted Humdrum data:
**kern **kern **kern
*part3 *part2 *part1
*staff3 *staff2 *staff1
*clefG2 *clefG2 *clefG2
*k[] *k[] *k[]
*M4/4 *M4/4 *M4/4
=1 =1 =1
*tremolo * *
8cL 4e 2g
8c . .
* *^ *
* *tremolo * *
8c 8fL 16dLL .
. . 16d .
8c 8fJ 16d .
. . 16d .
8c 16gLL 16d 4.g
. 16g 16d .
8c 16g 16d .
. 16gJJ 16d .
8c 32aLLL 16d .
. 32a . .
. 32a 16d .
. 32a . .
8cJ 32a 16d 8g
. 32a . .
. 32a 16dJJ .
. 32aJJJ . .
* *v *v *
=2 =2 =2
1c 1e 2d 2f 2g 2b
. 2d 2f 4.g 4.b
. . 8g 8b
=3|| =3|| =3||
16cLL 2e 2g
16c . .
16c . .
16c . .
16c . .
16c . .
16c . .
16c . .
16c 8eL 4.g
16c . .
16c 8e .
16c . .
16c 8e .
16c . .
16c 8eJ 8g
16cJJ . .
=4 =4 =4
1c 1e 2d 2f 2g 2b
. 32d 32fLLL 4.g 4.b
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f .
. 32d 32f 8g 8b
. 32d 32f .
. 32d 32f .
. 32d 32fJJJ .
= = =
*- *- *-
!!!system-decoration: s1,s2,s3
No *Xtremolo
marks are added at the moment, just *tremolo
just before first tremolo in spine.
MusicXML input:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<identification>
<encoding>
<software>MuseScore 3.3.4</software>
<encoding-date>2020-03-19</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="yes" value="yes"/>
<supports element="print" attribute="new-system" type="yes" value="yes"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7.05556</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1683.78</page-height>
<page-width>1190.55</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<word-font font-family="FreeSerif" font-size="10"/>
<lyric-font font-family="FreeSerif" font-size="11"/>
</defaults>
<part-list>
<score-part id="P1">
<part-name></part-name>
<score-instrument id="P1-I1">
<instrument-name></instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
<score-part id="P2">
<part-name></part-name>
<score-instrument id="P2-I1">
<instrument-name></instrument-name>
</score-instrument>
<midi-device id="P2-I1" port="1"></midi-device>
<midi-instrument id="P2-I1">
<midi-channel>2</midi-channel>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
<score-part id="P3">
<part-name></part-name>
<score-instrument id="P3-I1">
<instrument-name></instrument-name>
</score-instrument>
<midi-device id="P3-I1" port="1"></midi-device>
<midi-instrument id="P3-I1">
<midi-channel>3</midi-channel>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="346.99">
<print>
<system-layout>
<system-margins>
<left-margin>0.00</left-margin>
<right-margin>0.00</right-margin>
</system-margins>
<top-system-distance>170.00</top-system-distance>
</system-layout>
</print>
<attributes>
<divisions>2</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note default-x="87.63" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="209.12" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="307.54" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
</measure>
<measure number="2" width="244.12">
<note default-x="16.76" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="16.76" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="111.00" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="111.00" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="194.25" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
<note default-x="194.25" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
</barline>
</measure>
<measure number="3" width="238.52">
<note default-x="16.76" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="111.00" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="194.25" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
</measure>
<measure number="4" width="247.52">
<note default-x="16.76" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="16.76" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="111.00" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="111.00" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>up</stem>
</note>
<note default-x="194.25" default-y="-30.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
<note default-x="194.25" default-y="-20.00">
<chord/>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
</measure>
</part>
<part id="P2">
<measure number="1" width="346.99">
<print>
<staff-layout number="1">
<staff-distance>65.00</staff-distance>
</staff-layout>
</print>
<attributes>
<divisions>2</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note default-x="87.99" default-y="-145.00">
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note default-x="148.55" default-y="-140.00">
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<notations>
<ornaments>
<tremolo type="single">1</tremolo>
</ornaments>
</notations>
</note>
<note default-x="209.12" default-y="-135.00">
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<notations>
<ornaments>
<tremolo type="single">2</tremolo>
</ornaments>
</notations>
</note>
<note default-x="269.68" default-y="-130.00">
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<notations>
<ornaments>
<tremolo type="single">3</tremolo>
</ornaments>
</notations>
</note>
<backup>
<duration>6</duration>
</backup>
<note default-x="148.19" default-y="-150.00">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>6</duration>
<voice>2</voice>
<type>half</type>
<dot/>
<stem>down</stem>
<notations>
<ornaments>
<tremolo type="single">2</tremolo>
</ornaments>
</notations>
</note>
</measure>
<measure number="2" width="244.12">
<note default-x="16.76" default-y="-150.00">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="16.76" default-y="-140.00">
<chord/>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="110.64" default-y="-150.00">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="110.64" default-y="-140.00">
<chord/>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
</barline>
</measure>
<measure number="3" width="238.52">
<note default-x="16.76" default-y="-145.00">
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="110.64" default-y="-145.00">
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<ornaments>
<tremolo type="single">1</tremolo>
</ornaments>
</notations>
</note>
</measure>
<measure number="4" width="247.52">
<note default-x="16.76" default-y="-150.00">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="16.76" default-y="-140.00">
<chord/>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
<note default-x="110.64" default-y="-150.00">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<ornaments>
<tremolo type="single">3</tremolo>
</ornaments>
</notations>
</note>
<note default-x="110.64" default-y="-140.00">
<chord/>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
</note>
</measure>
</part>
<part id="P3">
<measure number="1" width="346.99">
<print>
<staff-layout number="1">
<staff-distance>65.00</staff-distance>
</staff-layout>
</print>
<attributes>
<divisions>2</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note default-x="84.67" default-y="-260.00">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
<notations>
<ornaments>
<tremolo type="single">1</tremolo>
</ornaments>
</notations>
</note>
</measure>
<measure number="2" width="244.12">
<note default-x="13.80" default-y="-260.00">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
</note>
<note default-x="13.80" default-y="-250.00">
<chord/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
</barline>
</measure>
<measure number="3" width="238.52">
<note default-x="13.80" default-y="-260.00">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
<notations>
<ornaments>
<tremolo type="single">2</tremolo>
</ornaments>
</notations>
</note>
</measure>
<measure number="4" width="247.52">
<note default-x="13.80" default-y="-260.00">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
</note>
<note default-x="13.80" default-y="-250.00">
<chord/>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>whole</type>
</note>
</measure>
</part>
</score-partwise>
There will be bugs to fix and some more enhancements, but this is close enough for now.
Fingered tremolos need to be implemented next.
timebase
unfortunately does not work with rhytmic values crossing the barline:file.krn
timebase -t 16 file.krn
output:
Would it be possible to allow this kind of rhytms in
timebase
?It would be also very helpful if
timebase
was built in Verovio Humdrum Viewer - that would help to deal with tremolo for instance.