我刚开始使用javascript代码使用MIDI,因此我想创建一个仅根据用户输入生成MIDI文件的应用程序。我已经看过使用MIDI.js了,但是我不确定是否需要任何库。理想情况下,我希望能够使用音符值而不是十六进制MIDI代码...我需要在其中使用转换器plugin.js吗?
我目前的研究表明,生成声音字体是建议的方法。但是,我想导出/生成用于专业DAW的MIDI文件。
谢谢你的帮助。
这是非常容易使用:
最简单的安装方法是使用npm。
$ npm install midi-writer-js
Run Code Online (Sandbox Code Playgroud)
然后
var MidiWriter = require('midi-writer-js');
Run Code Online (Sandbox Code Playgroud)
var tracks = [];
for(t of <your existing track array>){
var notes = [];
for(n of <your existing note array for the track>){
notes.push(new MidiWriter.NoteEvent({pitch: <array of all notes in the chord>, duration: <how long the chord should last>});
}
var newTrack = new MidiWriter.Track();
newTrack.addEvent(notes, function(event, index){ return {sequential: true}; });
tracks.push(newTrack);
}
Run Code Online (Sandbox Code Playgroud)
var writer = new MidiWriter.Writer(tracks);
writer.saveMIDI(<filename>);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1292 次 |
| 最近记录: |