You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cffi library 'libsndfile.dll' has no function, constant or global variable named 'sf_wchar_open' #465
Firstly, wanted to start with saying thanks @bastibe for all your work and dedication
I'm trying to run soundfile on Windows on ARM64, I get the following error when calling sf.read function:
Error processing input: cffi library 'libsndfile.dll' has no function, constant or global variable named 'sf_wchar_open'.
Looking at dumpbin.exe /exports I can see libsndfile.dll (ARM64) contains sf_wchar_open, and creating a little test program I can call the function via cffi successfully.
I've tried reinstalling soundfile and cffi to no avail - I should mention pip install didn't deploy the DLL, and I had to place it manually.
Appreciate any help/thoughts.
import cffi
import os
ffi = cffi.FFI()
ffi.cdef("""
typedef struct SNDFILE_tag SNDFILE;
typedef struct SF_INFO {
long long frames;
int samplerate;
int channels;
int format;
int sections;
int seekable;
} SF_INFO;
SNDFILE* sf_wchar_open(const wchar_t* path, int mode, SF_INFO* sfinfo);
""")
def load_dll_and_test():
try:
dll_path = "libsndfile_arm64.dll"
lib = ffi.dlopen(dll_path)
print(f"Successfully loaded {dll_path}")
sfinfo = ffi.new("SF_INFO *")
file_path = "test.wav" # Replace with actual file path
wchar_path = ffi.new("wchar_t[]", file_path)
sndfile = lib.sf_wchar_open(wchar_path, 0x10, sfinfo)
if sndfile != ffi.NULL:
print("Successfully opened audio file")
print(f"Sample rate: {sfinfo.samplerate}")
print(f"Channels: {sfinfo.channels}")
print(f"Frames: {sfinfo.frames}")
else:
print("Failed to open audio file")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
load_dll_and_test()
I have an arm64 version of libsndfile ready to be deployed. However, I'm still waiting for numpy and cffi to deploy their arm64 wheels. As far as I can tell, numpy has released a preview for Python 3.14, and CFFI is working on it.
But until they are published and available, we can't release soundfile.
cgohlke has kindly compiled wheels here for CFFI & numpy: Windows on Arm Python Libraries.
Can we test against those in the interim? I was able call CFFI and use the libsndfile you have provided.
Thanks again.
Last time I tried, sysconfig.get_platform() reported arm64 on Windows regardless of whether you're running an x64 or arm64 binary on an arm processor. This made it impossible to determine the correct binary.
Activity
bastibe commentedon Jul 28, 2025
I have an arm64 version of libsndfile ready to be deployed. However, I'm still waiting for numpy and cffi to deploy their arm64 wheels. As far as I can tell, numpy has released a preview for Python 3.14, and CFFI is working on it.
But until they are published and available, we can't release soundfile.
alpinedelight commentedon Jul 28, 2025
cgohlke has kindly compiled wheels here for CFFI & numpy: Windows on Arm Python Libraries.
Can we test against those in the interim? I was able call CFFI and use the libsndfile you have provided.
Thanks again.
bastibe commentedon Jul 28, 2025
Did you use the arm64 library from here? https://github.com/bastibe/libsndfile-binaries/tree/a3e6f9769d0c7e91d2d036cf0fdbe5b4bbf18b87
alpinedelight commentedon Jul 28, 2025
yessir
bastibe commentedon Jul 29, 2025
Last time I tried,
sysconfig.get_platform()reported arm64 on Windows regardless of whether you're running an x64 or arm64 binary on an arm processor. This made it impossible to determine the correct binary.See, e.g. #463 for reference.
alpinedelight commentedon Jul 29, 2025
You're right - mad.
Not elegant, but in lieu of any official function, one could attempt to load both, i.e.
bastibe commentedon Aug 5, 2025
That's actually an acceptable workaround. Thank you.