no-chris / chord-symbol

The definitive chord symbol parser and renderer for Javascript/NodeJS.
https://chord-symbol.netlify.app
MIT License
151 stars 8 forks source link

chord.parserConfiguration is empty #380

Closed infojunkie closed 3 years ago

infojunkie commented 3 years ago

I'm upgrading ireal-musicxml to use chord-symbol v2.0.0. Here's how I initialize chord-symbol:

    this.parseChord = chordParserFactory();
    this.renderChord = chordRendererFactory({
      useShortNamings: true,
      printer: 'raw'
    });

When I parse a chord, I find that chord.parserConfiguration is empty. I am therefore unable to access the default altIntervals as per https://github.com/infojunkie/ireal-musicxml/commit/88d3172a5ef00393d290880552dbe3c911ab767e#diff-5d77c7a8c22384d31a9d6748dae7d1f06ebd95a6c2f8d2cae3dce0150dc38a64R982

Am I doing something wrong? I would expect the chord.parserConfiguration to include the defaults (as it did in v1.2.0).

infojunkie commented 3 years ago

Note that I don't need the chord.parserConfiguration. I could get the altered degrees from chord.normalized.alterations directly, instead of detecting alt in there.

no-chris commented 3 years ago

Hello!

Indeed this is part of the breaking change, though not properly documented 😅

The idea is that chord.parserConfiguration should only contain what you configured, and not the default values. It used to contain the default values due to the weird way this configuration was previously handled.

But I see the use case and why it was convenient for you to have this list. tbh I'm too tired today to think about it properly. But I've also started the work on the musicxml filter on my side, so the solution will definitely come up at some point 😄

infojunkie commented 3 years ago

The idea is that chord.parserConfiguration should only contain what you configured, and not the default values. It used to contain the default values due to the weird way this configuration was previously handled.

From a user's perspective, I think the expectation is to access the current configuration, regardless of whether it's default or custom.

no-chris commented 3 years ago

That would make sense indeed

no-chris commented 3 years ago

For your immediate needs, you could also decide for yourself what should be the intervals yielded by the alt modifier. After all, it's unlikely that this chord-symbol configuration will ever be exposed to your public API.

no-chris commented 3 years ago

I will consider this closed since the wanted information can now be found in the chord.normalized.alterations array (see #392), as it should have been from the start, if only I would not have rushed alt support! 🤷🏻‍♂️

Feel free to re-open if needed.

infojunkie commented 3 years ago

Thanks! When I build chord-symbol@v2.1.0 locally and point my module to it, my update branch builds successfully. However, because your branch does NOT contain the updated built library, using a github dependency will not work (since the library still contains pre-v2.1.0 code). Would be great to update your lib folder in the various branches :pray:

no-chris commented 3 years ago

Done