Potentially because of access to a bad guitar, but seems like there's still a lot of noise in real world input. Consider some of these solutions to reduce noise:
Input Signal Analysis:
Print out or visualize the raw FFT results for both YouTube audio and your live guitar.
Compare the harmonic structures and overall frequency content.
Preprocessing:
Implement a high-pass filter to reduce low-frequency noise.
Try normalizing the input signal.
HPS Algorithm Adjustment:
Experiment with different numbers of harmonics in your HPS calculation.
Try weighting higher harmonics more heavily.
Frequency Range Focus:
Implement a bandpass filter focusing on the expected frequency range of guitar strings (about 80 Hz to 1000 Hz).
Peak Detection:
Improve your peak detection algorithm to be more robust against noise.
Implement a minimum threshold for peak detection.
Multiple Frame Analysis:
Analyze multiple short frames of audio and use a voting or averaging system.
Potentially because of access to a bad guitar, but seems like there's still a lot of noise in real world input. Consider some of these solutions to reduce noise:
Input Signal Analysis:
Print out or visualize the raw FFT results for both YouTube audio and your live guitar. Compare the harmonic structures and overall frequency content.
Preprocessing:
Implement a high-pass filter to reduce low-frequency noise. Try normalizing the input signal.
HPS Algorithm Adjustment:
Experiment with different numbers of harmonics in your HPS calculation. Try weighting higher harmonics more heavily.
Frequency Range Focus:
Implement a bandpass filter focusing on the expected frequency range of guitar strings (about 80 Hz to 1000 Hz).
Peak Detection:
Improve your peak detection algorithm to be more robust against noise. Implement a minimum threshold for peak detection.
Multiple Frame Analysis:
Analyze multiple short frames of audio and use a voting or averaging system.