-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
52 lines (45 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var extend = require('extend');
var optionAliases = require('./lib/optionAliases');
var parse = require('./lib/parse');
var optimize = require('./lib/optimize');
var generate = require('./lib/generate');
var defaultOptions = optionAliases.aa;
function opt(mml, options) {
var parsed = parseMml(mml, options);
var optimized = optimizeMml(parsed, options);
var generated = generateMml(optimized, options);
return generated;
}
function parseMml(mml, options) {
options = options || {};
var outputOptions = getOptions(options.output);
var parserOptions = extend({}, getOptions(options.input), {
tpqn: outputOptions.tpqn,
minimumNoteDuration: outputOptions.tpqn,
transpose: options.transpose || 0
});
var parsed = parse(mml, parserOptions);
return parsed;
}
function optimizeMml(tokens, options) {
options = options || {};
var outputOptions = getOptions(options.output);
var optimized = optimize(tokens, outputOptions);
return optimized;
}
function generateMml(tokens, options) {
options = options || {};
var outputOptions = getOptions(options.output);
var generated = generate(tokens, outputOptions);
return generated;
}
function getOptions(alias) {
if (!alias)
return defaultOptions;
return optionAliases[alias] || defaultOptions;
}
module.exports = opt;
module.exports.parse = parseMml;
module.exports.optimize = optimizeMml;
module.exports.generate = generateMml;
module.exports.getOptions = getOptions;