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.9.0.tar.gz
(683.4 kB
view hashes)
Built Distributions
pysdif3-0.9.0-cp311-cp311-win32.whl
(375.1 kB
view hashes)
pysdif3-0.9.0-cp310-cp310-win32.whl
(376.1 kB
view hashes)
pysdif3-0.9.0-cp39-cp39-win_amd64.whl
(408.6 kB
view hashes)
pysdif3-0.9.0-cp39-cp39-win32.whl
(162.8 kB
view hashes)
Close
Hashes for pysdif3-0.9.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b96bc59113fc95b25b446b335ff63f4b3f43a4dcf5b067a0118203913cf89e0 |
|
MD5 | de306a9c89dd20ef216cd0aed9e03e0d |
|
BLAKE2b-256 | 5a4a53c849c4af6efc15da8324a3e73a7049595f83591ae030604431a559f924 |
Close
Hashes for pysdif3-0.9.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f54bde327b10df5549a2f9f7bbaa65be41a00d8149f90e8746032a97acff99 |
|
MD5 | fe887041c83ddd8dcf0e537bb8b31261 |
|
BLAKE2b-256 | 70bb8573e56f24e69f31c1d74d06667524013a2835b99c42fef56e12d3e0db18 |
Close
Hashes for pysdif3-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e97f5b9ca1783afd5f972a21c18103f8b766f36d287763cc75e39c6c61ae3956 |
|
MD5 | a10490c7546c460ea1f2a5ac44ab04bb |
|
BLAKE2b-256 | 944627829daacbada4f50731dbe80ae76157a68352fc0d79129de22e37065be0 |
Close
Hashes for pysdif3-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3260d8aaa047bc93d903541266251125e9fe0a17fa1489cd6c92d5bb71d25ec5 |
|
MD5 | 69afb57cdc82b342c8ec228de2a8924d |
|
BLAKE2b-256 | 3e4b52d7ff3e3504cdd9ce7891d99f99a4013d54ba0699fa8ded367dcf4e5ff1 |
Close
Hashes for pysdif3-0.9.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0833ae18f0c978bccba404fd5b711235e8c74f2ee43c557c5a99e0e2d7be4d04 |
|
MD5 | eccea6ee9120e57121a229c9258f7127 |
|
BLAKE2b-256 | 84eb4a70211040c383d87e699000629781e42a26bd2593343877b3b1074ae15b |
Close
Hashes for pysdif3-0.9.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cca6d99ac1b5e2b192be1509a8ca8395892af6dc83992aff6253e270181692d1 |
|
MD5 | 1fd1a036f9b3965be2ad4eb51ffe5445 |
|
BLAKE2b-256 | 38a16553181fff17b4c5fa71f2d36f7e99b3faf4518789af6d273484ca0836c3 |
Close
Hashes for pysdif3-0.9.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e36718d8f18d57cf6b71f167f795f94e9f22c56e92996836c8acddbafc91f14 |
|
MD5 | f7ee96655799c8c23d2b109b4af62d34 |
|
BLAKE2b-256 | 2aa9814cd6284205fc40d9f7b04e8bdf583962f8d158c794860a8a7247c102c5 |
Close
Hashes for pysdif3-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350e2fce8b2f918862529d9679d54744eca71b94e48f08a574da65588341051b |
|
MD5 | f2b6d8482f6e4b56471bab37fc7a5cd3 |
|
BLAKE2b-256 | 7f13dd94985c0690767e0f0216f9aea6b2e5e723e7a1a42b211078515d282aef |
Close
Hashes for pysdif3-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7309c404aafd20d8a39b90fbf8a894a697b51bcdad3399787c6f3cc15e55d3d8 |
|
MD5 | 2cb4682f0cf7bde53d9c214f6e86d982 |
|
BLAKE2b-256 | a949f2e132237a8c9dc1d367e8864a230de0bbce73adc41cf1aec2bf699f7c35 |
Close
Hashes for pysdif3-0.9.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbacf078843b0d2763db504233a3b08209473e354fe4eca6f3ed60a425313226 |
|
MD5 | d986ab1f76d3304b381f3847d4fd99e2 |
|
BLAKE2b-256 | f0523b662da6c39b5b57cae8333a115670d88cc9fc97babf18772af62c10eb90 |
Close
Hashes for pysdif3-0.9.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc3331147c64003514e328921b47d4162bbdec33fc926b3cf09e166eb9397916 |
|
MD5 | ed10acef317ec4483d0b4661f6aa81e6 |
|
BLAKE2b-256 | 86d085470e25e90246246786b0779829aa2eee60295519c666c3447306d15c9c |
Close
Hashes for pysdif3-0.9.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff46cd3cf7c8d5f83d88feb856da5610071c409c3a5927afa87db0483029fd0 |
|
MD5 | 3f4a598347d74b10ca566fa31e11e289 |
|
BLAKE2b-256 | d76b40332207521bc5ddd27983c5d3c1edc86d59cc476de07b47348101aad6e9 |
Close
Hashes for pysdif3-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a70040f4cfd526940d34041f82ee272800f64c17b2a1bb824943c0302ff40c |
|
MD5 | b9ec6e38bac78376156d40be684057b2 |
|
BLAKE2b-256 | 0eb018c39d460d38710cf3da3a858777eceb2ec8a9dd60e83de4c2b06db33731 |
Close
Hashes for pysdif3-0.9.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f4aabb2dc91fd95290c0149a7410a407b5240e1dcebaff0c69168ab6e9d1229 |
|
MD5 | e54fe7934ddeee2b65c7f5530ddfc5d6 |
|
BLAKE2b-256 | 5eece2cf86bb520d045531ce1c4fe77e16166dc8f16d782054405ebd9e9ad88e |
Close
Hashes for pysdif3-0.9.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efc277bab2c38fb2ee4d96b011a033c82c7a3658b82473508c6b27529734a178 |
|
MD5 | 13747516fbc035d551e1a73cc19d82a5 |
|
BLAKE2b-256 | 2211d623badd79c2f0320f1877f1be14ac3f2239790f89d90a4907266eb2df8a |