【发布时间】:2018-12-12 11:33:13
【问题描述】:
我一直在尝试使用 node.js 脚本将一些数据转换为音乐。由于某种原因,该脚本仅返回一个注释:
github 上的原始脚本:https://github.com/wbkd/from-data-to-sound 有 res.concat(scribble.scale('c',但是抛出了一个错误 Invalid Scale name。
const scribble = require('scribbletune');
// example data
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
const min = Math.min(...data);
const octaves = [...Array(5)].map((d, i) => i + 1); // [1, 2, 3, 4, 5]
// creates array of notes like 'c1', 'd1', 'e1', 'gb1', 'ab1', 'bb1', 'c2', ...
const notes = octaves.reduce((res, octave) =>
res.concat(scribble.scale('c1 major', 'whole tone', octave, false))
, []);
const midiData = scribble.clip({
notes: data.map(value => notes[value - min]),
pattern: 'x',
noteLength: '1/16',
});
// write the MIDI file ????????????
scribble.midi(midiData, 'data-sonification.mid');
【问题讨论】:
标签: javascript node.js midi