annotate dsp/keydetection/GetKeyMode.h @ 461:9414df58fd0e

Fix an issue is a mutithreading context The global profile buffers where used concurrently by different threads leading to wrong detection results. This is fixed by using a local copy of the buffers. In addition, this commit also includes some minor performance improvements.
author Daniel Schürmann <daschuer@mixxx.org>
date Fri, 24 May 2019 21:40:47 +0200
parents 02cb97d2dee8
children 64fc3009d0a3
rev   line source
c@232 1 /*
c@378 2 Copyright (c) 2005 Centre for Digital Music ( C4DM )
c@378 3 Queen Mary Univesrity of London
c@378 4
c@378 5 This program is free software; you can redistribute it and/or
c@378 6 modify it under the terms of the GNU General Public License as
c@378 7 published by the Free Software Foundation; either version 2 of the
c@378 8 License, or (at your option) any later version. See the file
c@378 9 COPYING included with this distribution for more information.
c@232 10 */
c@232 11
c@265 12 #ifndef GETKEYMODE_H
c@232 13 #define GETKEYMODE_H
c@232 14
c@232 15
c@232 16 #include "dsp/rateconversion/Decimator.h"
c@232 17 #include "dsp/chromagram/Chromagram.h"
c@232 18
c@232 19
c@232 20 class GetKeyMode
c@232 21 {
c@232 22 public:
c@234 23 GetKeyMode( int sampleRate, float tuningFrequency,
c@234 24 double hpcpAverage, double medianAverage );
c@232 25
c@232 26 virtual ~GetKeyMode();
c@232 27
c@232 28 int process( double* PCMData );
c@232 29
daschuer@461 30 double krumCorr( const double *pDataNorm, const double *pProfileNorm,
daschuer@461 31 int shiftProfile, unsigned int length );
c@232 32
c@232 33 unsigned int getBlockSize() { return m_ChromaFrameSize*m_DecimationFactor; }
c@232 34 unsigned int getHopSize() { return m_ChromaHopSize*m_DecimationFactor; }
c@232 35
c@232 36 double* getChroma() { return m_ChrPointer; }
daschuer@458 37 unsigned int getChromaSize();
c@232 38
c@232 39 double* getMeanHPCP() { return m_MeanHPCP; }
c@232 40
daschuer@459 41 double* getKeyStrengths();
c@265 42
c@268 43 bool isModeMinor( int key );
c@232 44
c@232 45 protected:
c@232 46
c@232 47 double m_hpcpAverage;
c@232 48 double m_medianAverage;
c@232 49 unsigned int m_DecimationFactor;
c@232 50
c@232 51 //Decimator (fixed)
c@232 52 Decimator* m_Decimator;
c@232 53
c@232 54 //chroma configuration
c@234 55 ChromaConfig m_ChromaConfig;
c@232 56
c@232 57 //Chromagram object
c@232 58 Chromagram* m_Chroma;
c@232 59
c@232 60 //Chromagram output pointer
c@232 61 double* m_ChrPointer;
c@232 62
c@232 63 //Framesize
c@232 64 unsigned int m_ChromaFrameSize;
c@232 65 //Hop
c@232 66 unsigned int m_ChromaHopSize;
c@232 67
c@232 68
c@232 69 unsigned int m_ChromaBuffersize;
c@232 70 unsigned int m_MedianWinsize;
c@232 71
c@232 72 unsigned int m_bufferindex;
c@232 73 unsigned int m_ChromaBufferFilling;
c@232 74 unsigned int m_MedianBufferFilling;
c@232 75
c@232 76
c@232 77 double* m_DecimatedBuffer;
c@232 78 double* m_ChromaBuffer;
c@232 79 double* m_MeanHPCP;
c@232 80
daschuer@461 81 double* m_MajProfileNorm;
daschuer@461 82 double* m_MinProfileNorm;
c@232 83 double* m_MajCorr;
c@232 84 double* m_MinCorr;
c@232 85 int* m_MedianFilterBuffer;
c@232 86 int* m_SortedBuffer;
c@265 87
c@265 88 double *m_keyStrengths;
c@232 89 };
c@232 90
c@232 91 #endif // !defined GETKEYMODE_H