UNPKG

node-red-contrib-music

Version:

Synthesise music with node-red. The beat node creates regular beats at a rate you can control, and which can be sunchronised with other machines. The divider node adds information to beat events, dividing beats into bars, bars into phrases, phrases into s

17 lines (12 loc) 522 B
// commonly used functions, imported by synth.js, soundfx.js, looper.js // exponential scale with 0->0 and 100->1 function volume2amp (node) { let volume = Math.max(0, node.volume); const globalVolume = node.context().flow.get('volume') || node.context().global.get('volume'); if (globalVolume !== null && globalVolume >= 0) { volume = volume * globalVolume / 100; } const base = 1.02; return (Math.pow(base, volume) - 1) / (Math.pow(base, 100) - 1); } module.exports = { volume2amp };