Add a basic selection of instruments from the MIDI and chiptune categories
This commit is contained in:
43
tasks/assets.ts
Normal file
43
tasks/assets.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import * as http from "http";
|
||||
import * as https from "https";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
const root = `${path.dirname(process.argv[1])}/..`;
|
||||
const assets = `${root}/assets`;
|
||||
|
||||
function download(filename: string, url: string): void {
|
||||
var file = fs.createWriteStream(filename);
|
||||
var protocol = url.startsWith("https://") ? https : http;
|
||||
protocol.get(url, response => {
|
||||
response.pipe(file);
|
||||
});
|
||||
}
|
||||
|
||||
if (!fs.existsSync(assets)) {
|
||||
fs.mkdirSync(assets);
|
||||
}
|
||||
download(
|
||||
`${assets}/md-icons.css`,
|
||||
"https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
);
|
||||
download(
|
||||
`${assets}/material.indigo-pink.min.css`,
|
||||
"https://code.getmdl.io/1.3.0/material.indigo-pink.min.css"
|
||||
);
|
||||
download(
|
||||
`${assets}/material.min.js`,
|
||||
"https://code.getmdl.io/1.3.0/material.min.js"
|
||||
);
|
||||
download(
|
||||
`${assets}/mdl-selectfield.min.css`,
|
||||
"https://cdn.rawgit.com/kybarg/mdl-selectfield/mdl-menu-implementation/mdl-selectfield.min.css"
|
||||
);
|
||||
download(
|
||||
`${assets}/mdl-selectfield.min.js`,
|
||||
"https://cdn.rawgit.com/kybarg/mdl-selectfield/mdl-menu-implementation/mdl-selectfield.min.js"
|
||||
);
|
||||
download(
|
||||
`${assets}/dialog-polyfill.min.css`,
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.5.0/dialog-polyfill.min.css"
|
||||
);
|
22
tasks/deploy.ts
Normal file
22
tasks/deploy.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as ghPages from "gh-pages";
|
||||
import * as path from "path";
|
||||
|
||||
const root = `${path.dirname(process.argv[1])}/..`;
|
||||
|
||||
ghPages.publish(
|
||||
root,
|
||||
{
|
||||
"src": [
|
||||
"index.html",
|
||||
"index.css",
|
||||
"assets/*.css",
|
||||
"assets/*.js",
|
||||
"audio/**/*.flac",
|
||||
]
|
||||
},
|
||||
err => {
|
||||
if (err !== undefined) {
|
||||
console.log(`Failure: ${err}`);
|
||||
}
|
||||
}
|
||||
);
|
59
tasks/samples.ts
Normal file
59
tasks/samples.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as process from "process";
|
||||
import * as child_process from "child_process";
|
||||
import * as yaml from "js-yaml";
|
||||
import { InstrumentData, notes } from "../src/index";
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
console.error("Must specify location of Bosca Ceoil clone with CLI export functionality.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const root = `${path.dirname(process.argv[1])}/..`;
|
||||
const tmp = `${root}/tmp`;
|
||||
const boscaCeoilDir = process.argv[2];
|
||||
const instrumentData: InstrumentData = yaml.safeLoad(fs.readFileSync(`${root}/instruments.yaml`).toString());
|
||||
const song = fs.readFileSync(`${root}/audio/main.ceol`).toString().split(",");
|
||||
|
||||
if (!fs.existsSync(tmp)) {
|
||||
fs.mkdirSync(tmp);
|
||||
}
|
||||
|
||||
for (const [instrument, { index }] of Object.entries(instrumentData)) {
|
||||
const instrumentDir = `${root}/audio/${instrument}`;
|
||||
|
||||
if (!fs.existsSync(instrumentDir)) {
|
||||
fs.mkdirSync(instrumentDir);
|
||||
}
|
||||
|
||||
for (const note of notes) {
|
||||
if (fs.existsSync(`${instrumentDir}/${note.toLowerCase()}.ogg`)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(`${tmp}/${instrument}-${note.toLowerCase()}.wav`)) {
|
||||
song[8] = index.toString();
|
||||
song[20] = (0 + 12 * notes.indexOf(note)).toString();
|
||||
fs.writeFileSync(`${tmp}/${instrument}.ceol`, song.join(","));
|
||||
|
||||
console.log(`${instrument}: ${note}`);
|
||||
|
||||
child_process.execSync(
|
||||
`adl application.xml -- ${tmp}/main.ceol --export ${tmp}/${instrument}-${note.toLowerCase()}.wav`,
|
||||
{ cwd: boscaCeoilDir },
|
||||
);
|
||||
}
|
||||
|
||||
child_process.execSync(
|
||||
`sox ${tmp}/${instrument}-${note.toLowerCase()}.wav -C 5 ${instrumentDir}/${note.toLowerCase()}.ogg silence 0 1 0.1 0.1%`,
|
||||
{ cwd: root },
|
||||
);
|
||||
|
||||
fs.unlinkSync(`${tmp}/${instrument}-${note.toLowerCase()}.wav`);
|
||||
}
|
||||
}
|
||||
|
||||
if (fs.existsSync(`${tmp}/main.ceol`)) {
|
||||
fs.unlinkSync(`${tmp}/main.ceol`);
|
||||
}
|
Reference in New Issue
Block a user