Wrapper for the SDIF library for audio analysis
Project description
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
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-1.0.0.tar.gz
(733.7 kB
view hashes)
Built Distributions
pysdif3-1.0.0-cp312-cp312-win32.whl
(441.4 kB
view hashes)
pysdif3-1.0.0-cp311-cp311-win32.whl
(443.9 kB
view hashes)
pysdif3-1.0.0-cp310-cp310-win32.whl
(443.9 kB
view hashes)
pysdif3-1.0.0-cp39-cp39-win_amd64.whl
(474.3 kB
view hashes)
pysdif3-1.0.0-cp39-cp39-win32.whl
(179.0 kB
view hashes)
Close
Hashes for pysdif3-1.0.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332b4ea15d521150ac7c15f8b035110a9401303c4a1b2d3d38dd2287decb7386 |
|
MD5 | e43c167242ab7c466daa1aba1687dbf0 |
|
BLAKE2b-256 | d086f368fdc99f775fdbc28b78e357ccd03ed8a83120f9be732366cd669867f5 |
Close
Hashes for pysdif3-1.0.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a0bbbba497e913b4734f19be4c5349235a69ca7b4a76a1f54cb227f3c3c3daa |
|
MD5 | 8e5a5fe01d37b2009f4b0d570a6b520e |
|
BLAKE2b-256 | f0ea379678c0ef78bf612fd1f8977bbd9eb8306d758687d6eb2682a2936d5104 |
Close
Hashes for pysdif3-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 353d881f0a44ffdc662aad9f5bc15f91985742eda397377f320461caabdf68b8 |
|
MD5 | 4fd933231a1f0d20165e47969c91f186 |
|
BLAKE2b-256 | 6587c593ada97c58cdf10a61de3f9fcc0a96587d54e4991f5eb84b873d015370 |
Close
Hashes for pysdif3-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84fe06d2cf28d070aef285f4c4d4290f41d1adfb6970b1c9abbc77049f077de8 |
|
MD5 | 37b79252963d014c3b01bb19a745de60 |
|
BLAKE2b-256 | 0c423081882e33bf72fd6ad36bd080c51351e247128695d1d44f56b8a43e94d4 |
Close
Hashes for pysdif3-1.0.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99b64cdda2180113a3f4afc00e9cfd5d7e7e57550c285a280536bb770353849d |
|
MD5 | 31f3fe619fe903d81c6416ed979e57c5 |
|
BLAKE2b-256 | ce93ecf24218e399bf3f486c014741d94d57c78ce0307c463c1c363a8c529b1a |
Close
Hashes for pysdif3-1.0.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37d883d158b706f2119130c865db4fb804a79391694b845fb4a46447e4016f62 |
|
MD5 | 5ce548cf821149cb89a52f630bf857c7 |
|
BLAKE2b-256 | b19bcea9f8ff3d86ec820d39f70c14723707531f27420c121e6ada037068586a |
Close
Hashes for pysdif3-1.0.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 752593f0ab52962311c49f333bc1f125fef6cc83f62f336d9625fa3df52f06eb |
|
MD5 | b45de44a11e3726d2e86ccfa3b5c8528 |
|
BLAKE2b-256 | 85cc57c63b0931a2ddbc3219a1c237b2948cbdc537f077b5ae1426adc2aff25b |
Close
Hashes for pysdif3-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81cc7be01052b45d0767cc2bc3413a619d70d261fd8074d9967f1dfbb37796d1 |
|
MD5 | 6e1fb08303b300773191b82b68326d69 |
|
BLAKE2b-256 | a8c61ed048834c1e90e16768710f25ae4c3fe29a8c5e7558abed819c10860b0a |
Close
Hashes for pysdif3-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea1ad363f3af40eaab729f5746a0df0eae7e01881b11fe11498f627fefb404d2 |
|
MD5 | cd7eba047294e3a053155490d1fb9249 |
|
BLAKE2b-256 | 0aadcc3d1e1be9b09ce87c2f6c4cd71f043a8bc3ac8378ed2497de38daa4a573 |
Close
Hashes for pysdif3-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef4e90ff32e03b5885f0494aaa342afdb1d1c0b1100e452b5ad83b7b7642aecb |
|
MD5 | fed0aea5626eed1b37edce6aa1cfa5a2 |
|
BLAKE2b-256 | 8d72d406008650abe9a3e527c015483d029a863e9c7a762c68cf308bf3c197fc |
Close
Hashes for pysdif3-1.0.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d028adcdecf99891b47b6aae0f144a0f0b7c24041b37326e066eca80dca29dbc |
|
MD5 | f0e4fb56274d7bf7d7bed82f621465ef |
|
BLAKE2b-256 | 6c3f0e4f1723f9439fc3a76585fcd3853c7b5a76273df97ea267ae5413e54ab4 |
Close
Hashes for pysdif3-1.0.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2d2a2e70c413ab89b6fd60bbbdbda74161734ab3857d465d5d9e0effe93300f |
|
MD5 | 9a7921484719baca57b07f24b1952858 |
|
BLAKE2b-256 | 022100ed0d61945f450248fbba1c339f4e0454658652bb1e15f6dc9ceabbb17c |
Close
Hashes for pysdif3-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4075edc2a41fac1b4d3e6609acfbe8e71a88b45d5b8e713df0d6ea7bdacc01d |
|
MD5 | 91f75aa855059079904ca7937b4b8da3 |
|
BLAKE2b-256 | aeae0ee1f0aceeb1e81a439ac50f2f1ee6900210eccda453d695e0ae3dcc1535 |
Close
Hashes for pysdif3-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea38f16f32ddeec12ebc16e2550d90fa06e8625d1e4d08e092edb5783b18a688 |
|
MD5 | dac86b4960b29a379f206d6787cb2b53 |
|
BLAKE2b-256 | 5051478da0b5ec00963cbf2b855a91282325d11f70e333a68b9af35e3fdac159 |
Close
Hashes for pysdif3-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e95bbf84faff4f05842f7c455ed591b0d65e7b846ae08f1c66ca874a07b174c0 |
|
MD5 | 9730624c49bc24fd48e2ebb654cd7a12 |
|
BLAKE2b-256 | 1f0229848f5523c14b6144da9e5b710fae7df132d5bd52ef8470e0489707df7d |
Close
Hashes for pysdif3-1.0.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7fc48f3ee3350d31e6259445e9ad83508a3d238f3aa09557da8cb24db61111f |
|
MD5 | be59286698c256cb96300f2577bbcf91 |
|
BLAKE2b-256 | 4d97ab873cb7faf62910640a3e671e70c769d11536d11fc4f269f8455dbc2cee |
Close
Hashes for pysdif3-1.0.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa7c570c901f98823205e01b9aa4e970537112095d00fff8558c135f0da7f282 |
|
MD5 | 835033b7bd41b59143d37c32ed75baf9 |
|
BLAKE2b-256 | 9d228bb6e8088df00407c0cc20de225cb1b6cd4b513ab12d84db64993d0c48ed |
Close
Hashes for pysdif3-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7578b1dc9ce92e4a042e3447c0f1121568ae6fc4aac9ec28abedd6f301f0be |
|
MD5 | 1155a7b6601e807770dce099589ee410 |
|
BLAKE2b-256 | ba6ac36159dba3fccd87783188a323deabc84c97df7301c63f5da4137cfaed48 |
Close
Hashes for pysdif3-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f99b3665706852d573da0c987a207b1d1af076d2184c99e5df4feae29547f1db |
|
MD5 | 5cfc2ead2e70fda15a87729ef2eb5bba |
|
BLAKE2b-256 | 19804b73b24aa774cc9693f291dbc70f41486198c69bc5e544eafdf2050ee755 |
Close
Hashes for pysdif3-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78ee4a3510cc17cc406821cb0f8572a2825889657c44b9b2c2e3c9badbf04b7b |
|
MD5 | 9cb6f0a9ed559a38389777e3ec94e477 |
|
BLAKE2b-256 | 87a8f880e375bc066e785578fcd98eb9b14c14085ca5e3e110a490ae9e670d33 |