Add quarter-comma meantone tuning
This commit is contained in:
parent
865823b00d
commit
97c33b7d13
28
index.html
28
index.html
@ -39,26 +39,14 @@
|
|||||||
<article>
|
<article>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><small>Tuning</small></legend>
|
<legend><small>Tuning</small></legend>
|
||||||
<label>
|
<select id="tuning">
|
||||||
<input type="radio" name="tuning" value="equal">
|
<option value="equal">Equal</option>
|
||||||
Equal temperament
|
<option value="perfect-5th">Perfect 5th</option>
|
||||||
</label>
|
<option value="lower-5th">Lower 5th</option>
|
||||||
<label>
|
<option value="quartmean-5th">Quarter-comma meantone 5th</option>
|
||||||
<input type="radio" name="tuning" value="5th">
|
<option value="quartmean-lower-5th">Quarter-comma meantone lower 5th</option>
|
||||||
Perfect 5th
|
<option value="perfect-3rd">Perfect major 3rd</option>
|
||||||
</label>
|
</select>
|
||||||
<label>
|
|
||||||
<input type="radio" name="tuning" value="4th">
|
|
||||||
Perfect 4th
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="tuning" value="maj3rd">
|
|
||||||
Perfect major 3rd
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="tuning" value="min3rd">
|
|
||||||
Perfect minor 3rd
|
|
||||||
</label>
|
|
||||||
<label>
|
<label>
|
||||||
From:
|
From:
|
||||||
<select id="tuning-from"></select>
|
<select id="tuning-from"></select>
|
||||||
|
30
index.js
30
index.js
@ -243,10 +243,14 @@ function refreshHolds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tuneFraction(key, fromKey, fraction) {
|
function tuneFactor(key, fromKey, factor) {
|
||||||
|
const index = keyIndex(key);
|
||||||
const fromIndex = keyIndex(fromKey);
|
const fromIndex = keyIndex(fromKey);
|
||||||
const freq = frequencies[fromIndex] * fraction;
|
if (index > fromIndex) {
|
||||||
setFrequency(key, freq);
|
setFrequency(key, frequencies[fromIndex] * factor);
|
||||||
|
} else {
|
||||||
|
setFrequency(key, frequencies[fromIndex] / factor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tuneEqual(key, fromKey) {
|
function tuneEqual(key, fromKey) {
|
||||||
@ -305,17 +309,19 @@ function setupListeners() {
|
|||||||
document.getElementById('tune').onclick = () => {
|
document.getElementById('tune').onclick = () => {
|
||||||
const key = document.getElementById("current-note").innerHTML;
|
const key = document.getElementById("current-note").innerHTML;
|
||||||
const fromkey = document.getElementById('tuning-from').value;
|
const fromkey = document.getElementById('tuning-from').value;
|
||||||
const method = radioValue('tuning');
|
const method = document.getElementById('tuning').value;
|
||||||
if (method === 'equal') {
|
if (method === 'equal') {
|
||||||
tuneEqual(key, fromkey);
|
tuneEqual(key, fromkey);
|
||||||
} else if (method === '5th') {
|
} else if (method === 'perfect-5th') {
|
||||||
tuneFraction(key, fromkey, 3/2);
|
tuneFactor(key, fromkey, 3/2);
|
||||||
} else if (method === '4th') {
|
} else if (method === 'lower-5th') {
|
||||||
tuneFraction(key, fromkey, 4/3);
|
tuneFactor(key, fromkey, 2/3);
|
||||||
} else if (method === 'maj3rd') {
|
} else if (method === 'quartmean-5th') {
|
||||||
tuneFraction(key, fromkey, 5/4);
|
tuneFactor(key, fromkey, Math.pow(5, 1/4));
|
||||||
} else if (method === 'min3rd') {
|
} else if (method === 'quartmean-lower-5th') {
|
||||||
tuneFraction(key, fromkey, 6/5);
|
tuneFactor(key, fromkey, Math.pow(5, 1/4));
|
||||||
|
} else if (method === 'perfect-3rd') {
|
||||||
|
tuneFactor(key, fromkey, 5/4);
|
||||||
}
|
}
|
||||||
refreshHolds();
|
refreshHolds();
|
||||||
updateOptions(key);
|
updateOptions(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user