Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从React Native为Node.js使用easymidi_Node.js_React Native_Midi_Synthesizer - Fatal编程技术网

从React Native为Node.js使用easymidi

从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) =&

我有一个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) => {
        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库中尝试一些: