{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "https://not-things.com/schemas/timeseq-script-1.2.0.schema.json",
	"title": "TimeSeq Script 1.2.0",
	"description": "JSON Schema (version 1.2.0) for the scripts that are used by the not-things TimeSeq VCV Rack module.",
	"$ref": "#/definitions/script",
	"definitions": {
		"script": {
			"description": "The root element of a TimeSeq JSON script",
			"type": "object",
			"properties": {
				"$schema": {
					"type": "string",
					"format": "uri"
				},
				"type": {
					"description": "Identifies this file as a not-things TimeSeq JSON script.",
					"const": "not-things_timeseq_script"
				},
				"version": {
					"description": "The version of the not-things TimeSeq JSON script specification that the document conforms to.",
					"const": "1.2.0"
				},
				"timelines": {
					"description": "The timeline instances that will be executed in this script.",
					"type": "array",
					"items": {
						"$ref": "#/definitions/timeline"
					}
				},
				"global-actions": {
					"description": "A list of actions that will be executed when the script is loaded.",
					"type": "array",
					"items": {
						"$ref": "#/definitions/action"
					}
				},
				"input-triggers": {
					"description": "A list of input-triggers for this script.",
					"type": "array",
					"items": {
						"$ref": "#/definitions/input-trigger"
					}
				},
				"sequences": {
					"description": "A list of sequences that can be used in this script.",
					"type": "array",
					"items": {
						"$ref": "#/definitions/sequence"
					}
				},
				"component-pool": {
					"$ref": "#/definitions/component-pool"
				}
			},
			"required": [ "type", "version" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"sequence": {
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the sequence.",
					"type": "string",
					"minLength": 1
				},
				"values": {
					"description": "The list of values in this sequence.",
					"type": "array",
					"items": {
						"$ref": "#/definitions/value"
					}
				},
				"retrieve-voltage-once": {
					"description": "Whether the voltage of a value should be retrieved once or repeatedly when it is requested multiple times without the position in the sequence changing in between.",
					"type": "boolean",
					"default": "false"
				},
				"shared": {
					"description": "Whether the active position of this sequence will be shared by a references that use it, or whether each reference will have its own distinct position (default=true).",
					"type": "boolean",
					"default": true
				}
			},
			"required": [ "id", "values" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"component-pool": {
			"description": "A pool of reusable objects that can be referenced from elsewhere in the script.",
			"type": "object",
			"properties": {
				"segment-blocks": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/segment-block" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"segments": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/segment-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"inputs": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/input-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"outputs": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/output-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"calcs": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/calc-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"values": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/value-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"actions": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/action-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"ifs": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/if-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				},
				"tunings": {
					"type": "array",
					"items": {
						"allOf": [
							{ "$ref": "#/definitions/tuning-full" },
							{ "$ref": "#/definitions/referenceable" }
						]
					}
				}
			}
		},
		"timeline": {
			"type": "object",
			"properties": {
				"time-scale": {
					"$ref": "#/definitions/time-scale"
				},
				"loop-lock": {
					"description": "Identifies if lanes in this timeline will only loop when all have completed, or will loop individually",
					"type": "boolean",
					"default": false
				},
				"lanes": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/lane"
					}
				}
			},
			"required": [ "lanes" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"time-scale": {
			"description": "Identifies how timing calculations should be performed in a timeline",
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"sample-rate": {
							"description": "If a segment in the timeline of this time-scale has a duration expressed in samples, these samples will be relative to this sample-rate instead of the active sample rate of VCV Rack.",
							"type": "integer",
							"minimum": 1
						}
					},
					"required": [ "sample-rate" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"bpm": {
							"description": "If a segment in the timeline of this time-scale has a duration expressed in beats, this value will specify the number of Beats Per Minute.",
							"type": "integer",
							"minimum": 1
						},
						"bpb": {
							"description": "If a segment in the timeline of this time-scale has a duration expressed in beats, this value will specify the number of Beats Per Bar.",
							"type": "integer",
							"minimum": 1
						}
					},
					"required": [ "bpm" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				}
			]
		},
		"lane": {
			"description": "The sequencing core of the not-things TimeSeq script, allowing segments to be scheduled in order.",
			"type": "object",
			"properties": {
				"segments": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/segment"
					}
				},
				"auto-start": {
					"description": "Indicate if this lane should automatically start when the script is started.",
					"type": "boolean",
					"default": true
				},
				"loop": {
					"description": "Loop to the first segment once the last segment in the lane has completed.",
					"type": "boolean",
					"default": false
				},
				"repeat": {
					"description": "How many times the segments in this lane should be repeated. Values 0 and 1 mean that the segments are only executed once. Has no impact if loop is set to true.",
					"type": "integer",
					"minimum": 0
				},
				"start-trigger": {
					"description": "The id of the internal trigger that will cause this lane to start running if it is not already running.",
					"type": "string",
					"minLength": 1
				},
				"restart-trigger": {
					"description": "The id of the internal trigger that will cause this lane to start running from its first segment, or restart from its first segment if it is already running.",
					"type": "string",
					"minLength": 1
				},
				"stop-trigger": {
					"description": "The id of the internal trigger that will cause this lane to stop if it is currently running.",
					"type": "string",
					"minLength": 1
				},
				"disable-ui": {
					"description": "Specifies if the L LED on the UI should light up when this lane loops.",
					"type": "boolean",
					"default": false
				}
			},
			"required": [ "segments" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"segment": {
			"oneOf": [
				{ "$ref": "#/definitions/segment-full" },
				{ "$ref": "#/definitions/reference" }
			]
		},
		"segment-full": {
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"duration": {
							"$ref": "#/definitions/duration"
						},
						"actions": {
							"type": "array",
							"items": {
								"$ref": "#/definitions/action"
							}
						},
						"disable-ui": {
							"description": "Specifies if the S LED on the UI should light up when this segment starts.",
							"type": "boolean",
							"default": false
						}
					},
					"required": [ "duration" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"segment-block": {
							"description": "The id of a segment-block that will be inserted in the place of this segment. Can not be combined with duration and disable-ui.",
							"type": "string",
							"minLength": 1
						},
						"actions": {
							"type": "array",
							"items": {
								"$ref": "#/definitions/action"
							}
						}
					},
					"required": [ "segment-block" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				}
			]
		},
		"duration": {
			"description": "Specifies how long a segment should last.",
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"samples": {
							"description": "Specifies the segment duration in number of samples.",
							"oneOf": [
								{
									"type": "integer",
									"minimum": 1
								},
								{ "$ref": "#/definitions/value-full" }
							]
						}
					},
					"required": [ "samples" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"millis": {
							"description": "Specifies the segment duration in number of milliseconds.",
							"oneOf": [
								{
									"type": "number",
									"exclusiveMinimum": 0
								},
								{ "$ref": "#/definitions/value-full" }
							]
						}
					},
					"required": [ "millis" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"beats": {
							"description": "Specifies the segment duration in number of beats. The timeline time-scale must have 'bmp' set to specify how long one beat lasts.",
							"oneOf": [
								{
									"type": "number"
								},
								{ "$ref": "#/definitions/value-full" }
							]
						},
						"bars": {
							"description": "Specifies the segment duration in number of beats. Can only be used in combination with 'beats'. The timeline time-scale must have 'bpb' set to specify how many beats go in a bar.",
							"type": "integer",
							"minimum": 1
						}
					},
					"required": [ "beats" ],
					"if": {
						"properties": { "bars": { "type": "integer" } },
						"required": [ "bars" ]
					},
					"then": {
						"properties": { "beats": { "type": "number", "minimum": 0 } }
					},
					"else": {
						"properties": { "beats": { "type": "number", "exclusiveMinimum": 0 } }
					},
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"hz": {
							"description": "Specifies the segment duration in Hertz.",
							"oneOf": [
								{
									"type": "number",
									"exclusiveMinimum": 0
								},
								{ "$ref": "#/definitions/value-full" }
							]
						}
					},
					"required": [ "hz" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				}
			]
		},
		"value": {
			"description": "A value that evaluates to a voltage.",
			"oneOf": [
				{
					"$ref": "#/definitions/value-full"
				},
				{
					"type": "number",
					"minimum": -10,
					"maximum": 10
				},
				{
					"$ref": "#/definitions/value-note"
				},
				{
					"$ref": "#/definitions/reference"
				}
			]
		},
		"value-note": {
			"description": "A fixed note value, translated into the corresponding 1V/Oct value.",
			"type": "string",
			"pattern": "^[A-Ga-g][0-9](?:[+-])?$"
		},
		"value-full": {
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"voltage": {
							"description": "A fixed voltage. Unless 'no-limit' is set to 'true', the value must be within the -10 to 10 voltage range.",
							"type": "number"
						},
						"no-limit": {
							"description": "Can only be used in combination with 'voltage'. If set to 'true', disables the -10 to 10 limitation of the voltage value.",
							"type": "boolean",
							"default": false
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }
					},
					"required": [ "voltage" ],
					"if": {
						"properties": { "no-limit": { "const": true } },
						"required": [ "no-limit" ]
					},
					"else": {
						"properties": { "voltage": { "type": "number", "minimum": -10, "maximum": 10 } }
					},
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"note": {
							"$ref": "#/definitions/value-note"
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "note" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"variable": {
							"description": "Use a previously set variable as voltage value source.",
							"type": "string",
							"minLength": 1
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "variable" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"input": {
							"$ref": "#/definitions/input"
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "input" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"output": {
							"$ref": "#/definitions/output"
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "output" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"rand": {
							"$ref": "#/definitions/rand"
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "rand" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"sequence": {
							"$ref": "#/definitions/sequence-value"
						},
						"calc": { "$ref": "#/definitions/value-full-shared-properties/calc" },
						"quantize": { "$ref": "#/definitions/value-full-shared-properties/quantize" }

					},
					"required": [ "sequence" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				}
			]
		},
		"value-full-shared-properties": {
			"calc": {
				"type": "array",
				"items": {
					"$ref": "#/definitions/calc"
				}
			},
			"quantize": {
				"description": "Allows the value to be quantized to the nearest note value.",
				"type": "boolean",
				"default": false
			}
		},
		"action": {
			"oneOf": [
				{ "$ref": "#/definitions/action-full" },
				{ "$ref": "#/definitions/reference" }
			]
		},
		"action-full": {
			"description": "Executes an action as part of segment processing.",
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"set-value": { "$ref": "#/definitions/set-value" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "set-value" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"set-polyphony": { "$ref": "#/definitions/set-polyphony" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "set-polyphony" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"set-label": { "$ref": "#/definitions/set-label" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "set-label" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"set-variable": { "$ref": "#/definitions/set-variable" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "set-variable" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"assert": { "$ref": "#/definitions/assert" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "assert" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"trigger": {
							"description": "Fires an internal trigger with the specified id.",
							"type": "string",
							"minLength": 1
						},
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "trigger" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"move-sequence": { "$ref": "#/definitions/move-sequence" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "move-sequence" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"clear-sequence": {
							"type": "string",
							"minLength": 1
						},
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "clear-sequence" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"add-to-sequence": { "$ref": "#/definitions/add-to-sequence" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "add-to-sequence" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"timing": { "$ref": "#/definitions/action-full-timing-start-end-property/timing" },
						"remove-from-sequence": { "$ref": "#/definitions/remove-from-sequence" },
						"if": { "$ref": "#/definitions/if" }
					},
					"required": [ "remove-from-sequence" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"oneOf": [
						{
							"properties": {
								"timing": {
									"const": "glide"
								},
								"start-value": {
									"$ref": "#/definitions/value"
								},
								"end-value": {
									"$ref": "#/definitions/value"
								},
								"ease-factor": {
									"type": "number",
									"minimum": -5,
									"maximum": 5,
									"default": 0
								},
								"ease-algorithm": {
									"enum": [ "sig", "pow" ],
									"default": "sig"
								},
								"output": {
									"$ref": "#/definitions/output"
								},
								"if": {
									"$ref": "#/definitions/if"
								}
							},
							"required": [ "timing", "start-value", "end-value", "output" ],
							"patternProperties": { "^x-|^id$": true },
							"additionalProperties": false
						},
						{
							"properties": {
								"timing": {
									"const": "glide"
								},
								"start-value": {
									"$ref": "#/definitions/value"
								},
								"end-value": {
									"$ref": "#/definitions/value"
								},
								"ease-factor": {
									"type": "number",
									"minimum": -5,
									"maximum": 5,
									"default": 0
								},
								"ease-algorithm": {
									"enum": [ "sig", "pow" ],
									"default": "sig"
								},
								"variable": {
									"description": "Name of the variable that should be set to the current glide value.",
									"type": "string",
									"minLength": 1
								},
								"if": {
									"$ref": "#/definitions/if"
								}
							},
							"required": [ "timing", "start-value", "end-value", "variable" ],
							"patternProperties": { "^x-|^id$": true },
							"additionalProperties": false
						}
					]
				},
				{
					"properties": {
						"timing": {
							"const": "gate"
						},
						"output": {
							"$ref": "#/definitions/output"
						},
						"gate-high-ratio": {
							"type": "number",
							"minimum": 0,
							"maximum": 1,
							"default": 0.5
						},
						"if": {
							"$ref": "#/definitions/if"
						}
					},
					"required": [ "timing", "output" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				}
			]
		},
		"action-full-timing-start-end-property": {
			"timing": {
				"enum": [ "start", "end" ],
				"default": "start"
			}
		},
		"input": {
			"oneOf": [
				{ "$ref": "#/definitions/input-full" },
				{
					"description": "An input in shorthand notation, referencing the first channel of the input with the specified index.",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				{ "$ref": "#/definitions/reference" }
			]
		},
		"input-full": {
			"description": "One of the channels on an input port of TimeSeq.",
			"type": "object",
			"properties": {
				"index": {
					"description": "The index of the input (1-based).",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				"channel": {
					"description": "The channel to use within the input signal.",
					"type": "integer",
					"minimum": 1,
					"maximum": 16
				}
			},
			"required": [ "index" ],
			"patternProperties": { "^x-|^id$": true },
			"additionalProperties": false
		},
		"output": {
			"oneOf": [
				{ "$ref": "#/definitions/output-full" },
				{
					"description": "An output in shorthand notation, referencing the first channel of the output with the specified index.",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				{ "$ref": "#/definitions/reference" }
			]
		},
		"output-full": {
			"description": "One of the channels on an output port of TimeSeq.",
			"type": "object",
			"properties": {
				"index": {
					"description": "The index of the output (1-based).",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				"channel": {
					"description": "The channel to use within the output signal.",
					"type": "integer",
					"minimum": 1,
					"maximum": 16
				}
			},
			"required": [ "index" ],
			"patternProperties": { "^x-|^id$": true },
			"additionalProperties": false
		},
		"rand": {
			"description": "Generate a random value in a specified lower and upper range",
			"type": "object",
			"properties": {
				"lower": {
					"$ref": "#/definitions/value"
				},
				"upper": {
					"$ref": "#/definitions/value"
				}
			},
			"required": [ "lower", "upper" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"calc": {
			"oneOf": [
				{ "$ref": "#/definitions/calc-full" },
				{ "$ref": "#/definitions/reference" }
			]
		},
		"calc-full": {
			"description": "Performs a calculation operation on a value voltage.",
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"add": {
							"description": "Adds a value to the current voltage result.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "add" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"sub": {
							"description": "Subtracts a value from the current voltage result.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "sub" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"mult": {
							"description": "Multiplies a value with the current voltage result.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "mult" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"div": {
							"description": "Divides the current voltage result by a value.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "div" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"max": {
							"description": "Takes the maximum of the current voltage and another value.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "max" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"min": {
							"description": "Takes the minimum of the current voltage and another value.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "min" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"remain": {
							"description": "Divides the current voltage by a value and uses the remainder of the division.",
							"$ref": "#/definitions/value"
						}
					},
					"required": [ "remain" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"trunc": {
							"description": "Takes the whole part of the current voltage, discarding the decimal data (i.e. truncate)",
							"const": true
						}
					},
					"required": [ "trunc" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"frac": {
							"description": "Takes the decimal part of the current voltage, discarding the whole part (i.e. fractional)",
							"const": true
						}
					},
					"required": [ "frac" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"round": {
							"description": "Rounds the current voltage either up, down or to the nearest whole value.",
							"enum": [ "up", "down", "near" ]
						}
					},
					"required": [ "round" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"quantize": {
							"description": "Quantizes the current voltage to a tuning.",
							"$ref": "#/definitions/tuning"
						}
					},
					"required": [ "quantize" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"sign": {
							"description": "Changes the sign of the current voltage to positive or negative (if needed).",
							"enum": [ "pos", "neg" ]
						}
					},
					"required": [ "sign" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"vtof": {
							"description": "Interprets the current voltage as a 1V/Oct value and converts it into a frequency value.",
							"const": true
						}
					},
					"required": [ "vtof" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				}
			]
		},
		"if": {
			"oneOf": [
				{ "$ref": "#/definitions/if-full" },
				{ "$ref": "#/definitions/reference" }
			]
		},
		"if-full-tolerance": {
			"tolerance": {
				"description": "Specifies how much two values may differ while still being considered equal. For usage in combination with 'eq' or 'ne'.",
				"type": "number",
				"minimum": 0,
				"default": 0
			}
		},
		"if-full": {
			"description": "A conditional that allows values to be compared.",
			"type": "object",
			"oneOf": [
				{
					"properties": {
						"eq": {
							"description": "Checks that two values are equal.",
							"$ref": "#/definitions/if-child-values"
						},
						"tolerance": { "$ref": "#/definitions/if-full-tolerance/tolerance" }
					},
					"required": [ "eq" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"ne": {
							"description": "Checks that two values are not equal.",
							"$ref": "#/definitions/if-child-values"
						},
						"tolerance": { "$ref": "#/definitions/if-full-tolerance/tolerance" }
					},
					"required": [ "ne" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"lt": {
							"description": "Checks that the first value is less than the second.",
							"$ref": "#/definitions/if-child-values"
						}
					},
					"required": [ "lt" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"lte": {
							"description": "Checks that the first value is less than or equal to the second.",
							"$ref": "#/definitions/if-child-values"
						}
					},
					"required": [ "lte" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"gt": {
							"description": "Checks that the first value is greater than the second.",
							"$ref": "#/definitions/if-child-values"
						}
					},
					"required": [ "gt" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"gte": {
							"description": "Checks that the first value is greater than or equal to the second.",
							"$ref": "#/definitions/if-child-values"
						}
					},
					"required": [ "gte" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"and": {
							"description": "Checks that child if conditionals are all true.",
							"$ref": "#/definitions/if-child-ifs"
						}
					},
					"required": [ "and" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				},
				{
					"properties": {
						"or": {
							"description": "Checks that at least one of the child if conditionals is true.",
							"$ref": "#/definitions/if-child-ifs"
						}
					},
					"required": [ "or" ],
					"patternProperties": { "^x-|^id$": true },
					"additionalProperties": false
				}
			]
		},
		"if-child-values": {
			"type": "array",
			"items": {
				"$ref": "#/definitions/value"
			},
			"minItems": 2,
			"maxItems": 2
		},
		"if-child-ifs": {
			"type": "array",
			"items": {
				"$ref": "#/definitions/if"
			},
			"minItems": 2
		},
		"input-trigger": {
			"description": "Monitor an input port for incoming trigger or gate signals and fire an internal trigger when one is detected.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the internal trigger that will be fired if a trigger signal is detected on the input port.",
					"type": "string",
					"minLength": 1
				},
				"input": {
					"description": "The input port on which to listen for trigger signals.",
					"$ref": "#/definitions/input"
				}
			},
			"required": [ "id", "input" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"segment-block": {
			"description": "A group of segments that can be inserted into a sequence.",
			"type": "object",
			"properties": {
				"segments": {
					"description": "The list of segments for this block",
					"type": "array",
					"items": {
						"$ref": "#/definitions/segment"
					}
				},
				"repeat": {
					"description": "Specifies how many times the segments in the segment block should be repeated before moving to the next step in the sequence",
					"type": "integer",
					"minimum": 1
				}
			},
			"required": [ "segments" ],
			"patternProperties": { "^x-|^id$": true },
			"additionalProperties": false
		},
		"tuning": {
			"oneOf": [
				{ "$ref": "#/definitions/tuning-full" },
				{ "$ref": "#/definitions/reference" }
			]
		},
		"tuning-full": {
			"description": "A tuning/scale to which values can be quantized using the 'quantize' action.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the tuning that can be used to reference it.",
					"type": "string",
					"minLength": 1
				},
				"notes": {
					"description": "The notes / 1V/Oct voltages that are part of this tuning.",
					"type": "array",
					"items": {
						"oneOf": [
							{
								"description": "A tuning note identified by a 1V/Oct voltage value",
								"type": "number"
							},
							{
								"description": "A tuning note identified by a note name and optional accidental",
								"type": "string",
								"pattern": "^[A-Ga-g](?:[+-])?$"
							}
						]
					},
					"minItems": 1
				}
			},
			"required": [ "notes" ],
			"patternProperties": { "^x-|^id$": true },
			"additionalProperties": false
		},
		"set-value": {
			"description": "Update the voltage on one of the output ports",
			"type": "object",
			"properties": {
				"output": {
					"description": "The output port on which to set the voltage",
					"$ref": "#/definitions/output"
				},
				"value": {
					"description": "The value to set the output port voltage to.",
					"$ref": "#/definitions/value"
				}
			},
			"required": [ "output", "value" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"set-polyphony": {
			"description": "Set the number of channels on an output port.",
			"type": "object",
			"properties": {
				"index": {
					"description": "Which output port to set the polyphony on.",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				"channels": {
					"description": "The number of channels the output port should have.",
					"type": "integer",
					"minimum": 1,
					"maximum": 16
				}
			},
			"required": [ "index", "channels" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"set-label": {
			"description": "Set the label of a TimeSeq output port.",
			"type": "object",
			"properties": {
				"index": {
					"description": "The index of the output port on which to set the label.",
					"type": "integer",
					"minimum": 1,
					"maximum": 8
				},
				"label": {
					"description": "The label to assign to the output port.",
					"type": "string",
					"minLength": 1
				}
			},
			"required": [ "index", "label" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"set-variable": {
			"description": "Set a variable to a value voltage.",
			"type": "object",
			"properties": {
				"name": {
					"description": "The name of the variable that will be assigned a value.",
					"type": "string",
					"minLength": 1
				},
				"value": {
					"$ref": "#/definitions/value"
				}
			},
			"required": [ "name", "value" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"assert": {
			"description": "Perform an assertion, validation that the specified expectation is met.",
			"type": "object",
			"properties": {
				"expect": {
					"description": "The expectation that must evaluate to true in order for the assertions to succeed.",
					"$ref": "#/definitions/if"
				},
				"name": {
					"description": "The name that will be used when triggering an assert failure",
					"type": "string",
					"minLength": 1
				},
				"stop-on-fail": {
					"description": "Indicates if TimeSeq should stop executing the script when the assertion fails.",
					"type": "boolean",
					"default": true
				}
			},
			"required": [ "expect", "name" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"move-sequence": {
			"description": "Move the currently active position in a sequence.",
			"oneOf": [
				{
					"type": "object",
					"properties": {
						"id": {
							"description": "The id of the sequence in which the active position should be moved.",
							"type": "string",
							"minLength": 1
						},
						"direction": {
							"description": "The direction in which the position should be moved.",
							"$ref": "#/definitions/sequence-move-direction",
							"default": "forward"
						},
						"wrap": {
							"description": "Whether the position should wrap around if it reaches the end or the start of the sequence.",
							"type": "boolean",
							"default": true
						}
					},
					"required": [ "id" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				},
				{
					"type": "object",
					"properties": {
						"id": {
							"description": "The id of the sequence in which the active position should be moved.",
							"type": "string",
							"minLength": 1
						},
						"position": {
							"description": "The index in the sequence (zero-based) to which the position should be moved.",
							"type": "integer"
						}
					},
					"required": [ "id", "position" ],
					"patternProperties": { "^x-": true },
					"additionalProperties": false
				}
			]
		},
		"add-to-sequence": {
			"description": "Adds a value to a sequence.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the sequence the value will be added.",
					"type": "string",
					"minLength": 1
				},
				"value": {
					"description": "The value to add to the sequence",
					"$ref": "#/definitions/value"
				},
				"position": {
					"description": "The position at which the value should be added to the sequence.",
					"type": "integer",
					"default": -1
				},
				"as-constant-voltage": {
					"description": "Whether the current voltage of the value should be determined and added to the sequence as a constant voltage, or if the value should be re-evaluated each time it is used in the sequence.",
					"type": "boolean",
					"default": true
				}
			},
			"required": [ "id", "value" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"remove-from-sequence": {
			"description": "Removes a value from sequence.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the sequence the value will be removed from.",
					"type": "string",
					"minLength": 1
				},
				"position": {
					"description": "The position of the value that will be removed.",
					"type": "integer",
					"default": -1
				}
			},
			"required": [ "id" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"sequence-value": {
			"description": "A value from a sequence",
			"oneOf": [
				{
					"type": "string",
					"description": "Reference the sequence by just the id. Will extract the current value from the sequence and subsequently move the sequence forward (with wrap-around if needed).",
					"minLength": 1
				},
				{
					"$ref": "#/definitions/sequence-value-full"
				}
			]
		},
		"sequence-value-full": {
			"description": "A full value from a sequence definition.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the sequence that provides the values.",
					"type": "string"
				},
				"move-before": {
					"description": "How to move the current position within the sequence before extracting the value (default = none).",
					"$ref": "#/definitions/sequence-move-direction",
					"default": "none"
				},
				"move-after": {
					"description": "How to move the current position within the sequence before extracting the value (default = forward).",
					"$ref": "#/definitions/sequence-move-direction",
					"default": "forward"
				},
				"wrap": {
					"description": "Whether the sequence will wrap around when reaching the start or the end of the sequence (default = true).",
					"type": "boolean",
					"default": true
				}
			},
			"required": [ "id" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"sequence-move-direction": {
			"enum": [ "forward", "backward", "random", "none" ]
		},
		"reference": {
			"description": "A reference to an object instance in the component-pool of the script.",
			"type": "object",
			"properties": {
				"ref": {
					"description": "The id of the referenced object.",
					"type": "string",
					"minLength": 1
				}
			},
			"required": [ "ref" ],
			"patternProperties": { "^x-": true },
			"additionalProperties": false
		},
		"referenceable": {
			"description": "An object in the component-pool that can be referenced by id from elsewhere.",
			"type": "object",
			"properties": {
				"id": {
					"description": "The id of the referenceable object.",
					"type": "string",
					"minLength": 1
				}
			},
			"required": [ "id" ]
		}
	}
}
