diff --git a/.gitignore b/.gitignore index 08f01db..273e392 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /node_modules -.gitignore \ No newline at end of file +/built \ No newline at end of file diff --git a/app.js b/app.ts similarity index 98% rename from app.js rename to app.ts index cefddb8..c5cc0b2 100644 --- a/app.js +++ b/app.ts @@ -1,3 +1,4 @@ +import * as Tone from 'tone'; import { sopranoTones, altoTones, tenorTones, bassTones, extractPitchset, diff --git a/built/app.js b/built/app.js index d03acf3..d3bf093 100644 --- a/built/app.js +++ b/built/app.js @@ -1,3 +1,4 @@ +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 diff --git a/built/src/styleUtils.js b/built/src/styleUtils.js index 06f598b..5f8712b 100644 --- a/built/src/styleUtils.js +++ b/built/src/styleUtils.js @@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge 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'); diff --git a/built/src/toneGeneration.js b/built/src/toneGeneration.js index fbc809e..7c408fb 100644 --- a/built/src/toneGeneration.js +++ b/built/src/toneGeneration.js @@ -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#"]; export const extractPitchset = (pitches) => { // 1) determine pitch set from given array of pitches - let pitchset = []; + let pitchset; for (let each of pitches) { // filters numbers from above tones const str = each; @@ -20,7 +20,7 @@ export const extractPitchset = (pitches) => { pitchset.push(pitchNumber); } // 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); return pitchset; }; diff --git a/src/styleUtils.js b/src/styleUtils.ts similarity index 89% rename from src/styleUtils.js rename to src/styleUtils.ts index 3b7a4a0..8231e4c 100644 --- a/src/styleUtils.js +++ b/src/styleUtils.ts @@ -1,11 +1,13 @@ +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 showStart = document.getElementsByClassName('show-on-start') as HTMLCollectionOf; +export const hideStart = document.getElementsByClassName('hide-on-start') as HTMLCollectionOf; export const showMore = document.getElementById('info-button'); -export const moreInfo = document.getElementsByClassName('more-info'); +export const moreInfo = document.getElementsByClassName('more-info') as HTMLCollectionOf; export let appReady = false; diff --git a/src/toneGeneration.js b/src/toneGeneration.ts similarity index 92% rename from src/toneGeneration.js rename to src/toneGeneration.ts index 9787eaf..59224b6 100644 --- a/src/toneGeneration.js +++ b/src/toneGeneration.ts @@ -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 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 - let pitchset = []; + let pitchset: number[]; for (let each of pitches) { // 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) - pitchset.sort((a,b) => a < b); + pitchset.sort((a,b) => a - b); console.log(pitchset); return pitchset; diff --git a/tsconfig.json b/tsconfig.json index e583438..5fd7e6a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "outDir": "./built", "allowJs": true, - "target": "es2016" + "target": "es2016", + "moduleResolution": "node" }, "include": ["./src/**/*"] } \ No newline at end of file