Giter Site home page Giter Site logo

audiolazy's People

Contributors

danilobellini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audiolazy's Issues

[Question] AR prediction with ZFilter FIR

Iam trying to understand how the ZFilter object does its operation in the fitted time series (with Levinson Durbin AutoCorrelation coefficients) when you put the time series in the object caller in order to do Auto Regression, ie, x[t] = a[t-1]*x[t-1]+a[t-2]*x[t-2]+...+a[t-order]*x[t-order]

so i call:

Order=...
zf=levinson_durbin(acorr(timeseries[N-Order-1:N-1]),order=Order) # here iam fitting the 'a' coefficients according to the last Order elements of timeseries

fitted=zf(timeseries[N-Order-1:N-1]).take(Order)) # what exactly the FIR filter is doing here ? when 
 i call take to get Order elements based on the timeseries window of size Order ? 

Seems that the first element of the fitting by FIR, when i call take, is almost exactly the the same of the original series, while the others are not.

I would like to know what the FIR is doing depending upon the argment of .take, and why i cannot take more then Order elements, since i would like to do the AutoRegressive prevision, then use it to do another prevision with the same fitted FIR (like in the AR formula given above).

Thank you for your time and patience.

Log plot sampling

The LinearFilter.plot method samples nicely for linear plots, but when asked to output logarithmic plots (i.e., when fscale == "log") the freqs (and freqs_label)
sampling values should also be logarithmically distributed to keep the pixel-distance distribution linear, like what happens in iso226_plot.py.

Tests fail for pytest 3.2 and later

The tests are failing for pytest 3.2 and later, since the location of the XFailed class has moved.

audiolazy/tests/__init__.py:21: in <module>
    from _pytest.skipping import XFailed
E   ImportError: cannot import name XFailed

Support for newer python versions (> 3.7)

Bumping the python version from 3.6 fails because of a missing import from the collections library:

ImportError                               Traceback (most recent call last)
Cell In [2], line 7
      5 from scipy import signal
      6 import IPython.display as ipd
----> 7 from audiolazy import levinson_durbin
      8 import speech_test
      9 get_ipython().run_line_magic('matplotlib', 'inline')

File /opt/conda/lib/python3.10/site-packages/audiolazy/__init__.py:67
     16 """
     17 AudioLazy package
     18 
   (...)
     61 under the terms of the GPLv3.
     62 """
     64 # Some dunders and summary docstrings initialization
     65 __modules__, __all__, __doc__ = \
     66   __import__(__name__ + "._internals", fromlist=[__name__]
---> 67             ).init_package(__path__, __name__, __doc__)
     69 # Import all modules contents to the main namespace
     70 exec(("from .{} import *\n" * len(__modules__)).format(*__modules__))

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:117, in init_package(package_path, package_name, docstring)
    102 """
    103 Package initialization, to be called only by ``__init__.py``.
    104 
   (...)
    114 used by the package to import every module into the main package namespace.
    115 """
    116 module_names = get_module_names(package_path)
--> 117 modules = get_modules(package_name, module_names)
    118 dunder_all = dunder_all_concat(modules)
    119 for module in modules:

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:59, in get_modules(package_name, module_names)
     57 def get_module(name):
     58   return __import__(".".join([package_name, name]), fromlist=[package_name])
---> 59 return [get_module(name) for name in module_names]

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:59, in <listcomp>(.0)
     57 def get_module(name):
     58   return __import__(".".join([package_name, name]), fromlist=[package_name])
---> 59 return [get_module(name) for name in module_names]

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:58, in get_modules.<locals>.get_module(name)
     57 def get_module(name):
---> 58   return __import__(".".join([package_name, name]), fromlist=[package_name])

File /opt/conda/lib/python3.10/site-packages/audiolazy/lazy_analysis.py:23
     20 from __future__ import division
     22 from math import sin, cos, pi
---> 23 from collections import deque, Sequence, Iterable
     24 from functools import wraps, reduce
     25 from itertools import chain

ImportError: cannot import name 'Sequence' from 'collections' (/opt/conda/lib/python3.10/collections/__init__.py)

"OSError: [Errno -9985] Device unavailable"

While trying to use the I/O wire example provided with the master (io_wire.py) with any other audio API than the default, I always get this error (in PyCharm CE, W7 x64 with Python 3.5.1)):
(The [...]'s are redactions on my path, the actual traceback contains the full path.)

Traceback (most recent call last):
  File "C:/[...]/audiolazy_master/examples/io_wire.py", line 46, in <module>
    pr.play(pr.record())
  File "C:\[...]\lib\site-packages\audiolazy\lazy_io.py", line 270, in play
    new_thread = AudioThread(self, audio, **kwargs)
  File "C:\[...]\lib\site-packages\audiolazy\lazy_io.py", line 401, in __init__
    **kwargs)
  File "C:\[...]\lib\site-packages\pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "C:\[...]\lib\site-packages\pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9985] Device unavailable

