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