diff --git a/README.md b/README.md index 4adf8db0..c7490a77 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ npm start ## Operators +See `Language` section for alternative language definitions. + To display the list of operators inside of Orca, use `CmdOrCtrl+G`. - `A` **add**(*a* b): Outputs sum of inputs. @@ -149,7 +151,15 @@ All commands have a shorthand equivalent to their first two characters, for exam - `midi:1;2` Set Midi output device to `#1`, and input device to `#2`. - `udp:1234;5678` Set UDP output port to `1234`, and input port to `5678`. - `osc:1234` Set OSC output port to `1234`. -- `lang:clr;default` Incrementally load language interpreters (`clr` clears the language library entirely). Multiple languages can be combined. +- `lang:clr;default;etc` Incrementally load language libraries (`clr` clears the language library entirely). Multiple languages can be combined. + +### Language + +Orca language is a "library" of operators (everything that is not a command) that together define its behavior. Orca has the ability to dynamically load and combine multiple operator libraries at runtime, effectively allowing you to reconfigure the language. For example, you may want this for playing older compositions that are no longer compatible with the current Orca, or to experiment with alternative operators without affecting mainline Orca. Language reconfiguration lets you tailor the language to your individual composition. + +Orca starts with a `default` library, additional libraries can be loaded and combined via the `lang` command. Library loading is incremental, that is, operators defined in the new library are added to runtime, replacing existing operators. A given library may define all operators or only some. To completely clear the runtime library and start with the blank slate use the `clr` library. + +You can see available libraries and their documentation [here](https://github.com/hundredrabbits/Orca/blob/master/desktop/sources/scripts/library). ## Base36 Table diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 81334acd..05b42f58 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -9,6 +9,7 @@ + diff --git a/desktop/sources/scripts/core/library/README.md b/desktop/sources/scripts/core/library/README.md new file mode 100644 index 00000000..fc6a6c70 --- /dev/null +++ b/desktop/sources/scripts/core/library/README.md @@ -0,0 +1,15 @@ +Orca language is a "library" of operators (everything that is not a command) that together define its behavior. Orca has the ability to dynamically load and combine multiple operator libraries at runtime, effectively allowing you to reconfigure the language. For example, you may want this for playing older compositions that are no longer compatible with the current Orca, or to experiment with alternative operators without affecting mainline Orca. Language reconfiguration lets you tailor the language to your individual composition. + +Orca starts with a `default` library, additional libraries can be loaded and combined via the `lang` command. Library loading is incremental, that is, operators defined in the new library are added to runtime, replacing existing operators. A given library may define all operators or only some. To completely clear the runtime library and start with the blank slate use the `clr` library. + +## Available libraries + +"Complete" means you get a fully functioning Orca by loading just that library, "incremental" means it only defines a subset of operators and you need something loaded before that to get a full Orca (usually `default`). + +* `clr`: a special library that unloads all definitions +* `default`: mainline Orca language, loaded at startup (complete) +* `orca157`: Orca before the BFL breaking change (complete) (TODO) +* `base`: not a very useful library by itself, defines the basics such as comments and numbers +* `sb*`: Sborca collection of alternative operators (see `sborca.md`) + +## Usage examples \ No newline at end of file diff --git a/desktop/sources/scripts/core/library/sborca.js b/desktop/sources/scripts/core/library/sborca.js new file mode 100644 index 00000000..fb102108 --- /dev/null +++ b/desktop/sources/scripts/core/library/sborca.js @@ -0,0 +1,38 @@ +`use strict` + +/* global Operator */ +/* global library */ + +library.sbz = { + 'z': function OperatorZ (orca, x, y, passive) { + Operator.call(this, orca, x, y, 'z', passive) + + this.name = 'lerp' + this.info = 'Transitions operand to target by duration' + + this.ports.stepped = { x: -2, y: 0, default: '0' } + this.ports.duration = { x: -1, y: 0, default: '8' } + this.ports.target = { x: 1, y: 0 } + this.ports.output = { x: 0, y: 1, sensitive: true, reader: true, output: true } + + this.operation = function (force = false) { + const duration = this.listen(this.ports.duration, true) + const target = this.listen(this.ports.target, true) + const val = this.listen(this.ports.output, true) + var stepped = this.listen(this.ports.stepped, true) + if (stepped >= duration) { + stepped = duration + this.output(stepped, this.ports.stepped) + } + if (val !== target) { + if (stepped === duration) { stepped = 0 } // previous iteration done, ok to restart + const steps = duration - stepped + const remaining = target - val + const mod = Math.round(remaining / steps) + this.output(orca.keyOf(val + mod), this.ports.output) + this.output(orca.keyOf(stepped + 1), this.ports.stepped) + } + } + } +} + diff --git a/desktop/sources/scripts/core/library/sborca.md b/desktop/sources/scripts/core/library/sborca.md new file mode 100644 index 00000000..4064e2bf --- /dev/null +++ b/desktop/sources/scripts/core/library/sborca.md @@ -0,0 +1,9 @@ +Sborca collection of alternative operators + +## `sbz` (incremental) + +Defines: + +* `Z` **lerp**(*step* *duration* target): duration-based variant of `Z` + +TODO \ No newline at end of file