humlib icon indicating copy to clipboard operation
humlib copied to clipboard

Inconsistent rhythm analysis when using HumdrumFile.read()

Open malcolmsailor opened this issue 10 months ago • 0 comments

There seems to be an issue reading certain humdrum files using the approach given in the example in the readme.

Here, the test file I'm using is humdrum-data/polish/toeschi-carl-joseph/pl-sa--236-a-vi-40--001-001_sinfonia-allegro.krn. I save the following code copied from the example in README in cli/testread.cpp and compiling and running it on the test file:

#include "humlib.h"

using namespace std;
using namespace hum;

int main(int argc, char **argv) {
  if (argc != 2) {
	 return 1;
  }
  HumdrumFile infile;
  if (!infile.read(argv[1])) {
	 return 1;
  }
  return 0
}

When I run that, I get

Error: Inconsistent rhythm analysis occurring near line 722
Expected durationFromStart to be: 190 but found it to be 377/2
Line: 8G\       .       8B-/    .       16dd\yy .       16f/    .       .       .       .       .

On the other hand, if I use the file-reading approach that I found in cli/durations.cpp, as follows, I don't get any error:

#include "humlib.h"

using namespace std;
using namespace hum;

int main(int argc, char **argv) {
  Options options;
  options.process(argc, argv);

  HumdrumFileStream instream(options);
  HumdrumFile infile;
  while (instream.read(infile)) {
  }

  return 0;
}

I'm not sure whether this is a bug in the code in the README, a bug in the HumdrumFile.read method, or an error in the file (although I found similar behavior with a number of files in the polish/ folder).

malcolmsailor avatar Apr 16 '24 18:04 malcolmsailor