Ggwave to wav/mp3 buffer

A while back i created a node minimodem which was using an old cli application for (de)coding strings to audio...
This only worked on the server-side, playing/listening on a default audio device. It runs great but I need something different now...

I want to utilize ggwave to create the same system but so that the audio is being played/listened by the node-red dashboard...
I got in a problem where i don't know how to convert ggwave.encode waveform to buffer so i can send it to an audio out node..
Here is the function i have:

        "id": "54eedcef98ce14ab",
        "type": "function",
        "z": "6b666f2f1c1a7887",
        "name": "working",
        "func": "var factory = ggwave\nvar waveform\nvar parameters \nvar instance\nfactory().then(function (ggwave) {\n    var parameters = ggwave.getDefaultParameters();\n    var instance = ggwave.init(parameters);\n    var payload = 'hel';\n    var waveform = ggwave.encode(instance, payload, ggwave.TxProtocolId.GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 10);\n    node.send({ payload: waveform})\n});\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
                "var": "ggwave",
                "module": "ggwave"
        "x": 320,
        "y": 240,
        "wires": [

The output is a string with random numbers:


I tried to parse the webpage example javascript to node-red but figured out that the script is utilizing AudioContext(Web Audio API) that i remember does not work in node-red...

Does anyone have any solution?

The output is actually an int8array

You can convert it using Buffer.from()


var factory = ggwave
factory().then(function (ggwave) {
    var parameters = ggwave.getDefaultParameters();
    var instance = ggwave.init(parameters);
    var waveform = ggwave.encode(instance, msg.payload, ggwave.TxProtocolId.GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 10);
    var buf = Buffer.from(waveform);
    node.send({topic: "wave", payload: buf})
}).catch(function(err) {
    node.error(err, msg);

I get an error when trying to play it via audio_out (dashboard) node...
Catch node does not show any errors from audio_out node...

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.