Skip to content

Instantly share code, notes, and snippets.

@phoebejaffe
Created August 1, 2020 14:58
Show Gist options
  • Save phoebejaffe/e5e18fffcc0e3ec8302cd716777f116f to your computer and use it in GitHub Desktop.
Save phoebejaffe/e5e18fffcc0e3ec8302cd716777f116f to your computer and use it in GitHub Desktop.
/**
* This calculator tries to distribute however many strings you want over whatever
* range you want using the same approximate distribution of gauges on Ernie Ball
* strings. Replace the following three numbers (16, 9, 42) with your preferences.
* To run this code, open any window in Google Chrome and open the JavaScript Console
* (View => Developer => JavaScript Console), then paste all of this code in and
* press enter. It should print your answer in the console. Tweak numbers and re-run
* as much as you want
*/
// HOW MANY STRINGS?
let numStrings = 16;
// WHAT'S THE LOWEST AND HIGHEST GAUGE YOU WANT TO USE?
let [gaugeLow, gaugeHigh] = [9, 42];
(() => {
const distributeGauges = (_, i, {length}) =>
Math.pow(i/(length-1), 1.73) * length * (gaugeHigh-gaugeLow)/(length) + gaugeLow;
const { round } = Math;
const gauges = new Array(numStrings).fill(0).map(distributeGauges).map(round);
console.log(`With ${numStrings} strings on your instrument, you can use the following gauges:
${gauges.join(', ')}`
);
})();
@phoebejaffe
Copy link
Author

Interactive version here! https://playcode.io/644991/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment