a few more conflicts resolved

This commit is contained in:
Mikayla Dobson
2022-05-12 14:48:51 -05:00
parent 232fc281c0
commit ccf63258f5
8 changed files with 0 additions and 161 deletions

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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";
}
});
}

View File

@@ -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);
};
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -1,5 +0,0 @@
export const vectorToPitches = (vector: number[]): string[] => {
return [''];
}

View File

@@ -1,15 +0,0 @@
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es2018",
"module": "ESNext",
"moduleResolution": "node",
},
"include": [
"./src/**/*", "./app"
],
"exclude": [
"/_tone"
]
}