码迷,mamicode.com
首页 > 其他好文 > 详细

Echoprint系列--编译

时间:2015-06-09 17:36:18      阅读:568      评论:0      收藏:0      [点我收藏+]

标签:

最近要做一个音乐相关的客户端,其中一个功能是音乐识别,搜索了一些资料选择Echoprint来开发,Echoprint是开源免费的,而且多种客户端都支持能节约很多时间,今天主要下载和编译源码以及测试。(备注:我的开发环境是Mac,所以下面以及之后都是Mac的环境)

1、官网

官网地址:http://echoprint.me

2、安装依赖环境

  • 首先安装HomeBrew
  • 安装依赖库 

    brew install ffmpeg boost taglib

    安装的目录都在

    /usr/local/Cellar

3、下载源码

git clone -b release-4.12 git://github.com/echonest/echoprint-codegen.git


下载完源码后进入src并打开Makefile

adsl-172-10-1-12:~ zhangjie$ cd echoprint-codegen

adsl-172-10-1-12:echoprint-codegen zhangjie$ cd src/

adsl-172-10-1-12:src zhangjie$ vim Makefile 

修改其中变量BOOST_CFLAGS为你当前安装的boost目录

BOOST_CFLAGS=-I/usr/local/Cellar/boost/1.58.0/include

修改

 34 libcodegen: $(MODULES_LIB)

 35 ifeq ($(UNAME),Darwin)

 36         libtool -dynamic -flat_namespace -install_name libcodegen.$(VERSION).dylib -lSystem -compatibility_version $(VERSION_COMPAT) \

 37                 -macosx_version_min 10.6 -current_version $(VERSION) -o libcodegen.$(VERSION).dylib -undefined suppress \

 38             $(MODULES_LIB) -framework vecLib -framework Accelerate

 39 else

 40         $(CXX) -shared -fPIC -Wl,-soname,$(SONAME) -o $(LIBNAME).$(VERSION) $(MODULES_LIB) -lz

 41 endif

如果38行中有-framework vecLib则去掉

变为如下:

 34 libcodegen: $(MODULES_LIB)

 35 ifeq ($(UNAME),Darwin)

 36         libtool -dynamic -flat_namespace -install_name libcodegen.$(VERSION).dylib -lSystem -compatibility_version $(VERSION_COMPAT) \

 37                 -macosx_version_min 10.6 -current_version $(VERSION) -o libcodegen.$(VERSION).dylib -undefined suppress \

 38             $(MODULES_LIB)  -framework Accelerate

 39 else

 40         $(CXX) -shared -fPIC -Wl,-soname,$(SONAME) -o $(LIBNAME).$(VERSION) $(MODULES_LIB) -lz

 41 endif

4、编译

adsl-172-10-1-12:src zhangjie$ vim Makefile 

adsl-172-10-1-12:src zhangjie$ make

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o Codegen.o Codegen.cxx

In file included from Codegen.cxx:12:

In file included from ./AudioBufferInput.h:14:

./AudioStreamInput.h:53:10: warning: ‘StdinStreamInput::ProcessFile‘ hides overloaded virtual function [-Woverloaded-virtual]

    bool ProcessFile(const char* filename){ return ProcessStandardInput();}

         ^

./AudioStreamInput.h:26:18: note: hidden overloaded virtual function ‘AudioStreamInput::ProcessFile‘ declared here: different number of parameters (3 vs 1)

    virtual bool ProcessFile(const char* filename, int offset_s=0, int seconds=0);

                 ^

1 warning generated.

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o Fingerprint.o Fingerprint.cxx

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o MatrixUtility.o MatrixUtility.cxx

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o SubbandAnalysis.o SubbandAnalysis.cxx

In file included from SubbandAnalysis.cxx:8:

./AudioStreamInput.h:53:10: warning: ‘StdinStreamInput::ProcessFile‘ hides overloaded virtual function [-Woverloaded-virtual]

    bool ProcessFile(const char* filename){ return ProcessStandardInput();}

         ^

./AudioStreamInput.h:26:18: note: hidden overloaded virtual function ‘AudioStreamInput::ProcessFile‘ declared here: different number of parameters (3 vs 1)

    virtual bool ProcessFile(const char* filename, int offset_s=0, int seconds=0);

                 ^

1 warning generated.

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o Whitening.o Whitening.cxx

In file included from Whitening.cxx:8:

./AudioStreamInput.h:53:10: warning: ‘StdinStreamInput::ProcessFile‘ hides overloaded virtual function [-Woverloaded-virtual]

    bool ProcessFile(const char* filename){ return ProcessStandardInput();}

         ^

./AudioStreamInput.h:26:18: note: hidden overloaded virtual function ‘AudioStreamInput::ProcessFile‘ declared here: different number of parameters (3 vs 1)

    virtual bool ProcessFile(const char* filename, int offset_s=0, int seconds=0);

                 ^

1 warning generated.

libtool -dynamic -flat_namespace -install_name libcodegen.4.1.2.dylib -lSystem -compatibility_version 4.1 \

-macosx_version_min 10.6 -current_version 4.1.2 -o libcodegen.4.1.2.dylib -undefined suppress \

    AudioBufferInput.o AudioStreamInput.o Base64.o Codegen.o Fingerprint.o MatrixUtility.o SubbandAnalysis.o Whitening.o  -framework Accelerate

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o Metadata.o Metadata.cxx

g++ -Wall -I/usr/local/Cellar/boost/1.58.0/include `taglib-config --cflags` -fPIC -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG -c -o main.o main.cxx

In file included from main.cxx:17:

./AudioStreamInput.h:53:10: warning: ‘StdinStreamInput::ProcessFile‘ hides overloaded virtual function [-Woverloaded-virtual]

    bool ProcessFile(const char* filename){ return ProcessStandardInput();}

         ^

