You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe there's an error in the implementation of the chromaFeatures. In stChromaFeaturesInit if values of freq is smaller than Cp=27.5 the nChroma values will have negative index due to the log(freq/Cp) term on line 246 this will happen when fs/nfft < Cp
The down stream effect of this is that in stChromaFeatures, nChroma is used as indices to initialize CC[nChroma] = spec, which, if the indices are negative, will incorrectly index C from the end of the array. Also if nChroma has multiple of the same index it would override each other.
Is the ChromaFeature in pyAudioAnalysis a similar implementation to http://www.ctralie.com/Teaching/ECE381_DataExpeditions_Lab1/? if so there is a chroma matrix generator in librosa that might be useful or this custom implementation of chroma matrix by myself might also be helpful
def _stChromaFeaturesInit(nfft, fs):
"""
This function initializes the chroma matrices used in the calculation of the chroma features
"""
chroma_matrix = np.zeros((12, nfft))
freqs = np.array([((f + 1) * fs) / (2 * int(nfft)) for f in range(int(nfft))])
base_freq = 880 # reference hz for the A note
freqs_halfstep_approx = (np.log2(freqs / base_freq) * 12)
note_indices = (np.round(freqs_halfstep_approx) % 12).astype(int)
halfsteps_freq = base_freq*2**(np.round(freqs_halfstep_approx)/12)
for i in range(12):
chroma_matrix[i, note_indices == i] = 1
return chroma_matrix, halfsteps_freq
if __name__ == '__main__':
nfft = 1000
fs = 16000
chroma_matrix, _ = _stChromaFeaturesInit(nfft, fs)
import matplotlib.pyplot as plt
plt.imshow(chroma_matrix, aspect='auto')
plt.yticks(range(12), ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'], fontsize=9)
plt.ylabel('frequency bins 8hz per bin')
plt.show()
pass
this will produce the following chroma matrix
which can then be used with spec to generate chromaF (assuming the implementation is the same as the link above).
The text was updated successfully, but these errors were encountered:
Is the chromaF calculated in pyAudioAnalysis suppose to be a vector of the sum of the frame's chromagram energy at each of the 12 notes, normalized by the energy of the frame?
I believe there's an error in the implementation of the chromaFeatures. In
stChromaFeaturesInit
if values of freq is smaller thanCp=27.5
the nChroma values will have negative index due to thelog(freq/Cp)
term on line 246 this will happen whenfs/nfft < Cp
The down stream effect of this is that in
stChromaFeatures
, nChroma is used as indices to initializeC
C[nChroma] = spec
, which, if the indices are negative, will incorrectly index C from the end of the array. Also if nChroma has multiple of the same index it would override each other.Is the ChromaFeature in pyAudioAnalysis a similar implementation to http://www.ctralie.com/Teaching/ECE381_DataExpeditions_Lab1/? if so there is a chroma matrix generator in librosa that might be useful or this custom implementation of chroma matrix by myself might also be helpful
this will produce the following chroma matrix
which can then be used with
spec
to generatechromaF
(assuming the implementation is the same as the link above).The text was updated successfully, but these errors were encountered: