codebase retrofitted to typescript
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
.gitignore
|
/built
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as Tone from 'tone';
|
||||||
import {
|
import {
|
||||||
sopranoTones, altoTones, tenorTones, bassTones,
|
sopranoTones, altoTones, tenorTones, bassTones,
|
||||||
extractPitchset,
|
extractPitchset,
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as Tone from 'tone';
|
||||||
import { sopranoTones, altoTones, tenorTones, bassTones, extractPitchset, } from "./src/toneGeneration.js";
|
import { sopranoTones, altoTones, tenorTones, bassTones, extractPitchset, } from "./src/toneGeneration.js";
|
||||||
const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones];
|
const pitchsets = [sopranoTones, altoTones, tenorTones, bassTones];
|
||||||
// initialize four synth voices
|
// initialize four synth voices
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
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");
|
||||||
export const showStart = document.getElementsByClassName('show-on-start');
|
export const showStart = document.getElementsByClassName('show-on-start');
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const bassTones = ["C2", "D2", "E2", "F2", "G2", "A2", "Bb2", "B2", "C3",
|
|||||||
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 extractPitchset = (pitches) => {
|
export const extractPitchset = (pitches) => {
|
||||||
// 1) determine pitch set from given array of pitches
|
// 1) determine pitch set from given array of pitches
|
||||||
let pitchset = [];
|
let pitchset;
|
||||||
for (let each of pitches) {
|
for (let each of pitches) {
|
||||||
// filters numbers from above tones
|
// filters numbers from above tones
|
||||||
const str = each;
|
const str = each;
|
||||||
@@ -20,7 +20,7 @@ export const extractPitchset = (pitches) => {
|
|||||||
pitchset.push(pitchNumber);
|
pitchset.push(pitchNumber);
|
||||||
}
|
}
|
||||||
// these are sorted from lowest to highest index (something like an interval vector)
|
// these are sorted from lowest to highest index (something like an interval vector)
|
||||||
pitchset.sort((a, b) => a < b);
|
pitchset.sort((a, b) => a - b);
|
||||||
console.log(pitchset);
|
console.log(pitchset);
|
||||||
return pitchset;
|
return pitchset;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
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");
|
||||||
|
|
||||||
export const showStart = document.getElementsByClassName('show-on-start');
|
export const showStart = document.getElementsByClassName('show-on-start') as HTMLCollectionOf<HTMLElement>;
|
||||||
export const hideStart = document.getElementsByClassName('hide-on-start');
|
export const hideStart = document.getElementsByClassName('hide-on-start') as HTMLCollectionOf<HTMLElement>;
|
||||||
|
|
||||||
export const showMore = document.getElementById('info-button');
|
export const showMore = document.getElementById('info-button');
|
||||||
export const moreInfo = document.getElementsByClassName('more-info');
|
export const moreInfo = document.getElementsByClassName('more-info') as HTMLCollectionOf<HTMLElement>;
|
||||||
|
|
||||||
export let appReady = false;
|
export let appReady = false;
|
||||||
|
|
||||||
@@ -9,9 +9,9 @@ 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 extractPitchset = (pitches) => {
|
export const extractPitchset = (pitches: string[]) => {
|
||||||
// 1) determine pitch set from given array of pitches
|
// 1) determine pitch set from given array of pitches
|
||||||
let pitchset = [];
|
let pitchset: number[];
|
||||||
|
|
||||||
for (let each of pitches) {
|
for (let each of pitches) {
|
||||||
// filters numbers from above tones
|
// filters numbers from above tones
|
||||||
@@ -25,7 +25,7 @@ export const extractPitchset = (pitches) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// these are sorted from lowest to highest index (something like an interval vector)
|
// these are sorted from lowest to highest index (something like an interval vector)
|
||||||
pitchset.sort((a,b) => a < b);
|
pitchset.sort((a,b) => a - b);
|
||||||
console.log(pitchset);
|
console.log(pitchset);
|
||||||
|
|
||||||
return pitchset;
|
return pitchset;
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./built",
|
"outDir": "./built",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"target": "es2016"
|
"target": "es2016",
|
||||||
|
"moduleResolution": "node"
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*"]
|
"include": ["./src/**/*"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user