Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random jumps between G3 and G4 #88

Open
pablogila opened this issue Aug 5, 2024 · 10 comments
Open

Random jumps between G3 and G4 #88

pablogila opened this issue Aug 5, 2024 · 10 comments

Comments

@pablogila
Copy link

When tuning the 4th string of a Spanish guitar, it indicates G3 (correct) and suddenly it jumps to G4. It does not happen with the rest of the strings.

@thetwom
Copy link
Owner

thetwom commented Aug 5, 2024

Hi, thanks for the report. I cannot say how easy is to get around this problem. Sometimes the underlying sound looses most of the characteristica of the lower tone. But it would be good to get a sound sample. The tuner app has the option to record samples and store it to a wave file (please read especially point 4 carefully to understand that the sound BEFORE pressing is stored, not AFTER):

  1. Go to preferences and scroll down. You will find the option of recording duration in scientific mode. Turn this up to maximum.
  2. Switch on scientific mode.
  3. Go back to the tuner, you will now see a record button at the bottom.
  4. Pluck you string and wait for the phenomena to happen. After it happened, let it sound for e.g. 1 more second, then press the record button. It will save the 5 seconds BEFORE pressing the button.
  5. Give a filename and store it somewhere.
  6. Better listen to the stored file before sharing to make sure, it is really something you want to share.
  7. Provide the file here (maybe you have to zip it before ...

If possible, also provide sound samples of the other strings. Maybe also several samples of the 4th string.

Then I could analyze the sounds and see if improvements are possible.

Let me know, in case of questions.

@pablogila
Copy link
Author

Hello! Thanks for your reply. Here are the samples, I hope the naming is self-explanatory. I catched some other notes failing when recorded from an arm-distance. The close samples were recorded with the phone on top of the guitar.
tuner_issue_#88_samples.zip

@thetwom
Copy link
Owner

thetwom commented Aug 13, 2024

Thanks a lot. I quickly listened to the samples and think that they will be very helpful to analyse the issue. Can't promise that I can solve it, but I will at least try :-).

@thetwom
Copy link
Owner

thetwom commented Aug 14, 2024

Very interesting data. The second harmonic (or overtone) is extremely dominant, leading to the observed behaviour. But the characteristic of the fundamental tone ( the one you expect) is clearly there.

Here, e.g. the picture for E2, where there is a very dominant peak at ~160Hz (which corresponds to E3). But there are also peaks at multiples of ~80Hz means that E2 is the fundamental. Having dominant frequencies is normally no problem, but in this case it just very dominant :-).
image

In summary, this makes a perfect testcase to better improve the tuner behaviour, so thanks for providing this.

For the time being you can try plucking the string at other positions (especially closer to the center) to trigger less overtones. This of course does not solve the shortcomings of the tuner, but maybe makes it more usable for now :-).

@pablogila
Copy link
Author

Wow! This is such an interesting graph, thanks for sharing. I did not think the pluck position would matter that much, that is a pretty good point. I will do some tests with different positions, will let you know how it turns out. May I ask how did you process the audio files to plot the frequencies?

@thetwom
Copy link
Owner

thetwom commented Aug 19, 2024

May I ask how did you process the audio files to plot the frequencies?

Do you refer software or the underlying method? About software, these are python-based scripts that I am using to analyse different samples in order to avoid improving the tuner for one instrument on cost of another. So with each new sample of other instruments, I can get a better picture of the performance. Sharing the scripts would not be an issue, but I also guess not as helpful, since they are not made user friendly for end users ;-).

About the method, the shown graph is the Fourier transform of a small part of your sound sample. The Fourier transform is one of the most basic algorithms in signal analysis and gives a very good picture about the characteristics of a tone.

The difficulty is to find a reliable way analyse the resulting Fourier transform :-). The used algorithms seems to work well quite often. But as you see, there is enough room for improvement :-).

@pablogila
Copy link
Author

That's interesting. I figure that the spectra graph from the science mode is a fourier decomposition. I was able to record some samples by plucking in the middle of the string, and that way the detection worked properly. Plucking at 1/4th the second harmonic dominated just as in the picture you previously provided. Here are the samples, in case you find them useful:
tuner_plucked_in_the_middle.zip

It sounds reasonable to avoid improving one instrument on cost of others. However, when not in science mode but in each specific instrument mode, would it make sense to take into account that second harmonics may appear? For example, we know that G3 is the expected harmonic in a 6-string guitar, so if the footprint of a G4 is detected, it could be understood that we are working with G3, etc.

@thetwom
Copy link
Owner

thetwom commented Aug 21, 2024

Thanks a lot for the further testing. It is good to know that plucking at the middle changes the picture as expected.

Yes, exactly, the spectrum in science mode is the Fourier decomposition. It is used in combination with the second graph (autocorrelation) to find the most probable (not from a mathematical sense of view) and accurate tone.

However, when not in science mode but in each specific instrument mode, would it make sense to take into account that second harmonics may appear?

Ideally, this would not be needed. In my opinion consistency is fundamental for user experience, meaning that if you pluck a note while having one instrument set, the same tone is detected with another instrument set (of course this doesn't help, if the tuner can' t decide where to go :-D). Also it might be very hard to adjust correctly ... . This said, your suggestion is of course still perfectly valid. Why not use extra knowledge if it is there :-).

For now I have still hopes that by using the new insights from your data I can improve the tuner behaviour in general. As shown, the data you provided shows a clear trend to the actual tone. At least for one tone I can adjust the some parameters, and it will work very well. Unfortunately, it makes many other samples worse :-). So the "only" thing is to combine the knowledge such it works all the time :D. I have some ideas to do this, but it needs some time to test.

@pablogila
Copy link
Author

I am glad that this conversation was fruitful, I found it quite interesting. If you need more samples in a certain setup, I will be happy to record them :D

@thetwom
Copy link
Owner

thetwom commented Sep 15, 2024

So, I tried around a lot. Hopefully, I came up with a significant improvement. At least for the different sound samples, the situation is much better, now but to be honest, my testing uses not exactly the same code base as the tuner (but a very similar one), so there still can be issues.

Maybe you are willing to test the version: v7.0.0-rc2
But please note that this version has a major version jump, so you can not safely go back to a v6....-version without loosing your settings and custom instruments. So, if you have custom instruments, better export them before. About the settings, you would have to remember them :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants