{ "info": { "author": "Valentin Berlier", "author_email": "berlier.v@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# pynbs\n\n[![PyPI](https://img.shields.io/pypi/v/pynbs.svg)](https://pypi.org/project/pynbs/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pynbs.svg)](https://pypi.org/project/pynbs/)\n\n> A simple python library to read and write [.nbs files](https://hielkeminecraft.github.io/OpenNoteBlockStudio/nbs)\nfrom [Open Note Block Studio](https://hielkeminecraft.github.io/OpenNoteBlockStudio/). Compatible with\npython 2 and 3.\n\n`pynbs` makes it possible to easily iterate over Note Block Studio songs.\n\n```python\nimport pynbs\n\nfor tick, chord in pynbs.read('demo_song.nbs'):\n print(tick, [note.key for note in chord])\n```\n\nYou can also use `pynbs` to generate new songs programmatically.\n\n```python\nimport pynbs\n\nnew_file = pynbs.new_file(song_name='Hello world')\nnew_file.notes.extend([\n pynbs.Note(tick=i, layer=0, instrument=0, key=i + 35) for i in range(10)\n])\n\nnew_file.save('new_file.nbs')\n```\n\n## Installation\n\nThe package can be installed with `pip`.\n\n```bash\n$ pip install pynbs\n```\n\nThe latest release follows the latest version of the nbs file format\n[specification](https://hielkeminecraft.github.io/OpenNoteBlockStudio/nbs)\n(version 3).\n\n## Basic usage\n\n### Reading files\n\nYou can use the `read()` function to read and parse a specific nbs file.\n\n```python\ndemo_song = pynbs.read('demo_song.nbs')\n```\n\nThe `read()` function returns a `pynbs` file object. These objects have several\nattributes that mirror the binary structure of nbs files.\n\n#### Header\n\nThe first attribute is `header`, the file header. It contains information about\nthe file.\n\n```python\nheader = demo_song.header\n```\n\nAttribute | Type | Details\n:---------------------------|:--------|:------------------------------------------------\n`header.version` | `int` | The NBS format version.\n`header.default_instruments`| `int` | The amount of instruments from vanilla Minecraft in the song.\n`header.song_length` | `int` | The length of the song, measured in ticks.\n`header.song_layers` | `int` | The id of the last layer with at least one note block in it.\n`header.song_name` | `str` | The name of the song.\n`header.song_author` | `str` | The author of the song.\n`header.original_author` | `str` | The original song author of the song.\n`header.description` | `str` | The description of the song.\n`header.tempo` | `float` | The tempo of the song.\n`header.auto_save` | `bool` | Whether auto-saving has been enabled.\n`header.auto_save_duration` | `int` | The amount of minutes between each auto-save.\n`header.time_signature` | `int` | The time signature of the song.\n`header.minutes_spent` | `int` | The amount of minutes spent on the project.\n`header.left_clicks` | `int` | The amount of times the user have left clicked.\n`header.right_clicks` | `int` | The amount of times the user have right clicked.\n`header.blocks_added` | `int` | The amount of times the user have added a block.\n`header.blocks_removed` | `int` | The amount of times the user have removed a block.\n`header.song_origin` | `str` | The file name of the original midi or schematic.\n\n> For more information about all these fields, check out the [official specification](https://hielkeminecraft.github.io/OpenNoteBlockStudio/nbs).\n\n#### Notes\n\nThe `notes` attribute holds a list of all the notes of the song in order.\n\n```python\nfirst_note = demo_song.notes[0]\n```\n\nAttribute | Type | Details\n:---------------- |:------|:------------------------------------------------\n`note.tick` | `int` | The tick at which the note plays.\n`note.layer` | `int` | The id of the layer in which the note is placed.\n`note.instrument` | `int` | The id of the instrument.\n`note.key` | `int` | The key of the note. (between 0 and 87)\n\n#### Layers\n\nThe `layers` attribute holds a list of all the layers of the song in order.\n\n```python\nfirst_layer = demo_song.layers[0]\n```\n\nAttribute | Type | Details\n:-----------------|:------|:------------------------\n`layer.id` | `int` | The id of the layer.\n`layer.name` | `str` | The name of the layer.\n`layer.volume` | `int` | The volume of the layer.\n`layer.panning` | `int` | The stereo panning of the layer.\n\n#### Instruments\n\nThe `instruments` attribute holds a list of all the custom instruments of the\nsong in order.\n\n```python\nfirst_custom_instrument = demo_song.instruments[0]\n```\n\nAttribute | Type | Details\n:----------------------|:-------|:----------------------------------------------------------\n`instrument.id` | `int` | The id of the instrument.\n`instrument.name` | `str` | The name of the instrument.\n`instrument.file` | `str` | The name of the sound file of the instrument.\n`instrument.pitch` | `int` | The pitch of the instrument. (between 0 and 87)\n`instrument.press_key` | `bool` | Whether the piano should automatically press keys with the instrument when the marker passes them.\n\n### Iterating over songs\n\nIterating over a `pynbs` file object yields consecutively all the chords of the song with\nthe associated tick.\n\n```python\nfor tick, chord in demo_song:\n ...\n```\n\n`chord` is a list of all the notes that play during the tick `tick`.\n\n### Creating new files\n\nYou can create new files using the `new_file()` function. The function lets\nyou specify header attributes with keyword arguments.\n\n```python\nnew_file = pynbs.new_file(song_name='Hello world')\n```\n\nThe function returns a new `pynbs` file object that you can now edit\nprogrammatically.\n\n### Saving files\n\nYou can use the `save()` method to encode and write the file to a specified\nlocation.\n\n```python\nnew_file.save('new_file.nbs')\n```\n\n### Upgrading old files\n\nWhile `pynbs` is up-to-date with the specification of the open source continuation\nof Minecraft Note Block studio, the original file format is still supported by the\n`read()` function, making it possible to bulk upgrade songs to the new format.\n\n```python\nimport glob\nimport pynbs\n\nfor old_file in glob.glob('*.nbs'):\n pynbs.read(old_file).save(old_file)\n```\n\n---\n\nLicense - [MIT](https://github.com/vberlier/pynbs/blob/master/LICENSE)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vberlier/pynbs", "keywords": "note-block-studio minecraft nbs-files", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pynbs", "package_url": "https://pypi.org/project/pynbs/", "platform": "any", "project_url": "https://pypi.org/project/pynbs/", "project_urls": { "Homepage": "https://github.com/vberlier/pynbs" }, "release_url": "https://pypi.org/project/pynbs/0.3.0/", "requires_dist": null, "requires_python": ">=2.7", "summary": "A simple python library to read and write .nbs files from Note Block Studio", "version": "0.3.0" }, "last_serial": 5693120, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "2dd78552fdf102de66e018368c51b173", "sha256": "55d39e1fb380c4c88174dfa468c14634a7ddd7d99eba3d90335365b554b0c046" }, "downloads": -1, "filename": "pynbs-0.2.1.tar.gz", "has_sig": false, "md5_digest": "2dd78552fdf102de66e018368c51b173", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 4526, "upload_time": "2018-04-21T14:08:34", "url": "https://files.pythonhosted.org/packages/3f/54/0779578ba42401d05303983d45a4fc15176400466bf3d5360144861944a8/pynbs-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "8efcdc8184c511b399347dd4f2435de0", "sha256": "27d7a77729a5ab0bbce32782064a9912ff8f82d3effb1b695dc86e9534e8e54f" }, "downloads": -1, "filename": "pynbs-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8efcdc8184c511b399347dd4f2435de0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 4781, "upload_time": "2018-04-21T14:14:41", "url": "https://files.pythonhosted.org/packages/f7/61/5d075c0d4fece0add02808325ad278abc45016bf8dcc6feab07b9610b024/pynbs-0.2.2-py2.py3-none-any.whl" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "d4831fecd6791ac403ab5455af96b000", "sha256": "c072cabbe7c6e243305a47c79e0eac19a5754aec36123f499c90774618e88521" }, "downloads": -1, "filename": "pynbs-0.2.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d4831fecd6791ac403ab5455af96b000", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 4828, "upload_time": "2018-04-21T14:25:20", "url": "https://files.pythonhosted.org/packages/a2/d4/05bb59a56e2f569853b32bd92e9ae3a8a4252d95abca9aff9b160b00b15b/pynbs-0.2.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d3c0c3f693d2b406e4844777f9a6fc7", "sha256": "b3cd871efa2d3ea46cbcc3856a8a8b7f3e9c3f130c6fe073d04bb780007efa8b" }, "downloads": -1, "filename": "pynbs-0.2.3.tar.gz", "has_sig": false, "md5_digest": "0d3c0c3f693d2b406e4844777f9a6fc7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 4639, "upload_time": "2018-04-21T14:25:07", "url": "https://files.pythonhosted.org/packages/20/ce/049e310769bee92c981ad804f97bf78efd0bb700f3635aaf6c3229618c17/pynbs-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "a4a86dc01d36dac0348cc5f34057feef", "sha256": "809825ce80de76508f2a54018dc356adda1287d520ca7b6235fc55e2132ed996" }, "downloads": -1, "filename": "pynbs-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a4a86dc01d36dac0348cc5f34057feef", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 4851, "upload_time": "2018-04-21T14:37:08", "url": "https://files.pythonhosted.org/packages/f5/f8/04f7389081d50fb19ee6b16ea85a389ddd1b1b918f4b987dd42c59d52dcb/pynbs-0.2.4-py2.py3-none-any.whl" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "4dd27ce5604830877c700fd15069fb2b", "sha256": "8131c0e14710df08f6676e92dd56a0dbfbbc13455aa0e1f1de8e55aa8e46f92a" }, "downloads": -1, "filename": "pynbs-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4dd27ce5604830877c700fd15069fb2b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 4854, "upload_time": "2018-09-28T20:48:50", "url": "https://files.pythonhosted.org/packages/a9/27/7ece065db50d43de76dafbf7082e547a79f875c3bfb3fed282bee30b0579/pynbs-0.2.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "35732ba0516e3492e39769816e76269f", "sha256": "7f3a23811a853457ff01784882c9f30a00a8a25f82beefb8a0d536b786205c20" }, "downloads": -1, "filename": "pynbs-0.2.5.tar.gz", "has_sig": false, "md5_digest": "35732ba0516e3492e39769816e76269f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5021, "upload_time": "2018-09-28T20:48:51", "url": "https://files.pythonhosted.org/packages/6f/36/19602f55696e0938bf69b008d4cab04d07cef9c8669221a0e3b4869171b5/pynbs-0.2.5.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "fe3e05f971c4457da62ee5c90d07579f", "sha256": "551cc53c940734527b68f239a2ed3c37432efa66ddfc5a5a39ac2a10ced9b539" }, "downloads": -1, "filename": "pynbs-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fe3e05f971c4457da62ee5c90d07579f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 5326, "upload_time": "2019-08-18T00:30:43", "url": "https://files.pythonhosted.org/packages/f7/9c/30a0860b9de45faeaaeaedd67a2f310bbd3145c7321ab4c8f7f1b791378e/pynbs-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ad52e718b3d0ae100c4b02921cce781", "sha256": "2387372bdc7124989cfde6b187474f970ba3dad9e4566532a849a82aac8df35f" }, "downloads": -1, "filename": "pynbs-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1ad52e718b3d0ae100c4b02921cce781", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5588, "upload_time": "2019-08-18T00:30:45", "url": "https://files.pythonhosted.org/packages/97/9b/1b41a01767cf22c7f28077062c812c1739ab74caae1898638e0321b768da/pynbs-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fe3e05f971c4457da62ee5c90d07579f", "sha256": "551cc53c940734527b68f239a2ed3c37432efa66ddfc5a5a39ac2a10ced9b539" }, "downloads": -1, "filename": "pynbs-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fe3e05f971c4457da62ee5c90d07579f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 5326, "upload_time": "2019-08-18T00:30:43", "url": "https://files.pythonhosted.org/packages/f7/9c/30a0860b9de45faeaaeaedd67a2f310bbd3145c7321ab4c8f7f1b791378e/pynbs-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ad52e718b3d0ae100c4b02921cce781", "sha256": "2387372bdc7124989cfde6b187474f970ba3dad9e4566532a849a82aac8df35f" }, "downloads": -1, "filename": "pynbs-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1ad52e718b3d0ae100c4b02921cce781", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5588, "upload_time": "2019-08-18T00:30:45", "url": "https://files.pythonhosted.org/packages/97/9b/1b41a01767cf22c7f28077062c812c1739ab74caae1898638e0321b768da/pynbs-0.3.0.tar.gz" } ] }