repairs to file system
This commit is contained in:
3
app.js
3
app.js
@@ -1,6 +1,3 @@
|
|||||||
import { pitchsets } from "./src/harmonyUtil.js";
|
|
||||||
import { extractPitchset } from "./src/vector_logic/extractPitchset.js";
|
|
||||||
|
|
||||||
// initialize four synth voices
|
// initialize four synth voices
|
||||||
const soprano = new Tone.Synth().toDestination();
|
const soprano = new Tone.Synth().toDestination();
|
||||||
const alto = new Tone.Synth().toDestination();
|
const alto = new Tone.Synth().toDestination();
|
||||||
|
|||||||
@@ -124,10 +124,5 @@
|
|||||||
<script type="module" src="./src/harmonyUtil.js"></script>
|
<script type="module" src="./src/harmonyUtil.js"></script>
|
||||||
<script type="module" src="./src/audioUtil.js"></script>
|
<script type="module" src="./src/audioUtil.js"></script>
|
||||||
<script type="module" src="./app.js"></script>
|
<script type="module" src="./app.js"></script>
|
||||||
<!-- vector logic scripts -->
|
|
||||||
<script type="module" src="./src/vector_logic/evaluateVector.js"></script>
|
|
||||||
<script type="module" src="./src/vector_logic/extractPitchset.js"></script>
|
|
||||||
<script type="module" src="./src/vector_logic/findVector.js"></script>
|
|
||||||
<script type="module" src="./src/vector_logic/numbersToPitches.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { soundChord } from "../app.js";
|
import { soundChord } from "../app.js";
|
||||||
import { getRandomPitches } from "./harmonyUtil.js";
|
import { getRandomPitches } from "./vector_logic/getRandomPitches.js";
|
||||||
import { extractPitchset } from "./vector_logic/extractPitchset.js";
|
import { extractPitchset } from "./vector_logic/extractPitchset.js";
|
||||||
|
import { getProceduralPitches } from "./vector_logic/getProceduralPitches.js";
|
||||||
|
|
||||||
// initial test: generate a single, random chord
|
// initial test: generate a single, random chord
|
||||||
export const fullRandomChord = () => {
|
export const fullRandomChord = () => {
|
||||||
@@ -11,6 +12,10 @@ export const fullRandomChord = () => {
|
|||||||
return pitchset;
|
return pitchset;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const evaluatedChord = () => {
|
export const evaluatedChord = (prevPitches = ["C3", "G3", "C4", "G4"]) => {
|
||||||
return fullRandomChord();
|
let pitches = getProceduralPitches(prevPitches);
|
||||||
|
soundChord(pitches);
|
||||||
|
let pitchset = extractPitchset(pitches);
|
||||||
|
|
||||||
|
return pitchset;
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
import { extractPitchset } from "./vector_logic/extractPitchset.js";
|
|
||||||
import { evaluateVector } from "./vector_logic/evaluateVector.js";
|
|
||||||
import { extractPitchName } from "./vector_logic/extractPitchName.js";
|
|
||||||
|
|
||||||
export const sopranoTones = ["B5", "A5", "G5", "F#5", "F5", "E5", "D5", "C5", "B4", "Bb4", "A4", "G4", "F#4", "F4", "E4"];
|
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 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 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"];
|
export const bassTones = ["C2", "D2", "E2", "F2", "G2", "A2", "Bb2", "B2", "C3", "D3", "E3", "F3", "G3"];
|
||||||
|
|
||||||
export const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones];
|
export const pitchsets = [bassTones, tenorTones, altoTones, sopranoTones];
|
||||||
|
|
||||||
export const musicalPitches = ['A', "Bb", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"];
|
export const musicalPitches = ['A', "Bb", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"];
|
||||||
|
|
||||||
@@ -29,45 +25,3 @@ const transposePitches = (pitchNames, interval) => {
|
|||||||
pitchNames.forEach(pitch => transposed.push((pitch + interval) % 12));
|
pitchNames.forEach(pitch => transposed.push((pitch + interval) % 12));
|
||||||
return transposed;
|
return transposed;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRandomPitches = () => {
|
|
||||||
// pitches stored in Tone.js string format
|
|
||||||
let pitches = [];
|
|
||||||
let formattedPitches = [];
|
|
||||||
|
|
||||||
for (let voice of pitchsets) {
|
|
||||||
// finds a random index, excluding any which may already exist in the array
|
|
||||||
let index;
|
|
||||||
let pitch;
|
|
||||||
let formattedPitch;
|
|
||||||
|
|
||||||
// loops until four distinct chord members are received
|
|
||||||
while (formattedPitches.length <= pitchsets.indexOf(voice)) {
|
|
||||||
index = Math.floor(Math.random() * 100) % voice.length;
|
|
||||||
pitch = voice[index];
|
|
||||||
|
|
||||||
formattedPitch = extractPitchName(pitch);
|
|
||||||
if (!formattedPitches.includes(formattedPitch)) {
|
|
||||||
formattedPitches.push(formattedPitch);
|
|
||||||
pitches.push(pitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(formattedPitches);
|
|
||||||
console.log(pitches);
|
|
||||||
return pitches;
|
|
||||||
}
|
|
||||||
|
|
||||||
// an additional method based on the structure of the method above,
|
|
||||||
// but taking principles of music theory into account.
|
|
||||||
export const getProceduralPitches = () => {
|
|
||||||
let pitches = [];
|
|
||||||
let formattedPitches = [];
|
|
||||||
|
|
||||||
for (let voice of pitchsets) {
|
|
||||||
let index;
|
|
||||||
let pitch;
|
|
||||||
let formattedPitch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getRandomPitches } from "../harmonyUtil.js";
|
import { getRandomPitches } from './getRandomPitches.js';
|
||||||
import { extractPitchset } from "./extractPitchset.js";
|
import { extractPitchset } from "./extractPitchset.js";
|
||||||
import { findVector } from "./findVector.js";
|
import { findVector } from "./findVector.js";
|
||||||
|
|
||||||
|
|||||||
34
src/vector_logic/getProceduralPitches.js
Normal file
34
src/vector_logic/getProceduralPitches.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { pitchsets } from "../harmonyUtil.js";
|
||||||
|
import { extractPitchName } from "./extractPitchName.js";
|
||||||
|
|
||||||
|
// an additional method based on the structure of getRandomPitches,
|
||||||
|
// but taking some principles of music theory into account.
|
||||||
|
export const getProceduralPitches = (prevPitches) => {
|
||||||
|
// prevPitches is passed in to ensure there is no linear dissonance within voices
|
||||||
|
let pitches = [];
|
||||||
|
let formattedPitches = [];
|
||||||
|
|
||||||
|
for (let voice of pitchsets) {
|
||||||
|
let index;
|
||||||
|
let formattedPitch;
|
||||||
|
|
||||||
|
while (pitches.length <= pitchsets.indexOf(voice)) {
|
||||||
|
// the first section of this while loop is more free.
|
||||||
|
index = Math.floor(Math.random() * 100) % voice.length;
|
||||||
|
formattedPitch = extractPitchName(voice[index]);
|
||||||
|
|
||||||
|
// this initial condition will apply only to the bass voice,
|
||||||
|
if (!pitches.length) {
|
||||||
|
pitches.push(voice[index]);
|
||||||
|
} else {
|
||||||
|
// now we need some repeating logic for the remaining four voices
|
||||||
|
while (pitches.length !== (pitchsets.indexOf(voice) + 1)) {
|
||||||
|
pitches.push(pitchsets.indexOf(voice));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(pitches);
|
||||||
|
return pitches;
|
||||||
|
}
|
||||||
29
src/vector_logic/getRandomPitches.js
Normal file
29
src/vector_logic/getRandomPitches.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { pitchsets } from "../harmonyUtil.js";
|
||||||
|
import { extractPitchName } from "./extractPitchName.js";
|
||||||
|
|
||||||
|
export const getRandomPitches = () => {
|
||||||
|
// pitches stored in Tone.js string format
|
||||||
|
let pitches = [];
|
||||||
|
let formattedPitches = [];
|
||||||
|
|
||||||
|
for (let voice of pitchsets) {
|
||||||
|
// finds a random index, excluding any which may already exist in the array
|
||||||
|
let index;
|
||||||
|
let formattedPitch;
|
||||||
|
|
||||||
|
// loops until four distinct chord members are received
|
||||||
|
while (formattedPitches.length <= pitchsets.indexOf(voice)) {
|
||||||
|
index = Math.floor(Math.random() * 100) % voice.length;
|
||||||
|
|
||||||
|
formattedPitch = extractPitchName(voice[index]);
|
||||||
|
if (!formattedPitches.includes(formattedPitch)) {
|
||||||
|
formattedPitches.push(formattedPitch);
|
||||||
|
pitches.push(voice[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(formattedPitches);
|
||||||
|
console.log(pitches);
|
||||||
|
return pitches;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user