Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/no-chris/chord-symbol-musicxml
MusicXml renderer for the chord-symbol library
https://github.com/no-chris/chord-symbol-musicxml
chord-symbols chords chordsheet guitar-chords music music-theory musicxml musicxml-format
Last synced: 8 days ago
JSON representation
MusicXml renderer for the chord-symbol library
- Host: GitHub
- URL: https://github.com/no-chris/chord-symbol-musicxml
- Owner: no-chris
- License: mit
- Created: 2021-01-19T18:43:14.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-01T06:25:20.000Z (over 3 years ago)
- Last Synced: 2024-11-23T03:20:19.683Z (2 months ago)
- Topics: chord-symbols, chords, chordsheet, guitar-chords, music, music-theory, musicxml, musicxml-format
- Language: JavaScript
- Homepage: https://chord-symbol.netlify.app/
- Size: 1.89 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://www.travis-ci.com/no-chris/chord-symbol-musicxml.svg?branch=main)](https://www.travis-ci.com/no-chris/chord-symbol-musicxml)
[![Coverage Status](https://coveralls.io/repos/github/no-chris/chord-symbol-musicxml/badge.svg?branch=main)](https://coveralls.io/github/no-chris/chord-symbol-musicxml?branch=main)
[![codebeat badge](https://codebeat.co/badges/a51aca5d-ec03-4eaf-a04d-bff666a0cf4e)](https://codebeat.co/projects/github-com-no-chris-chord-symbol-musicxml-main)`chord-symbol-musicxml` is a pluggable rendering filter for `chord-symbol` that generates chords in the MusicXml notation. It outputs a plain Javascript object that can easily be turned into an XML `harmony` entity using a library such as [jstoxml](https://github.com/davidcalhoun/jstoxml).
See a [live demo](https://chord-symbol.netlify.app/)!
# Installation
```shell
npm install --save chord-symbol-musicxml
```# Usage
```javascript
import { chordParserFactory, chordRendererFactory } from 'chord-symbol';
import { musicXmlRenderer } from 'chord-symbol-musicxml';const parseChord = chordParserFactory();
const renderChord = chordRendererFactory({
printer: 'raw',
customFilters: [musicXmlRenderer],
});const parsed = parseChord('C7sus(b5)/Gb');
const rendered = renderChord(parsed);console.log(rendered.musicxml);
````rendered.musicxml` contains the following object structure:
```json
{
"_name": "harmony",
"_content": [
{
"_name": "root",
"_content": [{ "_name": "root-step", "_content": "C" }]
},
{
"_name": "kind",
"_attrs": { "text": "7sus" },
"_content": "dominant"
},
{
"_name": "bass",
"_content": [
{ "_name": "bass-step", "_content": "G" },
{ "_name": "bass-alter", "_content": "-1" }
]
},
{
"_name": "degree",
"_attrs": { "print-object": "no" },
"_content": [
{ "_name": "degree-value", "_content": "3" },
{ "_name": "degree-alter", "_content": "0" },
{ "_name": "degree-type", "_content": "subtract" }
]
},
{
"_name": "degree",
"_attrs": { "print-object": "no" },
"_content": [
{ "_name": "degree-value", "_content": "4" },
{ "_name": "degree-alter", "_content": "0" },
{ "_name": "degree-type", "_content": "add" }
]
},
{
"_name": "degree",
"_content": [
{ "_name": "degree-value", "_content": "5" },
{ "_name": "degree-alter", "_content": "-1" },
{ "_name": "degree-type", "_content": "alter" }
]
}
]
}
```If you want some XML string, you can use `jstoxml` to convert the Javascript object into an XML entity
```javascript
import { toXML } from 'jstoxml';const xml = toXML(rendered.musicxml);
console.log(xml);
```This will output the following String:
```xml
C
dominant
G
-1
3
0
subtract
4
0
add
5
-1
alter
```