sf2utils


Namesf2utils JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummarySound font 2 parsing library and utilities
upload_time2024-01-11 11:11:45
maintainer
docs_urlNone
author
requires_python>=2.7
licenseGPLv3+
keywords soundfont sf2 sound font
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Sf2Utils
========

Sf2Utils is a soundfont 2 parsing library and companion utility.
It is meant for developers aiming to use soundfont 2 file as input,
typically for converting to another format.

Installation
------------

Sf2Utils is installable from PyPI with a single pip command::

    pip install sf2utils

Alternatively, Sf2utils can be run directly from sources after a git pull::

    git clone https://gitlab.com/zeograd/sf2utils.git
    cd sf2utils && python setup.py install


Companion script
----------------

**sf2parse** is a command line utility used to parse a sound font 2 file.
It is meant as debug companion for the **sf2utils** parser library as it shows
what is understood from its parser.

::

    usage: sf2parse [-h] [-d] sf2_filename

    LGPL v3+ 2016-2024 Olivier Jolly

    positional arguments:
      sf2_filename  input file in SoundFont2 format

    optional arguments:
      -h, --help    show this help message and exit
      -d, --debug   debug parsing [default: False]

    Parse sf2 file and display info about it


Library use
-----------

**sf2utils** can be used as a library for parsing SoundFont2 files.
There are 2 API levels, a low level and high level one.
They both open SoundFont2 file the same way::

    from sf2utils.sf2parse import Sf2File
    with open('file.sf2', 'rb') as sf2_file:
        sf2 = Sf2File(sf2_file)

Note that opening the file is up to the library user because samples
data are lazy loaded. Accessing sample data will seek and read data.
You shouldn't access sample data outside of the content in which
the file is opened, as it will fail.

Low level library API
.....................

Once sf2 is a valid Sf2File, all metadata are available via the
property **raw**, which has fields for the various sections in a
SoundFont2 file.

* **sf2.raw.info** is a dictionary with all info in the info block of the SoundFont2 file with keys as binary strings.

* **sf2.raw.smpl_offset** is the offset in the original file where the sample data are located.

* **sf2.raw.sm24_offset** is the offset in the original file where the complementary 8bits of sample data are located.

* **sf2.raw.pdta** is the main metadata structure, a dictionary with tuples named after the specification and indexed using specification structure names :
    * Pbag -> 'gen', 'mod'
    * Igen -> 'oper', 'amount'
    * Imod -> 'src_oper', 'dest_oper', 'amount', 'amount_src_oper', 'trans_oper'
    * Pmod -> 'src_oper', 'dest_oper', 'amount', 'amount_src_oper', 'trans_oper'
    * Pgen -> 'oper', 'amount'
    * Shdr -> 'sample_name', 'start', 'end', 'start_loop', 'end_loop', 'sample_rate', 'original_pitch', 'pitch_correction', 'sample_link', 'sample_type'
    * Phdr -> 'name', 'preset', 'bank', 'bag', 'library', 'genre', 'morphology'
    * Ibag -> 'gen', 'mod'
    * Inst -> 'name', 'bag'

With this API, field interpretation remains up to the library user.

High level library API
......................

With this API, info are available via the **info** property, which is a pretty printable tuple where every
field comes from the info block in the SoundFont2 file.

Samples are accessible via the **samples** property, which is a list of **Sf2Sample** from which you can
retrieve loop information and raw data.

Presets are in the **presets** property, which is a list of **Sf2Preset** from which you can list generators,
modulators, instruments and bags.

Instruments are in the **instruments** property, which is a list of **Sf2Instrument** from which you can
list bags of generators, modulators.

Bags are of class **Sf2Bag** and offer a wide range of property returning various high level info (about loop,
tuning, filters, envelopes, instruments, samples, ...) or None when no generator was found.

