{"id":13056,"library":"daccord","title":"d'accord","description":"d'accord is a focused JavaScript module designed for parsing complex music chord symbols, encompassing both Jazz and Classical notation standards. It accurately interprets a wide range of chords, from basic power chords like 'D#5' to sophisticated real book entries such as 'G7#5' and 'Dm7b5', or even intricate structures like 'Fsus4maj#11' or 'Cm13b5#9'. Crucially, d'accord only parses the chord suffix (the part without the root note) and returns an array of relative intervals (e.g., ['P1', 'm3', 'd5', 'm7']) rather than absolute notes. This design makes it a versatile tool for music theory applications, often used in conjunction with libraries like Teoria to construct full chords from a specified root note. The current stable version is 2.0.1. Release cadence is not explicitly stated but implies a steady maintenance, with major version updates indicating significant changes. Its key differentiator is its robust and forgiving parsing logic for a vast array of chord suffixes, specifically designed to output relative intervals for maximal flexibility in musical analysis and composition.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/saebekassebil/daccord","tags":["javascript","chord","music","teoria","parser"],"install":[{"cmd":"npm install daccord","lang":"bash","label":"npm"},{"cmd":"yarn add daccord","lang":"bash","label":"yarn"},{"cmd":"pnpm add daccord","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Commonly used in conjunction to construct full notes from parsed intervals and a root note.","package":"teoria","optional":true}],"imports":[{"note":"The primary export of the 'daccord' package is a default function for parsing chord symbols. While `require` is shown in older examples, ESM is also supported.","wrong":"import { daccord } from 'daccord'","symbol":"daccord","correct":"import daccord from 'daccord'"},{"note":"Standard CommonJS `require` syntax, as illustrated in the package's README and for compatibility in Node.js environments.","symbol":"daccord","correct":"const daccord = require('daccord')"}],"quickstart":{"code":"import daccord from 'daccord';\nimport teoria from 'teoria';\n\n// Create a root note, for example C4, using the Teoria library\nconst root = teoria.note('C4');\n\n// Parse a complex chord symbol (e.g., minor major seventh) into relative intervals\nconst intervals = daccord('m(maj7)');\n\n// Map the relative intervals to absolute notes using the chosen root note\n// This will return an array of Teoria Note objects\nconst notes = intervals.map(intervalStr => root.interval(intervalStr));\n\n// To get the string representation of the resulting notes:\nconst noteStrings = notes.map(note => note.toString());\n\nconsole.log(`Chord 'm(maj7)' from C4: ${noteStrings.join(', ')}`);\n\n// Example with error handling for unparsable chord strings\ntry {\n  // This will throw an error as 'invalidchord' is not a recognized symbol\n  daccord('invalidchord');\n} catch (error) {\n  // The error object thrown for invalid input has a 'name' property of 'ParseError'\n  if (error.name === 'ParseError') {\n    console.error(`Parsing error: ${error.message} at token '${error.token}' (index ${error.index})`);\n  } else {\n    console.error(`An unexpected error occurred: ${error.message}`);\n  }\n}","lang":"javascript","description":"Demonstrates parsing a chord symbol into relative intervals, combining it with Teoria to form absolute notes from a root, and includes robust error handling for invalid inputs."},"warnings":[{"fix":"To construct full chords with specific root notes, integrate d'accord with a music theory library like Teoria, using `teoria.note('C4').interval(intervalString)` to apply the parsed intervals to a chosen root.","message":"d'accord exclusively parses the chord suffix (e.g., 'm7b5') and outputs relative intervals (e.g., ['P1', 'm3', 'd5', 'm7']), not absolute notes. It explicitly ignores any root note provided in the input string (e.g., 'C' in 'Cm7').","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement explicit `try...catch` blocks around all calls to `daccord(chordstring)`. Check `error.name === 'ParseError'` within the catch block to handle parsing failures gracefully and extract relevant error information.","message":"When an input `chordstring` is unparsable, d'accord throws a `ParseError` object with specific details (message, title, token, index). It does not return `null` or an empty array.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always review the official changelog or release notes for d'accord when migrating between major versions (e.g., 1.x to 2.x) to understand specific breaking changes and necessary code adjustments.","message":"Upgrading from d'accord 1.x to 2.x involves a major version bump, which typically indicates breaking changes in the API surface, internal implementation, or parsing behavior. Direct drop-in replacement may lead to errors.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure that the `chordstring` argument is a valid musical chord suffix (e.g., 'maj7', 'm7b5', 'sus4'). Always wrap `daccord()` calls in a `try...catch` block to handle these expected parsing errors gracefully.","cause":"The input string provided to `daccord()` does not conform to any recognized chord symbol pattern, leading to a parsing failure.","error":"ParseError: Invalid chord string: 'unknownchord' at token 'unknownchord' (index 0)"},{"fix":"Verify that `teoria` is installed (`npm install teoria`), correctly imported (`import teoria from 'teoria';` or `const teoria = require('teoria');`), and that `root` is initialized using `teeria.note('C4')` (or another valid note string) before attempting to call `.interval()` on it.","cause":"This error typically occurs when the `teoria` library is not correctly installed, imported, or when the `root` variable is not a valid `teoria.note` object.","error":"TypeError: root.interval is not a function (when combining with Teoria)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}