craigsapp / humextra

C++ programs and library for processing Humdrum data files. Best to install from https://github.com/humdrum-tools/humdrum-tools . See https://github.com/craigsapp/humlib for modernized Humdrum file parsing library.
http://extras.humdrum.org
25 stars 8 forks source link

Adding the verbosity option to the arg parser of tsroot #5

Closed napulen closed 7 years ago

napulen commented 7 years ago

I still don't know why I am getting garbage in the tmpdir variable at line 172 and beyond: cout << "\t" << tmpdir << "/" << buffer << "." << randval << endl; but I am guessing it is some broken pointer, similar to this: http://stackoverflow.com/questions/33234693/strange-stdcout-behaviour-with-const-char/33234729

craigsapp commented 7 years ago

I think that the main problem with garbage after tmpdir is due to me using the wrong string function, using string::data() rather thanstring::c_str(). The difference between these two is that string::data() is not null-character terminated, so if the byte after the returned char* is not a null character, then garbage will be included from outside of the array. I am running this program in SELinux, which perhaps zeros out memory before loading a program, so I never notice such problems.

Commit https://github.com/craigsapp/humextra/commit/cdd011adf4f5da045de8e3b5f1c7d777478d1e61 should fix the problem. I have successfully compiled tsroot with the updated code but still have to run it to test it out.

napulen commented 7 years ago

I remember changing the data() function to c_str(), and it was still breaking the buffer for me, so it looked like an out of scope problem was more likely. However, I am not sure. I am running on a Linux Mint VM. Thanks, I will check that commit later.

craigsapp commented 7 years ago

Assigning string::c_str() to a const char* as I was also doing is also not so good as well, since the pointer can become invalid if a non-const string function is used after assignment, or the string is destroyed. So that might be the real problem.

craigsapp commented 7 years ago

The new version is working for me in Fedora 24:

bin/tsroot -rp --midir bin --meldir bin h://chorales/chor001

I copied the melisma programs plus the key2humdrum and harmony2humdrum scripts into the humextra/bin directory (and ran the command from the root directory of humextra), so --midir and --meldir point to the same directory. The -r option generates the roman-numeral analysis, and the -p option prepends the analysis to the start of the input data spines.

Result:

