### Install chords-db Package Source: https://context7.com/tombatossals/chords-db/llms.txt Installs the chords-db package using npm. This is the initial step to integrate the chord database into your JavaScript project. ```bash npm install @tombatossals/chords-db ``` -------------------------------- ### Chord Data Structure Example Source: https://context7.com/tombatossals/chords-db/llms.txt Illustrates the structure of a single chord object within the database. It includes key, suffix, and an array of possible positions, each with detailed fingering and fret information. ```javascript { key: 'A', // Musical key (C, Db, D, Eb, E, F, Gb, G, Ab, A, Bb, B) suffix: 'major', // Chord type (major, minor, dim, aug, 7, maj7, m7, etc.) positions: [ { frets: 'x02220', // Fret positions (x = muted, 0 = open, 1-9/a-f = fret number) fingers: '001230', // Finger numbers (0 = not pressed, 1-4 = finger) baseFret: 1, // Starting fret position (default: 1) barres: 5, // Barre fret position (optional) capo: true, // Whether position uses a barre/capo (optional) midi: [57, 61, 64] // MIDI note values (piano only) } ] } ``` -------------------------------- ### Import Guitar Chord Database Source: https://context7.com/tombatossals/chords-db/llms.txt Imports the complete guitar chord database from the installed package. Allows access to guitar metadata, available keys, suffixes, and specific chord data. ```javascript import guitar from '@tombatossals/chords-db/lib/guitar.json'; // Access guitar metadata console.log(guitar.main.strings); // 6 console.log(guitar.main.fretsOnChord); // 4 console.log(guitar.main.name); // "Guitar" console.log(guitar.tunings.standard); // ["E2", "A2", "D3", "G3", "B3", "E4"] // Access available keys and suffixes console.log(guitar.keys); // ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"] console.log(guitar.suffixes); // ["major", "minor", "dim", "aug", "7", "maj7", "m7", ...] // Access specific chord const aMinor = guitar.chords.A.find(chord => chord.suffix === 'minor'); ``` -------------------------------- ### Accessing and Filtering Individual Chords Source: https://context7.com/tombatossals/chords-db/llms.txt Demonstrates how to access all variations of a specific chord (e.g., 'A') from the imported database and then filter them by suffix (e.g., 'major', 'minor', '7'). Also shows how to get the first position of a filtered chord. ```javascript // Get all A chord variations const aChords = guitar.chords.A; // Filter by suffix const aMajor = aChords.find(c => c.suffix === 'major'); const aMinor = aChords.find(c => c.suffix === 'minor'); const a7 = aChords.find(c => c.suffix === '7'); // Get first position of A major const firstPosition = aMajor.positions[0]; console.log(firstPosition.frets); // "x02220" console.log(firstPosition.fingers); // "001230" ``` -------------------------------- ### Build Project with Yarn (Shell) Source: https://github.com/tombatossals/chords-db/blob/master/README.md This command is used to generate a new version of the chords-db library, typically after adding new chords or making modifications to the database. ```bash yarn build ``` -------------------------------- ### Test Project with Yarn (Shell) Source: https://github.com/tombatossals/chords-db/blob/master/README.md This command runs tests on the newly added chords or modifications within the chords-db project. It is useful for detecting basic mistakes before committing changes. ```bash yarn test ``` -------------------------------- ### Importing Guitar Chord Data Source: https://context7.com/tombatossals/chords-db/llms.txt Import the full guitar chord database and access its metadata, keys, suffixes, and specific chords. ```APIDOC ## Importing Guitar Chord Data ### Description Import the full guitar chord database and access its metadata, keys, suffixes, and specific chords. ### Method Import ### Endpoint `@tombatossals/chords-db/lib/guitar.json` ### Request Body None ### Response #### Success Response (200) - **guitar** (object) - The guitar chord database object. - **main** (object) - Metadata about the guitar. - **strings** (number) - Number of strings on the guitar. - **fretsOnChord** (number) - Number of frets displayed on a chord diagram. - **name** (string) - The name of the instrument. - **tunings** (object) - Available tunings for the instrument. - **standard** (array) - Array of strings representing the standard tuning. - **keys** (array) - Array of strings representing the available musical keys. - **suffixes** (array) - Array of strings representing the available chord suffixes. - **chords** (object) - An object where keys are musical keys and values are arrays of chord objects. - **[KEY]** (array) - Array of chord objects for a specific key. - **key** (string) - The musical key of the chord. - **suffix** (string) - The chord type (e.g., 'major', 'minor'). - **positions** (array) - Array of fingering variations for the chord. - **frets** (string) - Fret positions (e.g., 'x02220'). - **fingers** (string) - Finger numbers (e.g., '001230'). - **baseFret** (number) - Starting fret position. - **barres** (number, optional) - Barre fret position. - **capo** (boolean, optional) - Indicates if a barre/capo is used. ### Request Example ```javascript import guitar from '@tombatossals/chords-db/lib/guitar.json'; // Access guitar metadata console.log(guitar.main.strings); // 6 console.log(guitar.main.fretsOnChord); // 4 console.log(guitar.main.name); // "Guitar" console.log(guitar.tunings.standard); // ["E2", "A2", "D3", "G3", "B3", "E4"] // Access available keys and suffixes console.log(guitar.keys); // ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"] console.log(guitar.suffixes); // ["major", "minor", "dim", "aug", "7", "maj7", "m7", ...] // Access specific chord const aMinor = guitar.chords.A.find(chord => chord.suffix === 'minor'); ``` ### Response Example ```json { "main": { "strings": 6, "fretsOnChord": 4, "name": "Guitar", "tunings": { "standard": ["E2", "A2", "D3", "G3", "B3", "E4"] } }, "keys": ["C", "Db", ...], "suffixes": ["major", "minor", ...], "chords": { "A": [ { "key": "A", "suffix": "minor", "positions": [ { "frets": "x02210", "fingers": "032100", "baseFret": 1 } ] } ] } } ``` ``` -------------------------------- ### Import Instrument Metadata Source: https://context7.com/tombatossals/chords-db/llms.txt Imports a JSON file containing metadata for all supported instruments. This includes details like the number of strings, frets per chord, instrument name, and standard tunings. ```javascript import instruments from '@tombatossals/chords-db/lib/instruments.json'; // instruments.json structure: { "guitar": { "strings": 6, "fretsOnChord": 4, "name": "Guitar", "tunings": { "standard": ["E2", "A2", "D3", "G3", "B3", "E4"] } }, "ukulele": { "strings": 4, "fretsOnChord": 4, "name": "Ukulele", "tunings": { "standard": ["G4", "C4", "E4", "A4"] } }, "piano": { "keys": 88, "name": "Piano" } } ``` -------------------------------- ### Importing Ukulele Chord Data Source: https://context7.com/tombatossals/chords-db/llms.txt Import the ukulele chord database and access its metadata, tunings, and specific chords. ```APIDOC ## Importing Ukulele Chord Data ### Description Import the ukulele chord database and access its metadata, tunings, and specific chords. ### Method Import ### Endpoint `@tombatossals/chords-db/lib/ukulele.json` ### Request Body None ### Response #### Success Response (200) - **ukulele** (object) - The ukulele chord database object. - **main** (object) - Metadata about the ukulele. - **strings** (number) - Number of strings on the ukulele. - **fretsOnChord** (number) - Number of frets displayed on a chord diagram. - **tunings** (object) - Available tunings for the ukulele. - **standard** (array) - Array of strings representing the standard tuning. - **keys** (array) - Array of strings representing the available musical keys. - **suffixes** (array) - Array of strings representing the available chord suffixes. - **chords** (object) - An object where keys are musical keys and values are arrays of chord objects. ### Request Example ```javascript import ukulele from '@tombatossals/chords-db/lib/ukulele.json'; // Access ukulele metadata console.log(ukulele.main.strings); // 4 console.log(ukulele.main.fretsOnChord); // 4 console.log(ukulele.tunings.standard); // ["G4", "C4", "E4", "A4"] // Get C major chord positions const cMajor = ukulele.chords.C.find(chord => chord.suffix === 'major'); console.log(cMajor.positions); ``` ### Response Example ```json { "main": { "strings": 4, "fretsOnChord": 4, "name": "Ukulele", "tunings": { "standard": ["G4", "C4", "E4", "A4"] } }, "keys": ["C", "Db", ...], "suffixes": ["major", "minor", ...], "chords": { "C": [ { "key": "C", "suffix": "major", "positions": [ { "frets": "0003", "fingers": "0003", "baseFret": 1 } ] } ] } } ``` ``` -------------------------------- ### Importing Piano Chord Data Source: https://context7.com/tombatossals/chords-db/llms.txt Import the piano chord database and access its metadata and specific chords, including MIDI values. ```APIDOC ## Importing Piano Chord Data ### Description Import the piano chord database and access its metadata and specific chords, including MIDI values. ### Method Import ### Endpoint `@tombatossals/chords-db/lib/piano.json` ### Request Body None ### Response #### Success Response (200) - **piano** (object) - The piano chord database object. - **main** (object) - Metadata about the piano. - **keys** (number) - Number of keys on the piano. - **name** (string) - The name of the instrument. - **keys** (array) - Array of strings representing the available musical keys. - **suffixes** (array) - Array of strings representing the available chord suffixes. - **chords** (object) - An object where keys are musical keys and values are arrays of chord objects. - **[KEY]** (array) - Array of chord objects for a specific key. - **key** (string) - The musical key of the chord. - **suffix** (string) - The chord type (e.g., 'major', 'minor'). - **positions** (array) - Array of fingering variations for the chord. - **midi** (array) - Array of MIDI note values for the chord positions. ### Request Example ```javascript import piano from '@tombatossals/chords-db/lib/piano.json'; // Access piano chord with MIDI values const dMajor = piano.chords.D.find(chord => chord.suffix === 'major'); console.log(dMajor.positions[0].midi); // [62, 66, 69] ``` ### Response Example ```json { "main": { "keys": 88, "name": "Piano" }, "keys": ["C", "Db", ...], "suffixes": ["major", "minor", ...], "chords": { "D": [ { "key": "D", "suffix": "major", "positions": [ { "midi": [62, 66, 69] } ] } ] } } ``` ``` -------------------------------- ### Available Chord Suffixes Source: https://context7.com/tombatossals/chords-db/llms.txt Lists common chord suffixes available across different instruments in the chords-db library. ```APIDOC ## Available Chord Suffixes ### Description Lists common chord suffixes available across different instruments in the chords-db library. ### Parameters None ### Response #### Success Response (200) - **suffixes** (array) - An array of strings representing common chord suffixes. ### Request Example ```javascript // Common suffixes available across instruments: const suffixes = [ 'major', 'minor', 'dim', 'dim7', 'sus2', 'sus4', '7sus4', 'aug', '6', '69', '7', '7b5', 'aug7', '9', '9b5', 'aug9', '7b9', '7#9', '11', '9#11', '13', 'maj7', 'maj7b5', 'maj7#5', 'maj9', 'maj11', 'maj13', 'm6', 'm69', 'm7', 'm7b5', 'm9', 'm9b5', 'm11', 'mmaj7', 'mmaj7b5', 'mmaj9', 'mmaj11', 'add9', 'madd9' ]; ``` ### Response Example ```json [ "major", "minor", "dim", "dim7", "sus2", "sus4", "7sus4", "aug", "6", "69", "7", "7b5", "aug7", "9", "9b5", "aug9", "7b9", "7#9", "11", "9#11", "13", "maj7", "maj7b5", "maj7#5", "maj9", "maj11", "maj13", "m6", "m69", "m7", "m7b5", "m9", "m9b5", "m11", "mmaj7", "mmaj7b5", "mmaj9", "mmaj11", "add9", "madd9" ] ``` ``` -------------------------------- ### Accessing Individual Chords Source: https://context7.com/tombatossals/chords-db/llms.txt Demonstrates how to access all variations of a specific chord (e.g., all A chords) and filter them by suffix. ```APIDOC ## Accessing Individual Chords ### Description Demonstrates how to access all variations of a specific chord (e.g., all A chords) and filter them by suffix. ### Method Data access via imported JSON object ### Endpoint N/A (accessed after importing guitar, ukulele, or piano JSON) ### Parameters None ### Request Example ```javascript // Assuming 'guitar' is imported from '@tombatossals/chords-db/lib/guitar.json' // Get all A chord variations const aChords = guitar.chords.A; // Filter by suffix const aMajor = aChords.find(c => c.suffix === 'major'); const aMinor = aChords.find(c => c.suffix === 'minor'); const a7 = aChords.find(c => c.suffix === '7'); // Get first position of A major const firstPosition = aMajor.positions[0]; console.log(firstPosition.frets); // "x02220" console.log(firstPosition.fingers); // "001230" ``` ### Response None (this is a code example demonstrating data manipulation after import) ``` -------------------------------- ### Instrument Metadata Source: https://context7.com/tombatossals/chords-db/llms.txt Access a JSON file containing metadata for each supported instrument, including string count, fret display, and tunings. ```APIDOC ## Instrument Metadata ### Description Access a JSON file containing metadata for each supported instrument, including string count, fret display, and tunings. ### Method Import ### Endpoint `@tombatossals/chords-db/lib/instruments.json` ### Request Body None ### Response #### Success Response (200) - **instruments** (object) - An object containing metadata for each instrument. - **guitar** (object) - **strings** (number) - **fretsOnChord** (number) - **name** (string) - **tunings** (object) - **standard** (array) - **ukulele** (object) - **strings** (number) - **fretsOnChord** (number) - **name** (string) - **tunings** (object) - **standard** (array) - **piano** (object) - **keys** (number) - **name** (string) ### Request Example ```javascript import instruments from '@tombatossals/chords-db/lib/instruments.json'; // instruments.json structure: { "guitar": { "strings": 6, "fretsOnChord": 4, "name": "Guitar", "tunings": { "standard": ["E2", "A2", "D3", "G3", "B3", "E4"] } }, "ukulele": { "strings": 4, "fretsOnChord": 4, "name": "Ukulele", "tunings": { "standard": ["G4", "C4", "E4", "A4"] } }, "piano": { "keys": 88, "name": "Piano" } } ``` ### Response Example ```json { "guitar": { "strings": 6, "fretsOnChord": 4, "name": "Guitar", "tunings": { "standard": ["E2", "A2", "D3", "G3", "B3", "E4"] } }, "ukulele": { "strings": 4, "fretsOnChord": 4, "name": "Ukulele", "tunings": { "standard": ["G4", "C4", "E4", "A4"] } }, "piano": { "keys": 88, "name": "Piano" } } ``` ``` -------------------------------- ### Import Ukulele Chord Database Source: https://context7.com/tombatossals/chords-db/llms.txt Imports the ukulele chord database. Provides access to ukulele-specific metadata like the number of strings and standard tuning, as well as chord positions. ```javascript import ukulele from '@tombatossals/chords-db/lib/ukulele.json'; // Access ukulele metadata console.log(ukulele.main.strings); // 4 console.log(ukulele.main.fretsOnChord); // 4 console.log(ukulele.tunings.standard); // ["G4", "C4", "E4", "A4"] // Get C major chord positions const cMajor = ukulele.chords.C.find(chord => chord.suffix === 'major'); console.log(cMajor.positions); ``` -------------------------------- ### Import Piano Chord Database Source: https://context7.com/tombatossals/chords-db/llms.txt Imports the piano chord database. This allows developers to access piano-specific chord data, including MIDI note values for each chord position. ```javascript import piano from '@tombatossals/chords-db/lib/piano.json'; // Access piano chord with MIDI values const dMajor = piano.chords.D.find(chord => chord.suffix === 'major'); console.log(dMajor.positions[0].midi); // [62, 66, 69] ``` -------------------------------- ### Chord Data Structure Source: https://context7.com/tombatossals/chords-db/llms.txt Details the structure of individual chord objects within the database, including key, suffix, and position variations. ```APIDOC ## Chord Data Structure ### Description Details the structure of individual chord objects within the database, including key, suffix, and position variations. ### Parameters None ### Response #### Success Response (200) - **chord object** (object) - **key** (string) - Musical key (C, Db, D, Eb, E, F, Gb, G, Ab, A, Bb, B). - **suffix** (string) - Chord type (major, minor, dim, aug, 7, maj7, m7, etc.). - **positions** (array) - Array of fingering variations. - **frets** (string) - Fret positions (x = muted, 0 = open, 1-9/a-f = fret number). - **fingers** (string) - Finger numbers (0 = not pressed, 1-4 = finger). - **baseFret** (number) - Starting fret position (default: 1). - **barres** (number, optional) - Barre fret position. - **capo** (boolean, optional) - Whether position uses a barre/capo. - **midi** (array, optional) - MIDI note values (piano only). ### Request Example None ### Response Example ```javascript { "key": "A", "suffix": "major", "positions": [ { "frets": "x02220", "fingers": "001230", "baseFret": 1, "barres": 5, "capo": true, "midi": [57, 61, 64] } ] } ``` ``` -------------------------------- ### List of Available Chord Suffixes Source: https://context7.com/tombatossals/chords-db/llms.txt Provides a comprehensive list of common chord suffixes supported by the chords-db library. These suffixes can be used to filter and identify specific chord types across different instruments. ```javascript // Common suffixes available across instruments: const suffixes = [ 'major', 'minor', 'dim', 'dim7', 'sus2', 'sus4', '7sus4', 'aug', '6', '69', '7', '7b5', 'aug7', '9', '9b5', 'aug9', '7b9', '7#9', '11', '9#11', '13', 'maj7', 'maj7b5', 'maj7#5', 'maj9', 'maj11', 'maj13', 'm6', 'm69', 'm7', 'm7b5', 'm9', 'm9b5', 'm11', 'mmaj7', 'mmaj7b5', 'mmaj9', 'mmaj11', 'add9', 'madd9' ]; ``` -------------------------------- ### Define Dsus2 Guitar Chord Structure (JavaScript) Source: https://github.com/tombatossals/chords-db/blob/master/README.md This snippet defines the structure for a Dsus2 chord on a guitar. It includes an 'export default' statement for module systems. The 'positions' array contains variations, each specifying 'frets', 'fingers', optional 'barres', and 'capo' status. ```javascript export default { key: 'D', suffix: 'sus2', positions: [{ frets: '0320xx', fingers: '031000' }, { frets: '55775x', fingers: '114310', barres: 5, capo: true }] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.