
Show HN: How to Tune a Guitar - mathisonian
https://mathisonian.github.io/idyll/how-to-tune-a-guitar/
======
wilsonnb
This is really cool.

If your main focus is to teach people how to tune a guitar, you should
consider mentioning that you always want to tune a sharp guitar string to
slightly below the correct pitch and then tune it up.

Any slack present in the string winding can cause the string to go out of tune
easily if you loosen the string to the correct tension. Tightening to the
correct tension doesn't have that problem.

If your guitar has locking tuners, this isn't necessary because there is no
string winding and therefore no slack. For anyone who doesn't know, a locking
tuner clamps down onto the string to hold it in place instead of having the
string wound around it.

This picture is of a locking set of tuners. The person is about to press down
the locking mechanism for the low E string to hold it in place. Note that the
other strings have no winding around the peg.

[http://www.prsguitars.com/csc/tuners/lock_4.jpg](http://www.prsguitars.com/csc/tuners/lock_4.jpg)

Most guitars don't come with locking tuners but I would recommend that
everyone use them because they make changing strings so much easier.

Anyways, I really like your web page. Cool stuff.

~~~
dbkaplun
> Any slack present in the string winding can cause the string to go out of
> tune easily if you loosen the string to the correct tension.

You can get around that by using harmonics. Because you play harmonics without
pushing all the way down, you can achieve a more precise tune.

The strongest harmonic is achieved when you gently place your finger on the
string directly over the metal fret. A harmonic can only be achieved when you
do not press the string all the way down into the fret.

The harmonic on the 7th fret of one string is the same note as the harmonic on
the 5th fret on the next higher string. This is true for all consecutive
string pairs other than (G, B).

You can tune using these pairs of harmonics to tune more precisely than
pressing all the way down.

You will need to tune the (G, B) pair without harmonics.

~~~
klodolph
> You can get around that by using harmonics. Because you play harmonics
> without pushing all the way down, you can achieve a more precise tune.

The big problem with trying to tune a guitar that way is that you're tuning a
guitar so it's in tune when you don't press the strings, but then when you
actually play it you _do_ press down the strings. Strings 5 and 6 should be
tuned slightly flat relative to the first four, the exact amount depends on
your play style, but if you don't tune them a bit flat then they'll sound
sharp when you're playing. If you haven't tried this yourself you might guess
that it's subtle effect, but depending on your play style it can be huge.

The other problem is that the harmonics are actually 2 cents off of an equal
tempered fifth, and if you tune six strings that way you'll end up 10 cents
off. Your octaves will sound wrong.

~~~
dbkaplun
> The big problem with trying to tune a guitar that way is that you're tuning
> a guitar so it's in tune when you don't press the strings, but then when you
> actually play it you do press down the strings.

When you press the strings, they will all press equally, playing a correct
relative tune.

------
mathisonian
Hi HN - I'm one of the authors of this post and I lead an open source software
project called Idyll that tries to make it easier to write interactive posts
like this for the web. This is part of a research project I'm doing while
completing a phd at the university of washington.

If you like this one, check out other examples that have been made with the
tool here: [https://idyll-lang.org/gallery](https://idyll-lang.org/gallery)

~~~
pen2l
I just logged in to say that I love you for creating both this specific
application and for software you are creating to make things like this. I
loved the explanation, I love the execution, and I love the spirit behind
this. More power to you man.

------
korethr
I suggest turning off the distortion by default for the 1st stage of tuning
with the electric tuner. The distortion can mask being slightly (+/\- 5 cents)
out of tune, making it hard to hear even though the tuner says it's still
wrong. Additionally, in all my years of playing, I have never fed a tuner with
a distorted signal from the amplifier, but a clean one; the tuner pedal is the
very first item in my effects chain before the amplifier. I suspect it is
easier for a tuner to pick out a(n) (in)correctly tuned note from a clean
tone, as there's simply less frequencies in the FFT to sort through. It may
also make it easier for users to pick out the fundamental and it's natural
harmonics in the FFT.

Another suggestion is to model how the tone will go slightly sharp on the
attack. How much depends on how much tension the strings are under, and thus
all the things that effect that (tuned note, string tension & scale length).

~~~
jamesb93
You should always tune to clean. If you have any sort of distortion
(particularly digital) you start to introduce aliasing and will have the pitch
detection algorithm locking on to frequencies that have wrapped around the
nyquist.

------
bmurphy1976
Seems like a neat idea, but controlling the tuners with the mouse is really
fussy and annoying. There seems to be some kind of delayed reaction and I
frequently overshot the frequency I was targeting (a problem I don't have when
tuning my actual guitars).

~~~
raverbashing
Agreed, this was not smooth at all, and using a touchpad seems to make it
worse.

------
kmm
Doesn't work on Chrome 66 due to recent policy changes with regard to autoplay

[https://developers.google.com/web/updates/2017/09/autoplay-p...](https://developers.google.com/web/updates/2017/09/autoplay-
policy-changes#webaudio)

I checked it out in Firefox. Very neat :)

~~~
mathisonian
I've just pushed a fix for this in case of errors due to the new policy. Not a
huge fix but I wish it didn't need to be done.

~~~
telesilla
Doesn't work for me in Chrome Beta or Canary I'm afraid, unless I reload the
page which is probably not intuitive for many users.

What I've been doing is sending a pop-up to users on audio-critical pages
(where audio is the entire point of the site) that says "hi, let's get
started, you'll hear audio on this page so please adjust your headphones or
speakers" and that seems to give the best result. It's also helpful on a page
like yours where the sound is quite loud and I found it a bit loud for my
headphones. You must also just provide a button that changes the sound volume
which would have the same effect, of telling Chrome that the user has
interacted with the page.

------
Stenzel
The distortion sounds like it is applied to individual strings, if it were
applied after summing, it would not only resemble more a real electric guitar,
but also sum- and difference frequencies of detuned strings would be audible
much nicer as beating.

Furthermore, the intervals E-A/A-D/D-G and B-E are not exactly perfect
fourths, they should be equal tempered. Luckily the difference is almost
negligible for the fourth, the perfect interval would be 4/3 = 1.3333 versus
2^(5/12) = 1.3348 for equal temperament. The interval G-B however is a major
third, here the perfect interval is 5/4 = 1.25 while equal tempered is
2^(4/12) = 1.26 Those minor errors accumulate if one string is tuned based on
the preceding one, the interval from lowest to highest strings can be
calculated:

(4/3)^4 * 5/4 = 3.95 for perfect intervals, 2^(4 * 5/12) * 2^(4/12) = 4 for
equal temperament.

The highest string should be exactly two octaves (= a factor of 4) above the
lowest one, so the equal temperament should be preferred. A practical result
is that tuning a guitar using only intervals of adjacent strings will never
really converge to the ideal result, so tuning (fretted) octaves and
flageolets should be used in addition.

~~~
korethr
The distortion sounds _are_ being distorted on individual strings, as opposed
to after summing. If you look at the credits, and follow the link to the sound
sources, you can find the files used. If you listen, you'll be able to match
them up. While I agree that the distortion should happen after summing, I
suspect the playing and summing of individual already-distorted string sounds
was done because that's what could be implemented simply and easily. Applying
distortion after summing may well require more extensive coding, or stuff
that's computationally intensive enough to slow down the browser (I don't know
this for certain, I'm guessing).

I'm not faulting the author for this, I probably would have done the same.

~~~
korethr
Now that I type this out, I find myself curious just how much work it would
take to implement a software-modelled distortion in the browser. I guess
that's another entry for my list of "Hey, wouldn't it be neat if I could do
$FOO" type projects.

~~~
raphlinus
Not actually that hard. You want a WaveShaperNode. Of course, tuning the curve
and other parameters so it sounds _good_ is nontrivial.

[1]: [https://developer.mozilla.org/en-
US/docs/Web/API/WaveShaperN...](https://developer.mozilla.org/en-
US/docs/Web/API/WaveShaperNode)

------
elihu
When tuning by making the open strings beatless, it's useful to know that
tuning an interval until the beats disappear isn't the same as tuning to the
equal tempered standard.

A just 4th (4:3 frequency ratio) is about 2 cents flat of an equal tempered
4th, and a just major third (5:4 frequency ratio) is about 14 cents flat of
the equal tempered major third.

------
elihu
Nicely done. One correction: the sound(s) that arise from two different notes
sounding together are sum and difference tones, not overtones. Each individual
tone has a collection of overtones (i.e. the harmonic series), and those and
the fundamentals can interact to produce an audible beat when they aren't in
tune, which can be the sum or difference of two frequencies that are almost
but not quite in sync with each other.

------
jacobn
If you don't have perfect pitch and want to get a better understanding for
what your guitar is doing, try using a spectrum analyzer app to visualize how
the sound changes as you pluck a string.

The el-cheapo guitar I bought once just didn't hold the note very accurately
over time (i.e. pluck string, then it would vibrate at the correct-ish
frequency for ~0.5s, then quickly veer off).

Had to use a spectrum analyzer since the guitar was so out of tune that the
electric tuner couldn't even pick up which string it was...

(wasn't my idea to use the spectrum analyzer, back in college a friend of mine
tuned his dorm piano - which are much harder to tune - using that technique,
worked quite well)

~~~
eric_h
> back in college a friend of mine tuned his dorm piano - which are much
> harder to tune - using that technique

I feel as though "much harder" to tune understates the difference between
tuning a piano and a guitar considerably :P

It's ~40x as many strings!

~~~
magduf
Um, I'm not so sure about that. Sure, there's a lot more strings on a piano,
but they're all separate from each other, and once one is tuned, it's tuned
and you can move on to the next one.

Try tuning a guitar that has a Floyd Rose locking tremelo system. The bridge
is floating on a pivot with springs, so the tension of the strings is
collectively working against the 2 or 3 large springs on the bridge. So every
time you tighten or loosen one string, you're changing the tuning on the other
5! And adjusting intonation is a pain too, because if you finally get the
strings all in tune, then when you adjust one string's intonation, it throws
off everything again. (And worse, to adjust the intonation on a Floyd Rose,
you have to completely loosen the string so you can get to the tiny little hex
screw to unlock the intonation adjustment, and the way it's designed you don't
really have an easy way of fine-tuning it.)

~~~
elektronaut
Pianos are like that too. There is a LOT of string tension, and the soundboard
warps. Raising the pitch requires carefully balancing by tiny adjustments in
several passes.

------
zengid
This is really neat and well crafted!

Constructive feedback:

After you tune the guitar and hit the 'play a lick', the notes ring on too
long. I'm not sure how you've configured your sound generators, but you'll
need to configure an envelope on the sound that cuts it off before the next
note rings. This would come down to simply adjusting the 'release' parameter
to be very small (though not zero) so that the sound decays quickly before the
next note begins.

Also, after that, in the paragraph under "How does it work", the statement
"Guitars generate noise through the vibration of their strings" is a little
bothersome. While this is true, it would be more correct to say _sound_ (or
even pitches) instead of noise. The technical meaning of noise is a random
distribution of frequencies across the sound spectrum, and actually sounds
like the static you hear when you're radio is not tuned into a station. It's
somewhat true because a guitar string _will_ generate a quick burst of noise
after being plucked, but after that the string settles into a resonating cycle
that follows the harmonic series, which is definitely not noise.

Third nitpick... oh man, I'll try to be brief, but I would just take out the
section on beats and 'overtones'. As elihu mentioned, its actually 'difference
tones'. Overtones are a part of a single sound. I would take the part out
because it's actually bad practice to eliminate beats when tuning a guitar
using open strings (in other words, tuning by perfect fourths) because the
frets of a guitar are tuned to 12 Tone Equal temperament. If you eliminate the
beats in a perfect fourth it will be a Justly tuned perfect fourth, which is
498 cents. An equally tempered perfect fourth is 500 cents even. The result
would be the A string will be 2 cents flat, and then the D string will be 4
cents flat, and the G string 6 cents.. etc. If you want to keep the part about
beats and tune by ear, its better to play the A on the E string and tune using
a unison. _Then_ you can use the beats trick!

Disclosure: BA in Music with emphasis on Guitar and Sound Design. (See, BA's
aren't completely useless!)

~~~
zodPod
I kind of wish the "lick" would've been playable with the untuned guitar. It'd
be fun to see the difference you make by tuning it.

------
matell
not sure if I miss something, but I haven't figured out how to use the tuning
knobs :( I tried mouseover, click, click+drag, in vertical and also in
horizontal direction, but the tone didn't moved in any direction.

~~~
chipuni
I agree that using the tuning knobs was not very intuitive. I _guess_ that
you're supposed to click on the knob, hold it down, and move up or down to
tune -- but there was no feedback (except from the sound, which changed
slowly.)

------
kristiandupont
Slightly off topic, I love how I am seeing tone.js pop up in projects
everywhere. MIDI and VST's have created an extraordinary universe of musical
devices but I think a wave of little web-based generators and effects will
allow some truly novel approaches to music and audio arts.

------
jacquesm
Very nice. In the spirit of constructive feedback: if you want to properly
simulate a guitar that is out of tune because it has been stored for a long
time (to better match your initial storyline) the high end should drop more
than the low end.

~~~
wyclif
This is good feedback—I thought the same thing. It would be a lot more
realistic this way.

------
Konryan
This needs some visual feedback when you try turning the knobs.

------
SwellJoe
I've been a guitarist (off and on) for 30+ years, and I'm oddly fascinated by
tuning methods and practices.

The best educated guitarist I've ever known (he was an LA studio guy who moved
back to my home town to raise his family and was teaching at the high school
for fine arts I attended...literally everyone here has heard songs he played
on, and probably a few musicians he's taught) used a technique I haven't seen
very often, but it's been my favorite method. It's based on chords and the
naturally occurring "beating" when intervals in chords are "right". Basically,
you're switching back and forth between perfect fourths and fifths across all
the strings and finding the best balance between them; when the beating is
minimized, your guitar's first position is about as well-tuned as it can
possibly be, given the limitations and oddities of intonation on a fretted
equal-tempered instrument and the different sizes of strings. This is how I
tune, unless I'm going to be playing way up the neck, in which case I tune
with an alternate further up the neck to accommodate that position better.

The interesting thing about this, and the thing that always confused people
who see me tuning is that overdrive/distortion makes this method work _better_
, not worse. It exacerbates the beating and makes it more clear when you're
tuning it right.

James Taylor devised a system that accommodated the way lower strings tend to
rise in pitch when strummed aggressively; he'd tune a tiny bit flat on the low
strings, getting close to on-the-nose as you went up the strings until the
high E was exactly right. You would adjust this method slightly based on gauge
of strings and whether the G string is wound or not. In this way strumming
hard wouldn't end up sounding sharp on the bottom and out of tune across the
instrument. This seems like a pain in the ass, to me, since you need a tuner
and to memorize the settings across the neck to get it exactly right, so I
have only done it as an experiment. I couldn't hear a positive difference
compared to my usual method of tuning with chords (which already accommodates
the sharpening of low strings because we're tuning to chord shapes).

A common method I've seen maybe most often, especially among metal guitarists
who tune down and bass players is the harmonics method (5th and 7th frets of
strings next to each other). This has the benefit of bringing the tuning notes
up into a higher register where our hearing is more accurate. Distortion
doesn't hinder this method either, so rock guys can do it without changing
their amp settings or whatever. But...and this is a big but. This isn't
actually a great method for getting good tuning, because it will be the
natural harmonics of the strings, which _aren 't_ exactly the same as the
notes on an equal-tempered instrument. This was the method I used when I was a
kid. The traditional fifth fret (and fourth fret) method, that is the first
method most guitarists are taught, is still better than this one, because it
accounts for equal temperament.

~~~
sooheon
I'm intrigued. Any video of this method?

~~~
SwellJoe
I just tried to find a video of it, and couldn't...but, it's hard to search
for "tuning guitar with fourths and fifths" because it brings back information
about various kinds of tunings for guitar rather than using it as a method for
tuning.

It's kinda weird; I assumed it was something common, but now that I think of
it, I don't think I've ever seen anyone use it that didn't learn it from that
same teacher or from me. The professor who taught it to me was a teacher at
University of Miami during the Jaco/Metheny era in the early 70s, toured with
Bruce Hornsby for a few years, and then worked in LA as a session musician for
a couple of decades (he was never famous, but traveled in famous circles), so
I assumed he got it from one of those places and that it would be kinda common
knowledge.

I should dig into this more, and if it's _not_ common knowledge somewhere I
should make a video (and a cult) about it, because it's really the bee's
knees, IMHO. It's super fast to use, once you've got good ears for it, and it
results in any guitar, even those with poor intonation, being at least
playable for basic chords and such in the first position.

It isn't really complicated. You can derive it from first principles of just
knowing that fourths and fifths and octaves are perfect intervals, and then
just make chord shapes that are all fourths and fifths and octaves of any
other note being played and walk them up and down across the strings until
you've got no beating (or as little beating as is achievable, if the
intonation is poor). By the time you've gone up and down a couple of times,
you're pretty well locked in and it sounds great. Even if you don't have an
ear for fourths and fifths, you can still use this to "tighten up" the tuning
on a guitar by doing the usual fifth fret/fourth fret tuning that every
beginner book or class teaches first and following up with this method to come
to a reasonable compromise with the intonation of the guitar and the oddities
of wound vs unwound strings (the fourth/third or third/second string
changeover is always a bit tricky even with a compensated bridge).

Anyway, I'll keep poking at the google to see if I can find this method
documented somewhere, and if not, I'll write it up and make a video. It really
should be more commonly known/used now that I think of it.

Edit: This Stack Exchange thread includes people who do either fourths _or_
fifths tuning, which is close to what I'm talking about, but they never quite
get to stacking up fourths, fifths and octaves in a few chord shapes (which is
where, I think, the magic for compensating for intonation problems comes
from). [https://music.stackexchange.com/questions/3078/what-are-
the-...](https://music.stackexchange.com/questions/3078/what-are-the-various-
methods-of-tuning-the-guitar)

~~~
mushishi
If you post a video, please let me know, thank you!

------
feedjoelpie
Guitar pedant: Shouldn't the up/down on the tuning keys be opposite directions
on opposite sides of the headstock?

~~~
sp821543
Yes, although I think this application/audience warrants visual consistency
over realism.

------
squarefoot
Knowing how to tune a guitar (bass, etc) is one of the first thing any player
should learn, but next to it are recognizing that your guitar is out of tune
and how to make sure you don't have to retune it every 5 minutes. The first
comes with practice and musical training and the second requires a good
knowledge on how to mount strings. A string fixed the wrong way will force the
player to tune at every song or more often, so learning how to put strings in
place is vital. There is a self-locking technique well explained in youtube
videos; look for it because it will come very handy.

------
JimiofEden
Really cool. Audio didn't work for me on chrome though

~~~
mathisonian
Sorry to hear about the audio issues! I tested on chrome and macOS, and didn't
encounter anything like that. I'm curious what OS you're using, or maybe its
just Google's new 'smart' autoplay policy.

~~~
thefifthsetpin
It absolutely is that. I experienced the problem, captured

    
    
        options.context = new window.AudioContext();
    

from index.js at line 224, and then just bound a user-action (I went with
document.body.addEventListener('click')) and used that to call
options.context.resume().

After which point, it was cool. =)

------
cybervegan
The "Play notes with a 5.00 Hz difference" section seems like a massive leap
from the section before, without the same level of explanation that preceded
it. I can't perceive/work out what they are talking about - I'm not sure what
I'm listening for. Could be because of my freaky Asperger's brain wiring tho.

I learning to play electric guitar, and have wanted to learn to tune by ear
for ages. It's frustrating that I was able to follow along with ease up to
this point, but now feel I've been pushed in at the deep end. It's just so
_close_ but not quite there.

------
snarfy
I still have a tuning fork for tuning by ear. When I started playing, electric
tuners were somewhat new and relatively expensive. At this point I've used the
fork enough I almost don't need it.

------
scrumper
This is fun and educational. Good work. I think you should take 5m to line up
the tops of the strings and fix the string spacing in the zoomed-in headstock
image. It looks sloppy at the moment.

------
dirkk0
Very cool indeed! Doesn't work in Chrome 66 anymore, due to blocked audio:
[https://www.dailydot.com/debug/chrome-autoplay-block-
games/](https://www.dailydot.com/debug/chrome-autoplay-block-games/)

------
jmull
I get errors on Safari (latest public version as of a few days ago):

First an alert: "It looks like Chrome audio autoplay is giving us troubles.
Close this and tap the loading bar to continue loading audio."

Then "undefined is not an object (evaluating 'new Tone.FFT')" where I'm
guessing some kind of media is supposed to go.

------
vectorEQ
fun page. i tune my guitar differently, but same principle. i put ON
distortion, and then pluck harmonics on different strings. if they are out of
tune its really obvious due to the phasing, and you can adjust it untill it
sounds like a clean note. same principe but much much easier / clearer to hear
if it's exactly in tune with another string.

also if you tune, always tighten last. if you release tension then it might
shift a little and be in shitty tuning again. if you tighten the last then
it;s less chance of this de tuning suddenly while playing.

you can tune all strings using harmonics on the 5th/7th frets, where g/b set
will need 4th / 5th fret or so. al the notes you need across the strings are
around those frets anyway and it;s really easy to hear if you have the right
ones.

------
kuroguro
Hmm... I get no sound on chrome for some reason. Works fine on FF.

_edit_

See kmm's comment, chrome seems to be intentionally blocking it.

------
khitchdee
well. while using some dsp to get the frequencies right makes sense from an
analytical point of view, from a more mood oriented standpoint which seems
more aligned with the nature of music and its associations with mood it makes
more sense to tune a guitar without any measurements using instruments other
than your ears in other words tuning by ear while this is an inexact science
and in theory, each tume you tune your guitar it will by definition be
alightly out of tune the true test would be whether you like the sound or not
given this as a goal, how you tune your guitar, would depend on what you were
planning to play. you would probably tune your chord progressions

------
mattnewport
Reminded me of my high school physics project on tuning a guitar using beats
on harmonics:
[https://en.m.wikipedia.org/wiki/Beat_(acoustics)](https://en.m.wikipedia.org/wiki/Beat_\(acoustics\))

------
jakobegger
Somehow this isn‘t working properly for me on my iPhone. It‘s not always clear
what parts are touchable, and hitting the right spot is sometimes difficult
(eg hitting strings is difficult with my fat fingers)

I like the idea, but the UX on mobile is a bit frustrating.

------
punchclockhero
Recently learned that many digital recorders have a tuner feature while
looking for a cheap one for field recordings. Might be worth a shot.

------
gempir
Thanks for asking before downloading 30mb on my mobile connection. Seems this
site is well thought out

------
throw7
very cool /aol

add: i'm using seamonkey 2.49.2 and the zooming of the guitar in and out
doesn't quite work once in awhile obscuring the text. don't take it as your
fault, i'm actually impressed this worked at all.

------
the_cat_kittles
pretty good, nice execution, and im sure this is not targeted at people like
me. but i figure i would add, just for those that are curious: there is more
to tuning than just this. how hard you play the strings, where on the neck you
play, the relative gauges, what the weathers going to do, the sound you like-
all things that make it more complicated. there is also what your bandmates
are doing. there are also mechanical factors that make for difficulty in
getting the string to make the pitch you want, as other posters noted. i say
all this to celebrate the wonderful endless complexity that "simple" things
have when they exist in the real, corporeal world. its something i think can
be forgotten by people who hang out on a computer mostly.

------
mike555
This looks great.

What technologies are you using for sound and for visualization?

~~~
mathisonian
Thanks Mike.

The sound is using tone.js [0] (with a slight modification to make the tuning
work).

The rest is built with \- idyll (for the overall structure of the post) [1] \-
d3 with svg and canvas (for the tuner and visualizations) [2] \- sketchapp and
a plugin [3] to design the guitar

[0] [https://tonejs.github.io/](https://tonejs.github.io/) [1] [https://idyll-
lang.org/](https://idyll-lang.org/) [2] [https://d3js.org/](https://d3js.org/)
[3] [https://github.com/mathisonian/sketch-interactive-
export](https://github.com/mathisonian/sketch-interactive-export)

------
kepikoi
Good example for chromes autoplay policy breaking the web

~~~
dawnerd
I figured chrome would show something saying it blocked yet nothing. That's
really the annoying part for me.

~~~
zodPod
Yeah ultimately the feature itself, blocking autoplay, is fantastic. I got so
sick of spam bullshit playing videos when I loaded sites. However, it
definitely should warn!

------
squiggy22
I wish more people knew how to tune their beat by ear.

------
tomasien
Chrome's new audio settings ruined this for me

------
locrelite
<Pedantry>Doesn't take into account neck deformation when string tension
changes.</Pedantry>

------
meggar
I usually just play this chord, and then adjust any notes that are off:

E--0--

B--0--

G--9--

D--9--

A--7--

E--0--

------
dgurney
super cool. Nice work

