1
$\begingroup$

I have various samples of various instruments sound, and I'm trying to classify them using pyAudioAnalysis and various Machine Learning algorithms. The samples record the instrument playing different notes, which obviously alters their frequency spectrum. I am looking for a way to separate the information about the note, ideally by reducing the harmonics of the relevant frequency, so that the feature extraction step does not give relevance to this information. Does it make sense? Is there a "simple" way to achieve this?

Thank you in advance.

$\endgroup$
6
  • 2
    $\begingroup$ i can't figure out what you mean. what "information about the note" are you trying to filter out? and, by "filter out", do you mean remove to get rid of, or to extract this information from the recorded audio. $\endgroup$ Commented Dec 16, 2016 at 6:31
  • $\begingroup$ For instance, an instrument playing a 440Hz A note will have a "strong" harmonic around 440Hz, plus various harmonics at 220Hz, 880Hz etc. I would like to remove this information as far as possible, in order to avoid misclassification due to the "note" similarity (eg. two samples from different instruments playing the same note classified as the same instrument). $\endgroup$
    – phagio
    Commented Dec 16, 2016 at 8:10
  • 2
    $\begingroup$ well, no, it is possible for a musical note to lack energy at it's fundamental, as long as it has energy in other harmonics. and 220 Hz would be a sub-harmonic to 440 Hz. if there was any appreciable energy at 220 Hz, it would sound like A below middle C not the A above it. so, again, what is the "information" you want removed? its pitch? are you trying to classify instruments independent of their pitch? $\endgroup$ Commented Dec 16, 2016 at 8:15
  • $\begingroup$ Pitch is the word! Basically yes, since the first attempts of classification yielded sometimes unaccurate results I wanted to verify if removing the pitch information would improve the accuracy. $\endgroup$
    – phagio
    Commented Dec 16, 2016 at 8:23
  • $\begingroup$ You could try to find the fundamental and then shift everything in frequency domain so that all fundamental frequencies are mapped to the same frequency (e.g. 0Hz). But: there'd still be the harmonic "spacing", and that happens to be the same frequency and multiples thereof. $\endgroup$ Commented Dec 16, 2016 at 9:29

1 Answer 1

1
$\begingroup$

Attenuating the harmonics of your instruments isn't really a viable option, because you'll end up annihilating the signal itself. The harmonics here are what are sampling the behaviour of your instrument.

I'm not sure if I'd call it simple, but a possible solution to separating the contribution of pitch in such a classification system might be cepstral liftering.

This is, calculate a cepstral representation of the recording of each instrument (the Fourier transform of the logarithm of the frequency response) and separate the periodic components (pitch) from the aperiodic (perhaps timbre?). Such separation is known as liftering - the analog of filtering in the cepstral domain.

The separated signals should roughly correspond to a periodic signal and an impulse response better characterising the instrument.

This is an approach used in to separate the harmonics of speech (carrying pitch information) from the transfer function of the vocal tract (which generates a filter forming vowels amongst other characteristics).

I'm not sure if this will work in your case, but I think it would be worth exploring.

$\endgroup$
4
  • $\begingroup$ Thank you for your suggestions, Speedy! I've read around the web about liftering. Do you know about any library around (such as python speech features which would actually be able to 'lifter' these components? $\endgroup$
    – phagio
    Commented Dec 16, 2016 at 15:43
  • $\begingroup$ I'm afraid not, but there's a number of libraries out there that perform the calculation of the cepstrum (such as python-acoustics). If you follow some of the tutorials around on the web the liftering stage should be fairly straightforward to implement. $\endgroup$
    – Speedy
    Commented Dec 16, 2016 at 16:27
  • $\begingroup$ I've just noticed that python_speech_features has a function called ceplifter. This might be what you're looking for? $\endgroup$
    – Speedy
    Commented Dec 16, 2016 at 16:44
  • $\begingroup$ Thank you again, Speedy :) I will delve in these libraries and look for clues. $\endgroup$
    – phagio
    Commented Dec 18, 2016 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.