{ "name": "cos-example", "patches": { "@/main": { "path": "@/main" }, "@/cos": { "nodes": { "BJWf2zrbz": { "id": "BJWf2zrbz", "type": "xod/patch-nodes/input-number", "position": { "x": 68, "y": 0 }, "label": "RAD" }, "S1vGhGBbz": { "id": "S1vGhGBbz", "type": "xod/patch-nodes/output-number", "position": { "x": 68, "y": 204 } }, "HkBQ6fBZG": { "id": "HkBQ6fBZG", "type": "xod/patch-nodes/not-implemented-in-xod", "position": { "x": 68, "y": 102 } } }, "comments": { "SJcQpGBWG": { "id": "SJcQpGBWG", "position": { "x": 136, "y": 102 }, "size": { "width": 204, "height": 51 }, "content": "That’s a C++ marker node. Double click it to edit the code." } }, "path": "@/cos", "attachments": [ { "filename": "patch.cpp", "encoding": "utf-8", "content": "\n// Ignore this for now. The definition is required by XOD but we\n// not use it for cos\nstruct State { };\n\n// This is an obligatory marker. XOD will put pin definitions there\n{{ GENERATED_CODE }}\n\n// The `evaluate` function is the node’s entry point. It is the only\n// function XOD requires to implement. The context parameter is a\n// black-box object you’ll pass to various API functions.\nvoid evaluate(Context ctx) {\n // `getValue` function reads a pin. In angle brackets, it takes a\n // name of the pin in form input_PINLABEL (input_RAD in our case)\n Number x = getValue(ctx);\n\n // Next, we use regular C++ to perform some actions. Our case is trivial.\n // All we have to do is to call the standard C++ cos function.\n // Note the data type `Number`. It’s the type XOD uses to represent numbers\n // on the current platform.\n Number result = cos(x);\n\n // `emitValue` is like `getValue`, but it writes values rather than read.\n // Note we use `OUT` label to access our unlabeled output terminal.\n // `OUT` is the default name when you omit the label.\n emitValue(ctx, result);\n}\n" } ] } } }