Mercurial > hg > vamp-tempogram
comparison SpectrogramProcessor.cpp @ 25:fe23998968b4
* Added tempogram via autocorrelation feature, using AutocorrelationProcessor
* Moved calculateMax() from NoveltyCurveProcessor to SpectrogramProcessor
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Wed, 20 Aug 2014 16:00:37 +0100 |
parents | 957b83524c06 |
children | 4cf2d163127b |
comparison
equal
deleted
inserted
replaced
24:957b83524c06 | 25:fe23998968b4 |
---|---|
54 } | 54 } |
55 | 55 |
56 return spectrogramT; | 56 return spectrogramT; |
57 } | 57 } |
58 | 58 |
59 //calculate max of spectrogram | |
60 float SpectrogramProcessor::calculateMax(const Spectrogram &spectrogram) | |
61 { | |
62 float max = 0; | |
63 | |
64 int length = spectrogram.size(); | |
65 int height = length > 0 ? spectrogram[0].size() : 0; | |
66 | |
67 for (int i = 0; i < length; i++){ | |
68 for (int j = 0; j < height; j++){ | |
69 max = max > fabs(spectrogram[i][j]) ? max : fabs(spectrogram[i][j]); | |
70 } | |
71 } | |
72 | |
73 return max; | |
74 } | |
75 | |
59 //process method | 76 //process method |
60 Spectrogram SpectrogramProcessor::process(const float * const pInput, const size_t &inputLength, const float * pWindow, const bool &transposeOutput) const | 77 Spectrogram SpectrogramProcessor::process(const float * const pInput, const size_t &inputLength, const float * pWindow) const |
61 { | 78 { |
62 Spectrogram spectrogram; | 79 Spectrogram spectrogram; |
63 | 80 |
64 int readBlockPointerIndex = 0; | 81 int readBlockPointerIndex = 0; |
65 int writeBlockPointer = 0; | 82 int writeBlockPointer = 0; |
94 | 111 |
95 readBlockPointerIndex += m_hopSize; | 112 readBlockPointerIndex += m_hopSize; |
96 writeBlockPointer++; | 113 writeBlockPointer++; |
97 } | 114 } |
98 | 115 |
99 if(transposeOutput) return transpose(spectrogram); | 116 return spectrogram; |
100 else return spectrogram; | |
101 } | 117 } |