4

I'm running Python 2.7.3 [MSC v.1500 32 bit (Intel)] on win32.

I need to build portaudio with ASIO support and bind it to pyaudio to use it under Windows 7. Basically I want to access ASIO driver from python and I figured out this is the way. I'm following the manual from pyaudio webpage http://people.csail.mit.edu/hubert/pyaudio/. The manual is rather outdated, gcc does not support -mno-cygwin flag any more. What I did:

  1. Download PyAudio-0.2.7 from their webpage
  2. Download the stable portaudio-v19 http://www.portaudio.com/download.html
  3. Dropped the "-mno-cygwin" options from the manual and compiled the portaudio (gcc version 4.5.3)
  4. Edited C:\Python27\Lib\distutils\cygwinccompiler.py and removed "-mno-cygwin" flag from the file.
  5. I ran the suggested pyaudio compilation but I'm getting a gcc error

    $ ../Python27/python.exe setup.py build --static-link -cmingw32
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    copying src\pyaudio.py -> build\lib.win32-2.7
    running build_ext
    building '_portaudio' extension
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    creating build\temp.win32-2.7\Release\src
    C:\MinGW\bin\gcc.exe -mdll -O -Wall -I./portaudio-v19\include/ -Ic:\Python27\inc
    lude -Ic:\Python27\PC -c src/_portaudiomodule.c -o build\temp.win32-2.7\Release\
    src\_portaudiomodule.o -fno-strict-aliasing
    writing build\temp.win32-2.7\Release\src\_portaudio.def
    C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-2.7\Release\src\_portaudiomodul
    e.o build\temp.win32-2.7\Release\src\_portaudio.def -Lc:\Python27\libs -Lc:\Pyth
    on27\PCbuild -lwinmm -lpython27 -lmsvcr90 -o build\lib.win32-2.7\_portaudio.pyd
    ./portaudio-v19\lib/.libs/libportaudio.a -lwinmm
    gcc: error: ./portaudio-v19\lib/.libs/libportaudio.a: No such file or directory
    error: command 'gcc' failed with exit status 1
    

I assume the portaudio compilation failed. I think the mentioned libportaudio.a is a linux file. Can you tell what went wrong?

3 Answers3

1

But the file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ does not support ASIO unfortunately. To get ASIO support you also need to get the ASIO SDK. I managed to get it to compile with visual studio 2010 x64, but still trying to figure out how to make it use ASIO in practice (output is still only 2 channels when there should be 4-8 my card

Laughingrice
  • 341
  • 2
  • 5
0

Unfortunately, I wasn't also able to record more than two tracks with the build of PyAudio from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio.

So I compiled portaudio with Microsoft Visual Studio (free version) according to

http://portaudio.com/docs/v19-doxydocs/compile_windows_asio_msvc.html http://portaudio.com/docs/v19-doxydocs/compile_windows.html

Note that we have to download ASIO SDK library from https://www.steinberg.net/developers for ASIO support.

Then I also built pyaudio with the portaudio_x64.dll (compiled with MSVC) like:

python setup.py build_ext -I .\portaudio\include -L .\portaudio\mybuild\Release -l portaudio_x86
python setup.py install

When I met an error message:

>>> import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\subf\AppData\Local\Programs\Python\Python310\Lib\site-packages\PyAudio-0.2.12-py3.10-win-amd64.egg\pyaudio.py", line 116, in <module>
    import _portaudio as pa
ImportError: DLL load failed while importing _portaudio: DLL load failed

I solved the problem by coping the portaudio DLL to the directory of pyaudio library directly:

copy portaudio_x64.dll C:\Users\myid\AppData\Local\Programs\Python\Python310\Lib\site-packages\PyAudio-0.2.12-py3.10-win-amd64.egg

I succeeded in recording more than two channels with pyaudio. More helps will be obtained from https://stackoverflow.com/posts/74188301.

Thank you.

Gwang-Jin
  • 1
  • 2
-1

It's because the file is actually called libportaudio.dll.a after being compiled on windows, but even renaming it doesn't sort the problem. Much easier to just download and install the binary from http://www.lfd.uci.edu/~gohlke/pythonlibs/

Installing pyaudio to work with cygwin's python is another matter, that's the problem I'm having.

SColvin
  • 11,584
  • 6
  • 57
  • 71
  • In the given link @SColvin you can read `PyAudio provides bindings for the PortAudio library. Excludes ASIO support.` – Basj Dec 25 '13 at 21:58