├── .gitignore ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── examples └── lookup.py ├── src ├── AudioBufferInput.cxx ├── AudioBufferInput.h ├── AudioStreamInput.cxx ├── AudioStreamInput.h ├── Base64.cxx ├── Base64.h ├── Codegen.cxx ├── Codegen.h ├── Common.h ├── File.h ├── Fingerprint.cxx ├── Fingerprint.h ├── Makefile ├── MatrixUtility.cxx ├── MatrixUtility.h ├── Metadata.cxx ├── Metadata.h ├── Params.h ├── SubbandAnalysis.cxx ├── SubbandAnalysis.h ├── Whitening.cxx ├── Whitening.h ├── echoprint-codegen-ios │ ├── README.md │ ├── echoprint-codegen-ios.xcconfig │ ├── echoprint-codegen-ios.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── echoprint-codegen-ios │ │ └── echoprint-codegen-ios-Prefix.pch ├── main.cxx ├── win_funcs.h └── win_unistd.h └── windows ├── .gitignore ├── README.md ├── codegen.sln ├── codegen.vcxproj └── codegen.vcxproj.filters /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.dylib 3 | *.so 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | See the LICENSE file for important license information. 2 | 3 | Whitening, SubbandAnalysis, Fingerprint 4 | Dan Ellis 5 | Brian Whitman 6 | 7 | AudioBufferInput, AudioStreamInput, Codegen, Common, File, MatrixUtility, Metadata 8 | Tristan Jehan 9 | Paul Lamere 10 | Jason Sundram 11 | Brian Whitman 12 | 13 | Murmurhash2 14 | Austin Appleby 15 | 16 | Base64 17 | Rene Nyffenegger 18 | 19 | Contributors 20 | Alastair Porter 21 | efsavage 22 | alsuren 23 | artgillespie 24 | yhorng 25 | divan 26 | 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Contributions are welcomed. Open a pull-request or an issue. 3 | 4 | ## Code of conduct 5 | This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code. 6 | 7 | [code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | echoprint-codegen is open source software licensed under the "MIT License" 2 | More information about the MIT License: http://en.wikipedia.org/wiki/MIT_License 3 | 4 | Copyright (c) 2011 The Echo Nest Corporation 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | 24 | 25 | libcodegen makes use of the following pieces of software: 26 | 27 | - Murmurhash by Austin Appleby (Public Domain / MIT) 28 | http://sites.google.com/site/murmurhash/ 29 | 30 | - Boost (Boost Software License) 31 | http://www.boost.org/users/license.html 32 | 33 | - Base64.cpp and Base64.h, see source files for license 34 | Copyright (C) 2004-2008 René Nyffenegger 35 | 36 | 37 | codegen (the example binary that the makefile also builds) makes use of libcodegen and: 38 | 39 | - Taglib (LGPL) 40 | http://developer.kde.org/~wheeler/taglib.html 41 | 42 | - ffmpeg (via system shell, you must install ffmpeg on your own) 43 | http://www.ffmpeg.org/legal.html 44 | 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codegen for Echoprint 2 | 3 | **Note:** This project is no longer actively maintained 4 | 5 | Echoprint is an open source music fingerprint and resolving framework powered by the [The Echo Nest](http://the.echonest.com/ "The Echo Nest"). The [code generator](http://github.com/echonest/echoprint-codegen "echoprint-codegen") (library to convert PCM samples from a microphone or file into Echoprint codes) is open source (MIT licensed) and free for any use. The [server component](http://github.com/echonest/echoprint-server "echoprint-server") that stores and resolves queries is open source (Apache 2 licensed) and free for any use. The [data for resolving to millions of songs](http://echoprint.me/data "Echoprint Data") is free for any use provided any changes or additions are merged back to the community. 6 | 7 | [Read more about Echoprint here](http://echoprint.me) 8 | 9 | There are two modes of operation of the Echoprint codegen: 10 | 11 | 1. the codegen library (libcodegen) is meant to be linked into code that passes it a buffer of PCM data and will output a code string. 12 | 13 | 2. the codegen binary runs standalone, accepts filenames as inputs and runs in a multithreaded worker mode. 14 | 15 | ## Requirements 16 | 17 | ### For libcodegen 18 | 19 | * Boost >= 1.35 20 | * zlib 21 | 22 | ### Additional requirements for the codegen binary 23 | 24 | * [TagLib](http://developer.kde.org/~wheeler/taglib.html "TagLib") 25 | * ffmpeg - this is called via shell and is not linked into codegen 26 | 27 | On Ubuntu or Debian you can install these dependencies with: 28 | 29 | sudo apt-get install ffmpeg libboost1.42-dev libtag1-dev zlib1g-dev 30 | On OS-X with [homebrew](http://mxcl.github.io/homebrew/) you can use: 31 | 32 | brew install ffmpeg boost taglib 33 | 34 | On Windows: 35 | 36 | Refer to the documentation under the windows folder for more specifics. 37 | 38 | The binary generated in Windows will be named codegen by default where as on Linux or Mac OS-X it is named echoprint-codegen. 39 | 40 | ## Notes about libcodegen: 41 | 42 | Code generation takes a buffer of floating point PCM data sampled at 11025 Hz and mono. 43 | 44 | Codegen * pCodegen = new Codegen(const float* pcm, uint numSamples, int start_offset); 45 | 46 | pcm: a buffer of floats, mono, 11025 Hz 47 | numSamples: the number of samples 48 | start_offset: creates a hint to the server on where the sample is taken from in the original file if known 49 | 50 | string code = pCodegen->getCodeString(); 51 | 52 | The code string is just a base64 encoding of a zlib compression of the original code string, which is a hex encoded series of ASCII numbers. See API/fp.py in echoprint-server for decoding help. 53 | 54 | You only need to query for 20 seconds of audio to get a result. 55 | 56 | ## Notes about the codegen binary 57 | 58 | The makefile builds an example code generator that uses libcodegen, called "codegen." This code generator has more features -- it will output ID3 tag information and uses ffmpeg to decode any type of file. If you don't need to compile libcodegen into your app you can rely on this. Note that you need to have ffmpeg installed and accessible on your path for this to work. 59 | 60 | ./echoprint-codegen billie_jean.mp3 10 30 61 | 62 | Will take 30 seconds of audio from 10 seconds into the file and output JSON suitable for querying: 63 | 64 | {"metadata":{"artist":"Michael jackson", "release":"800 chansons des annes 80", "title":"Billie jean", "genre":"", "bitrate":192, "sample_rate":44100, "seconds":294, "filename":"billie_jean.mp3", "samples_decoded":220598, "given_duration":30, "start_offset":10, "version":4.00}, "code_count":846, "code":"JxVlIuNwzAMQ1fxCDL133+xo1rnGqNAEcWy/ERa2aKeZmW... 65 | 66 | You can host your own [Echoprint server](http://github.com/echonest/echoprint-server "echoprint-server") and ingest or query to that. 67 | 68 | Codegen also runs in a multithreaded mode for bulk resolving: 69 | 70 | ./echoprint-codegen -s 10 30 < file_list 71 | 72 | Will compute codes for every file in file_list for 30 seconds starting at 10 seconds. (It tries to be smart about the number of threads to use.) It will output a JSON list. 73 | 74 | ## Statistics 75 | 76 | ### Speed 77 | 78 | Codegen scans audio at roughly 250x real time per processor after decoding and resampling to 11025 Hz. This means a full song can be scanned in less than 0.5s on an average computer, and an amount of audio suitable for querying (30s) can be scanned in less than 0.04s. 79 | 80 | Decoding from MP3 will be the bottleneck for most implementations. Decoders like mpg123 or ffmpeg can decode 30s mp3 audio to 11025 PCM in under 0.10s. 81 | 82 | clump:echoprint-codegen bwhitman$ time mpg123 -q -s -4 -n 1200 song.mp3 > /dev/null 83 | real 0m0.079s 84 | user 0m0.067s 85 | sys 0m0.007s 86 | 87 | ### Accuracy 88 | 89 | Look at http://echoprint.me for information on the accuracy of the echoprint system. 90 | 91 | ## FAQ 92 | 93 | Q: I get "Couldn't decode any samples with: ffmpeg" when running codegen 94 | 95 | A: When running the example code generator (echoprint-codegen) make sure ffmpeg is accessible to your path. Try running ffmpeg filename.mp3 on the file you are testing the code generator with. If it doesn't work, codegen won't work. 96 | -------------------------------------------------------------------------------- /examples/lookup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This script takes an audio file and performs an echoprint lookup on it. 4 | # Requirements: pyechonest >= 4.2.15 http://code.google.com/p/pyechonest/ 5 | # The echoprint-codegen binary (run make from ../src) 6 | # an Echo Nest API key 7 | 8 | import sys 9 | import os 10 | 11 | import pyechonest.config as config 12 | import pyechonest.song as song 13 | 14 | config.CODEGEN_BINARY_OVERRIDE = os.path.abspath("../echoprint-codegen") 15 | 16 | # Put your API key in a shell variable ECHO_NEST_API_KEY, or put it here 17 | # config.ECHO_NEST_API_KEY='KEY HERE' 18 | 19 | def lookup(file): 20 | # Note that song.identify reads just the first 30 seconds of the file 21 | fp = song.util.codegen(file) 22 | if len(fp) and "code" in fp[0]: 23 | # The version parameter to song/identify indicates the use of echoprint 24 | result = song.identify(query_obj=fp, version="4.11") 25 | print "Got result:", result 26 | if len(result): 27 | print "Artist: %s (%s)" % (result[0].artist_name, result[0].artist_id) 28 | print "Song: %s (%s)" % (result[0].title, result[0].id) 29 | else: 30 | print "No match. This track may not be in the database yet." 31 | else: 32 | print "Couldn't decode", file 33 | 34 | 35 | if __name__ == "__main__": 36 | if len(sys.argv) < 2: 37 | print >>sys.stderr, "Usage: %s