从React Native为Node.js使用easymidi
我有一个React本机应用程序,在后端我使用Node.js 实际上我在node.js中有这个从React Native为Node.js使用easymidi,node.js,react-native,midi,synthesizer,Node.js,React Native,Midi,Synthesizer,我有一个React本机应用程序,在后端我使用Node.js 实际上我在node.js中有这个 const easymidi = require('easymidi'); const output = new easymidi.Output('Mindy', true); function playSound(req, res) { console.log('play sound ....'); const sendNote = (noteValue, duration) =&
const easymidi = require('easymidi');
const output = new easymidi.Output('Mindy', true);
function playSound(req, res) {
console.log('play sound ....');
const sendNote = (noteValue, duration) => {
output.send('noteon', noteValue);
setTimeout(() => {
output.send('noteoff', noteValue);
}, duration);
}
setInterval(() => {
const noteValue = {
note: 12 * 4,
velocity: 127,
channel: 1
}
sendNote(noteValue, 500);
}, 1000);
res.status(200).send({ message: 'play sound' });
}
如果我调用playSound
,我必须运行合成器才能再现声音
是否有任何方法可以从React本机应用程序调用playSound
,并在移动设备上播放此声音?easymidi()构建在仅在OSX/Windows/Linux上工作的节点midi()上。
人们不太可能在移动设备上使用它。
您可能想在浏览器MIDI库中尝试一些: