12 种乐器预设,将合成引擎转化为真实乐器。点击其中一种,然后弹奏下方的键盘(或使用您的 MIDI 控制器)。每种预设都会配置波形、包络、滤波器、齐奏和颤音。
const synth = new ChiptuneSynth();
await synth.init();
// Load instruments onto tracks
synth.loadInstrument('violin', 0); // Track 0 = Violin
synth.loadInstrument('piano', 1); // Track 1 = Piano
// Play a chord
synth.playNoteByName('A', 4, 0, 2); // Violin A4
synth.playNoteByName('C', 4, 1, 2); // Piano C4
synth.playNoteByName('E', 4, 1, 2); // Piano E4
// List all instruments
console.log(ChiptuneSynth.getInstrumentNames());
// ['piano','violin','cello','flute','organ','brass',
// 'harmonica','synthLead','synthPad','synthBass','marimba','electricGuitar']
// Enable MIDI controller
const devices = await synth.enableMIDI({ track: 0 });
console.log('MIDI devices:', devices);