I have a React Native application and in the backend I use Node.js.
Actually I have this in 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' });
}
If I call playSound
I have to have a synthesizer running for the sound to be reproduced.
Is there any way to call playSound
from React Native application and have this sound be played on the mobile device?