no-chris / chord-symbol Goto Github PK
View Code? Open in Web Editor NEWThe definitive chord symbol parser and renderer for Javascript/NodeJS.
Home Page: https://chord-symbol.netlify.app
License: MIT License
The definitive chord symbol parser and renderer for Javascript/NodeJS.
Home Page: https://chord-symbol.netlify.app
License: MIT License
C4
C(b13)
C(b9)
I tried following the installation instructions, I get Uncaught SyntaxError: Cannot use import statement outside a module
– both if I clone this repository or I install as node module. Is there any intermediary step I might be missing?
I tried loading it both via <script src="
and import {...} from 'path'
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
).
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, ...?
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.
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
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.
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?
Cadd4
is parsed as Csus(add3)
, which I would like to understand better.
Is this the more technically "correct" name for the chord? If not, why is it parsed as it is?
Is there any way I can keep/render the simpler version?
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.
Raw renderer return an object with the wrong "input" property if the notation system of the original chord is not english.
Does not return null anymore
How would you get back all notes when you parse a chord with a bass note?
E.g. the Chord DMaj7/G contain only the Dmaj7 notes in the notes array. The G is not included.
input": {
"symbol": "DMAJ7/G",
},
"notes": [
"D",
"F#",
"A",
"C#"
]
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)
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
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;
};
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.)
It seems no bass notes with # or b works with german notation.
The chord H7/F# does not work.
Neither does H/Db.
For actual example, check out this tab
https://nortabs.net/tab/944/
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)');
Forgot to update tpyescript def with all 2.0.0 changes
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:
harmony
elements - noting that their specification is pretty close to your approachThanks!
Hello!
Adding chord fingering for piano will be trivial with this web component:
https://github.com/jutunen/custom-piano-keys
regards,
Jussi
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.
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.
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:
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.