weegreenblobbie / nsound

nsound is a C++ library and python module for real-time sound synthesis.
GNU General Public License v2.0
17 stars 1 forks source link

failed to create AudioBackend #9

Open weegreenblobbie opened 7 years ago

weegreenblobbie commented 7 years ago

A user sent email with the following issue:

I'm getting start to use Nsound(I installed it this morning). I am trying to run the example 1, but I have always the same problem:

~$ python example1.py 
src/Nsound/AudioPlayback.cc:130: Nsound::AudioPlayback::AudioPlayback():: failed to create AudioBackend!
Traceback (most recent call last):
  File "example1.py", line 42, in <module>
    pb = AudioPlayback(sr, 1, 16)
  File "/usr/local/lib/python2.7/dist-packages/Nsound.py", line 2876, in __init__
    this = _Nsound.new_AudioPlayback(sample_rate, channels, bits_per_sample)
RuntimeError: src/Nsound/AudioPlayback.cc:130: Nsound::AudioPlayback::AudioPlayback():: failed to create AudioBackend!

I am using ubunut 15.10 and I have installed all the pre-requirements.

weegreenblobbie commented 7 years ago

Let's try the following:

  1. verify you can play audio on the default sound card with another program (watch a youtube video, or use aplay on the command line)
  2. verify nsound was compiled with protaudio, this can be done with the following code:
import Nsound as ns
ns.AudioPlayback.getBackendType() == ns.BACKEND_TYPE_LIBPORTAUDIO

If this is False, perhaps Nsound didn't detect port audio. When compiling, check that you see:

pip install --user nsound
Downloading/unpacking nsound
  Downloading Nsound-0.9.4.tar.gz (2.5MB): 2.5MB downloaded
  Running setup.py (path:/tmp/pip_build_nhilton/nsound/setup.py) egg_info for package nsound
    Checking for scons ... /usr/bin/scons
    Checking for swig ... /usr/bin/swig
    Configuring Nsound ... done
        release         : Nsound-0.9.4
        ao              : no
        c++11           : yes
        cuda            : no
        float64         : yes
        little-endian   : yes
        matplotlib      : yes
        openmp          : no
        portaudio       : yes
        real-time-audio : yes

So the two lines that should say yes are

        portaudio       : yes
        real-time-audio : yes

If not, make sure you have the package portaudio19-dev installed and try again.

weegreenblobbie commented 7 years ago

User sent email with:

I still continue to have problems... As your advice, I found that the problem was the not.installation of the package portaudio19-dev. So, I installed it, by terminal, but still, when I compile I have this problem:

sudo python setup.py install
Checking for scons ... /usr/local/bin/scons
Checking for swig ... /usr/bin/swig
Configuring Nsound ... done
    release         : Nsound-0.9.3
    ao              : no
    c++11           : yes
    cuda            : no
    float64         : yes
    little-endian   : yes
    matplotlib      : yes
    openmp          : no
    portaudio       : no
    real-time-audio : no
running install
running build
running build_py
copying Nsound.py -> build/lib.linux-x86_64-2.7
running build_ext
running install_lib
copying build/lib.linux-x86_64-2.7/Nsound.py -> /usr/local/lib/python2.7/dist-packages
byte-compiling /usr/local/lib/python2.7/dist-packages/Nsound.py to Nsound.pyc
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/Nsound-0.9.3.egg-info
Writing /usr/local/lib/python2.7/dist-packages/Nsound-0.9.3.egg-info

And I am sure that the installation was good because:

sudo apt-get install portaudio19-dev
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze       
Lettura informazioni sullo stato... Fatto
portaudio19-dev è già alla versione più recente.
weegreenblobbie commented 7 years ago

I see that you're building from the source archive, so let's do the following:

  1. download nsound-0.9.4 (link)
  2. execute this scons command so we can see all the gory details
scons setup_builder.py --config=force

And you will see this output:

scons: Reading SConscript files ...
Building with 4 threads

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Help Nsound, please submit bug reports if things aren't working for you.

http://sourceforge.net/tracker/?atid=767640&group_id=147193&func=browse

Contact Nick for help: weegreenblobbie_yahoo_com

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Using Python2.7.6

