diff --git a/app.ts b/app.ts index c5cc0b2..e908bdc 100644 --- a/app.ts +++ b/app.ts @@ -60,8 +60,6 @@ let slowClock = 0; const transportStart = document.getElementById('transport-start'); -let transport; - const loop = new Tone.Loop((time) => { audioTest(); }, "8n").start(0); diff --git a/built/app.js b/built/app.js deleted file mode 100644 index d3bf093..0000000 --- a/built/app.js +++ /dev/null @@ -1,55 +0,0 @@ -import * as Tone from 'tone'; -import { sopranoTones, altoTones, tenorTones, bassTones, extractPitchset, } from "./src/toneGeneration.js"; -const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones]; -// initialize four synth voices -const soprano = new Tone.Synth().toDestination(); -const alto = new Tone.Synth().toDestination(); -const tenor = new Tone.Synth().toDestination(); -const bass = new Tone.Synth().toDestination(); -// test function for audio is armed -export const audioTest = () => { - soprano.triggerAttackRelease("C5", "16n"); - alto.triggerAttackRelease("F4", "16n"); - tenor.triggerAttackRelease("E4", "16n"); - bass.triggerAttackRelease("G3", "16n"); -}; -// allows a chord to be generated with input from another function -export const soundChord = (pitches) => { - const [s, a, t, b] = pitches; - soprano.triggerAttackRelease(s, "8n"); - alto.triggerAttackRelease(a, "8n"); - tenor.triggerAttackRelease(t, "8n"); - bass.triggerAttackRelease(b, "8n"); -}; -// initial test: generate a single, random chord -export const fullRandomChord = () => { - let pitches = []; - for (let voice of pitchsets) { - // finds a random index, excluding any which may already exist in the array - let index; - do { - index = Math.floor(Math.random() * 100) % voice.length; - } while (pitches.includes(voice[index])); - pitches.push(voice[index]); - console.log(voice[index]); - } - for (let i = 0; i < pitches.length; i++) { - if (pitches[i] === pitches[i + 1]) { - console.log("CAUGHT"); - } - } - soundChord(pitches); - extractPitchset(pitches); -}; -// set up transport -let clock = 0; -let slowClock = 0; -const transportStart = document.getElementById('transport-start'); -let transport; -const loop = new Tone.Loop((time) => { - audioTest(); -}, "8n").start(0); -loop.probability = 0.8; -transportStart.onclick = () => { - Tone.Transport.start(); -}; diff --git a/built/src/harmonyUtil.js b/built/src/harmonyUtil.js deleted file mode 100644 index 1ba6c6f..0000000 --- a/built/src/harmonyUtil.js +++ /dev/null @@ -1,53 +0,0 @@ -import { extractPitchset } from "./toneGeneration.js"; -// interval definitions: -const intervals = { - 0: "unison", - 1: "minor second", - 2: "major second", - 3: "minor third", - 4: "major third", - 5: "perfect fourth", - 6: "tritone" - // all intervals beyond this invert to one of the previous intervals -}; -// helper functions -const transposePitches = (pitches, interval) => { - let transposed = []; - pitches.forEach(pitch => transposed.push((pitch + interval) % 12)); - return transposed; -}; -const findVector = (pitches) => { - let sorted = pitches.sort((x, y) => x - y); - // sorted = sorted.filter((num, idx) => { - // return sorted.indexOf(num) === idx; - // }); - // finds each interval and logs it as a duple - let intervalClasses = []; - 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 = (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; -}; -// analysis -let dMajor = extractPitchset(["D", "F#", "A", "D"]); -const eMajor = transposePitches(dMajor, 2); -console.log(eMajor); -console.log(''); -let dMajVector = findVector(dMajor); -console.log(dMajVector); -let complexVector = findVector([0, 3, 4, 7, 8, 11]); -console.log(complexVector); -let splitThird = findVector([0, 3, 4, 7]); -console.log(splitThird); diff --git a/built/src/inputHandling.js b/built/src/inputHandling.js deleted file mode 100644 index 4477d97..0000000 --- a/built/src/inputHandling.js +++ /dev/null @@ -1,60 +0,0 @@ -import { audioTest, fullRandomChord } from '../app.js'; -// slider variables referring to DOM -export const sopranoVol = document.getElementById('soprano-vol'); -const sopranoVolTarget = document.getElementById('soprano-vol-target'); -export const sopLFO = document.getElementById('sop-lfo'); -const sopLFOTarget = document.getElementById('sop-lfo-target'); -export const altoVol = document.getElementById('alto-vol'); -const altoVolTarget = document.getElementById('alto-vol-target'); -export const altoLFO = document.getElementById('alto-lfo'); -const altoLFOTarget = document.getElementById('alto-lfo-target'); -export const tenVol = document.getElementById('ten-vol'); -const tenVolTarget = document.getElementById('ten-vol-target'); -export const tenLFO = document.getElementById('ten-lfo'); -const tenLFOTarget = document.getElementById('ten-lfo-target'); -export const bassVol = document.getElementById('bass-vol'); -const bassVolTarget = document.getElementById('bass-vol-target'); -export const bassLFO = document.getElementById('bass-lfo'); -const bassLFOTarget = document.getElementById('bass-lfo-target'); -// logic for displaying values on HTML labels -// S -sopranoVol.oninput = (e) => { - const target = e.target; - sopranoVolTarget.innerHTML = target.value; -}; -sopLFO.oninput = (e) => { - const target = e.target; - sopLFOTarget.innerHTML = ` ${target.value} Hz.`; -}; -// A -altoVol.oninput = (e) => { - const target = e.target; - altoVolTarget.innerHTML = target.value; -}; -altoLFO.oninput = (e) => { - const target = e.target; - altoLFOTarget.innerHTML = ` ${target.value} Hz.`; -}; -// T -tenVol.oninput = (e) => { - const target = e.target; - tenVolTarget.innerHTML = target.value; -}; -tenLFO.oninput = (e) => { - const target = e.target; - tenLFOTarget.innerHTML = ` ${target.value} Hz.`; -}; -// B -bassVol.oninput = (e) => { - const target = e.target; - bassVolTarget.innerHTML = target.value; -}; -bassLFO.oninput = (e) => { - const target = e.target; - bassLFOTarget.innerHTML = ` ${target.value} Hz.`; -}; -// audio-adjacent input handling -const synthButton = document.getElementById('synth-button'); -synthButton.onclick = audioTest; -const randChord = document.getElementById('rand-chord'); -randChord.onclick = fullRandomChord; diff --git a/built/src/styleUtils.js b/built/src/styleUtils.js deleted file mode 100644 index 5f8712b..0000000 --- a/built/src/styleUtils.js +++ /dev/null @@ -1,45 +0,0 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -import * as Tone from 'tone'; -export const startButton = document.getElementById("start-tone"); -export const synthButton = document.getElementById("synth-button"); -export const showStart = document.getElementsByClassName('show-on-start'); -export const hideStart = document.getElementsByClassName('hide-on-start'); -export const showMore = document.getElementById('info-button'); -export const moreInfo = document.getElementsByClassName('more-info'); -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 = () => __awaiter(void 0, void 0, void 0, function* () { - yield 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/built/src/toneGeneration.js b/built/src/toneGeneration.js deleted file mode 100644 index 7c408fb..0000000 --- a/built/src/toneGeneration.js +++ /dev/null @@ -1,28 +0,0 @@ -// we start with a selection of pitches that generally work okay together -export const sopranoTones = ["B5", "A5", "G5", "F#5", "F5", "E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4"]; -export const altoTones = ["E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4", "D4", "C4", "B3", "Bb3", "A3", "G3"]; -export const tenorTones = ["G4", "F#4", "F4", "E4", "D4", "C4", "B3", "Bb3", "A3", "G3", "F3", "E3", "D3", "C3"]; -export const bassTones = ["C2", "D2", "E2", "F2", "G2", "A2", "Bb2", "B2", "C3", "D3", "E3", "F3", "G3"]; -// now we define some rules to allow for the program to follow so it can some basic tenets of music theory -// we're going to include all pitches, so that it can use semitone-based pitch logic. -// this is focused on base-12, something computers understand quite well -const musicalPitches = ['A', "Bb", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]; -export const extractPitchset = (pitches) => { - // 1) determine pitch set from given array of pitches - let pitchset; - 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); - console.log(pitchset); - return pitchset; -}; -// no tritones -// no minor 2nds or major 7ths