Process finished with exit code 1

Here is the modified script for the wire:

[...]
from audiolazy import chunks, AudioIO
import sys

# Choose API via command-line
api = sys.argv[1] if sys.argv[1:] else None
print(api)

# Amount of samples per chunk to be sent to PortAudio
chunks.size = 1 if api == "jack" else 16

with AudioIO(True, api="asio") as pr: # A player-recorder
  pr.play(pr.record())

When using the I/O wire example provided with the PyAudio master (PyAudio-0.2.9.tar/test/wire_full.py), the wire works perfectly fine, the ASIO device is detected and the wire established. Here is the script, with the index of my ASIO device being 12:

import pyaudio
import sys

CHUNK = 256
WIDTH = 2
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5

if sys.platform == 'darwin':
    CHANNELS = 1

p = pyaudio.PyAudio()

stream = p.open(format=p.get_format_from_width(WIDTH),
                channels=CHANNELS,
                rate=RATE,
                input=True,
                input_device_index=12,
                output_device_index=12,
                output=True,
                frames_per_buffer=CHUNK)

print("* recording")

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    stream.write(data, CHUNK)

print("* done")

stream.stop_stream()
stream.close()

p.terminate()

Here's the info for the device, as given by as given by p.get_device_info_by_index(12):

{'defaultLowInputLatency': 0.0014512471655328798, 'name': 'Yamaha Steinberg USB ASIO', 'defaultHighInputLatency': 0.0014512471655328798, 'index': 12, 'structVersion': 2, 'maxOutputChannels': 2, 'defaultLowOutputLatency': 0.0014512471655328798, 'maxInputChannels': 2, 'defaultHighOutputLatency': 0.0014512471655328798, 'hostApi': 2, 'defaultSampleRate': 44100.0}

Sorry if it it's a PICNIC.

Plot methods testing

Some AudioLazy methods lacks automated testing. Coveralls says the least covered file is the lazy_filters.py, and most of the tests it's lacking is about its interface with Matplotlib.

It seems difficult to test a plot. But some tests might be done on the output figure to see at least whether:

  • Whether the output result is indeed a figure
  • Assert if the amount of axes is ok
  • Axes data should match expected values (for different input parameters)
  • A circle should be printed in the zplot

A much more difficult test would be matching the resulting image with an image analysis procedure to "see" (literally) whether the elements (and their displacement) are correct. Testing pixel-by-pixel wouldn't help if small details are changed (e.g. font face in different systems), so that shouldn't be done.

For now (and for this issue), at least the basic internal information itemized above should be tested.

ALSA underrun above rate=22000

Hey Danilo love the library. Hoping to make use of the lazy eval to do some DSP for a visual-audio art piece I'm working on.

When I try to run the examples I get static noise and stdout contains errors about ALSA lib pcm.c:8526:(snd_pcm_recover) underrun occurred

I eventually found that lowering rate on AudioIo.play avoids these errors.

sound = WavStream("static/mono.wav")
print(sound.channels, sound.rate)

with AudioIO(True, api="alsa") as player: 
    player.play(sound, rate= int(sound.rate // 3))  # Plays correctly

with AudioIO(True) as player:
    player.play(sound, rate= int(sound.rate // 2))

The first play is slowed down 3x but otherwise plays correctly. During the second play an error is printed about a hundred times to the console and the sound is just strongly static (with a little of the correct signal mixed in) for ~1 second (the clip is 22 seconds long).

Any idea why this might would be happening?

Issue with STFT overlap_add: ValueError: need at least one array to concatenate

Hello,

I tried both the robotize and roll magnitude examples and experienced the same error. From robotize:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_io.py", line 414, in run
    for chunk in chunks(self.audio,
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_io.py", line 89, in chunks
    for block in blocks(seq, size, padval=padval):
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_misc.py", line 99, in blocks
    for el in seq:
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_analysis.py", line 790, in overlap_add
    gain = np.sum(np.abs(np.vstack(steps)), 0).max()
  File "<__array_function__ internals>", line 5, in vstack
  File "/home/sevagh/.local/lib/python3.8/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate

The stacktrace shows Python 3.8, so I downgraded to 3.6 and get the same error.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.