musicxml


Namemusicxml JSON
Version 1.6 PyPI version JSON
download
home_pagehttps://github.com/alexgorji/musicxml.git
Summarygenerating musicxml
upload_time2024-12-23 22:17:16
maintainerNone
docs_urlNone
authorAlex Gorji
requires_python<3.13,>=3.9
licenseMIT
keywords music musicxml xml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            musicxml is a python library for creating musicxml files. It is largely based on xsd definitions of MusicXML 4.0.

musicxml is also a part of library: musicscore. Feel free to check out under: [https://github.com/alexgorji/musicscore](https://github.com/alexgorji/musicscore) & [https://musicscore.readthedocs.io](https://musicscore.readthedocs.io)

INSTALLATION

1. Check the version of python on your computer: `python --version`. This library has been developed with python 3.9. Possibly you have to
   install this version (for example via Homebrew or whatever way you choose.)

2. Make a new folder and create a virtual environment for your project and install musicxml via pip:
    * mkdir <project>
    * cd <project>
    * python3 -m venv venv
    * source venv/bin/activate
    * pip install --upgrade pip
    * pip install musicxml

The SOURCECODE can be found on Github: https://github.com/alexgorji/musicxml

Each musicxml element can be created as an instance of a class which behaves (hopefully exactly!) as the musicxml schema
(version 4, see musicxml_4_0.xsd in musicxml.generate_classes) specifies, e.g.:

```
pitch = XMLPitch()
```

Children can be added with method add_child(<xmlelement>):

```
pitch.add_child(XMLStep('G'))
```

As a shortcut it is possible to add, remove or change child with a dot operator:

```
pitch.xml_step = 'G'
```

is equivalent to:

```
pitch.xml_step = XMLStep('G')
```

change:

```
pitch.xml_step = 'F'
```

or remove:

```
pitch.xml_step = None
```

Dot operator can also be used as a shortcut to get a child:

```
print(pitch.xml_step.value)
```

The value of an element (which be translated to text of xml element) can be set during or after creation:

```
octave = pitch.add_child(XMLOctave())
octave.value = 3
```

Attributes also can be added during or after creation:

```
font = XMLFont(font_family='Arial')
font.font_size = 17.2
```

A variety of errors are thrown during creating an object (for example if you try to add a child of a wrong type or to add a wrong attribute)
. The method to_string() calls an intern final check before exporting the xml element to a string to be sure you didn't forget any required
children and attributes.

An existing musicxml file can be parsed easily with parser's parse_musicxml(file_path) function.

Each element creates a rather complicated tree format container with xsd indicator objects (XSDSequence, XSDChoice, XSDGroup, XSDElement)
which represent their counterparts in a xsd structure to validate and order its children (take a peek inside the file musicxml_4_0.xsd in
musicxml.generate_classes to get a feeling for its complexity). If a child is going to be added to an element it tries to 'hook' this child
inside a XSDElement leaf of this container tree which has the same name as the child. For elements which use a choice indicator (XSDChoice)
it can happen, that the current chosen path throws an error since this particular path does not have a XSDElement leaf with child's name, or
it could for example require another not existing child in the final check. It these cases the parent element tries to attach its children
to another choice path and see if the problem can be solved. On this account although some thorough testings have been done, there is yet no
guaranty that in some cases the library does not behave as it should. Please let me know if you discover a bug!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alexgorji/musicxml.git",
    "name": "musicxml",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.9",
    "maintainer_email": null,
    "keywords": "music, musicxml, xml",
    "author": "Alex Gorji",
    "author_email": "aligorji@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0a/ec/ecbbc9ae7d8e28c58adab12692c3ee3e786e907171cf88029d24eb80153a/musicxml-1.6.tar.gz",
    "platform": null,
    "description": "musicxml is a python library for creating musicxml files. It is largely based on xsd definitions of MusicXML 4.0.\n\nmusicxml is also a part of library: musicscore. Feel free to check out under: [https://github.com/alexgorji/musicscore](https://github.com/alexgorji/musicscore) & [https://musicscore.readthedocs.io](https://musicscore.readthedocs.io)\n\nINSTALLATION\n\n1. Check the version of python on your computer: `python --version`. This library has been developed with python 3.9. Possibly you have to\n   install this version (for example via Homebrew or whatever way you choose.)\n\n2. Make a new folder and create a virtual environment for your project and install musicxml via pip:\n    * mkdir <project>\n    * cd <project>\n    * python3 -m venv venv\n    * source venv/bin/activate\n    * pip install --upgrade pip\n    * pip install musicxml\n\nThe SOURCECODE can be found on Github: https://github.com/alexgorji/musicxml\n\nEach musicxml element can be created as an instance of a class which behaves (hopefully exactly!) as the musicxml schema\n(version 4, see musicxml_4_0.xsd in musicxml.generate_classes) specifies, e.g.:\n\n```\npitch = XMLPitch()\n```\n\nChildren can be added with method add_child(<xmlelement>):\n\n```\npitch.add_child(XMLStep('G'))\n```\n\nAs a shortcut it is possible to add, remove or change child with a dot operator:\n\n```\npitch.xml_step = 'G'\n```\n\nis equivalent to:\n\n```\npitch.xml_step = XMLStep('G')\n```\n\nchange:\n\n```\npitch.xml_step = 'F'\n```\n\nor remove:\n\n```\npitch.xml_step = None\n```\n\nDot operator can also be used as a shortcut to get a child:\n\n```\nprint(pitch.xml_step.value)\n```\n\nThe value of an element (which be translated to text of xml element) can be set during or after creation:\n\n```\noctave = pitch.add_child(XMLOctave())\noctave.value = 3\n```\n\nAttributes also can be added during or after creation:\n\n```\nfont = XMLFont(font_family='Arial')\nfont.font_size = 17.2\n```\n\nA variety of errors are thrown during creating an object (for example if you try to add a child of a wrong type or to add a wrong attribute)\n. The method to_string() calls an intern final check before exporting the xml element to a string to be sure you didn't forget any required\nchildren and attributes.\n\nAn existing musicxml file can be parsed easily with parser's parse_musicxml(file_path) function.\n\nEach element creates a rather complicated tree format container with xsd indicator objects (XSDSequence, XSDChoice, XSDGroup, XSDElement)\nwhich represent their counterparts in a xsd structure to validate and order its children (take a peek inside the file musicxml_4_0.xsd in\nmusicxml.generate_classes to get a feeling for its complexity). If a child is going to be added to an element it tries to 'hook' this child\ninside a XSDElement leaf of this container tree which has the same name as the child. For elements which use a choice indicator (XSDChoice)\nit can happen, that the current chosen path throws an error since this particular path does not have a XSDElement leaf with child's name, or\nit could for example require another not existing child in the final check. It these cases the parent element tries to attach its children\nto another choice path and see if the problem can be solved. On this account although some thorough testings have been done, there is yet no\nguaranty that in some cases the library does not behave as it should. Please let me know if you discover a bug!\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "generating musicxml",
    "version": "1.6",
    "project_urls": {
        "Homepage": "https://github.com/alexgorji/musicxml.git",
        "Repository": "https://github.com/alexgorji/musicxml.git"
    },
    "split_keywords": [
        "music",
        " musicxml",
        " xml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c69f59c0ada9b3384ea042733ffd966d34fe0b2e108b7c602a0ae6eb432c3fec",
                "md5": "4590c24d601b05479114576f29ff727e",
                "sha256": "c2e4b305192090068561d15db3579412c51c276041f5f3b0f2417142274da6b8"
            },
            "downloads": -1,
            "filename": "musicxml-1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4590c24d601b05479114576f29ff727e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.9",
            "size": 978150,
            "upload_time": "2024-12-23T22:17:14",
            "upload_time_iso_8601": "2024-12-23T22:17:14.272732Z",
            "url": "https://files.pythonhosted.org/packages/c6/9f/59c0ada9b3384ea042733ffd966d34fe0b2e108b7c602a0ae6eb432c3fec/musicxml-1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0aececbbc9ae7d8e28c58adab12692c3ee3e786e907171cf88029d24eb80153a",
                "md5": "40d9aed316d541ca5033b7b62f9024ec",
                "sha256": "1620521f5a329bc73b3d87bafad8537169a8bb750cccfe0614de049bbb0cd4fc"
            },
            "downloads": -1,
            "filename": "musicxml-1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "40d9aed316d541ca5033b7b62f9024ec",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.9",
            "size": 873043,
            "upload_time": "2024-12-23T22:17:16",
            "upload_time_iso_8601": "2024-12-23T22:17:16.845590Z",
            "url": "https://files.pythonhosted.org/packages/0a/ec/ecbbc9ae7d8e28c58adab12692c3ee3e786e907171cf88029d24eb80153a/musicxml-1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-23 22:17:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alexgorji",
    "github_project": "musicxml",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "musicxml"
}
        
Elapsed time: 0.41821s