JavaScript library for microtonal tuning systems.
Try the live demo.

Features
- calculate cents based on various temperaments
- calculate nth harmonic of a given frequency
- ftom (frequency to MIDI function)
- mtof (MIDI to frequency function)
- get note name for a given MIDI note
supported temperaments
Setup
import tune.js library
<script src="tune.js"></script>
now you can use the library to create a tuner
myTuner = new Tuner();
var options = {
temperament: 'equal',
fundamental: 440
};
var myTuner = new Tuner(options);
Functions
temperament
set the current temperament
myTuner.setTemperament("meantone");
get the current temperament
myTuner.getTemperament();
tune
calculate the cents given a specific frequency
myTuner.tune(448);
Other (static) functions
harmonic series
get nth harmonic of a given frequency
harmonic(frequency, partial)
get the 3rd harmonic of 440
Tuner.harmonic(440, 3);
MIDI to frequency (mtof)
calculate the frequency given a specific MIDI note
Tuner.mtof(60);
frequency to MIDI (ftom)
calculate the MIDI note given a specific frequency
Tuner.ftom(440);
MIDI note to note name
get note name from MIDI note number
you can use a negative number to get the flat
Tuner.getNoteName(63);
Tuner.getNoteName(-63);
or use a second argument sharp or flat to get enharmonic note name
Tuner.getNoteName(63, 'sharp');
Tuner.getNoteName(63, 'flat');
tune.js API
attributes
| attribute |
type |
options |
default |
temperament |
string |
equal, just, pythagorean, meantone, werckmeister |
equal |
fundamental |
number |
any integer or float |
440 |
Options
temperament
Set the temperament for a given tuner.
Type: string
Default: equal
Available values: equal just pythagorean meantone werckmeisterI werckmeisterII werckmeisterIII
Examples
var myTuner = new Tuner({
temperament: "meantone"
});
myTuner.setTemperament('pythagorean');
myTuner.getTemperament();
fundamental
Set the target frequency for a given tuner.
Type: number
Default: 440
Available values: integer or float
Examples
var myTuner = new Tuner({
fundamental: 440
});
myTuner.setFundamental(442);
myTuner.getFundamental();
Functions
tune()
Calculte cents
Examples
var myTuner = new Tuner({
temperament: 'meantone',
fundamental: 440
});
myTuner.tune(439);
Contributing
Any contributions you make are greatly appreciated. Any bugs and change requests are to be reported on the issues tab. If you don’t like coding, you can contribute by becoming a sponsor.

Questions?
Please write to [email protected] or visit instrument.bible.

评论