Giter Site home page Giter Site logo

no-chris / chord-symbol Goto Github PK

View Code? Open in Web Editor NEW
148.0 3.0 8.0 28.39 MB

The definitive chord symbol parser and renderer for Javascript/NodeJS.

Home Page: https://chord-symbol.netlify.app

License: MIT License

JavaScript 66.97% HTML 33.03%
chords music music-theory parser guitar guitar-chords piano ukulele chord-parsing chord

chord-symbol's Introduction

Build Status Coverage Status codebeat badge

ChordSymbol

ChordSymbol is the definitive chord symbol parser and renderer for Javascript/NodeJS.

Available packages

Package name Desription
chord-symbol The core library for parsing and rendering chord symbols
chord-symbol-ultimateguitar Generate Ultimate Guitar-friendly chord symbols

chord-symbol's People

Contributors

darrylnoakes avatar dependabot-preview[bot] avatar dependabot[bot] avatar ecstrema avatar no-chris avatar thbar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chord-symbol's Issues

Cadd4 is parsed as Csus(add3)

Cadd4 is parsed as Csus(add3), which I would like to understand better.

  1. Is this the more technically "correct" name for the chord? If not, why is it parsed as it is?

  2. Is there any way I can keep/render the simpler version?

Changed `Chord` type to a discriminated union

Could the Chord type be changed to a union? Preferably made up of two named subtypes (e.g., ChordData and ChordParseError).
Then, instead of checking every property I want to use, I can simply check whether the error property is present or not and the type will be narrowed.

Many links are broken

