Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: in method 'vstRender_renderAudio', argument 2 of type 'float *' #1

Closed
drscotthawley opened this issue Apr 28, 2018 · 4 comments

Comments

@drscotthawley
Copy link
Contributor

Hi Igor! I was able to build vstRedner and run it. At the very end of train.py, when it calls to render the noise, I get an error.

The VST I used is just a free Linux VST called 'ButterComp' (http://www.airwindows.com/category/dynamics/)

$ python train.py 
/opt/anaconda/envs/py36/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
JUCE v5.2.0
Attempting to load VST: /home/shawley/vst-dpm/NewUpdates/LinuxVST/ButterComp.so
Creating VST instance: ButterComp
Initialising VST: ButterComp (1.0.0.0)
Attempting to load VST: /home/shawley/vst-dpm/NewUpdates/LinuxVST/ButterComp.so
Creating VST instance: ButterComp
Initialising VST: ButterComp (1.0.0.0)
Traceback (most recent call last):
  File "train.py", line 58, in <module>
    r = vst_render.renderAudio(noise)
  File "/home/shawley/vst-dpm/vstRender/vstRender.py", line 113, in renderAudio
    return _vstRender.vstRender_renderAudio(self, input)
TypeError: in method 'vstRender_renderAudio', argument 2 of type 'float *'

(That h5py warning comes from numpy as is ignorable.)

This must be the swig error you were talking about: https://stackoverflow.com/questions/32692575/how-to-convert-numpy-ndarray-to-c-float

I modified vstRender.i...

$ cat vstRender.i
%module vstRender

%{
    #define SWIG_FILE_WITH_INIT
    #include "vstRender.h"
%}

%include "numpy.i"
%init %{
import_array();
%}
%apply ( float* IN_ARRAY1 ) { (float* input ) };

%include "vstRender.h"

At first it couldn't find numpy.i, so I grabbed it...

$ cd vstRender/src
$ curl -LO https://github.com/numpy/numpy/blob/master/tools/swig/numpy.i

Tried making

$ cd ..
$ make
swig3.0 -c++ -python -outdir . -o ./src/vstRender_wrap.cpp ./src/vstRender.i
./src/numpy.i:7: Error: Syntax error in input(1).
Makefile:49: recipe for target 'swig' failed
make: *** [swig] Error 1

I ended up asking a StackExchange post about this. We'll see who writes back.

@drscotthawley
Copy link
Contributor Author

drscotthawley commented Apr 28, 2018

Oh, duhh. When I downloaded numpy.i, I got all kinds of HTML tags. Should have used
curl -LO https://raw.githubusercontent.com/numpy/numpy/master/tools/swig/numpy.i

With the proper numpy.i, the build error changes to...

$ make
swig3.0 -c++ -python -outdir . -o ./src/vstRender_wrap.cpp ./src/vstRender.i
mkdir -p build/intermediate/Debug
g++  -MMD -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 -I/usr/include/alsa -I/usr/include/freetype2 -pthread -I/opt/anaconda/pkgs/python-3.6.0-0/include/python3.6m -I./VST3_SDK -I./JuceLibraryCode -I./JuceLibraryCode/modules -I/opt/anaconda3/include/python3.6m  -march=native -fPIC -g -ggdb -O0 -fPIC  -std=c++11  -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 -fPIC -fvisibility=hidden -o "build/intermediate/Debug/vstRender_wrap.o" -c "src/vstRender_wrap.cpp"
src/vstRender_wrap.cpp:3128:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
Makefile:61: recipe for target 'build/intermediate/Debug/vstRender_wrap.o' failed
make: *** [build/intermediate/Debug/vstRender_wrap.o] Error 1

So I added in to the Makefile a -I/opt/anaconda/pkgs/numpy-1.12.1-py36_0/lib/python3.6/site-packages/numpy/core/include so it could find arrayobject.h, rebuilt vstRender.so, re-ran train.py... and still got the same error from the start.

@igorgad
Copy link
Owner

igorgad commented Apr 28, 2018 via email

@drscotthawley
Copy link
Contributor Author

Ok, great! I was able to build and run, and at least now I get a segmentation fault! ;-) Could be the plugin I'm using...

python train.py 
/opt/anaconda/envs/py36/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
JUCE v5.2.0
Attempting to load VST: /home/shawley/vst-dpm/NewUpdates/LinuxVST/ButterComp.so
Creating VST instance: ButterComp
Initialising VST: ButterComp (1.0.0.0)
Attempting to load VST: /home/shawley/vst-dpm/NewUpdates/LinuxVST/ButterComp.so
Creating VST instance: ButterComp
Initialising VST: ButterComp (1.0.0.0)
Segmentation fault (core dumped)

Interesting that it creates the instance twice and initializes twice.

Anyway, since this particular issue is now solved, I'll close this.

@igorgad
Copy link
Owner

igorgad commented Apr 28, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants