{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "tag:showsync/beam/sbf_v3.schema.json:",
  "title": "Showsync Beam Fixture Profile v3",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "description": "Beam Fixture Profile schema version.",
      "type": "integer"
    },
    "profileVersion": {
      "description": "Profile version allows tracking any subsequent revisions of a profile file.",
      "type": "integer"
    },
    "manufacturer": {
      "description": "The manufacturer of the fixture.",
      "type": "string"
    },
    "model": {
      "description": "The model of the fixture.",
      "type": "string"
    },
    "modes": {
      "description": "Fixture's DMX channel modes.",
      "type": "object",
      "patternProperties": {
        "^[^$\n]+$": {
          "type": "object",
          "properties": {
            "channels": {
              "$ref": "#/$defs/channels"
            },
            "modulation": {
              "$ref": "#/$defs/modulation"
            },
            "colorspace": {
              "$ref": "#/$defs/colorspace"
            },
            "cells": {
              "$ref": "#/$defs/cells"
            }
          },
          "required": ["channels", "modulation", "colorspace", "cells"]
        }
      }
    }
  },
  "$defs": {
    "channels": {
      "description": "Fixture's DMX channels.",
      "type": "object",
      "patternProperties": {
        "^[^$\n]+$": {
          "type": "object",
          "properties": {
            "address8Bit": {
              "description": "8-bit DMX address.",
              "type": "integer",
              "minimum": 1,
              "maximum": 512
            },
            "address16BitMsb": {
              "description": "16-bit coarse (MSB) DMX address",
              "type": "integer",
              "minimum": 1,
              "maximum": 512
            },
            "address16BitLsb": {
              "description": "16-bit fine (LSB) DMX address",
              "type": "integer",
              "minimum": 1,
              "maximum": 512
            },
            "channel16BitLsb": {
              "description": "Name of the 16-bit fine (LSB) DMX channel",
              "type": "string"
            },
            "defaultValue": {
              "description": "Default value for the channel, in a 0-255 range for 8-bit channels and 0-65535 for 16-bit channels.",
              "type": "integer"
            },
            "highlightValue": {
              "description": "Highlight/test value for the channel, in a 0-255 range for 8-bit channels and 0-65535 for 16-bit channels.",
              "type": "integer"
            }
          },
          "oneOf": [
            {
              "description": "8-bit channel",
              "required": ["address8Bit"]
            },
            {
              "description": "16-bit coarse (MSB) channel",
              "required": ["address16BitMsb", "channel16BitLsb"]
            },
            {
              "description": "16-bit fine (LSB) channel",
              "required": ["address16BitLsb"]
            }
          ]
        }
      }
    },
    "modulation": {
      "description": "Generic modulation parameters with one-to-one mappings to fixture's channels. The key of the modulation object is the keyword used in Beam for Max objects to address the parameters.",
      "type": "object",
      "patternProperties": {
        "^[^$\n]+$": {
          "type": "object",
          "properties": {
            "channel": {
              "description": "Name of the channel (defined in mode's channels key) that this modulation maps to.",
              "type": "string"
            },
            "mergeMode": {
              "description": "Merge mode specifies how the modulation values for a channel are mixed when multiple lighting signals with this modulation are received for the same fixture.",
              "type": "string",
              "enum": ["addition", "weightedaverage", "htp"]
            },
            "fallback": {
              "description": "Fallback mode determines what happens if lighting signals containing this modulation stop being present in the output.",
              "type": "string",
              "enum": ["none", "last"]
            }
          },
          "required": ["channel", "mergeMode", "fallback"]
        }
      }
    },
    "colorspace": {
      "type": "object",
      "description": "Fixture color space describes how red/green/blue color modulation values translate to a lighting fixture's channels related to dimming and color.",
      "properties": {
        "colorspaceType": {
          "description": "Fixture color space type, determines the necessary components.",
          "type": "string",
          "enum": ["none", "dimmer", "rgb", "rgbi", "rgbw", "rgbwi", "cmyi"]
        },
        "additive": {
          "description": "Lighting fixture's additive components.",
          "type": "object",
          "propertyNames": {
            "enum": ["intensity", "red", "green", "blue", "white"]
          },
          "patternProperties": {
            "^[^$\n]+$": {
              "type": "object",
              "properties": {
                "channel": {
                  "type": "string"
                }
              },
              "required": ["channel"]
            }
          }
        },
        "subtractive": {
          "description": "Lighting fixture's subtractive components.",
          "type": "object",
          "propertyNames": {
            "enum": ["cyan", "magenta", "yellow"]
          },
          "patternProperties": {
            "^[^$\n]+$": {
              "type": "object",
              "properties": {
                "channel": {
                  "type": "string"
                }
              },
              "required": ["channel"]
            }
          }
        }
      },
      "required": ["colorspaceType"]
    },
    "cells": {
      "description": "Sub-components of an aggregate fixture, such as pixels in a pixel bar.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "description": "Cell name, such as Pixel 1.",
            "type": "string"
          },
          "modulation": {
            "$ref": "#/$defs/modulation"
          },
          "colorspace": {
            "$ref": "#/$defs/colorspace"
          },
          "cells": {
            "$ref": "#/$defs/cells"
          }
        },
        "required": ["name"]
      }
    }
  },
  "required": ["schemaVersion", "modes"]
}