All those classes have a **pretty_print** returning a pretty printed string, recursing over subelements.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sf2utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "soundfont sf2 sound font",
    "author": "",
    "author_email": "Olivier Jolly <olivier@pcedev.com>",
    "download_url": "https://files.pythonhosted.org/packages/db/2e/620aac9ad3c71b95841e4f97a4d9c17adab47baa37dacd16b4ab80c04d6f/sf2utils-1.0.0.tar.gz",
    "platform": null,
    "description": "Sf2Utils\n========\n\nSf2Utils is a soundfont 2 parsing library and companion utility.\nIt is meant for developers aiming to use soundfont 2 file as input,\ntypically for converting to another format.\n\nInstallation\n------------\n\nSf2Utils is installable from PyPI with a single pip command::\n\n    pip install sf2utils\n\nAlternatively, Sf2utils can be run directly from sources after a git pull::\n\n    git clone https://gitlab.com/zeograd/sf2utils.git\n    cd sf2utils && python setup.py install\n\n\nCompanion script\n----------------\n\n**sf2parse** is a command line utility used to parse a sound font 2 file.\nIt is meant as debug companion for the **sf2utils** parser library as it shows\nwhat is understood from its parser.\n\n::\n\n    usage: sf2parse [-h] [-d] sf2_filename\n\n    LGPL v3+ 2016-2024 Olivier Jolly\n\n    positional arguments:\n      sf2_filename  input file in SoundFont2 format\n\n    optional arguments:\n      -h, --help    show this help message and exit\n      -d, --debug   debug parsing [default: False]\n\n    Parse sf2 file and display info about it\n\n\nLibrary use\n-----------\n\n**sf2utils** can be used as a library for parsing SoundFont2 files.\nThere are 2 API levels, a low level and high level one.\nThey both open SoundFont2 file the same way::\n\n    from sf2utils.sf2parse import Sf2File\n    with open('file.sf2', 'rb') as sf2_file:\n        sf2 = Sf2File(sf2_file)\n\nNote that opening the file is up to the library user because samples\ndata are lazy loaded. Accessing sample data will seek and read data.\nYou shouldn't access sample data outside of the content in which\nthe file is opened, as it will fail.\n\nLow level library API\n.....................\n\nOnce sf2 is a valid Sf2File, all metadata are available via the\nproperty **raw**, which has fields for the various sections in a\nSoundFont2 file.\n\n* **sf2.raw.info** is a dictionary with all info in the info block of the SoundFont2 file with keys as binary strings.\n\n* **sf2.raw.smpl_offset** is the offset in the original file where the sample data are located.\n\n* **sf2.raw.sm24_offset** is the offset in the original file where the complementary 8bits of sample data are located.\n\n* **sf2.raw.pdta** is the main metadata structure, a dictionary with tuples named after the specification and indexed using specification structure names :\n    * Pbag -> 'gen', 'mod'\n    * Igen -> 'oper', 'amount'\n    * Imod -> 'src_oper', 'dest_oper', 'amount', 'amount_src_oper', 'trans_oper'\n    * Pmod -> 'src_oper', 'dest_oper', 'amount', 'amount_src_oper', 'trans_oper'\n    * Pgen -> 'oper', 'amount'\n    * Shdr -> 'sample_name', 'start', 'end', 'start_loop', 'end_loop', 'sample_rate', 'original_pitch', 'pitch_correction', 'sample_link', 'sample_type'\n    * Phdr -> 'name', 'preset', 'bank', 'bag', 'library', 'genre', 'morphology'\n    * Ibag -> 'gen', 'mod'\n    * Inst -> 'name', 'bag'\n\nWith this API, field interpretation remains up to the library user.\n\nHigh level library API\n......................\n\nWith this API, info are available via the **info** property, which is a pretty printable tuple where every\nfield comes from the info block in the SoundFont2 file.\n\nSamples are accessible via the **samples** property, which is a list of **Sf2Sample** from which you can\nretrieve loop information and raw data.\n\nPresets are in the **presets** property, which is a list of **Sf2Preset** from which you can list generators,\nmodulators, instruments and bags.\n\nInstruments are in the **instruments** property, which is a list of **Sf2Instrument** from which you can\nlist bags of generators, modulators.\n\nBags are of class **Sf2Bag** and offer a wide range of property returning various high level info (about loop,\ntuning, filters, envelopes, instruments, samples, ...) or None when no generator was found.\n\nAll those classes have a **pretty_print** returning a pretty printed string, recursing over subelements.\n",
    "bugtrack_url": null,
    "license": "GPLv3+",
    "summary": "Sound font 2 parsing library and utilities",
    "version": "1.0.0",
    "project_urls": {
        "Bug tracker": "https://gitlab.com/zeograd/sf2utils/-/issues",
        "Homepage": "https://gitlab.com/zeograd/sf2utils"
    },
    "split_keywords": [
        "soundfont",
        "sf2",
        "sound",
        "font"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "579243777460e1a973f62a636a48a21102ef19692151c70971f26af0a5e35808",
                "md5": "d69aeaf0b8900cd35d29dc2963364a82",
                "sha256": "df1cec08b32372d4924ec998a39fa84c6c17fd8ddff082f46eb55c5bff9c9d66"
            },
            "downloads": -1,
            "filename": "sf2utils-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d69aeaf0b8900cd35d29dc2963364a82",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7",
            "size": 21523,
            "upload_time": "2024-01-11T11:11:43",
            "upload_time_iso_8601": "2024-01-11T11:11:43.166799Z",
            "url": "https://files.pythonhosted.org/packages/57/92/43777460e1a973f62a636a48a21102ef19692151c70971f26af0a5e35808/sf2utils-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db2e620aac9ad3c71b95841e4f97a4d9c17adab47baa37dacd16b4ab80c04d6f",
                "md5": "ff3a05af39bd0e13baaf70e68df1be4b",
                "sha256": "463cff7e8711716ab04906ca52d15b50613ce99aa16b1212f84daa01ccab2002"
            },
            "downloads": -1,
            "filename": "sf2utils-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ff3a05af39bd0e13baaf70e68df1be4b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 23800,
            "upload_time": "2024-01-11T11:11:45",
            "upload_time_iso_8601": "2024-01-11T11:11:45.125944Z",
            "url": "https://files.pythonhosted.org/packages/db/2e/620aac9ad3c71b95841e4f97a4d9c17adab47baa37dacd16b4ab80c04d6f/sf2utils-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-11 11:11:45",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "zeograd",
    "gitlab_project": "sf2utils",
    "lcname": "sf2utils"
}
        
Elapsed time: 0.16331s