./AudioStreamInput.h:26:18: note: hidden overloaded virtual function ‘AudioStreamInput::ProcessFile‘ declared here: different number of parameters (3 vs 1)

    virtual bool ProcessFile(const char* filename, int offset_s=0, int seconds=0);

                 ^

1 warning generated.

g++ AudioBufferInput.o AudioStreamInput.o Base64.o Codegen.o Fingerprint.o MatrixUtility.o SubbandAnalysis.o Whitening.o Metadata.o `taglib-config --libs` -lz -lpthread -O3 -DBOOST_UBLAS_NDEBUG -DNDEBUG main.o -o ../echoprint-codegen


编译后会在src同级目录下生成一个echoprint-codegen二进制文件

ls

AUTHORS LICENSE README.md echoprint-codegen examples src windows

5、测试

./echoprint-codegen

Usage: ./echoprint-codegen [ filename | -s ] [seconds_start] [seconds_duration] [< file_list (if -s is set)]


./echoprint-codegen ~/Desktop/Maps.mp3 10 20

[

{"metadata":{"artist":"Maroon 5", "release":"Maps", "title":"Maps", "genre":"", "bitrate":128,"sample_rate":44100, "duration":252, "filename":"/Users/zhangjie/Desktop/Maps.mp3", "samples_decoded":220500, "given_duration":20, "start_offset":10, "version":4.12, "codegen_time":0.028393, "decode_time":0.203698}, "code_count":696, "code":"eJy1mFluJTsORLekeVgOKYr7X0IfyY13Xxso-cNdBioMp1ISpwgyK4SoMzxg7Rfs9ALvD0hBXxD9Bbm8oNoLenzBqA_Iabwg2wtae8HYL9D-gqUv8PKA0vYLRn7AD5VjL_hV9st4wTv7o73A_QG_yv5vMkgm_gxl2AN-w99f5aiNF4z-ArEXWHvADzkq_QU_ZEEeUGZ_geoDfpWj2F-Q5AWnfv4MTyX8IUe_4ZGkFzxzVEp9QFztBT_oVXrBOwvvOLf5gh-ysF_wG6b8Igs_dJy_mKPygr_HlFpf8IsM_pCjml4w6wPeWfjNVFDmeEC8gvdH-EEJ8wNSri-o-wU_9KM3y_oDfspgfMFvWBbtBaU94IccvbMQ1gveOXrPZr9iyjPOfb7gr2ndi2UtzeGt79VimElXabb6UKk5tKj_x9UwZ6x7TbGcVL_u_ez4rMaWw7jb7uo96q7ebXf1nve5KMuYofjKc-rUdE8uU6u1mGxz4NScHQL68hGm6tcqs5gmTgsbk2Jru6SlTeIIY7SRZPDOMukjzVq7ufZr1ceWrWI2y9BjaY1fBo2GJM5WZp19e6km1rXNdFc_Dn5W797r0Sc411xusyC1rvTfezFcIx-e1_q9OsPxcaHmgkWh1X6t_4rGzFOuW_dyn97K7t5nr9GMZaemMjeeEFulT-eed9S0y_rA9e3bsw-ULOTYY5SGBW0urTMOeK1xT2mLy-tuccxdtivD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XcPBRVFdu9qc6u9Y3ZQCqUSrkTp8C7tLalHvqiUPzMM31-rgvzDtpph8FqZvj3oC6h5tzWr2hDEWnu2VDp1R8ZiG3vsTmcedDhhI5wa3neHpIt8KbOG4_xpoVRHgb00ksA0II0Kg5RNWqFlUJ00SHd6O0JRJE0ORf1Tc1pZ4eLTiWmifroZIRoMZz54y2lXJAtS0KTp8LWSfKKxobiWHgyDao9wkeBPSg7alfMI_maCwKHoyJwtHJXO0yi_uhbf5kwlR-boqbCe320KwobGbX5imenLgtYafbDT3vaoyDpdOkE0xpyIa4j6_kCttIdvzz5A4w-QgSYsjBBhos-J0FPnKMHO1JTJgp-9zdmXTMVd5iXUd5L8hrOFWY7unejVpGid9j6lMrjTuoitFKMkaCx6Olvq6NMKaCWzIRNYM2bDXvT0QJGcNzNd1t5Ph8SSLoI6BcKLFJPjETxqv5Z-jNzn-wIp2e6-Tvdtp13bMYs755ZodxWdzfFuc2-yG38RLWZQEq20fiy65xU5jDmr94B_rZb7nyBcfu-4p6x4Bqez467e429IrlVflx-r7rZ72z2ULOX2gXvKt2cfoDKVz4Yl1eiX1AbKKTl1I6q27iqxPw4e2TKmy0A1BzkcVIovVlqxQpXNnNHambtaYnNgajt8GtbWPqNHJNIVTYZ69EGmK4_r67ZzFM10IifMXjJJEpxhPiGJ9a5Om-cb0qjPTIO7Vt0DlgdmibxN1wgo93n5OnNX7yn3ZBoLAfeS0vXyvnyPN6KmdzVu5OD73nPyfY85pLevvefKu0rB8MHAh4jydQVXj1UfW9ZpdB_4Mvd_n33gP_BT08A=", "tag":0}

这样就会把音乐的相关信息解析出来,其中code就是对应着Maps.mp3中10s到20s直接音乐对应的code,检索的时候使用code检索出响应的音乐。

6、下载地址

编译后的源码:http://pan.baidu.com/s/1mg5S5PA

Echoprint系列--编译

标签:

原文地址:http://blog.csdn.net/jwzhangjie/article/details/46425583

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!