generates an interval vector
This commit is contained in:
7
app.js
7
app.js
@@ -1,4 +1,7 @@
|
|||||||
import { sopranoTones, altoTones, tenorTones, bassTones, evaluateHarmony } from "./js/toneGeneration.js";
|
import {
|
||||||
|
sopranoTones, altoTones, tenorTones, bassTones,
|
||||||
|
extractPitchset,
|
||||||
|
} from "./js/toneGeneration.js";
|
||||||
|
|
||||||
const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones];
|
const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones];
|
||||||
|
|
||||||
@@ -47,7 +50,7 @@ export const fullRandomChord = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
soundChord(pitches);
|
soundChord(pitches);
|
||||||
evaluateHarmony(pitches);
|
extractPitchset(pitches);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up transport
|
// set up transport
|
||||||
|
|||||||
@@ -9,17 +9,26 @@ export const bassTones = ["C2", "D2", "E2", "F2", "G2", "A2", "Bb2", "B2", "C3",
|
|||||||
// this is focused on base-12, something computers understand quite well
|
// 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#"];
|
const musicalPitches = ['A', "Bb", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"];
|
||||||
|
|
||||||
export const evaluateHarmony = (pitches) => {
|
export const extractPitchset = (pitches) => {
|
||||||
let sorted = [];
|
// 1) determine pitch set from given array of pitches
|
||||||
|
let pitchset = [];
|
||||||
|
|
||||||
for (let each of pitches) {
|
for (let each of pitches) {
|
||||||
let matches = each.match(/(\d+)/);
|
// filters numbers from above tones
|
||||||
if (matches) {
|
const str = each;
|
||||||
sorted.push([each, matches]);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted = sorted.sort((a,b) => a[1] < b[1]);
|
// these are sorted from lowest to highest index (something like an interval vector)
|
||||||
console.log(sorted);
|
pitchset.sort((a,b) => a < b);
|
||||||
|
console.log(pitchset);
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
// no tritones
|
// no tritones
|
||||||
|
|||||||
Reference in New Issue
Block a user