maximecb / noisecraft

Browser-based visual programming language and platform for sound synthesis.

Home Page:https://noisecraft.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Unable to update string param using nodeParams dialog.

raisch opened this issue · comments

commented

Background

Added a new 'key' param with a blank string as its default.

    'OutPort': {
        ins: [{ name: 'amp', default: 1 }],
        outs: ['out'],
        params: [{ name: 'key', default: '' }],
        state: [],
        description: 'one out, with transport key',
    }

Expected Behavior

When opening the node params dialog and entering a string for the "key" param, the value of the param would be updated in the audio node.

Actual Behavior

Attempts to update the "key" param with "mix" caused the following error message to appear at the bottom of the dialog key must be a string, not a number and the following exception was displayed in the browser console:

RangeError: key must be a string, not a number
    at Module.validateParams (model.js:775:23)
    at UINode.saveParams (editor.js:1233:23)

Possible Fix

Add conditional test for string param, as in:

            input.oninput = function (evt)
            {
                if (input.value == 'null')
                    newParams[param.name] = null;
                // ==== START OF ADDITION
                else if (typeof param.default === 'string')
                    newParams[param.name] = input.value ;
                // ==== END OF ADDITION
                else
                    newParams[param.name] = Number(input.value);
            }