Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/sounddevice-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
arch: 'x86'
- os: windows-11-arm
arch: 'arm64'
- os: windows-11-arm
arch: 'x64'
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python
Expand All @@ -25,7 +27,7 @@ jobs:
architecture: ${{ matrix.arch }}
- name: Double-check Python version
run: |
python --version
python --version --version
- name: Clone Git repository (with submodules)
uses: actions/checkout@v6
with:
Expand All @@ -36,6 +38,7 @@ jobs:
run: |
python -m pip install .
- name: Import module
shell: bash
run: |
python -m sounddevice
python -c "import sounddevice as sd; print(sd._libname)"
Expand All @@ -45,6 +48,7 @@ jobs:
python -c "import sounddevice as sd; assert not any(a['name'] == 'ASIO' for a in sd.query_hostapis())"
- name: Import module (using the ASIO DLL)
if: startsWith(matrix.os, 'windows')
shell: bash
env:
SD_ENABLE_ASIO: 1
run: |
Expand Down
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@
# environment variables for cross-platform package creation
system = os.environ.get('PYTHON_SOUNDDEVICE_PLATFORM', platform.system())
machine = platform.machine().lower()
architecture0 = os.environ.get('PYTHON_SOUNDDEVICE_ARCHITECTURE',
'arm64' if machine in ['arm64', 'aarch64'] else platform.architecture()[0])
if 'PYTHON_SOUNDDEVICE_ARCHITECTURE' in os.environ:
architecture0 = os.environ['PYTHON_SOUNDDEVICE_ARCHITECTURE']
elif os.environ.get('PROCESSOR_ARCHITECTURE') in ['AMD64', 'x86', 'ARM64']:
architecture0 = {
'AMD64': '64bit',
'x86': '32bit',
'ARM64': 'arm64',
}[os.environ['PROCESSOR_ARCHITECTURE']]
elif machine in ['arm64', 'aarch64']:
architecture0 = 'arm64'
else:
architecture0 = platform.architecture()[0]

if system == 'Darwin':
libname = 'libportaudio.dylib'
Expand Down
14 changes: 10 additions & 4 deletions src/sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@
if _platform.system() == 'Darwin':
_libname = 'libportaudio.dylib'
elif _platform.system() == 'Windows':
if _platform.machine().lower() in ('arm64', 'aarch64'):
_platform_suffix = 'arm64'
else:
_platform_suffix = _platform.architecture()[0]
_platform_suffix = {
'AMD64': '64bit',
'x86': '32bit',
'ARM64': 'arm64',
}.get(_os.environ.get('PROCESSOR_ARCHITECTURE', ''), '')
if not _platform_suffix:
if _platform.machine().lower() in ('arm64', 'aarch64'):
_platform_suffix = 'arm64'
else:
_platform_suffix = _platform.architecture()[0]
if 'SD_ENABLE_ASIO' in _os.environ:
_libname = 'libportaudio' + _platform_suffix + '-asio.dll'
else:
Expand Down