__init__() 应该为使用 boost_python 的 python 模块返回 None,而不是 'NoneType'

如何解决__init__() 应该为使用 boost_python 的 python 模块返回 None,而不是 'NoneType'

我使用的是python3和我自己编译的[Renderman][1]

这个库使用了 boost_python,它通过 cpp 制作了 python 库。

test.py

import librenderman as rm     
engine = rm.RenderEngine(44100,512,512)

我有这样的错误

$python test.py
JUCE v5.2.0
Traceback (most recent call last):
  File "test.py",line 3,in <module>
    engine = rm.RenderEngine(44100,512)
TypeError: __init__() should return None,not 'nonetype'

搜索了一下,发现这是因为 python 2/3 差异。

然后检查链接

$otool -L librenderman.so 
librenderman.so:
    /usr/local/lib/librenderman.so.dylib (compatibility version 1.0.0,current version 1.0.0)
    @rpath/libpython3.7m.dylib (compatibility version 3.7.0,current version 3.7.0)
    @rpath/libboost_python37.dylib (compatibility version 0.0.0,current version 0.0.0)
    /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0,current version 4.0.0)
    /System/Library/Frameworks/AudioToolBox.framework/Versions/A/AudioToolBox (compatibility version 1.0.0,current version 1000.0.0)
    /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0,current version 2.0.0)
    /System/Library/Frameworks/AVKit.framework/Versions/A/AVKit (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0,current version 164.0.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0,current version 23.0.0)
    /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/CoreAudioKit.framework/Versions/A/CoreAudioKit (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI (compatibility version 1.0.0,current version 69.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0,current version 275.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0,current version 1.11.0)
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0,current version 610.3.7)
    @rpath/libc++.1.dylib (compatibility version 1.0.0,current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,current version 1292.60.1)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0,current version 2022.20.117)
    /System/Library/Frameworks/applicationservices.framework/Versions/A/applicationservices (compatibility version 1.0.0,current version 54.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0,current version 1770.255.0)
    /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0,current version 1463.2.1)
    /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0,current version 1122.11.0)
    /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0,current version 1.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0,current version 1770.255.0)
    /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0,current version 1.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0,current version 228.0.0)

我认为 python3 模块链接正确。

我应该在哪里以及如何解决这个问题??

虽然我熟悉python3,但不熟悉python2boost-python

任何建议都有帮助。

RenderEngine.h

/*
  ==============================================================================

    RenderEngine.h
    Created: 19 Feb 2017 9:47:15pm
    Author:  tollie

  ==============================================================================
*/

#ifndef RENDERENGINE_H_INCLUDED
#define RENDERENGINE_H_INCLUDED

#include <random>
#include <array>
#include <iomanip>
#include <sstream>
#include <string>
#include "Maximilian/maximilian.h"
#include "Maximilian/libs/maxiFFT.h"
#include "Maximilian/libs/maxiMFCC.h"
#include "../JuceLibraryCode/JuceHeader.h"

using namespace juce;

typedef std::vector<std::pair<int,float>>  PluginPatch;
typedef std::vector<std::array<double,13>> MFCCFeatures;

class RenderEngine
{
public:
    RenderEngine (int sr,int bs,int ffts) :
        sampleRate(sr),bufferSize(bs),fftSize(ffts),plugin(nullptr)
    {
        maxiSettings::setup (sampleRate,1,bufferSize);
    }

    virtual ~RenderEngine()
    {
        if (plugin != nullptr)
        {
            plugin->releaseResources();
            delete plugin;
        }
    }


    bool loadplugin (const std::string& path);

    void setPatch (const PluginPatch patch);

    const PluginPatch getPatch();

    void renderPatch (const uint8  midiNote,const uint8  midiveLocity,const double noteLength,const double renderLength);

    const MFCCFeatures getMFCCFrames();

    const MFCCFeatures getnormalisedMFCCFrames (const std::array<double,13>& mean,const std::array<double,13>& variance);

    const std::vector<double> getRMSFrames();

    const size_t getPluginParameterSize();

    const String getPluginParametersDescription();

    bool overridePluginParameter (const int   index,const float value);

    bool removeOverridenParameter (const int index);

    const std::vector<double> getAudioFrames();

    bool writetoWav(const std::string& path);

private:
    void fillAudioFeatures (const AudioSampleBuffer& data,maxiFFT&                 fft);

    void ifTimeSetNoteOff (const double& noteLength,const double& sampleRate,const int&    bufferSize,const uint8&  midiChannel,const uint8&  midiPitch,const uint8&  midiveLocity,const int&    currentBufferIndex,MidiBuffer&   bufferToNoteOff);

    void fillAvailablePluginParameters (PluginPatch& params);

    double               sampleRate;
    int                  bufferSize;
    int                  fftSize;
    maxiMFCC             mfcc;
    AudioPluginInstance* plugin;
    PluginPatch          pluginParameters;
    PluginPatch          overridenParameters;
    MFCCFeatures         mfccFeatures;
    std::vector<double>  processedMonoAudioPreview;
    std::vector<double>  rmsFrames;
    double               currentRmsFrame;
};


#endif  // RENDERENGINE_H_INCLUDED

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?