libKeyFinder
A small C++11 library for estimating the musical key of digital audio.
keyfinder.h
1 /*************************************************************************
2 
3  Copyright 2011-2015 Ibrahim Sha'ath
4 
5  This file is part of LibKeyFinder.
6 
7  LibKeyFinder is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  LibKeyFinder is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with LibKeyFinder. If not, see <http://www.gnu.org/licenses/>.
19 
20 *************************************************************************/
21 
22 #ifndef KEYFINDER_H
23 #define KEYFINDER_H
24 
25 #include "audiodata.h"
26 #include "lowpassfilterfactory.h"
27 #include "chromatransformfactory.h"
28 #include "spectrumanalyser.h"
29 #include "keyclassifier.h"
30 
31 namespace KeyFinder {
32 
33  class KeyFinder {
34  public:
35 
36  // for progressive analysis
37  void progressiveChromagram(AudioData audio, Workspace& workspace);
38  void finalChromagram(Workspace& workspace);
39  key_t keyOfChromagram(const Workspace& workspace) const;
40 
41  // for analysis of a whole audio file
42  key_t keyOfAudio(const AudioData& audio);
43 
44  // for experimentation with alternative tone profiles
45  key_t keyOfChromaVector(const std::vector<double>& chromaVector, const std::vector<double>& overrideMajorProfile, const std::vector<double>& overrideMinorProfile) const;
46 
47  private:
48  void preprocess(AudioData& workingAudio, Workspace& workspace, bool flushRemainderBuffer = false);
49  void chromagramOfBufferedAudio(Workspace& workspace);
50  key_t keyOfChromaVector(const std::vector<double>& chromaVector) const;
51  LowPassFilterFactory lpfFactory;
52  ChromaTransformFactory ctFactory;
53  TemporalWindowFactory twFactory;
54  };
55 
56 }
57 
58 #endif
Definition: audiodata.h:29
Definition: chromatransformfactory.h:30
Definition: keyfinder.h:33
Definition: lowpassfilterfactory.h:30
Definition: temporalwindowfactory.h:30
Definition: workspace.h:32