Show HN: Are you playing your violin (viola, guitar, etc.) in tune?
ctrager.github.io
ctrager.github.io
It looks like the app uses 12-tone equal temperament as the standard for "in tune". For violin it would probably be better to use a just intonation scale as the reference rather than ET. (ET major and minor thirds and sixths differ from just by about 15 cents.) Even better would be to be able to toggle between JI and ET.
A pretty good 12-tone just scale is to use 1:1, 9:8, 16:15, 6:5, 5:4, 4:3, 45:32, 3:2, 8:5, 5:3, 9:5, 15:9, and 2:1 is the octave. (Multiply the ratio by the frequency of whatever your root note is.) Though notably on a violin you run into a complication with the open E string. If the G string is 1:1 and the strings are all tuned in fifths, they're 1:1, 3:2, 9:4, and 27:8. 27:8 is octave-equivalent to the pythagorean major sixth 27:16 rather than the simpler 5:3 major sixth that goes better with the rest of the scale. So, if you go with a just scale there's a potential for people to be confused about why their open E string seems to be out of tune (and the answer is that unless they're deliberately trying to play a pythagorean major sixth it probably is).
I do highly recommend getting a clip-on electronic tuner, because if you want to change tunings quickly or you want to do drop D on a floating bridge, you are gonna need it!
The good thing about just intonation is that it's always the same. No configuration.
Pianos are "out of tune" so that they sound well to humans.
https://en.wikipedia.org/wiki/Piano_acoustics#The_Railsback_...
On the other hand, if the goal is to just be in the general ballpark and accuracy of +/- 15 cents or so is just rounding error, then ET is probably fine. (My own violin skills are pretty rudimentary, so ET would be good enough. But if I were better I'd probably want a JI tuner.)
It's a tradeoff between convenience and optimally consonant harmonies. ET makes a lot of sense for guitar because you have fixed frets (though JI guitars do exist), but violin can be played in any intonation so there's less reason to use ET unless you're accompanying an ET instrument like piano or guitar.
Yet, modern science still can't measure the harmoniousness of a song at a given point or overall -- we have neither the theory nor the math to do so. It is an active area of scientific research! I find that so cool.
* hypothesis-driven empirical test of a mathematical model
What about consonance and dissonance? We have both the math and the music theory for those. Wouldn't that be a measure of harmoniousness?
There isn't a meter capable of showing how consonant or dissonant a song is, at any point in time -- or for the song as a whole.
This page works on my Thinkpad/Ubuntu laptop, but won't work on my Android phone, I don't know why. It probably won't work if you try to sing into it rather than play an instrument because the human voice is so complex, in terms of its wave form. I guess. I'm a barely endurable amateur in this domain too. But if you have a musical instrument handy, it might entertain you for a few minutes.
Edit: after more playing around (heh) it does start to pick up the almost-E notes, F, G, etc. but is a little inconsistent. I tried monitoring the mic and even recording to play back what got picked up, and it sounds just as clear as the higher notes. Maybe something numerical happening in the Javascript fft?
I found for me that with sensitivity at 20 I can hit every note perfectly! This is a fun tool to quickly go from a melody idea to a DAW now.
I'm very impressed, I've shared with my social as well because I thought it was so cool! Thank you for sharing your work.
At first I too was tempted to build an app just like this, but when I mentioned this to my teacher, she made it very plain that the only way to learn intonation is: hear, move fingers, repeat. Anything that gets in the way of making that feedback loop as tight as possible---devices, tuners, even conscious thought---is a distraction. In hindsight I think she's right. Though I too am still a barely endurable amateur, my intonation has improved to the extent that it feels like I have grown a new organ in my brain that connects my ears directly to my fingers.
What's more important is thinking about what has to happen. It requires your ears, brain, and body, to all work together, to put the right finger in the right place, consistently. Because you can't be in tune without being consistently in tune. Developing consistency is also what makes it possible to figure out what you're actually doing wrong, and correct it.
I think singing is a good exercise for ear training. There are YouTube recordings of virtually the entire student violin repertoire. Sing along. Get the tune in your head. Also, you can work on this any time, even away from the instrument.
Often overlooked is that intonation is intimately tied to technique because of the consistency factor. There are many schools of technique, but if you just pick one -- typically your teacher's -- and correct yourself when you deviate from it, you will become more consistent, and this will put you in control of playing in tune.
When I'm playing, and notice that I'm out of tune in a particular passage, I analyze what I'm doing wrong with my technique. This is something that never becomes "good enough," but is a lifelong compulsion. They interviewed Ray Brown near the end of his life, and asked why he still needed to practice. He said: "I still need to improve my intonation." That was from a master whose intonation was considered to be impeccable.
Now here's my contrarian view about temperaments. Engineers get worked up about them, but most musicians are ambivalent. Intonation transcends temperament because it has to do with controlling your body and sounding good. Only keyboard and electronic instruments have definite temperaments. String instruments have useful harmonic intervals in some keys (the "fiddle keys") but not others. Wind instruments are all over the place. I don't think there's a meaningful concept of "temperament" in an orchestra or jazz band. But when everybody is in tune, the band has a more powerful sound.
As a final comment: An adult should not expect to make progress at the rate that kids can. And I advise adult beginners to just avoid double stops -- they are not important enough to justify the mental and physical trauma.
Imagine a code editor that, if it detects a syntax error, automatically erases the entire line, flashes some random pattern on the entire screen, and makes you start over.
It's brutal, because you're flooded with multiple concepts and difficult physical skills all at once, including tone production, intonation, reading, just hitting the right note instead of a wrong one, and so forth. Working on one thing may require blocking the other things out of your mind.
Learning a stringed instrument as an adult is very hard. I'm awed by anybody who can do it.
There's a great electric bass teacher named Jeff Berlin, who has also written about teaching, and he mentioned that he doesn't stop his students when they make mistakes, because correcting mistakes is something they can figure out on their own.
As others have commented, it seems to struggle with the low E and A strings of guitar. Thinking about this:
1. The smallest note interval is from open low E (82Hz) up to the next semitone (82*(2^(1/12) -1)), which is about 5Hz. This gives the maximum bin width.
2. The guitar range is approx 4 octaves, ie up to about 330Hz. The min sampling freq must be double this.
3.In practice the bin edges wont line up with the semitone boundaries, so we ought to aim for bin widths smaller than half of 5Hz above, say 2Hz. This guarantees that a bin exists that doesn't cross semitone boundaries.
4. As lower frequencies probably wont be sampled across an integer number of cycles, spectral smearing will occur. This can be reduced by making the binwidth even smaller, and by use of windowing in the time domain.
5. My environment has background noise (eg computer fan). Unless the noise is filtered out pre-sampling (which it probably isn't for most users) then this will fold back into the signal of interest. Sampling at a higher rate than 2 x 330Hz would allow separation of the noise from the signal. I'm not sure what sample rate is used in the app. If the noise goes up to 4kz (I'm guessing) then this implies a sample rate of 8kHz to remove it.
6. From the above: sample at 8kHz for 1 second, use a window funtion to reduce spectral leakage. 8192 samples is a handy power of 2. Smaller sized ffts are likely to struggle to identify the right bin at lower frequencies, and/or have more noise in the signal band to confuse the peak detector.
7. An oscilloscope display would be handy to verify that signal levels were ok, and that noise isn't too intrusive.
If done in software then a simple implementation of autocorrelation is O(n^2). An efficient implemementation is O(n.log(n)) (it uses two ffts).
The remaining figures still look ok though.
So something like a variance of pitch per note measured at the end.
In particular, something like Bach's cello suites tend to highlight these sort of intonation issues.
It's not free, but I think the functionality is a bit better than this. It handles fast passages and can change temperament, show how off you were, etc.
Could you make the staff and notes a big larger? The colors also are really difficult to discern.
I like it!
There's a form of synthesizers where you start with simple sin waves that sounds electronic and mechanical. You layer various overtones on it to create more realistic sounds. Gettign the same richnesss as a real instrument is tough since there tends to be aspects of "sub-structure" for lack of another word. Really cool stuff.
Also, for low frequencies with lots of overtones look into autocorrelation, that works quite well and can be efficient if you program it right.
Then I switched to very simple autocorrelation and then I switched to a fancier autocorrelation-based method called "Yin".
Also, There's also a comment "The logarithmically binned spectrum has a resolution of one cent". Does that mean that there is a bucket for each 1 cent? When I was using WebAudio I think the the buckets were something like 14 units of frequency apart (hz?), and I didn't discover a way to get finer resolution.
So you need to run multiple methods in parallel and decide based on the very rough distribution of the energy in the spectrum which method has the biggest chance of success, or, alternatively, to use the output of both methods to drive some logic that will assign a weight to the output of each.
It's a tricky problem, to put it mildly. Also, this is the simplest form of the problem, doing this accurately for multiple pitches at once is much harder.
Another source of inspiration is the 'onsets and frames' software that powers some automated transcription software:
https://github.com/magenta/magenta/tree/master/magenta/model...
I think if this code is over your head that maybe a good introduction course on signal processing would be a nice thing to have under your belt.
Best of luck!
If you can re-tune (fourth line 'F') after you've warmed up the instrument. You do that on that F because it is roughly in the middle of the range of the instrument meaning you'll be off the minimum on the other notes. If you tuned it on the highest or lowest note the other end would be off considerably.
The sax is a wonderful instrument but it is definitely a finicky one, I've never found one that had all the notes in tune when played without corrective measures, and I'm not even sure that it could be done, the flexibility you get in making it go sharp or flat on purpose comes with the price of having to correct almost every note you play.
Also: have you ever thought about how undefined the frequency of a sax really is? The seal is a large, round flap that drops down over a circular hole with a raised edge. Even if you open it fast there is a gradient there and no matter what you do the hole itself is shaped to practically guarantee a different frequency response for every part of its circumference! It's a miracle it works at all (same goes for flute, oboe and clarinet).