前言
node-red-contrib-lfo
是一个基于 Node-RED 的 LFO 使用包。LFO,即低频振荡器,是一种常用于音频合成中的波形发生器,也被应用在其他多媒体领域。本文将为大家介绍如何使用 node-red-contrib-lfo
包。
安装
使用 npm 包管理器,在终端执行以下命令进行安装:
npm install node-red-contrib-lfo
或者,通过 Node-RED 编辑器的“Manage Palette”菜单中的安装选项安装。
使用
node-red-contrib-lfo
包提供了三种不同类型的 LFO :
- Sine 波
- Sawtooth 波
- Square 波
Sine 波
创建一个 sine
LFO,运行 node-red
后打开 Node-RED 编辑器,在画布中将“LFO Sine”节点拖入。 此节点可以设置频率(单位为 Hz),振幅(单位为标准值),相位(单位为度数),时间偏移量(单位为秒)和输出时长。 节点将以时间为基础将发挥出的振幅(x轴)绘制为波形。 在“msg.payload”主题中发送数值后,节点将以设置的频率运行,将LFO带到“msg.payload”主题中。 下面是一个示例代码:
[{"id":"33188b49.b9b7ba","type":"inject","z":"8f14aaf5.7d63a8","name":"","topic":"","payload":"0.1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":340,"wires":[["3a724e24.bdeeea"]]},{"id":"3a724e24.bdeeea","type":"LFO Sine","z":"8f14aaf5.7d63a8","name":"","frequency":"5","amplitude":"10","phase":"0","offset":"0","duration":"4","x":390,"y":340,"wires":[["c3b1393f.8266f8"]]},{"id":"c3b1393f.8266f8","type":"debug","z":"8f14aaf5.7d63a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":590,"y":340,"wires":[]}]
Sawtooth 波
与 Sine 波不同,sawtooth节点不接受任何设置振幅的设置。与 Sine 波类似,frequency(频率)和phase(相位)设置都以hz和degree为单位。 下面是一个示例代码:
[{"id":"21b5808c.dc7c9","type":"inject","z":"8f14aaf5.7d63a8","name":"","topic":"","payload":"0.1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":480,"wires":[["abc7946a.101c5"]]},{"id":"abc7946a.101c5","type":"LFO Sawtooth","z":"8f14aaf5.7d63a8","name":"","frequency":"5","phase":"0","duration":"4","x":390,"y":480,"wires":[["1d7867f5.1988bf"]]},{"id":"1d7867f5.1988bf","type":"debug","z":"8f14aaf5.7d63a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":590,"y":480,"wires":[]}]
Square 波
类似于 sawtooth 节点,square(方波)节点也不接受任何设置振幅的设置。与 Sine 波和 Sawtooth 波类似,frequency(频率)和phase(相位)设置都以hz和degree为单位。 下面是一个示例代码:
[{"id":"e7c9ac50.1fb21","type":"inject","z":"8f14aaf5.7d63a8","name":"","topic":"","payload":"0.1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":620,"wires":[["c77ed3f3.16af7"]]},{"id":"c77ed3f3.16af7","type":"LFO Square","z":"8f14aaf5.7d63a8","name":"","frequency":"5","phase":"0","duration":"4","x":390,"y":620,"wires":[["1ad4fb43.7432eb"]]},{"id":"1ad4fb43.7432eb","type":"debug","z":"8f14aaf5.7d63a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":590,"y":620,"wires":[]}]
总结
本文介绍了如何使用 node-red-contrib-lfo
包中的 LFO,在 Node-RED 中赋予了更高的自由度。 祝您使用愉快!
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/6005565a81e8991b448d3338