From 784f31d1be2597b12f350ad3103e4b1befe1f9a3 Mon Sep 17 00:00:00 2001 From: MAC Date: Wed, 17 Sep 2014 12:00:57 +0200 Subject: [PATCH] Allow to use codes directly from libcodegen.so without the need to decode the output string back --- src/Codegen.cxx | 1 + src/Codegen.h | 5 ++++- src/FPCode.cxx | 17 +++++++++++++++++ src/FPCode.h | 19 +++++++++++++++++++ src/Fingerprint.h | 7 +------ src/Makefile | 3 ++- 6 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 src/FPCode.cxx create mode 100644 src/FPCode.h diff --git a/src/Codegen.cxx b/src/Codegen.cxx index b391b38..35cee01 100644 --- a/src/Codegen.cxx +++ b/src/Codegen.cxx @@ -39,6 +39,7 @@ Codegen::Codegen(const float* pcm, unsigned int numSamples, int start_offset) { pFingerprint->Compute(); _CodeString = createCodeString(pFingerprint->getCodes()); + _vCodes = pFingerprint->getCodes(); _NumCodes = pFingerprint->getCodes().size(); delete pFingerprint; diff --git a/src/Codegen.h b/src/Codegen.h index 5923d51..a36dde7 100644 --- a/src/Codegen.h +++ b/src/Codegen.h @@ -25,15 +25,17 @@ #define CODEGEN_API #endif +#include "FPCode.h" + class Fingerprint; class SubbandAnalysis; -struct FPCode; class CODEGEN_API Codegen { public: Codegen(const float* pcm, unsigned int numSamples, int start_offset); std::string getCodeString(){return _CodeString;} + std::vector const & getCodes() const {return _vCodes; } int getNumCodes(){return _NumCodes;} static double getVersion() { return ECHOPRINT_VERSION; } private: @@ -42,6 +44,7 @@ class CODEGEN_API Codegen { std::string compress(const std::string& s); std::string _CodeString; + std::vector _vCodes; int _NumCodes; }; diff --git a/src/FPCode.cxx b/src/FPCode.cxx new file mode 100644 index 0000000..a445e4e --- /dev/null +++ b/src/FPCode.cxx @@ -0,0 +1,17 @@ +// +// echoprint-codegen +// Copyright 2011 The Echo Nest Corporation. All rights reserved. +// + + +#include "FPCode.h" + +FPCode::FPCode() + : frame(0), code(0) {} + +FPCode::FPCode(FPCode const & copy) + : frame( copy.frame), code( copy.code) {} + +FPCode::FPCode(uint32_t f, uint32_t c) + : frame(f), code(c) {} + diff --git a/src/FPCode.h b/src/FPCode.h new file mode 100644 index 0000000..f2aa8a8 --- /dev/null +++ b/src/FPCode.h @@ -0,0 +1,19 @@ +// +// echoprint-codegen +// Copyright 2011 The Echo Nest Corporation. All rights reserved. +// + +#ifndef FPCODE_H +#define FPCODE_H + +#include + +struct FPCode { + FPCode(); + FPCode(FPCode const & copy); + FPCode(uint32_t f, uint32_t c); + uint32_t frame; + uint32_t code; +}; + +#endif /* FPCODE_H */ diff --git a/src/Fingerprint.h b/src/Fingerprint.h index cd4c784..4f9ac3f 100644 --- a/src/Fingerprint.h +++ b/src/Fingerprint.h @@ -19,12 +19,7 @@ #define HASH_BITMASK 0x000fffff #define SUBBANDS 8 -struct FPCode { - FPCode() : frame(0), code(0) {} - FPCode(uint f, int c) : frame(f), code(c) {} - uint frame; - uint code; -}; +#include "FPCode.h" unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed ); diff --git a/src/Makefile b/src/Makefile index 1bcbe3e..ce39a70 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,6 +22,7 @@ MODULES_LIB = \ AudioBufferInput.o \ AudioStreamInput.o \ Base64.o \ + FPCode.o \ Codegen.o \ Fingerprint.o \ MatrixUtility.o \ @@ -72,7 +73,7 @@ install: all mkdir -p $(DESTDIR)$(BINDIR) install ../echoprint-codegen $(DESTDIR)$(BINDIR) install -d $(DESTDIR)$(INCLUDEDIR)/echoprint - install -pm 644 Codegen.h $(DESTDIR)$(INCLUDEDIR)/echoprint/ + install -pm 644 FPCode.h Codegen.h $(DESTDIR)$(INCLUDEDIR)/echoprint/ mkdir -p $(DESTDIR)$(LIBDIR) ifeq ($(UNAME),Darwin) install -m 755 libcodegen.$(VERSION).dylib $(DESTDIR)$(LIBDIR)