humdrum-tools / verovio-humdrum-viewer

Verovio Humdrum Viewer
http://verovio.humdrum.org
37 stars 9 forks source link

Allow vertical searches #414

Open craigsapp opened 3 years ago

craigsapp commented 3 years ago

Allow vertical searches in msearch tool. verticalities are enclosed in parentheses, with the first element being the melodic note and the rest being vertical notes.

Example:

cd(eg)fg

Search for the melodic sequence cdefg, with note e also occurring at the same time as a g.

Qualifiers:

(e-g) means to search for an E-flat at the same time as a G.

(e-g#) means to search fro an E-flat at the same time as a G-sharp.

(e!g) means to search for an E that does not occur with a G at the same time.

(exg) means to search for an E that occurs at the same time as a G note attack

(etg) means to search for an E that occurs at the same time as a tied G note (sustain)

(e=g) means to search for an E that occurs with a G, but no other pitches in the sonority.

(egb) means to search for an E that occurs at the same time as a G and a B.

(e=gb) means to search for an E that occurs only with a G and a B (and no other sounding pitch).

(e=xgtb) means to search for an E that occurs only with a G note attack and a B note sustain. Pitch classes, e, g, and b are allowed to be duplicated.

(e==xgtb) means to search for an E that occurs only with a G note attack and a B note sustain and nothing else (except rests). Similar to a single equals sign, but more restrictive since this one does not allow duplications. Related would be (e==egb) which would mean a sonority that contains (either sounding or attacked) notes of 2 E's, 1 G and 1 G.

(e!g!b) means to search for an E that does not occur with a G note or a B note.

(e!xg) means to search for an E that does not occur at the same time as a G note attack

(*=egb) means any pitch where the only notes in the sonority are E G and B.

(23) means search for a note that has a melodic second and a veritcal third (for now octave equivalence as well, so also a vertical 10th.

(2!3) melodic second where the first note does not occur with a third.

(2!t3) melodic second where the first note does not occur with a sustained third.

(2xM3) melodic second where the frst note occurs with a major third note attack (or major 10th).

(2!xM3) melodic second where the first note does not occur at the same time as a note attack a major third above it (or a major tenth).

(14) as a rhythm: A whole note occuring at the same time as a quarter note.

(1x4) A whole note occuring at the same time as a note starting a quarter note.

(1t4) A whole note occuring at the same time as a sustained quarter note.

craigsapp commented 3 years ago

Commit https://github.com/craigsapp/humlib/commit/db2e7f863e70f9f70237eb9580051b8aba7a40c0 adds basic vertical searching.

Example:

gabc(dfa) which means to search for the melodic sequence "gabcd", and the D must have an F and A pitch sounding at the same time.

Screen Shot 2020-09-06 at 10 04 31 PM
craigsapp commented 3 years ago

Commit https://github.com/craigsapp/humlib/commit/54794337c901b8c8f57afb874e5ba689bfc114ff implements a lowest-pitch requirement for vertical searching:

(gbd) means search for all sonoities that contain at least one G, B and D:

Screen Shot 2020-09-07 at 2 09 47 PM

(gBd) means search for all sonorities that contain at least on G, B, and D, and the lowest pitch in the sonority must be a B:

Screen Shot 2020-09-07 at 2 10 54 PM

The order of the pitches in a vertical search does not matter, so (gdB) is equivalent to (gBd):

Screen Shot 2020-09-07 at 2 11 49 PM

But if the search is part of a melodic search the first note is the melodic note. So in these case the g pitch is activating the vertical search.

Searching for G being the lowest note in the sonority:

(Gbd)

Screen Shot 2020-09-07 at 2 13 40 PM

Notice that this does not necessarily mean a G chord in root position. It means that the pitch classes G B and D must be present at least once each, but there can be other pitch classes present, such as with this match in measure 5:

Screen Shot 2020-09-07 at 2 14 43 PM

Where there is an added e in the sonority.

Not yet implemented, but to require only the pitch classes G, B, and D, but no others, an equals sign has to be added to the vertical search:

(=gbd)

It will be allowed anywhere in the vertical search string (previously it was to be added after the first note to emphasize that is the melodic note, but to keep it similar it could even go at the end of the vertical search: (gbd=) or between any of the other notes (gb=d).

A single = sign means one or more of the given pitch classes. For a more specific vertical sonority, double equals == will be used to require an exact count of pitch classes, such as (==gBbd) which means that there must be only four notes in the sonority, and two of them must be B, and B also must be the lowest note in the sonority. In other words a G chord in first inversion where the third is doubled.

craigsapp commented 3 years ago

Commit https://github.com/craigsapp/humlib/commit/2e9a6c268f08cce849b1a030cc621b70a5d884d3 implements exclusive and exact vertical matching.

Examples:

Test data:

**kern  **kern  **kern  **kern
*clefF4 *clefGv2    *clefG2 *clefG2
*k[f#]  *k[f#]  *k[f#]  *k[f#]
*M3/4   *M3/4   *M3/4   *M3/4
=4  =4  =4  =4
2D; 2d; 2f#;    2a;
4GG 4d  4g  4b
=5  =5  =5  =5
4FF#    4A  4d  2dd
4GG 4B  4e  .
4AA 4c  4f# 4cc
=   =   =   =
*-  *-  *-  *-

(gbd) remains the same: meaning: search for a vertical sonority that contains one or more each of G, B, and D's. Other notes are allowed in the sonority, such as the E in the second match in measure 5:

Screen Shot 2020-09-08 at 10 52 10 AM

(=gbd) is an exclusive search: Only the diatonic pitch classes G, B, and D are allowed in the sonority. Notice that the GBDE sonority is no longer matches:

Screen Shot 2020-09-08 at 10 52 15 AM

(==gbd) is an exact search: only one G, one B and one D are allowed in the sonority. In this case nothing matches:

Screen Shot 2020-09-08 at 11 18 26 AM

(==ggbd) will match, however, since there are two G's in the test chord:

Screen Shot 2020-09-08 at 10 52 23 AM

(==gbbd) will not match, since there are not two B's in the test chord:

Screen Shot 2020-09-08 at 11 21 42 AM

(==Ggbd) will match since there are two G's and G is the lowest note in the chord:

Screen Shot 2020-09-08 at 11 23 25 AM

Chromatic searches

Chromatic exclusive searches work:

(=gnbndn)

Screen Shot 2020-09-08 at 11 24 54 AM

As well as mixed chromatic/diatonic searching:

(=gnbdn) which means G-natural, B with any chromatic alteration, D-natural:

Screen Shot 2020-09-08 at 11 25 47 AM

Chromatic and mixed exact searches do not yet work:

Screen Shot 2020-09-08 at 11 27 49 AM