bastibe / python-soundfile

SoundFile is an audio library based on libsndfile, CFFI, and NumPy
BSD 3-Clause "New" or "Revised" License
699 stars 107 forks source link

SF 0.10.3: sf.available_formats() does not include FLAC and OGG #282

Closed e13000 closed 3 years ago

e13000 commented 3 years ago

I've recently upgraded soundfile to the latest version on pypi (0.10.3.post1, Win64). Somehow, sf.available_formats() does not include FLAC and OGG anymore. Is this intentional?

This is what my soundfile returns:

{'AIFF': 'AIFF (Apple/SGI)', 'AU': 'AU (Sun/NeXT)', 'AVR': 'AVR (Audio Visual Research)', 'CAF': 'CAF (Apple Core Audio File)', 'HTK': 'HTK (HMM Tool Kit)', 'SVX': 'IFF (Amiga IFF/SVX8/SV16)', 'MAT4': 'MAT4 (GNU Octave 2.0 / Matlab 4.2)', 'MAT5': 'MAT5 (GNU Octave 2.1 / Matlab 5.0)', 'MPC2K': 'MPC (Akai MPC 2k)', 'PAF': 'PAF (Ensoniq PARIS)', 'PVF': 'PVF (Portable Voice Format)', 'RAW': 'RAW (header-less)', 'RF64': 'RF64 (RIFF 64)', 'SD2': 'SD2 (Sound Designer II)', 'SDS': 'SDS (Midi Sample Dump Standard)', 'IRCAM': 'SF (Berkeley/IRCAM/CARL)', 'VOC': 'VOC (Creative Labs)', 'W64': 'W64 (SoundFoundry WAVE 64)', 'WAV': 'WAV (Microsoft)', 'NIST': 'WAV (NIST Sphere)', 'WAVEX': 'WAVEX (Microsoft)', 'WVE': 'WVE (Psion Series 3)', 'XI': 'XI (FastTracker 2)'}

bastibe commented 3 years ago

Did you install the source distribution or the wheel?

e13000 commented 3 years ago

Did you install the source distribution or the wheel?

It's the wheel. I have uninstalled and reinstalled soundfile to confirm.

Collecting soundfile Using cached SoundFile-0.10.3.post1-py2.py3.cp26.cp27.cp32.cp33.cp34.cp35.cp36.pp27.pp32.pp33-none-win_amd64.whl (689 kB) Requirement already satisfied: cffi>=1.0 in c:\users\nhtan\miniconda3\envs\anhrs\lib\site-packages (from soundfile) (1.14.3) Requirement already satisfied: pycparser in c:\users\nhtan\miniconda3\envs\anhrs\lib\site-packages (from cffi>=1.0->soundfile) (2.20) Installing collected packages: soundfile Successfully installed soundfile-0.10.3.post1

bastibe commented 3 years ago

I suspect your soundfile is using some pre-installed version of libsndfile. What are your soundfile._snd and soundfile.__libsndfile_version__?

I just installed a new version of SoundFile on my Windows box, and mine did come with FLAC and OGG support.

e13000 commented 3 years ago

You are correct that my soundfile has used the wrong libsndfile.

>>> sf._snd
<Lib object for 'C:\Users\xxxx\miniconda3\envs\xxxx\Library\bin\sndfile.dll'>
>>> sf.__libsndfile_version__
'1.0.29'

It should have used C:\Users\xxxx\miniconda3\envs\xxxx\Lib\site-packages\_soundfile_data\libsndfile64bit.dll which is also available. This may have happened because, in my conda's environment.yml, I installed librosa using conda's conda-forge and soundfile using pip. I have modified my environment.yml to install both librosa and soundfile using pip. My soundfile now can read and write FLAC and OGG files. Many thanks for the help.

Anyway, is it possible to improve libsndfile's detection to avoid this problem?

bastibe commented 3 years ago

Anyway, is it possible to improve libsndfile's detection to avoid this problem?

SoundFile will always try to load a user-installed libsndfile before falling back on its own libsndfile. And that's really how it should be, otherwise it would be impossible to load a custom libsndfile at all.