Building on linux2, AMD64
bindir = /tmp/nsound-0.9.4/bin
libdir = /tmp/nsound-0.9.4/lib

Checking whether the C++ compiler worksyes
detecting compiler version ... gcc 4 8 4
checking if compiler works ... good
checking for C++11 features ... yes
checking endianess ... (cached) little
checking if math.h defines M_PI ... yes
Checking for C++ header file Python.h... yes
checking for matplotlib.pylab ... (cached) yes
checking for Matplotlib C API ... yes
Checking for C++ header file portaudio.h... yes
checking for portaudio.h V18 ... no
...
checking for portaudio.h V19 ... yes
...

where the two most important line for audio play back is:

checking for portaudio.h V19 ... yes
checking for libportaudio ... yes

If it says no, we can look at the config.log where it tried to detect portaudio:

less config.log

Then search the logfile for portaudio. You should start to find the gory details when you see the line:

scons: Configure: checking for portaudio.h V19 ... 

It's trying to detect the protaudio.h for V19, below the code snippet you will see the config result, on my system when it works I see this:

scons: Configure: checking for portaudio.h V19 ... 
.sconf_temp/conftest_9.cpp <-
  |
  |            #include <portaudio.h>
  |            #include <stdio.h>
  |
  |            int main(void)
  |            {
  |                PaDeviceInfo info;
  |
  |                double sr = info.defaultSampleRate;
  |
  |                return 0;
  |            }
  |
  |        
Compiling .sconf_temp/conftest_9.cpp
.sconf_temp/conftest_9.cpp: In function ‘int main()’:
.sconf_temp/conftest_9.cpp:9:24: warning: unused variable ‘sr’ [-Wunused-variable]
                 double sr = info.defaultSampleRate;
                        ^
.sconf_temp/conftest_9.cpp:9:34: warning: ‘info.PaDeviceInfo::defaultSampleRate’ is used uninitialized in this function [-Wuninitialized]
                 double sr = info.defaultSampleRate;
                                  ^
scons: Configure: yes

Okay, if it finds the header, then the next section is where it actually links with libportaudio and logs a list of devices to portaudio.log. In config.log you will find:

scons: Configure: checking for libportaudio ... 
... lots of output ...
scons: Configure: yes

I suspect you see a compiler or link error. This is where we'll get clues as to why it's not working. Please attach/send me the config.log and portaudio.log files.

AnnaDM87 commented 7 years ago

Hi! I'am here! I did as indicated by you, but still... When I executed this command : scons setup_builder.py --config=force `the audio back lines are:


Checking for C++ header file portaudio.h... yes
checking for portaudio.h V18 ... no
checking for portaudio.h V19 ... yes

I run sudo python setup.py install

Checking for scons ... /usr/local/bin/scons
Checking for swig ... /usr/bin/swig
Configuring Nsound ... done
    release         : Nsound-0.9.4
    ao              : no
    c++11           : yes
    cuda            : no
    float64         : yes
    little-endian   : yes
    matplotlib      : yes
    openmp          : no
    portaudio       : yes
    real-time-audio : yes

So, i tried to run the example:

python example1.py
src/Nsound/AudioPlayback.cc:130: Nsound::AudioPlayback::AudioPlayback():: failed to create AudioBackend!
Traceback (most recent call last):
  File "example1.py", line 42, in <module>
    pb = AudioPlayback(sr, 1, 16)
  File "/usr/local/lib/python2.7/dist-packages/Nsound.py", line 2876, in __init__
    this = _Nsound.new_AudioPlayback(sample_rate, channels, bits_per_sample)
RuntimeError: src/Nsound/AudioPlayback.cc:130: Nsound::AudioPlayback::AudioPlayback():: failed to create AudioBackend!

I don't have any idea to how continue! Sorry for the bothering!

Anna

weegreenblobbie commented 7 years ago

No problem at all. The output looks good, that the library is present, so lets make sure audio works on your computer.

  1. Does the sound work?
  2. Does the speaker test work in System Settings --> Sound? (gnome shell, don't know about unity)
  3. Does playback work at 44100 Hz? Try playing files at different sample rates
  4. Does audacity's audio playback work?