simple way of counting the aggregate rhythm of tied notes?

24 views
Skip to first unread message

Claire Arthur

unread,
Mar 4, 2022, 3:43:39 PM3/4/22
to starstarhug
Hi **huggers,

I was looking back through the various rhythm tools in base humdrum as well as humdrum extras and didn't seem to come across anything that could help me.... I'd love for someone to simply show me that I overlooked something!

I wanted to examine the rhythm distribution for a corpus that contains a lot of tied notes, so I need to grab the resulting duration from the tied objects (in other words, "untie" them to get the aggregate rhythm). I figured I should be aiming to output all rhythms to one record unless they are tied, keep them on the same record (then I'd do some post-processing to add numbers on the same line). It turns out it's quite hard to do this with the context command because it's really hard to use regexes with "[]"!! 

Just wondered if anyone had ideas for a simpler solution? 

Cheers,
Claire

Huron, David

unread,
Mar 4, 2022, 4:02:53 PM3/4/22
to starstarhug
Claire,

Yes, I can confirm that "context" has trouble with square brackets. However, the "humsed" command (at least on my Apple macOS Catalina 10.15.7) handles square brackets just fine.  So a possible work-around is to preprocess your data with humsed to replace square brackets with some other token that will allow context to work properly. For example:

humsed 's/\[/START/;s/\]/END/' inputfile | context -b 'START' -e 'END'

Then use humsed to eliminate the markers and us awk or some other easy language to sum all the numbers in a given line. Let me know if that's insufficiently clear.

-David




From: stars...@googlegroups.com <stars...@googlegroups.com> on behalf of Claire Arthur <claire....@gmail.com>
Sent: Friday, March 4, 2022 12:43 PM
To: starstarhug <stars...@googlegroups.com>
Subject: [**HUG] simple way of counting the aggregate rhythm of tied notes?
 
--
--
This is a message is from the **HUG newgroup.
To post to this group, send email to stars...@googlegroups.com
To unsubscribe from this group, send email to
starstarhug...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/starstarhug?hl=en
---
You received this message because you are subscribed to the Google Groups "starstarhug" group.
To unsubscribe from this group and stop receiving emails from it, send an email to starstarhug...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/starstarhug/3f612738-14c1-42a2-aa0f-3161650e7f78n%40googlegroups.com.

Claire Arthur

unread,
Mar 4, 2022, 4:12:30 PM3/4/22
to starstarhug
Good suggestion. That seemed to do the trick. Thanks David!

-Claire

Craig Sapp

unread,
Mar 12, 2022, 5:35:39 PM3/12/22
to stars...@googlegroups.com
Hello Claire,

Here is a more generalized solution which should be able to also handle music with subspines (such as piano music).   Chords are treated as a single unit, and different tie states in chord notes are ignored (only the first note in the chord will be considered).  And there are some corner cases for ties that are not yet handled properly (at spine splits, the open tie will only be searched for a tie closing in the left-hand of a spine split).


This is implemented in humlib, so to download and install:
        git clone ht...@github.com/craigsapp/humlib
        cd humlib
        make
        sudo make install
Or if you already have humlib on your computer, cd to the humlib directory and run these commands:
        make update
        make
        sudo make install

Here is an example usage on 370 Bach chorales:
        humcat -s h://chorales | durations | sortcount

Output (count on left, duration in quarter notes on right):

43648 1

29395 0.5

5385 2

2170 0.25

1253 3

1000 1.5

740 1R

655 1.5T

372 1T

250 2T

243 4

111 0.75

53 2.5T

38 3T

22 2R

16 1.75T

15 0.5R

10 0.125

9 6T

9 1.25T

8 8

8 6

8 5T

6 4T

5 3R

5 3.5T

3 0.75T

2 8T

2 2.75T

1 4R

1 2.25T

1 16T

1 4.5T

1 3.75T

1 7T

1 9T

1 14T


The most common duration is a quarter note, then eighth-note, etc.   A "T" at the end of the duration means that it was composed of a set of tied notes, "R" means the duration is from a rest, and "G" (not found in Chorales) means a grace note (but those are always having a 0 duration, so redundant).   You can use the T/R/G markers to adjust what you want to count.   For example, here is a list of only the tied notes:

        humcat -s h://chorales | durations | grep T | sortcount -p

The -p option for sortcount converts the absolute counts into percentages:

45.64 1.5T

25.92 1T

17.42 2T

3.69 2.5T

2.65 3T

1.11 1.75T

0.63 6T

0.63 1.25T

0.56 5T

0.42 4T

0.35 3.5T

0.21 0.75T

0.14 2.75T

0.14 8T

0.07 3.75T

0.07 14T

0.07 7T

0.07 16T

0.07 2.25T

0.07 9T

0.07 4.5T


The most common tied note group has the duration of a dotted quarter note (45.64% of all tie cases).

If you do not want to differentiate between tied and untied durations, but ignore rests:

        humcat -s h://chorales | durations | sed s/T// | grep -v R | sortcount

44020 1

29395 0.5

5635 2

2170 0.25

1655 1.5

1291 3

249 4

114 0.75

53 2.5

17 6

16 1.75

10 0.125

10 8

9 1.25

8 5

5 3.5

2 2.75

1 16

1 3.75

1 7

1 2.25

1 14

1 9

1 4.5



You can compare using the durations tool with other methods.  In theory the analyses should match, and if not, one (or both) of the methods has a bug that should be fixed.


---------------------------

There is also the tie tool available in the humlib repository.  The -m option will merge tied notes into a single attack (designed for cases like yours).   It can be installed via the humlib installation method described above, and you can view the results of the merge in VHV:


Screen Shot 2022-03-12 at 2.26.24 PM.png

Note whole note in Tenor measure 4 which has a quarter note merger from the following measure where there is now a black spot.

     humcat -s h://chorales | tie -m | durations | sortcount

44020 1

29395 0.5

5635 2

2170 0.25

1655 1.5

1291 3

740 1R

249 4

114 0.75

53 2.5

22 2R

17 6

16 1.75

15 0.5R

10 0.125

10 8

9 1.25

8 5

5 3R

5 3.5

2 2.75

1 14

1 9

1 2.25

1 4R

1 16

1 4.5

1 3.75

1 7



Mozart piano sonata duration histogram:

    humcat -s h://mozart/sonatas | durations | sed 's/[TG]//' | grep -v R | sortcount -p

The most common is a 16th note at 39% of note rhythms:

39.11 0.25

28.58 0.5

10.13 1

7.16 0.125

4.61 0.166667

3.02 0.333333

1.81 0

1.47 1.5

1.29 2

1.08 0.75

0.39 0.0625

0.35 3

0.31 0.375

0.12 1.25

0.12 0.0833333

0.12 4

0.05 0.625

0.05 2.5

0.03 0.03125

0.03 1.75

0.02 6

0.02 0.666667

0.02 0.875

0.02 3.5

0.02 2.25

0.01 1.33333

0.01 0.1875

0.01 0.0714286

0.01 5

0.01 1.125

0 0.6875

0 1.375

0 0.3125

0 0.5625

0 4.5

0 3.25

0 1.6875

0 2.75

0 0.571429

0 7

0 1.16667

0 16

0 5.25

0 4.75

0 0.0416667

0 0.583333

0 1.0625


-=+Craig


--

Craig Sapp

unread,
Mar 12, 2022, 6:33:03 PM3/12/22
to stars...@googlegroups.com
Hello Claire et al.,

Here is related analysis that is not exactly the original task that was wanted, but somewhat related and of interest for polyphonic music rhythm analyses.   The command:

     humcat -s h://chorales | composite -x | shed -e 's/kern-comp/kern/X' | durations | sortcount -p

does a duration analysis of the composite rhythms of the input scores.   The above command pipeline produces the results:

69.01 0.5

19.34 1

7.06 0.25

2.77 2

0.93 3

0.59 1R

0.18 4

0.04 1.5

0.03 0.125

0.02 0.75

0.01 2R

0.01 8

0.01 6


So 69% of the Bach chorales have a composite rhythmic value of an eighth note, and 19% quarter notes.

The composite tool option  -x suppresses the input score from being echoed with the output analysis.

The composite analysis is output into a spine headed by **kern-comp (for composite analysis in kern-like format).   VHV understands such formats as **kern-label and will treat the spine as notatable music, and I used **kern-comp to keep the input/analysis of the composite tool easily separable.

shed -e 's/kern-comp/kern/X' converts **kern-comp to **kern to allow the analysis data to be processed by the durations tool (since durations will only recognize **kern spines).   Shed is related to humsed ("shed" means "Humdrum SED" with the letters interposed to make it easier to say as well as make it less confused with humsed which has a similar name), but it has a different interface that allows for stream editing of Humdrum syntax beyond data lines:
In this case the sed command (with a non-standard X operator for editing exclusive interpretation tokens):
     s/kern-comp/kern/X
or more compact:
     s/-comp//X
means to change "kern-comp" to "kern" only if the token is an exclusive interpretation.

Here is an example of the composite tool viewed in VHV (with the analysis compiled and included along with the input data):

Screen Shot 2022-03-12 at 3.23.45 PM.png

Here is only the composite analysis displayed:

Screen Shot 2022-03-12 at 3.26.52 PM.png

-=+Craig


On Fri, 4 Mar 2022 at 12:43, Claire Arthur <claire....@gmail.com> wrote:
--
Reply all
Reply to author
Forward
0 new messages