Wrapper for the SDIF library for audio analysis
Project description
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
pip install pysdif3
Build from source
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
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
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysdif3-0.8.0.tar.gz
(683.3 kB
view hashes)
Built Distributions
pysdif3-0.8.0-cp311-cp311-win32.whl
(375.1 kB
view hashes)
pysdif3-0.8.0-cp310-cp310-win32.whl
(376.1 kB
view hashes)
pysdif3-0.8.0-cp39-cp39-win_amd64.whl
(408.6 kB
view hashes)
pysdif3-0.8.0-cp39-cp39-win32.whl
(162.8 kB
view hashes)
Close
Hashes for pysdif3-0.8.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5ca596e81a209f172a9a7736e25bc9402c045c45ea8222cc311dbdaec11fda1 |
|
MD5 | b2a4a6a0216a6bbd947afb55bc22fb04 |
|
BLAKE2b-256 | 8299eca7be1c7b368bffd0b14005b3a27acaa7fdb76fd1f5ba3a27158320db19 |
Close
Hashes for pysdif3-0.8.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 668ba733c189c49501b94f854b88a0518066b9b9e41d7ebe1ad25fd9494eab50 |
|
MD5 | d3d769ce0cf0280dac3ccaff30d95658 |
|
BLAKE2b-256 | 816f0635c679dfbd7145f9901e9ebce5aface1c1f446f356549b195189942917 |
Close
Hashes for pysdif3-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd4b7af2210d8ca82f41f5eb73cf4631c00a3c17038ea2e7a87fb43d3b4b270b |
|
MD5 | 56682d529d61291c6453af80e29258db |
|
BLAKE2b-256 | 59c104dbd5eea4ffba93df67680ccb7ead2f6b797e313c731d5611e387d85849 |
Close
Hashes for pysdif3-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6438f3bfd3f283eaba0a6cb08a44df6d418fa1b6fec0390134442c62cfcb1c1 |
|
MD5 | 9359d8484e5bc14a41ead6e8c40014f3 |
|
BLAKE2b-256 | 6e06a572f31dbdd0bd0ee425960c1b6fe5f5f1508730e2843c4ed0f74aebe5c1 |
Close
Hashes for pysdif3-0.8.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7db654b980dd68d9b5f59b8e8f739839763cad605e04bb570f499f6e0e17535 |
|
MD5 | b1eda28dabe892d2530072a00e2f8ae3 |
|
BLAKE2b-256 | 6b601780efd9bac213c07fb30c9e6e33340f29a65f94a514c9c3d590bbdf6e86 |
Close
Hashes for pysdif3-0.8.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35d0a2788a9732a53bd9cdf19dd3acc605732b2838ad3d8e947d0ef026c69964 |
|
MD5 | f0eb6127cbb06412cd85c98e163c1fb0 |
|
BLAKE2b-256 | 1f73e614d76a6ce215bba73f9d5497d8a7ef78995c57769036d712e8ea088f96 |
Close
Hashes for pysdif3-0.8.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea05438e89dd86b7db4c9de3d8e627af3ba522b62d2e48b17bf27c864f18fe9e |
|
MD5 | 6af7ddc24111ec38d076b119e66927fc |
|
BLAKE2b-256 | ac6e548c1bd0a8a632e3bdd990e36e4c323bfc621c00f8fa1c13b0a057802adb |
Close
Hashes for pysdif3-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aba33340714e53e18b1791311982874da89c90788e6f9ce5a0e3526dd826928 |
|
MD5 | f5519dc1ce238e257fb4c26aaec6b20a |
|
BLAKE2b-256 | 84637f9bd651710b53e5eb3c6aaa45e58ffd58917099656583c48447cfd8517b |
Close
Hashes for pysdif3-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1a88bf7a31e0c1c641c476c586a7d471c8a33363e130f2ac55d92b6dea6cb71 |
|
MD5 | de6f1e164d98497693eb521fdd4e7429 |
|
BLAKE2b-256 | 1ae7957c0857e00ac3de8dc24fbe3369074039cbced39afe91704c0ddf51a24b |
Close
Hashes for pysdif3-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41837ae02257c3b38fe7e55f8e466f7120b04622d8f703cf0f9269c66ac4d74f |
|
MD5 | fd133d97ddd7a28a0122c51c22b269c2 |
|
BLAKE2b-256 | 5354f5b9abd0527081e58d599bd6fdc5644e785c6b154da4e875114f9fb472c8 |
Close
Hashes for pysdif3-0.8.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3ea43633de4a9845f5eaeec3fca19da3a7113bcd12e0e7caa676fd01ff9613f |
|
MD5 | 1fd104740d82dc8455f23727810863c5 |
|
BLAKE2b-256 | cd98d1f4673b1aabb7708e9e1485aabc77f2eb9ae194231165df083ab7d83c93 |
Close
Hashes for pysdif3-0.8.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d6540b2da583febeb11563e5025e26bc27ea4dd27b8798e0d4a8a0cc55ed083 |
|
MD5 | 6bcb94e53a09eb272d28981c117429bf |
|
BLAKE2b-256 | 1e0d5f863278bb40b38ab4a895ee16cbd1f4893bd5a00371e6b6fa9c372e08b0 |
Close
Hashes for pysdif3-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8752aec7cab85ebfe8b3771af27d95c6dbb8577339cee08a9b5b5111a53d118 |
|
MD5 | 1926c405dc447c8b149b3e87207d83e5 |
|
BLAKE2b-256 | df1b287aa937a52a4aad6aafc723c7ba527d5df1f8eb243a5069af17203e7d0e |
Close
Hashes for pysdif3-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c49d1b42a6aea253520bab5e6e505cce39669769e44dc93d40cb3bbf863cfa1d |
|
MD5 | 6ec85e5cea4f1d3061e3aea42d9f2257 |
|
BLAKE2b-256 | d185d8c59b702cada0f58fda8663f837d3f96fedf0b4fda88f24a630eb8dbbcc |
Close
Hashes for pysdif3-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 125e22116271a2bc8fc11c155519ad1631ec75b3e611b98d2fa8f62d7527d6e3 |
|
MD5 | 689ad6f94af9064f581849d17a5295be |
|
BLAKE2b-256 | 64db05d32344f7f214fc6299786b4088908f5d29fb41e09b8fe391febc5aabc0 |