|sh-month| |sh-wheel|
.. |sh-month| image:: https://static.pepy.tech/badge/pysdif3/month
.. |sh-wheel| image:: https://img.shields.io/badge/binary%20wheel-linux%20win64%20macos--x86--64%20macos--arm64-green
SDIF for Python
===============
- Author: Eduardo Moguillansky
- Contact: ``eduardo.moguillansky@gmail.com``
This is a python wrapper to IRCAM’s sdif library
(http://sourceforge.net/projects/sdif/files/sdif/) to read and write
SDIF files. It consists of a core written in Cython and some other
utilities written in Python. The SDIF library is included in the package
and built together with the python wrapper.
**NB**: This software is released under the GPL v3 license.
--------------
Install
-------
.. code:: bash
pip install pysdif3
--------------
Build from source
-----------------
.. code:: bash
git clone https://github.com/gesellkammer/pysdif3
cd pysdif3
python3 setup.py install
--------------
Introduction
------------
Sdif files are used to store time-based analysis. A Sdif file consists
of time-tagged frames, each frame consisting of one or more matrices.
Read a Sdif file, read only selected matrices
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from pysdif import *
sdif = SdifFile("path.sdif")
# get metadata
print(sdif.get_NVTs())
for frame in sdif:
print(frame.time, frame.signature)
for matrix in frame:
if matrix.signature == b'1MAT':
print(matrix.get_data())
Write a Sdif file modifying a previous one
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from pysdif import *
infile = SdifFile("source.sdif")
outfile = SdifFile("out.sdif", "w").clone_definitions(infile)
for inframe in infile:
if inframe.signature != b'1TRC':
continue
with outfile.new_frame(inframe.signature, inframe.time) as outframe:
for matrix in inframe:
# 1TRC has columns index, freq, amp, phase
data = matrix.get_data(copy=True)
# modify frequency
data[:,1] *= 2
outframe.add_matrix(matrix.signature, data)
outfile.close()
Write a SDIF file from scratch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from pysdif import *
import numpy as np
sdif = SdifFile("rbep.sdif", "w")
# Add some metadata. This is optional
sdif.add_NVT({'creator': 'pysdif3'})
# Add any matrix definitions. In this case we add only one definition
# This is a matrix named "RBEP" with 6 columns
# Each row in this matrix represents a breakpoint within a frame
# Index: partial index to which a breakpoint belongs
# Frequency: the freq. of the breakpoint
# Amplitude: the amplitude of the breakpoint
# Phase: the phase
# Bandwidth: the "noisyness" of the breakpoint
# Offset: the time offset in relation to the frame time
sdif.add_matrix_type("RBEP", "Index, Frequency, Amplitude, Phase, Bandwidth, Offset")
# After all matrix types are defined we define the frames. A frame is defined
# in terms of the matrices it accepts.
# Here we define a frame named "RBEP" which takes only matrices of type "RBEP"
sdif.add_frame_type("RBEP", ["RBEP ReassignedBandEnhancedPartials"])
# Now we need to add the data. Since there is just one matrix per frame
# in this sdif we can use the shortcut sdif.new_frame_one_matrix which
# creates a frame and adds a matrix all at once
# The data is just fake data for the sake of an example
data = np.array([
[1, 440, 0.1, 0, 0, 0],
[2, 1000, 0.2, 0, 0, 0],
], dtype=float)
sdif.new_frame_one_matrix(frame_sig="RBEP", time=0.5, matrix_sig="RBEP", data=data)
# A second frame
data = np.array([
[1, 442, 0.1, 0, 0, 0],
[2, 1100, 0.1, 0, 0, 0]
], dtype=float)
sdif.new_frame_one_matrix(frame_sig="RBEP", time=0.6, matrix_sig="RBEP", data=data)
sdif.close()
--------------
Documentation
-------------
https://pysdif3.readthedocs.io/
Raw data
{
"_id": null,
"home_page": "https://github.com/gesellkammer/pysdif",
"name": "pysdif3",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "",
"author": "Eduardo Moguillansky",
"author_email": "eduardo.moguillansy@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/99/90/43cb8c36f28da9304e5f2c835368e5a57cdf91a0c7cddb2f587549867b76/pysdif3-1.0.0.tar.gz",
"platform": null,
"description": "|sh-month| |sh-wheel|\n\n.. |sh-month| image:: https://static.pepy.tech/badge/pysdif3/month\n.. |sh-wheel| image:: https://img.shields.io/badge/binary%20wheel-linux%20win64%20macos--x86--64%20macos--arm64-green\n\nSDIF for Python\n===============\n\n- Author: Eduardo Moguillansky\n- Contact: ``eduardo.moguillansky@gmail.com``\n\nThis is a python wrapper to IRCAM\u2019s sdif library\n(http://sourceforge.net/projects/sdif/files/sdif/) to read and write\nSDIF files. It consists of a core written in Cython and some other\nutilities written in Python. The SDIF library is included in the package\nand built together with the python wrapper. \n\n**NB**: This software is released under the GPL v3 license.\n\n--------------\n\nInstall\n-------\n\n.. code:: bash\n\n\n pip install pysdif3\n\n\n\n--------------\n\nBuild from source\n-----------------\n\n.. code:: bash\n\n\n git clone https://github.com/gesellkammer/pysdif3\n cd pysdif3\n\n python3 setup.py install\n\n--------------\n\nIntroduction\n------------\n\nSdif files are used to store time-based analysis. A Sdif file consists\nof time-tagged frames, each frame consisting of one or more matrices.\n\nRead a Sdif file, read only selected matrices\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n \n from pysdif import *\n sdif = SdifFile(\"path.sdif\")\n # get metadata\n print(sdif.get_NVTs())\n for frame in sdif:\n print(frame.time, frame.signature)\n for matrix in frame:\n if matrix.signature == b'1MAT':\n print(matrix.get_data())\n\nWrite a Sdif file modifying a previous one\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n\n from pysdif import *\n infile = SdifFile(\"source.sdif\")\n outfile = SdifFile(\"out.sdif\", \"w\").clone_definitions(infile)\n for inframe in infile:\n if inframe.signature != b'1TRC':\n continue\n with outfile.new_frame(inframe.signature, inframe.time) as outframe:\n for matrix in inframe:\n # 1TRC has columns index, freq, amp, phase\n data = matrix.get_data(copy=True)\n # modify frequency\n data[:,1] *= 2\n outframe.add_matrix(matrix.signature, data)\n outfile.close()\n\nWrite a SDIF file from scratch\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n\n from pysdif import *\n import numpy as np\n\n sdif = SdifFile(\"rbep.sdif\", \"w\")\n\n # Add some metadata. This is optional\n sdif.add_NVT({'creator': 'pysdif3'})\n\n # Add any matrix definitions. In this case we add only one definition\n # This is a matrix named \"RBEP\" with 6 columns\n # Each row in this matrix represents a breakpoint within a frame\n # Index: partial index to which a breakpoint belongs\n # Frequency: the freq. of the breakpoint\n # Amplitude: the amplitude of the breakpoint\n # Phase: the phase\n # Bandwidth: the \"noisyness\" of the breakpoint\n # Offset: the time offset in relation to the frame time\n sdif.add_matrix_type(\"RBEP\", \"Index, Frequency, Amplitude, Phase, Bandwidth, Offset\")\n\n # After all matrix types are defined we define the frames. A frame is defined\n # in terms of the matrices it accepts.\n # Here we define a frame named \"RBEP\" which takes only matrices of type \"RBEP\"\n sdif.add_frame_type(\"RBEP\", [\"RBEP ReassignedBandEnhancedPartials\"])\n\n # Now we need to add the data. Since there is just one matrix per frame\n # in this sdif we can use the shortcut sdif.new_frame_one_matrix which \n # creates a frame and adds a matrix all at once\n # The data is just fake data for the sake of an example\n data = np.array([\n [1, 440, 0.1, 0, 0, 0],\n [2, 1000, 0.2, 0, 0, 0], \n ], dtype=float)\n sdif.new_frame_one_matrix(frame_sig=\"RBEP\", time=0.5, matrix_sig=\"RBEP\", data=data)\n\n # A second frame\n data = np.array([\n [1, 442, 0.1, 0, 0, 0],\n [2, 1100, 0.1, 0, 0, 0]\n ], dtype=float)\n sdif.new_frame_one_matrix(frame_sig=\"RBEP\", time=0.6, matrix_sig=\"RBEP\", data=data)\n\n sdif.close()\n\n--------------\n\nDocumentation\n-------------\n\nhttps://pysdif3.readthedocs.io/\n",
"bugtrack_url": null,
"license": "",
"summary": "Wrapper for the SDIF library for audio analysis",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/gesellkammer/pysdif"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "999043cb8c36f28da9304e5f2c835368e5a57cdf91a0c7cddb2f587549867b76",
"md5": "b189defec7738bdabeb49c2a85b95da3",
"sha256": "7ad5e351c9399871a017542bd99fa0e93e6c7e249134fbeaf4ecb685bb8b7a75"
},
"downloads": -1,
"filename": "pysdif3-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "b189defec7738bdabeb49c2a85b95da3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 733669,
"upload_time": "2024-01-18T17:42:16",
"upload_time_iso_8601": "2024-01-18T17:42:16.542483Z",
"url": "https://files.pythonhosted.org/packages/99/90/43cb8c36f28da9304e5f2c835368e5a57cdf91a0c7cddb2f587549867b76/pysdif3-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-18 17:42:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gesellkammer",
"github_project": "pysdif",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pysdif3"
}