Hi Christophe, thanks for making this incredible project. I noticed that many links (e.g. the link to the API documentation on https://chord-symbol.netlify.app/, the link to modifiers.js in /chord-symbol/packages/chord-symbol/README.md) are broken and am creating this issue to let you know. In both of these cases, adding /packages/chord-symbol after the initial chord-symbol in the link fixes the issue.

UltimateGuitar replace entries will likely fail for several entries?!

I believe the current replace entries will fail in several instances.

An updated version I use is:
const chordSymbolUltimateGuitarRenderer = (chord: any) => {
chord.formatted.symbol = chord.formatted.symbol
.replace(/[(), ]/g, '')
.replace(/mM(?!aj)/g, 'mMaj')
.replace(/M(?!aj)/g, 'Maj')
.replace('°', 'dim');

return chord;
};

chord.parserConfiguration is empty

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 infojunkie/ireal-musicxml@88d3172#diff-5d77c7a8c22384d31a9d6748dae7d1f06ebd95a6c2f8d2cae3dce0150dc38a64R982

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

The chord renderer factory should change the type of the returned function based on the `printer` option

Currently, the renderer function returned by chordRendererFactory is always of the type (chord: Chord) => string.
However, if printer: "raw" is given as an option to the factory, the returned function actually returns a Chord.

Function overloads work for fixing it, by discriminating on the type of the options object.
Example:

type PrinterRaw = { printer: "raw" }

// The order is important: the first matching overload is used, hence the more specific one has to come first.
declare function chordRendererFactory(configuration: RendererConfiguration & PrinterRaw): (chord: CSChord) => CSChord
declare function chordRendererFactory(configuration?: RendererConfiguration): (chord: CSChord) => string

By the source code, I believe this issue exists with JSDoc-supplied types as well.

Explain why the chord parsing fails

Would be great to return an explanation when a chord fails to parse

@infojunkie since this is a suggestion of yours what API would you expect? return an error object, an error string, throw an exception, log an error, ...?

iReal Pro parsing and MusicXML representation

Hello!

Your module looks fantastic, and it's great that you are basing your work on solid literature. I am working on a leadsheet converter from iReal Pro to MusicXML, and I'm currently hand-parsing the iReal Pro chords, and hand-generating the MusicXML chords.

Since your module seems so, um, modular, it looks like a good candidate to replace both these functions in a coherent whole. I'm thinking specifically of the following:

Thanks!

Chords like A7+5 is parsed incorrectly

A7+5 is incorrectly parsed into A5, the same is A7(+5) instead of A7(#5).
However A7+ is correctly parsed into A7(#5).
The same error applies to A7-5, which is parsed into A5, instead of A7(b5).

My fix which seem to work for now is:
let valueCleaned = value;
valueCleaned = valueCleaned.replace(/+5/g, '(#5)');
valueCleaned = valueCleaned.replace(/-5/g, '(b5)');

Support for altered chords

It looks like alt or alt. as a modifier is not supported.

Even though it looks like a maybe broad modifier, there might still be a way for the renderer to parse it. It could, for instance, be translated into 7(b5b9#9#11b13) or simply 7(b5b9b13) or even 7(#9#11).

I would personnally opt for the fully-fledged 7(b5b9#9#11b13)

Gsus2 not parsing correctly

Given the chord Gsus2, Chord Symbol returns normalized.isSuspended value false. Whereas Gsus4 has true. Seems like a bug, unless there's something in music theory I'm not understanding?

Allow more rendering options

In bb-format, I wanted to render minor chords as with a "-" instead of a "mi" so I added a search-and-replace for it.
image

However, it is not the only that might want to have even shorter options (like Delta for Maj7), I thought I might as well add these options directly in this lib instead of post-processing it.

So here's the question: how should that be done? Should I:

  • add another "shortnamings" option? (this would mean changing shortnamings from a bool to an enum containing something like "academic", "short", "usingSymbols".
  • add a "useDashInsteadOfMiForMinor" option (with a better name). But then what about the delta for major7? Another option? We might end up with too many options like these.
  • keep the post processing, but make it easier to add post process hooks (custom processing/parsing/rendering rules)
  • anything else that seems more sensible?

Thanks

Types files are out of date

The src/typedefs.js file and the types/index.d.ts file are out of sync. The TS one is out of date.

For example, FormattedChord has no symbol property, and the chord renderer factory config still uses the useFlats options instead of accidentals.

I am using/looking at the v4 beta.

Configure the parser for specific notation systems

Improve mutlilingual parsing by allowing to selection the notation system in the parser configuration
Down the road, more meaningful errors because they will be scoped to a single notation system
https://de.wikipedia.org/wiki/Anderssprachige_Tonbezeichnungen#cite_note-2
https://happynote.com/music/music-theory-name-notes/
https://www.francemusique.fr/en/where-do-names-notes-come-15660

Also, will bring the ability to parse the latin Do by disabling english and german

Allow custom processing.

ChordSymbol uses a pipe-and-filters architecture for both parsing and rendering. The plan is to allow adding custom filters if such capability is needed (add extra information on parsing, define custom rendering rules, etc.)

Version 4 in Node complains about "Cannot use import statement outside a module"

First of all, thanks for a very good library!

I have spent more than 5 hours trying to upgrade my typescript node project to work after the changes between version 3 and 4, and have at this moment given up and rolled back to version 3.

The error given when running the program is:
SyntaxError: Cannot use import statement outside a module:

The error happens in:
/node_modules/chord-symbol/src/index.js:1
import './typedefs';
^^^^^^
SyntaxError: Cannot use import statement outside a module

I tried following several tutorials to see if setting typescript compiling to esnext and setting type to "module" in package.json would work but had to give up after hours of errors.
I also tried to see if it was only the first import line that stopped this from working, but then it fails on the second import in the same index.js file, so for some reasons all "imports" have stopped working.

I'm noe sure what changed between version 3 and 4 that made a standard typescript node project stop working, but I can confirm that chord-symbol version 4 works perfectly in react native expo.

Here are some tutorials I tried, but none of them helped.
https://stackoverflow.com/questions/71929951/typescript-syntaxerror-cannot-use-import-statement-outside-a-module-side-file
https://stackoverflow.com/questions/74766930/syntaxerror-cannot-use-import-statement-outside-a-module-in-nodejs-typescript

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.