!!!COM: Bach, Johann Sebastian
!!!CDT: 1685/02/21/-1750/07/28/
!!!OTL@@DE: Aus meines Herzens Grunde
!!!OTL@EN:      From the Depths of My Heart
!!!SCT: BWV 269
!!!PC#: 1
!!!AGN: chorale
**tshrm **tsroot    **kern  **kern  **kern  **kern
*ICvox  *ICvox  *ICvox  *ICvox  *ICvox  *ICvox
*   *   *Ibass  *Itenor *Ialto  *Isoprn
*   *   *I"Bass *I"Tenor    *I"Alto *I"Soprano
*>[A,A,B]   *>[A,A,B]   *>[A,A,B]   *>[A,A,B]   *>[A,A,B]   *>[A,A,B]
*>norep[A,B]    *>norep[A,B]    *>norep[A,B]    *>norep[A,B]    *>norep[A,B]    *>norep[A,B]
*>A *>A *>A *>A *>A *>A
*   *   *   *oclefC4    *oclefC3    *oclefC1
*   *   *clefF4 *clefGv2    *clefG2 *clefG2
*k[f#]  *k[f#]  *k[f#]  *k[f#]  *k[f#]  *k[f#]
*   *   *G: *G: *G: *G:
*M3/4   *M3/4   *M3/4   *M3/4   *M3/4   *M3/4
*MM100  *MM100  *MM100  *MM100  *MM100  *MM100
.   G   4GG 4B  4d  4g
=1  =1  =1  =1  =1  =1
.   G   4G  4B  4d  2g
.   C   4E  8cL 4e  .
.   C   .   8BJ .   .
.   D   4F# 4A  4d  4dd
=2  =2  =2  =2  =2  =2
I   G   4G  4G  2d  4.b
V   D   4D  4F# .   .
.   D   .   .   .   8a
vi  E   4E  4G  4B  4g
=3  =3  =3  =3  =3  =3
IV  C   4C  8cL 8eL 4.g
.   C   .   8BJ 8d  .
.   C   8BBL    4c  8e  .
.   D   8AAJ    .   8f#J    8a
I   G   4GG 4d  4g  4b
=4  =4  =4  =4  =4  =4
V   D   2D; 2d; 2f#;    2a;
I   G   4GG 4d  4g  4b
=5  =5  =5  =5  =5  =5
Vb  D   4FF#    4A  4d  2dd
I   G   4GG 4B  4e  .
V7c D   4AA 4c  4f# 4cc
=6  =6  =6  =6  =6  =6
Ib  G   4BB 4d  2g  4b
ii7b    A   4C  4e  .   2a
V7  D   4D  8dL 4f# .
.   D   .   8cJ .   .
=7  =7  =7  =7  =7  =7
I   G   2GG;    2B; 2d; 2g;
=:|!    =:|!    =:|!    =:|!    =:|!    =:|!
*>B *>B *>B *>B *>B *>B
.   G   4GG 4d  [4g 4b
=8  =8  =8  =8  =8  =8
.   G   4GG 4d  8gL]    4b
.   G   .   .   8f#J    .
ii  A   4AA 4c  8eL 4cc
.   A   .   .   8f#J    .
Ib  G   4BB 8BL [4g 4dd
.   G   .   8AJ .   .
=9  =9  =9  =9  =9  =9
.   G   4.BB    8BL 8gL]    4.dd
.   G   .   8cJ 8aJ .
.   G   .   4d  8gL .
.   D   8AA .   8f#J    8cc
.   G   4GG 4d  4g  4b
=10 =10 =10 =10 =10 =10
V   D   2D; 2d; 2f#;    2a;
vi  E   [4E 4B  4e  4g
=11 =11 =11 =11 =11 =11
.   E   4E] 4G  4e  2b
Ic  G   4D  4B  8f#L    .
.   G   .   .   8gJ .
iib A   4C  4e  4a  4cc
=12 =12 =12 =12 =12 =12
V   D   4.BB    2d  4a  2dd
V7  D   .   .   4.g .
.   D   8C  .   .   .
.   D   4D  4d  .   4cc
.   D   .   .   8f# .
=13 =13 =13 =13 =13 =13
I   G   8GGL    2.d 2g  2.b
.   G   8AAJ    .   .   .
.   G   4BB .   .   .
V7/IV   G   4GG .   4f  .
=14 =14 =14 =14 =14 =14
IV  C   2C; 2c; 2e; 2g;
I   G   4GG 4d  4g  4b
=15 =15 =15 =15 =15 =15
V7b D   4FF#    8dL 4.a 2dd
.   D   .   8cJ .   .
I   G   4GG 4B  .   .
.   G   .   .   8g  .
V7c D   4AA 4c  4f# 4cc
=16 =16 =16 =16 =16 =16
Ib  G   4BB 2d  2g  2b
.   G   4GG .   .   .
V7  D   4D  8dL [4f#    4a
.   D   .   8cJ .   .
=17 =17 =17 =17 =17 =17
vi7d    E   8EL 4B  8f#L]   4.g
.   E   8D  .   8eJ .
ii7 A   8C  4c  8eL .
.   A   8BB .   8f#J    8a
I   G   8AA 4d  4g  4b
.   G   8GGJ    .   .   .
=18 =18 =18 =18 =18 =18
V   D   2D; 2d; 2f#;    2a;
I   G   [4G 4d  4g  4b
=19 =19 =19 =19 =19 =19
V   D   4G] 2d  2a  2dd
.   D   4F# .   .   .
IVb C   [4E 4e  8gL 4cc
.   C   .   .   8f#J    .
=20 =20 =20 =20 =20 =20
vi7d    E   8EL]    2e  2g  4b
.   E   8DJ .   .   .
ii7b    A   4C  .   .   2a
V7  D   4D  8dL 4f# .
.   D   .   8cJ .   .
=21 =21 =21 =21 =21 =21
I   G   2GG;    2B; 2d; 2g;
==  ==  ==  ==  ==  ==
*-  *-  *-  *-  *-  *-
!!!YOR1: 371 vierstimmige Choralges&auml;nge von Johann Sebastian Bach,
!!!YOR2: 4th ed. by Alfred D&ouml;rffel (Leipzig: Breitkopf und H&auml;rtel,
!!!YOR3: c.1875). 178 pp. Plate "V.A.10".  reprint: J.S. Bach, 371 Four-Part
!!!YOR4: Chorales (New York: Associated Music Publishers, Inc., c.1940).
!!!SMS: B&H, 4th ed, Alfred D&ouml;rffel, c.1875, plate V.A.10
!!!EED:  Craig Stuart Sapp
!!!EEV:  2009/05/22
screen shot 2017-06-05 at 10 55 57 pm
napulen commented 7 years ago

Thank you, I also copied the binaries from melisma into the same bin folder than humextra so everything could be found by the shell command running inside tsroot. One question out of curiosity, has anyone ever tried to use the probabilistic approach from David Temperley (a.k.a. Melisma2) with the roman numerals of the key program to produce a functional harmonic analysis based on this? I am thinking on doing that for my M.Sc. Thesis, depending on the time. Something like this:

tsroot = kern2melisma | meter | harmony | key | key2humdrum tsroot2 = kern2melisma | melisma2 | key | key2humdrum

Does that make sense?

yipcma commented 7 years ago

I'm trying to get hold of the melisma2. The website is down from the esm link. Anyone knows where one may fetch melisma2? Thanks a lot in advance.

napulen commented 7 years ago

As it was a couple of months ago.

polyph.zip

yipcma commented 7 years ago

thanks a lot @napulen