

Fret.js: Procedural Fretboard Generator - daeken
http://demoseen.com/fretjs/

======
daeken
This is a project I've been working on the past couple days. My goal is to CNC
an entire guitar, and a big part of that is making a fretboard that doesn't
suck. So I decided to make use of the CSG.js library (
[https://github.com/evanw/csg.js/](https://github.com/evanw/csg.js/) ) and
some hacky polygon generation code to produce an entire fretboard from start
to finish.

I'm waiting on wood to be delivered at the moment, but pictures of the first
few runs will be going up as soon as that gets here.

~~~
michaelmior
Would be cool to have a couple examples in the repo especially since GitHub
has a built-in STL viewer.

~~~
daeken
I'll see about throwing in some STL examples. As it stands, though, you can
use the built-in viewer on the app with a (any?) WebGL browser.

Edit: Here's a 24-fret board with the 'wave dots' inlay. Looks great in their
viewer!
[https://github.com/daeken/fret.js/blob/master/example_stls/2...](https://github.com/daeken/fret.js/blob/master/example_stls/24_wave.stl)

~~~
danelectro
I like that, what kind of pickups are you going to put on it?

~~~
daeken
That fretboard (well, 22-fret version) is going on a PRS-style single cut with
no magnetic pickups, just a Graphtech Ghost wraparound piezo bridge. Cocobolo
fretboard, sapelle body (I think), curly redwood top. Should be a nice one.

------
noname123
I know this is probably for guitar luthiers. But would be pretty cool if
someone can make a js-based fretboard mapper for various scales and chords.

The current sites for this really suck.

~~~
daeken
Also working on that! I've been playing 8- and 7-strings mainly, and
_everything_ out there sucks. Doubt I'll post it here, but if you follow me on
twitter/github, you'll see it there. (daeken in both places)

~~~
noname123
Alright followed bro, let me know when you commit. I'll see if I can add a
patch.

------
danbmil99
we used to have to do this with a calculator and a ruler.

Most relevant line of code:

    
    
      return s - (s / (Math.pow(2, (i / 12))))
    

It still blows my mind that an irrational series like 2 ^ (i/12) is such a
close approximation to the harmonic series.

~~~
daeken
The fret placement was, slightly surprisingly, the absolute easiest part of
everything. 99% of my time was spent on the math for producing the base
fretboard shape (the fingerboard() function in fret_worker.js if you're
curious). Between getting the mesh right and doing the math for radius, it was
a bit of a beast, but it ended up working out well.

