Skip to content

Instantly share code, notes, and snippets.

@xavriley
Last active May 24, 2023 21:16
Show Gist options
  • Select an option

  • Save xavriley/8f907811d71abea8aa3f31db8b1535bc to your computer and use it in GitHub Desktop.

Select an option

Save xavriley/8f907811d71abea8aa3f31db8b1535bc to your computer and use it in GitHub Desktop.

Revisions

  1. xavriley revised this gist May 24, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions instructions to make the CLI binaries.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ```
    $ npm install -g pkg # https://github.com/vercel/pkg
    $ npm install -g chord-symbol # https://github.com/no-chris/chord-symbol
    $ pkg chord-parser.js
    ```
  2. xavriley created this gist May 24, 2023.
    32 changes: 32 additions & 0 deletions Example output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    $ ./chord-parser -c Cmaj7
    {
    input: {
    symbol: 'Cmaj7',
    rootNote: 'C',
    descriptor: 'maj7',
    parsableDescriptor: 'maj7',
    modifiers: [ 'add7' ],
    notationSystem: 'english'
    },
    normalized: {
    intervals: [ '1', '3', '5', '7' ],
    semitones: [ 0, 4, 7, 11 ],
    intents: { major: true, eleventh: false, alt: false },
    rootNote: 'C',
    quality: 'major7',
    isSuspended: false,
    extensions: [],
    alterations: [],
    adds: [],
    omits: [],
    notes: [ 'C', 'E', 'G', 'B' ]
    },
    formatted: {
    rootNote: 'C',
    bassNote: undefined,
    descriptor: 'ma7',
    chordChanges: [],
    symbol: 'Cma7'
    },
    parserConfiguration: {}
    }
    16 changes: 16 additions & 0 deletions chord-parser.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/env node

    const yargs = require("yargs");
    const chordSymbolLib = require("chord-symbol");

    const parseChord = chordSymbolLib.chordParserFactory();
    const renderChord = chordSymbolLib.chordRendererFactory({ useShortNamings: true });

    const options = yargs
    .usage("Usage: -c <inputChord>")
    .option("c", { alias: "inputChord", describe: "Chord symbol as a string", type: "string", demandOption: true })
    .argv;

    const chord = parseChord(options.inputChord);

    console.log(chord);
    4 changes: 4 additions & 0 deletions instructions to make the CLI binaries.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    ```
    $ npm install -g pkg # https://github.com/vercel/pkg
    $ pkg chord-parser.js
    ```