librosa 0.10.2 is now up on PyPI and conda-forge! #python#scipy#audio#dsp
Improvements to beat and onset detection, music notation, and compatibility with recent numpy/scipy/matplotlib.
The full changelog is available here: https://t.co/uXPN3acCIf
Happy coding!
@psobot @Puidii1 Well yeah ๐ Anyway this is a great feature to see! We've wanted to implement something like this in librosa for a while (stream-based resampling), but it's maddeningly tricky to get right while supporting a multitude of backend decoders and resamplers
@psobot @Puidii1 Whether soundfile itself does a full decode to implement the seek might be codec-dependent, but it's probably not fair to say it's uniformly O(N).
@psobot @Puidii1 This isn't entirely accurate. Librosa relies on soundfile to seek and truncate the file object prior to decoding, and that happens before resampling. This will of course induce boundary artifacts on resample, but it doesn't necessarily decode and resample the entire stream.
@hatonosukejp This looks like a monophonic signal. You might want to try librosa.pyin to estimate the f0 line instead of pulling it from chroma features
@TadaiMahiroFun This was fixed quite a while ago: https://t.co/Ss8cjt93S0 (released in 0.10.0) - the problem you have is from pinning librosa to an old version (0.9.2)
@bleepybloops Ah, your audioread results are implausibly fast because it's only pulling the header information (channels, sample rate, duration) and not necessarily decoding the entire stream like the others.
@drscotthawley @bleepybloops @faroit@keunwoochoi os.scandir is great if you need speed, but beware that it (and glob) can order files differently on different platforms. This is why we have a guaranteed-sorted wrapper in librosa (find_files) that lets you mask down to specific file extensions.
@bleepybloops @lostanlen BTW @faroit's excellent benchmarking repo does a good job of disentangling the decoder / plaftorm issues. It does need to be rerun with newer versions of everything though *nudge* ๐
@bleepybloops @lostanlen Audioread is unpredictable for benchmarking purposes because it abstracts away the decoding backend, and will do different things in different environments and platforms. Maybe it's using ffmpeg to decode, maybe it isn't!
Benchmarking is really hard, folks. ๐
@Aki__Singh If you don't need all the extra librosa functionality, soxr or libsamplerate are both solid choices. Both have python wrappers and conda(-forge) packages, and they're what we use under the hood.
@lexandstuff As for the root cause of this... floating point arithmetic is non-associative! In calculating the number of output samples, order matters:
>>> 44100 * (48000 / 44100.0)
48000.00000000001
>>> (44100 * 48000 ) / 44100.0
48000.0
@lexandstuff If you set fix=False in resample, you will sometimes get 48001 samples (eg with res_type='fft') and sometimes 48000 exactly (res_type='polyphase' or 'soxr_*').
We erred on the conservative side to avoid discarding samples while always providing a consistent output length.