> const r = Math.pow(2.0, 1.0 / 12.0);<p>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.<p>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 wrote this for my wife who is learning to play viola (I play violin at a barely endurable amateur level). It was to help her improve her intonation. As you play it draws the notes that you are playing on the musical staff, coloring them black for in tune, red for sharp, blue for flat.
It's one single html/javascript file, no server.<p>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.
Note that the most natural way to sing or play a fretless instrument isn't exactly 12 tone equal temperament. For example, if you play a major triad C-E-G as consonantly as possible, the frequency ratios C:E:G will be 4:5:6, which means 386 cents for C-E and 316 for E-G, instead of 400 and 300. The difference is quite audible. So be careful telling people they're 15 cents sharp or flat, as it's actually what makes the thirds and sixths in classical music sound so sweet!
Great idea, I love the idea of getting real-time transcription of what I'm attempting to play.<p>As others have commented, it seems to struggle with the low E and A strings of guitar. Thinking about this:<p>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.<p>2. The guitar range is approx 4 octaves, ie up to about 330Hz. The min sampling freq must be double this.<p>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.<p>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.<p>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.<p>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.<p>7. An oscilloscope display would be handy to verify that signal levels were ok, and that noise isn't too intrusive.
It might be worth exploring some consistency measurements. So for example if a tune is in the key of C major, people can have fun arguing about what pitch E should exactly be. But if the note is repeated in the melody but played with changing pitch then generally it will sound out of tune.<p>So something like a variance of pitch per note measured at the end.<p>In particular, something like Bach's cello suites tend to highlight these sort of intonation issues.
I use <a href="http://intonia.com/index.shtml" rel="nofollow">http://intonia.com/index.shtml</a> for this purpose. It's available on Android/iOS as well.<p>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.
Cool. I tried it with my viola but noticed the notes didn't appear correctly on the staff. Also it did jump a bit when I was playing a C major scale.<p>Could you make the staff and notes a big larger? The colors also are really difficult to discern.<p>I like it!
I'm a complete novice, but I remember hearing that we actually like to hear music ever so slightly off key. What does this analysis tool say for expert recordings?
I'll check it out with my cello when I'm not in a meeting. ;-) Of course we'll eventually need tenor and bass clefs, but certainly not an obstacle.