siggigue / pyfilterbank Goto Github PK
View Code? Open in Web Editor NEWImplementing a fractional octave filterbank for python. Based on Numpy and CFFI.
Implementing a fractional octave filterbank for python. Based on Numpy and CFFI.
sosfilter_c
gives wrong results when cascading multiple biquads. Some simple code to show:
import numpy as np
from pyfilterbank.sosfiltering import sosfilter_c
from scipy.signal import sosfilt
sos0 = np.array([
[0.9994671940803528, -1.980954885482788, 0.9816480278968811, 1.0, -1.9809452295303345, 0.981124997138977],
[0.9940603375434875, -1.8794806003570557, 0.89670330286026, 1.0, -1.8794806003570557, 0.8907635807991028]
])
sos1 = sos0.flatten()
x = np.random.random((16,))
z0 = np.zeros((sos0.shape[0], 2))
y0, z0 = sosfilt(sos0, x, zi=z0)
y1, z1 = sosfilter_c(x, sos1)
y2, _ = sosfilter_c(x, sos0[0])
y2, _ = sosfilter_c(y2, sos0[1])
y0
and y2
are identical except the numerical precision but y1
is incorrect.
I don't know much compiling and enviroment handling, the thing is that I can only import pyfilterbank if the module directory is in my working directory... how can the pakage be added to the default modules path? I'm on win10 using Spyder through Anaconda3
I successfully installed pyfilterbank
according to the installation on the README, with no errors.
But when I imported pyfilterbank
in my Jupiter notebook I received this error:
OSError: cannot load library '/Users/bg/miniforge3/envs/tf/lib/python3.8/site-packages/pyfilterbank/sosfilt.so': dlopen(/Users/bg/miniforge3/envs/tf/lib/python3.8/site-packages/pyfilterbank/sosfilt.so, 2): no suitable image found. Did find:
/Users/bg/miniforge3/envs/tf/lib/python3.8/site-packages/pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/bg/miniforge3/envs/tf/lib/python3.8/site-packages/pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00. Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/bg/miniforge3/envs/tf/lib/python3.8/site-packages/pyfilterbank/sosfilt.so'
Any advice on how to resolve this issue?
Hi. This library seems quite useful, especially for Gammatone which I have not found many other good packages for. However it is not installable with pip from PyPI. Can you add it there?
splweighting.weight_signal():
Argument in function definition ist data, but in return value x is used.
Simple fix would be changing x to data in call of lfilter()
octbank (multiple functions):
I assume there were some code changes in numpy 1.12 or 1.13 that start checking for integers as argument of np.zeros() , np.abs() and others. So it is necassary to cast the divisions, at least in my setup (Python 3.5.3)
$ gcc -c -std=c99 -O3 sosfilter.c
$ gcc -shared -o sosfilter.so sosfilter.o
should be changed into
$ gcc -c -std=c99 -O3 sosfilt.c
$ gcc -shared -o sosfilt.so sosfilt.o
Hi guys,
First thanks for writing this library. I'm using it for a sound project where I read the input from a microphone using the sounddevice library for python then giving the data to your library for dBa measurements.
The result is a bit off. When recording a quiet room using the microphone (samplerate 44100, dtype = int16), I get 30dBa. But when turning on a decibel-device (UNI-T UT353) it reads 40dBa.
Is my code wrong, or the UNI-T decibel-device?
Could it be that my ndarray contains int16, and not int24?
e.g.:
fbank = pyfilterbank(gammatone.GammatoneFilterbank(
48000, startband=-16, endband=32)
print(fbank.centerfrequencies)
will return frequencies from -14 to 36000.
Hi,
I am trying to use the pyfilterbank library under Ubuntu. When I try to run the example script
from pyfilterbank import octbank
octbank.example_plot()
I get the error "AttributeError: sosfilter_double_mimo: "function 'sosfilter_double_mimo' not found in library '/usr/local/lib/python2.7/dist-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfilt.so': /usr/local/lib/python2.7/dist-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfilt.so: undefined symbol: sosfilter_double_mimo".
Can anyone help me to fix the problem?
Best regards,
G.
Looks like you programmed exactly what I need. However, when running
import pyfilterbank
I get this error message:
cannot load library ./pyfilterbank/sosfilt.so: dlopen(./pyfilterbank/sosfilt.so, 2): no suitable image found. Did find: ./pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
Any idea what to change?
Hi guys,
I may have noticed a small error in the standardized_nominal_frequencies
array in the octbank.py file. I would say that the 3
value between 0.6
& 0.8
is wrong. It's not a big problem if you notice it, but you might want to change it if I'm right.
Thanks for your helpful work!
Hello, I installed the module and get this when running:
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/init.py", line 11, in
from . import butterworth
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/butterworth.py", line 9, in
from pyfilterbank.sosfiltering import bilinear_sos
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfiltering.py", line 74, in
_c = ffi.dlopen(_mylibpath)
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/cffi/api.py", line 832, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/cffi/api.py", line 827, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library '/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfilt.so': dlopen(/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfilt.so, 2): no suitable image found. Did find:
/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00. Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/lautaro_wlasenkov/opt/anaconda3/envs/pl-4_6/lib/python3.7/site-packages/pyfilterbank/sosfilt.so'
Can you help me?
Great project!
Besides the documentation regarding the different modules. Can you reference some information regarding what exactly each module do theoretically?
Is there a cookbook?
Dear all,
I would like to use this library for sound analysis in python but i have an error:
command: python test_octbank.py
Traceback (most recent call last): File "test_octbank.py", line 3, in <module> import pyfilterbank.octbank as fb File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/__init__.py", line 11, in <module> from . import butterworth File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/butterworth.py", line 9, in <module> from pyfilterbank.sosfiltering import bilinear_sos File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfiltering.py", line 74, in <module> _c = ffi.dlopen(_mylibpath) File "/usr/local/lib/python2.7/site-packages/cffi/api.py", line 139, in dlopen lib, function_cache = _make_ffi_library(self, name, flags) File "/usr/local/lib/python2.7/site-packages/cffi/api.py", line 742, in _make_ffi_library backendlib = _load_backend_lib(backend, libname, flags) File "/usr/local/lib/python2.7/site-packages/cffi/api.py", line 731, in _load_backend_lib return backend.load_library(name, flags) OSError: cannot load library /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfilt.so: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfilt.so, 2): no suitable image found. Did find: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfilterbank-0.0.0-py2.7.egg/pyfilterbank/sosfilt.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
please could you help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.