more merge conflict
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
// initialize four synth voices
|
// initialize four synth voices
|
||||||
// @ts-expect-error: namespace, Tone, for all of the following "expect-error calls"
|
|
||||||
const soprano = new Tone.Synth().toDestination();
|
const soprano = new Tone.Synth().toDestination();
|
||||||
// @ts-expect-error
|
|
||||||
const alto = new Tone.Synth().toDestination();
|
const alto = new Tone.Synth().toDestination();
|
||||||
// @ts-expect-error
|
|
||||||
const tenor = new Tone.Synth().toDestination();
|
const tenor = new Tone.Synth().toDestination();
|
||||||
// @ts-expect-error
|
|
||||||
const bass = new Tone.Synth().toDestination();
|
const bass = new Tone.Synth().toDestination();
|
||||||
|
|
||||||
// test function for audio is armed
|
// test function for audio is armed
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { soundChord } from '../app.js';
|
|
||||||
import { getRandomPitches } from "./harmonyUtil.js";
|
|
||||||
|
|
||||||
import { evaluateVector, rejectDissonance } from "./vector_logic/evaluateVector.js";
|
|
||||||
import { findVector } from "./vector_logic/findVector.js";
|
|
||||||
import { extractPitchset } from "./vector_logic/extractPitchset.js";
|
|
||||||
|
|
||||||
export const fullRandomChord = () => {
|
|
||||||
let pitches: string[] = getRandomPitches();
|
|
||||||
soundChord(pitches);
|
|
||||||
|
|
||||||
let pitchValues: number[] = extractPitchset(pitches);
|
|
||||||
pitchValues = findVector(pitchValues);
|
|
||||||
|
|
||||||
let evaluated = evaluateVector(pitchValues);
|
|
||||||
return evaluated;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const evaluatedChord = () => {
|
|
||||||
let pitches: string[] = getRandomPitches();
|
|
||||||
let pitchNums: number[] = extractPitchset(pitches);
|
|
||||||
let firstVector = findVector(pitchNums);
|
|
||||||
let finalVector = rejectDissonance(firstVector);
|
|
||||||
|
|
||||||
if (finalVector !== firstVector) console.log('caught');
|
|
||||||
|
|
||||||
soundChord(pitches);
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
import { audioTest } from '../app.js';
|
import { audioTest } from '../app.js';
|
||||||
<<<<<<< HEAD:src/inputHandling.ts
|
|
||||||
import { evaluatedChord, fullRandomChord } from './audioUtils.js';
|
|
||||||
=======
|
|
||||||
import { fullRandomChord, evaluatedChord } from './audioUtil.js';
|
import { fullRandomChord, evaluatedChord } from './audioUtil.js';
|
||||||
>>>>>>> backtrack:src/inputHandling.js
|
|
||||||
|
|
||||||
// slider variables referring to DOM
|
// slider variables referring to DOM
|
||||||
export const sopranoVol = document.getElementById('soprano-vol');
|
export const sopranoVol = document.getElementById('soprano-vol');
|
||||||
@@ -29,45 +25,45 @@ const bassLFOTarget = document.getElementById('bass-lfo-target');
|
|||||||
// logic for displaying values on HTML labels
|
// logic for displaying values on HTML labels
|
||||||
// S
|
// S
|
||||||
sopranoVol.oninput = (e) => {
|
sopranoVol.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
sopranoVolTarget.innerHTML = target.value;
|
sopranoVolTarget.innerHTML = target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sopLFO.oninput = (e) => {
|
sopLFO.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
sopLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
sopLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A
|
// A
|
||||||
altoVol.oninput = (e) => {
|
altoVol.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
altoVolTarget.innerHTML = target.value;
|
altoVolTarget.innerHTML = target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
altoLFO.oninput = (e) => {
|
altoLFO.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
altoLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
altoLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// T
|
// T
|
||||||
tenVol.oninput = (e) => {
|
tenVol.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
tenVolTarget.innerHTML = target.value;
|
tenVolTarget.innerHTML = target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
tenLFO.oninput = (e) => {
|
tenLFO.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
tenLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
tenLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// B
|
// B
|
||||||
bassVol.oninput = (e) => {
|
bassVol.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
bassVolTarget.innerHTML = target.value;
|
bassVolTarget.innerHTML = target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bassLFO.oninput = (e) => {
|
bassLFO.oninput = (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target;
|
||||||
bassLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
bassLFOTarget.innerHTML = ` ${target.value} Hz.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
export const startButton = document.getElementById("start-tone");
|
export const startButton = document.getElementById("start-tone");
|
||||||
export const synthButton = document.getElementById("synth-button");
|
export const synthButton = document.getElementById("synth-button");
|
||||||
|
|
||||||
export const showStart = document.getElementsByClassName('show-on-start') as HTMLCollectionOf<HTMLElement>;
|
export const showStart = document.getElementsByClassName('show-on-start');
|
||||||
export const hideStart = document.getElementsByClassName('hide-on-start') as HTMLCollectionOf<HTMLElement>;
|
export const hideStart = document.getElementsByClassName('hide-on-start');
|
||||||
|
|
||||||
export const showMore = document.getElementById('info-button');
|
export const showMore = document.getElementById('info-button');
|
||||||
export const moreInfo = document.getElementsByClassName('more-info') as HTMLCollectionOf<HTMLElement>;
|
export const moreInfo = document.getElementsByClassName('more-info');
|
||||||
|
|
||||||
export let appReady = false;
|
export let appReady = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
export const startButton = document.getElementById("start-tone");
|
|
||||||
export const synthButton = document.getElementById("synth-button");
|
|
||||||
|
|
||||||
export const showStart = document.getElementsByClassName('show-on-start') as HTMLCollectionOf<HTMLElement>;
|
|
||||||
export const hideStart = document.getElementsByClassName('hide-on-start') as HTMLCollectionOf<HTMLElement>;
|
|
||||||
|
|
||||||
export const showMore = document.getElementById('info-button');
|
|
||||||
export const moreInfo = document.getElementsByClassName('more-info') as HTMLCollectionOf<HTMLElement>;
|
|
||||||
|
|
||||||
export let appReady = false;
|
|
||||||
|
|
||||||
showMore.onclick = () => {
|
|
||||||
if (showMore.innerHTML === 'Show more info...') {
|
|
||||||
for (let element of moreInfo) {
|
|
||||||
element.style.display = 'block';
|
|
||||||
document.querySelector('#info-button').innerHTML = "Hide info";
|
|
||||||
}
|
|
||||||
} else if (showMore.innerHTML === 'Hide info') {
|
|
||||||
for (let element of moreInfo) {
|
|
||||||
element.style.display = 'none';
|
|
||||||
document.querySelector('#info-button').innerHTML = "Show more info...";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startButton.onclick = async () => {
|
|
||||||
// @ts-expect-error - namespace again, failed import from Tone
|
|
||||||
await Tone.start()
|
|
||||||
.then(() => {
|
|
||||||
appReady = true;
|
|
||||||
synthButton.style.display = "block";
|
|
||||||
startButton.style.display = "none";
|
|
||||||
|
|
||||||
for (let element of showStart) {
|
|
||||||
element.style.display = "flex";
|
|
||||||
}
|
|
||||||
for (let element of hideStart) {
|
|
||||||
element.style.display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { getRandomPitches } from "../harmonyUtil.js";
|
|
||||||
import { extractPitchset } from "./extractPitchset.js";
|
|
||||||
import { findVector } from "./findVector.js";
|
|
||||||
|
|
||||||
export const evaluateVector = (vector: number[]): boolean => {
|
|
||||||
return ((vector.includes(1) || vector.includes(6)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export const rejectDissonance = (pitchset: number[]) => {
|
|
||||||
const vector = findVector(pitchset);
|
|
||||||
|
|
||||||
// returns the pitchset and its vector if evaluateVector returns true,
|
|
||||||
if (evaluateVector(vector)) return vector;
|
|
||||||
|
|
||||||
// and recursively calls the function otherwise.
|
|
||||||
if (!evaluateVector(vector)) {
|
|
||||||
let newPitches: string[] = getRandomPitches();
|
|
||||||
let newPitchset: number[] = extractPitchset(newPitches);
|
|
||||||
rejectDissonance(newPitchset);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { musicalPitches } from "../harmonyUtil.js";
|
|
||||||
|
|
||||||
export const extractPitchset = (pitches: string[]): number[] => {
|
|
||||||
// 1) determine pitch set from given array of pitches
|
|
||||||
let pitchset: number[] = [];
|
|
||||||
|
|
||||||
for (let each of pitches) {
|
|
||||||
// filters numbers from above tones
|
|
||||||
const str = each;
|
|
||||||
const regex = /[0-9]/g;
|
|
||||||
const withoutNums = str.replace(regex, '');
|
|
||||||
const pitchNumber = musicalPitches.indexOf(withoutNums);
|
|
||||||
|
|
||||||
// ... so that they may be mapped onto numbers corresponding to the chromatic scale
|
|
||||||
pitchset.push(pitchNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
// these are sorted from lowest to highest index (something like an interval vector)
|
|
||||||
pitchset.sort((a,b) => a - b);
|
|
||||||
return pitchset;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
export const findVector = (pitches: number[]) => {
|
|
||||||
let sorted = pitches.sort((x,y) => x - y);
|
|
||||||
|
|
||||||
// finds each interval and logs it as a duple
|
|
||||||
let intervalClasses: number[] = [];
|
|
||||||
for (let i = 0; i < sorted.length; i++) {
|
|
||||||
let j = i+1;
|
|
||||||
|
|
||||||
// does not allow out of range values in the proceeding loop
|
|
||||||
if (j >= sorted.length) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
let thing: number = (sorted[j] - sorted[i]) % 6
|
|
||||||
if (!(intervalClasses.includes(thing))) {
|
|
||||||
intervalClasses.push(thing);
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
} while (j < sorted.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
intervalClasses = intervalClasses.sort((x,y) => x-y);
|
|
||||||
|
|
||||||
return intervalClasses;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export const vectorToPitches = (vector: number[]): string[] => {
|
|
||||||
|
|
||||||
|
|
||||||
return [''];
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "./built",
|
|
||||||
"allowJs": true,
|
|
||||||
"target": "es2018",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"./src/**/*", "./app"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"/_tone"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user