伦敦玛丽女王大学的VAMP插件是 BSD 许可软件的惊人集合。所有这些插件都是基于Sonic Visualizer软件 的。还有一个用于构建插件的插件 Sdk 。
您可以为 OSX / Linux / Win32 目标构建插件。
玛特皇后大学在这里很好地解释了插件架构以及如何为上面指定的不同平台构建。
Java 版本,jVamp 也是可用的。还有一个 Python 包装器。
但是,如何为 iOS 平台构建呢?
所以,我尝试将 Makefile 移植到 iOS。
首先我改变了文件
build/osx/Makefile.osx
这样:
CFLAGS := -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS
CXXFLAGS := $(CFLAGS)
LDFLAGS := -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread -exported_symbols_list=vamp-plugin.list -install_name qm-vamp-plugins.a
PLUGIN_EXT := .a
include build/general/Makefile.inc
然后构建
macbookproloreto:qm-vamp-plugins loreto$ make -f build/osx/Makefile.osx
cc -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS -I. -I../qm-dsp -c -o g2cstubs.o g2cstubs.c
c++ -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS -I. -I../qm-dsp -c -o plugins/AdaptiveSpectrogram.o plugins/AdaptiveSpectrogram.cpp
In file included from plugins/AdaptiveSpectrogram.cpp:15:
In file included from plugins/AdaptiveSpectrogram.h:18:
In file included from ../vamp-plugin-sdk/vamp-sdk/Plugin.h:40:
In file included from /usr/bin/../lib/c++/v1/string:430:
In file included from /usr/bin/../lib/c++/v1/iosfwd:90:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/wchar.h:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/sys/_types.h:32:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/sys/cdefs.h:655:2: **error: Unsupported
architecture
#error Unsupported architecture
^**
这里的第一个问题是存在不受支持的架构。
所以插件取决于我必须首先构建的 SDK:
cd /Users/loreto/Projects/AUDIO/VAMP/vamp-plugin-sdk
make -f build/Makefile.osx
由于我没有OGG/VORBIS库和 LOGG 库,因此发生了不同的错误。所以我稍微修改了 Makefile.osx 删除了 HOST_LIB 标志中的这些依赖项。无论如何,我不得不保留libsndfile:
HOST_LIBS = ./libvamp-hostsdk.a -L../10.8/inst/lib -lsndfile -ldl
所以我能够在这里构建静态库:
macbookproloreto:vamp-plugin-sdk loreto$ ls -l *.a
-rw-r--r-- 1 loreto staff 709840 17 Ott 23:56 libvamp-hostsdk.a
-rw-r--r-- 1 loreto staff 183720 17 Ott 23:56 libvamp-sdk.a
当然,这些静态库是针对 arch x86_64 的,所以我需要添加 armv7 arch:
ARCHFLAGS = -mmacosx-version-min=$(MINVERSION) -arch x86_64 -arch armv7
然后 make clean 再次编译
macbookproloreto:vamp-plugin-sdk loreto$ make -f build/Makefile.osx clean
macbookproloreto:vamp-plugin-sdk loreto$ make -f build/Makefile.osx
c++ -mmacosx-version-min=10.8 -arch x86_64 -arch armv7 -O2 -Wall -I. -I../10.8/inst/include -fPIC -c -o src/vamp-sdk/PluginAdapter.o src/vamp-sdk/PluginAdapter.cpp
In file included from src/vamp-sdk/PluginAdapter.cpp:37:
In file included from ./vamp-sdk/PluginAdapter.h:40:
In file included from /usr/include/c++/4.2.1/map:64:
In file included from /usr/include/c++/4.2.1/bits/stl_tree.h:68:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.2.1/bits/c++config.h:41:
In file included from /usr/include/c++/4.2.1/bits/os_defines.h:61:
In file included from /usr/include/unistd.h:71:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:33:
/usr/include/machine/_types.h:34:10: fatal error: 'arm/_types.h' file not found
#include "arm/_types.h"
^
1 error generated.
make: *** [src/vamp-sdk/PluginAdapter.o] Error 1
未找到 arm 的类型定义!这里的问题是正确的道路是
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/arm/_types.h
好的,让我们再次在 Makefile.osx 中解决这个问题:
ARCHFLAGS = -mmacosx-version-min=$(MINVERSION) -arch armv7
CFLAGS = $(ARCHFLAGS) -fPIC --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/
CXXFLAGS = $(ARCHFLAGS) -O2 -Wall -I. -fPIC
CPPFLAGS ="-pipe -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
然后制作静态目标:
make -f build/Makefile.osx sdkstatic
哇,它奏效了!我有一个适用于 iOS 的 vamp host sdk .a!(我想可以这么说)
macbookproloreto:vamp-plugin-sdk loreto$ ls -l *.a
-rw-r--r-- 1 loreto staff 301176 18 Ott 00:35 libvamp-hostsdk.a
-rw-r--r-- 1 loreto staff 76024 18 Ott 00:35 libvamp-sdk.a
好的,但让我们检查一下 otool,因为你永远不知道:
macbookproloreto:vamp-plugin-sdk loreto$ otool -hv libvamp-sdk.a
Archive : libvamp-sdk.a
libvamp-sdk.a(PluginAdapter.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 4 1128 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(RealTime.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 4 1060 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(FFT.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 4 584 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(acsymbols.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 3 500 SUBSECTIONS_VIA_SYMBOLS
好的,这就是 armv7 架构。
现在,再次回到插件 sdk 并更改
build/osx/Makefile.osx
如下:
CFLAGS := -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS
CXXFLAGS := $(CFLAGS)
include build/general/Makefile.inc
好的,再次制作:
macbookproloreto:dsp loreto$ make -f build/osx/Makefile.osx
繁荣!另一个问题:
/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS -I. -c -o dsp/wavelet/Wavelet.o dsp/wavelet/Wavelet.cpp
cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS -I. -c -o hmm/hmm.o hmm/hmm.c
hmm/hmm.c:21:10: fatal error: 'clapack.h' file not found
#include <clapack.h> /* LAPACK for matrix inversion */
^
1 error generated.
make: *** [hmm/hmm.o] Error 1
macbookproloreto:dsp loreto$ vi build/osx/Makefile.osx
未找到 LAPACK。
但至于这里的 Apple Docs ,Apple 从 iOS4.0 开始在 Accelerate.frameworks 中引入了 LAPACK!
事实上 clapack.h 在这里:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework /标题/clapack.h
所以让我们在 ../dsp/build/Makefile.osx 的某个地方添加它
CFLAGS := -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS
现在让我们再做一次,但让我检查一下拱门:
macbookproloreto:dsp loreto$ otool -hv libqm-dsp.a
Archive : libqm-dsp.a
libqm-dsp.a(Pitch.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 4 516 SUBSECTIONS_VIA_SYMBOLS
libqm-dsp.a(Chromagram.o):
Mach header
听起来不错!现在回到插件文件夹中的一级并制作
In file included from plugins/AdaptiveSpectrogram.cpp:15:
plugins/AdaptiveSpectrogram.h:22:10: fatal error: 'dsp/transforms/FFT.h' file not found
#include <dsp/transforms/FFT.h>
^
1 error generated.
嗯好的 dsp/ 错过了转换文件夹 - 天哪!
另一个错误:
clang: error: invalid argument '-install_name qm-vamp-plugins.a' only allowed with '-dynamiclib'
make: *** [qm-vamp-plugins.a] Error 1
让我们再次修复 Makefile.osx:
CFLAGS := -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS
CXXFLAGS := $(CFLAGS)
LDFLAGS := -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread
好的,现在错误是架构未定义符号错误:长看这里的要点, 如:
"std::cerr", referenced from:
"typeinfo for std::istream", referenced from:
"std::ostream::put(char)""
std::ostream::operator<<(int)",
这让我想起了boost C++ 库!
所以我需要得到提升,为 iOS 编译然后将它包含在 Makefile 中,它应该可以工作,不是吗?这可能需要很长时间...
所以现在就这样做
macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'
在从这里作为 iOS 框架分发获得提升并添加之后
-I/Users/loreto/Projects/AUDIO/LIBS/boost-ios/Dist/boost.framework/Headers/
我有同样的错误......嗯,我想我在这里错过了标准 C++ 库!
macbookproloreto:Headers loreto$ locate libc++.dylib | grep iPhoneOS7.0
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib
答对了!
所以
-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib
再次出错(doh)!
试过没有成功
-I/usr/lib/libstdc++.dylib
-lstdc++
卡在一个非常简单的链接问题上。
再次。
macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'
错误中最有趣的部分是正在编译的第一个静态库:
make -f build/osx/Makefile.osx
c++ -o qm-vamp-plugins.a g2cstubs.o plugins/AdaptiveSpectrogram.o plugins/BarBeatTrack.o plugins/BeatTrack.o plugins/DWT.o plugins/OnsetDetect.o plugins/ChromagramPlugin.o plugins/ConstantQSpectrogram.o plugins/KeyDetect.o plugins/MFCCPlugin.o plugins/SegmenterPlugin.o plugins/SimilarityPlugin.o plugins/TonalChangeDetect.o plugins/Transcription.o libmain.o -L../qm-dsp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread
Undefined symbols for architecture armv7:
"std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
_VampPlugin::Vamp::RealTime::toString() const in libvamp-sdk.a(RealTime.o)
_VampPlugin::Vamp::RealTime::toText(bool) const in libvamp-sdk.a(RealTime.o)
"std::basic_ios<char, std::char_traits<char> >::widen(char) const", referenced from:
_VampPlugin::Vamp::PluginAdapterBase::Impl::getDescriptor() in libvamp-sdk.a(PluginAdapter.o)
在这里我们可以看到编译的静态库之一不包含正确的架构。
我这里有两个静态库:
lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a
如果我在上面运行 otool,我可以看到它们的 cpu 时间都是 ARM7:
macbookproloreto:qm-vamp-plugins loreto$ otool -hv ../vamp-plugin-sdk/libvamp-sdk.a
Archive : ../vamp-plugin-sdk/libvamp-sdk.a
../vamp-plugin-sdk/libvamp-sdk.a(PluginAdapter.o):
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC ARM V7 0x00 OBJECT 4 1128 SUBSECTIONS_VIA_SYMBOLS
那么 Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib 是怎么回事?