diff --git a/app.ts b/app.js similarity index 88% rename from app.ts rename to app.js index 9aba773..2039e2c 100644 --- a/app.ts +++ b/app.js @@ -1,11 +1,7 @@ // initialize four synth voices -// @ts-expect-error: namespace, Tone, for all of the following "expect-error calls" const soprano = new Tone.Synth().toDestination(); -// @ts-expect-error const alto = new Tone.Synth().toDestination(); -// @ts-expect-error const tenor = new Tone.Synth().toDestination(); -// @ts-expect-error const bass = new Tone.Synth().toDestination(); // test function for audio is armed diff --git a/src/audioUtils.ts b/src/audioUtils.ts deleted file mode 100644 index 6e75b36..0000000 --- a/src/audioUtils.ts +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/src/styleUtils.ts b/src/styleUtils.ts deleted file mode 100644 index 7f47476..0000000 --- a/src/styleUtils.ts +++ /dev/null @@ -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; -export const hideStart = document.getElementsByClassName('hide-on-start') as HTMLCollectionOf; - -export const showMore = document.getElementById('info-button'); -export const moreInfo = document.getElementsByClassName('more-info') as HTMLCollectionOf; - -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"; - } - }); -} diff --git a/src/vector_logic/evaluateVector.ts b/src/vector_logic/evaluateVector.ts deleted file mode 100644 index 7c10385..0000000 --- a/src/vector_logic/evaluateVector.ts +++ /dev/null @@ -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); - }; -} \ No newline at end of file diff --git a/src/vector_logic/extractPitchset.ts b/src/vector_logic/extractPitchset.ts deleted file mode 100644 index aed92b1..0000000 --- a/src/vector_logic/extractPitchset.ts +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/src/vector_logic/findVector.ts b/src/vector_logic/findVector.ts deleted file mode 100644 index bdd8109..0000000 --- a/src/vector_logic/findVector.ts +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/src/vector_logic/numbersToPitches.ts b/src/vector_logic/numbersToPitches.ts deleted file mode 100644 index 2be75b7..0000000 --- a/src/vector_logic/numbersToPitches.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const vectorToPitches = (vector: number[]): string[] => { - - - return ['']; -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 0de2996..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./built", - "allowJs": true, - "target": "es2018", - "module": "ESNext", - "moduleResolution": "node", - }, - "include": [ - "./src/**/*", "./app" - ], - "exclude": [ - "/_tone" - ] -} \ No newline at end of file