PageRenderTime 162ms CodeModel.GetById 80ms app.highlight 3ms RepoModel.GetById 78ms app.codeStats 0ms

/thirdparty/liblastfm2/src/fingerprint/fplib/FingerprintExtractor.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 77 lines | 23 code | 18 blank | 36 comment | 0 complexity | 59cec2489c1fca3a108ad083fd4467a7 MD5 | raw file
 1/*
 2   Copyright 2005-2009 Last.fm Ltd. <mir@last.fm>
 3
 4   This file is part of liblastfm.
 5
 6   liblastfm is free software: you can redistribute it and/or modify
 7   it under the terms of the GNU General Public License as published by
 8   the Free Software Foundation, either version 3 of the License, or
 9   (at your option) any later version.
10
11   liblastfm is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef __FINGERPRINT_EXTRACTOR_H
20#define __FINGERPRINT_EXTRACTOR_H
21
22#include <utility> // for pair
23#include <cstddef> // for size_t
24
25namespace fingerprint {
26
27// -----------------------------------------------------------------------------
28
29class PimplData;
30
31class FingerprintExtractor
32{
33public:
34
35   FingerprintExtractor(); // ctor
36   ~FingerprintExtractor(); // dtor
37
38   // duration (in seconds!) is optional, but if you want to submit tracks <34 secs
39   // it must be provided. 
40   void initForQuery(int freq, int nchannels, int duration = -1);
41   void initForFullSubmit(int freq, int nchannels);
42
43   // return false if it needs more data, otherwise true
44   // IMPORTANT: num_samples specify the size of the *short* array pPCM, that is
45   //            the number of samples that are in the buffer. This includes
46   //            the stereo samples, i.e.
47   //            [L][R][L][R][L][R][L][R] would be num_samples=8
48   bool process(const short* pPCM, size_t num_samples, bool end_of_stream = false);
49
50   // returns pair<NULL, 0> if the data is not ready
51   std::pair<const char*, size_t> getFingerprint();
52
53   //////////////////////////////////////////////////////////////////////////
54
55   // The FingerprintExtractor assumes that the file start from the beginning
56   // but since the first SkipMs are ignored, it's possible to feed it with NULL.
57   // In order to know how much must be skipped (in milliseconds) call this function.
58   // Remark: this is only for "advanced" users!
59   size_t getToSkipMs();
60
61   // Return the minimum duration of the file (in ms)
62   // Any file with a length smaller than this value will be discarded
63   static size_t getMinimumDurationMs();
64
65   // return the version of the fingerprint
66   static size_t getVersion();
67
68private:
69
70   PimplData* m_pPimplData;
71};
72
73// -----------------------------------------------------------------------------
74
75} // end of namespace fingerprint
76
77#endif // __FINGERPRINT_EXTRACTOR_H