defined a function which identifies dissonance in a vector
This commit is contained in:
25
app.ts
25
app.ts
@@ -25,31 +25,6 @@ export const soundChord = (pitches: string[]) => {
|
|||||||
bass.triggerAttackRelease(b, "8n");
|
bass.triggerAttackRelease(b, "8n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial test: generate a single, random chord
|
|
||||||
export const fullRandomChord = () => {
|
|
||||||
let pitches: string[] = [];
|
|
||||||
for (let voice of pitchsets) {
|
|
||||||
// finds a random index, excluding any which may already exist in the array
|
|
||||||
let index: number;
|
|
||||||
|
|
||||||
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
|
// set up transport
|
||||||
const transportStart = document.getElementById('transport-start');
|
const transportStart = document.getElementById('transport-start');
|
||||||
|
|
||||||
|
|||||||
@@ -123,5 +123,6 @@
|
|||||||
<script type="module" src="./built/src/harmonyUtil.js"></script>
|
<script type="module" src="./built/src/harmonyUtil.js"></script>
|
||||||
<script type="module" src="./built/src/inputHandling.js"></script>
|
<script type="module" src="./built/src/inputHandling.js"></script>
|
||||||
<script type="module" src="./built/src/styleUtils.js"></script>
|
<script type="module" src="./built/src/styleUtils.js"></script>
|
||||||
|
<script type="module" src="./built/src/audioUtils.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -9,10 +9,11 @@ export const fullRandomChord = () => {
|
|||||||
let index: number;
|
let index: number;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if (!pitches) pitches = [];
|
||||||
index = Math.floor(Math.random() * 100) % voice.length;
|
index = Math.floor(Math.random() * 100) % voice.length;
|
||||||
} while (pitches.includes(voice[index]));
|
} while (pitches.includes(voice[index]) ?? false);
|
||||||
|
|
||||||
pitches.push(voice[index]);
|
pitches ? pitches.push(voice[index]) : pitches = [voice[index]];
|
||||||
console.log(voice[index]);
|
console.log(voice[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { audioTest, fullRandomChord } from '../app.js';
|
import { audioTest } from '../app.js';
|
||||||
|
import { fullRandomChord } from './audioUtils.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');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as Tone from 'tone';
|
import * as Tone from "tone";
|
||||||
|
|
||||||
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");
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { findVector, IntervalDefNames, musicalPitches } from './harmonyUtil';
|
|
||||||
|
|
||||||
// we start with a selection of pitches that generally work okay together
|
// we start with a selection of pitches that generally work okay together
|
||||||
const sopranoTones = ["B5", "A5", "G5", "F#5", "F5", "E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4"];
|
const sopranoTones = ["B5", "A5", "G5", "F#5", "F5", "E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4"];
|
||||||
const altoTones = ["E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4", "D4", "C4", "B3", "Bb3", "A3", "G3"];
|
const altoTones = ["E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4", "D4", "C4", "B3", "Bb3", "A3", "G3"];
|
||||||
@@ -17,16 +15,8 @@ export const pitchsets: string[][] = [sopranoTones, altoTones, tenorTones, bassT
|
|||||||
* no minor 2nds or major 7ths
|
* no minor 2nds or major 7ths
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const evaluateVector = (vector: number[]): boolean => {
|
export const evaluateVector = (vector: number[]): boolean => ((vector.includes(1) || vector.includes(6)));
|
||||||
let result: boolean;
|
|
||||||
|
export const rejectDissonance = (vector: number[]) => {
|
||||||
|
|
||||||
for (let x of vector) {
|
|
||||||
if (x === 1 || x === 6) {
|
|
||||||
result = false;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user