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.6.3.tar.gz
(1.5 MB
view hashes)
Built Distributions
pysdif3-0.6.3-cp39-cp39-win_amd64.whl
(216.5 kB
view hashes)
pysdif3-0.6.3-cp39-cp39-win32.whl
(180.7 kB
view hashes)
pysdif3-0.6.3-cp38-cp38-win_amd64.whl
(217.4 kB
view hashes)
pysdif3-0.6.3-cp38-cp38-win32.whl
(182.0 kB
view hashes)
Close
Hashes for pysdif3-0.6.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26609819d2b5ede89195a99adc07fcb95e3d0db45b6277d07a319e794bdefe4e |
|
MD5 | 776f80707248a3710c9e543aebb72d1c |
|
BLAKE2b-256 | 7c4833c80fa8b809c58771582f0fbe47d706f5fcec0054ac1519d3ff16bfc640 |
Close
Hashes for pysdif3-0.6.3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c69415870224b33cae21e2fc1e1fd9a7770a3eb7e1dd0fd1057489946de1e12a |
|
MD5 | 83c6b779e3f8a478b8cfc5b34358eac5 |
|
BLAKE2b-256 | 689a0c4027e3d4d01cb1baaf8b67c6963a2f7eefb9b3e0879fb754923b12c275 |
Close
Hashes for pysdif3-0.6.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12850045f5d716f3de4ea5f62bcfad1dc14743a52dbb1147bff85158034fdc0c |
|
MD5 | 6cbc9460170501cd30be6dd8df5959db |
|
BLAKE2b-256 | d3d9416ee53f1ef17ff06e5e16a84a8f2fa41d9dac1eb7ba9b91cba6913b3b46 |
Close
Hashes for pysdif3-0.6.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a3ec9d01d78d8d62ac7eabf91513e0a06df38f78339a16f1214f8fdabaa3442 |
|
MD5 | f8f28807068585585e4771f482faee0c |
|
BLAKE2b-256 | e9cf91e4f207b2b7ab31fd4b356d90be131c98b6ee4dcca7037aa3c40af7ba9c |
Close
Hashes for pysdif3-0.6.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14b9a4073428a39a34f02fb8ace4855b6bc67485f1f15d6a268f3c188a39ac19 |
|
MD5 | e4bae2865e5a21d35d412e5889a0f8cb |
|
BLAKE2b-256 | a4c7524f57e065745e0e19539147ad3f00e74f4252918697107c95ba58e9ebe8 |
Close
Hashes for pysdif3-0.6.3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d671f7d76bddee943bc6caf2a39c782e6fb6911c04ab13d8ea73bcbf7b2c7fe4 |
|
MD5 | 0ccb4f09d664737c48e8e465df93cacc |
|
BLAKE2b-256 | 56824260231d5ab64babf3e58c75390bb0384d4e723c7357c812e7cded891fe2 |
Close
Hashes for pysdif3-0.6.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fbd6dca53df727a102f7e5e764dc785efc7967627a3be5ae93d67ee81967646 |
|
MD5 | dc0f53170d2137a9c8627f895643e5b5 |
|
BLAKE2b-256 | ed1cf18cf31337f3c14ffa889f77ef73ef56a8ed91bb24ae760bf49b79bc577d |
Close
Hashes for pysdif3-0.6.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ee48de084b319114c80163f9ade5558711e74083708e5d023b2fea102359cdb |
|
MD5 | a5da9db47fc4b5c82e2fe03bf755b33e |
|
BLAKE2b-256 | 5e5af762960e19859cd9d087c39b72881560868eaf713f9f2b4fabff14915cf9 |