SPB Git

Repository Public

units.md 7.3 KB 209 lines markdown

1# Units23In ORIX Script a number carries its unit, exactly as on the front panel of a mixer. `-12dB` is a level, `800Hz` is a frequency, `4 beats` is a length of time. The unit is not decoration: it decides the type of the value, and the compiler checks it against the control you send it to.45## All the units67| Unit | Written | Type | Meaning |8| --- | --- | --- | --- |9| Decibels | `-12dB` | gain | Level relative to full scale or to the centre of a knob |10| Hertz | `80Hz` | frequency | |11| Kilohertz | `12kHz` | frequency | 1 kHz = 1000 Hz |12| Beats | `1beat`, `4beats`, `4 beats` | duration (musical) | One beat of the master clock |13| Bars | `1bar`, `8bars`, `8 bars` | duration (musical) | One bar = 4 beats |14| Fractions | `1/4beat`, `3/4beat`, `3/2bars` | duration (musical) | Numerator/denominator of a beat or a bar |15| Milliseconds | `250ms` | duration (absolute) | |16| Seconds | `2s`, `2sec` | duration (absolute) | |17| Minutes | `1min` | duration (absolute) | |18| Percent | `50%` | number | The number divided by 100 |19| BPM | `128bpm` | number | Readability only: `128bpm` is `128` |20| Semitones | `-2st` | number | Readability only: `-2st` is `-2` |2122Units are case-sensitive: `dB`, `Hz`, `kHz`, `ms`. Anything else after a number is the error `E-UNIT`.2324```orixdj-error25wait 5parsecs26```2728```text29Unknown unit 'parsecs'. Units: Hz, kHz, dB, beat(s), bar(s), s, ms, min, bpm, st, %. [E-UNIT]30```3132## Writing rules33341. **The unit touches the number.** `-12dB`, `20Hz`, `250ms`, `50%`.352. **The four musical words may stand apart.** `8 bars`, `4 beats`, `1 bar`, `1 beat` are accepted with one or more spaces, as long as the word is on the same line as the number. `8bars` is the same thing.363. **Fractions are written tight.** `1/4beat` and `3/2bars`, with no space inside the fraction. One space is allowed before the unit: `1/4 beat`.374. **Singular and plural are interchangeable.** `1beats` and `4beat` are accepted; write what reads well.3839## Decibels4041Decibels describe level. On a fader, 0 dB is the top and -60 dB is silence. On an EQ band or a trim, 0 dB is the centre: negative values cut and positive values boost.4243| Value | On a channel fader |44| --- | --- |45| `0dB` | Full level |46| `-6dB` | About half the amplitude |47| `-12dB` | About a quarter |48| `-60dB` | Silence |4950Each control has its own range; the reference lists them. The most used ones:5152| Control | Range |53| --- | --- |54| `deck.X.volume` | -60 dB … 0 dB |55| `deck.X.gain` (trim) | -24 dB … 12 dB |56| `deck.X.eq.low`, `eq.mid`, `eq.high` | -26 dB … 6 dB (-26 dB is a full kill) |57| `mixer.master.volume` | -60 dB … 6 dB |5859Decibels add: turning something down by 3 dB twice is turning it down by 6 dB.6061```orixdj62let step = -3dB63deck.A.eq.high = step + step      // -6 dB64wait 1 bar65deck.A.eq.high = 0dB66```6768A plain number or a percentage given to a gain control is read as a linear fader level (`50%` is about -6 dB). See [Types](types.md).6970## Hertz7172Frequencies describe filter corners and modulation speeds.7374| Region | Roughly |75| --- | --- |76| Sub and kick | 20 Hz – 120 Hz |77| Bass and low mids | 120 Hz – 500 Hz |78| Mids | 500 Hz – 4 kHz |79| Highs | 4 kHz – 20 kHz |8081For the channel filters, the "off" positions are at the ends of the range: `deck.X.filter.highpass = 20Hz` lets everything through, and so does `deck.X.filter.lowpass = 20kHz`.8283```orixdj84deck.A.filter.highpass = 300Hz     // remove the bass85wait 2 bars86deck.A.filter.highpass = 20Hz      // off87```8889## Beats and bars9091Musical durations follow the tempo: `4 beats` lasts longer at 100 BPM than at 140 BPM, but it is always one bar. One bar is four beats; the language has no other time signature.9293| Written | Beats | In 4/4 notation |94| --- | --- | --- |95| `4 bars` | 16 | Four bars |96| `1 bar` | 4 | One bar |97| `2 beats` | 2 | A half note |98| `1 beat` | 1 | A quarter note |99| `1/2beat` | 0.5 | An eighth note |100| `1/4beat` | 0.25 | A sixteenth note |101| `3/4beat` | 0.75 | A dotted eighth |102| `1/3beat` | 0.333 | An eighth-note triplet |103| `3/2bars` | 6 | A bar and a half |104105More in [Beats and Bars](beats-and-bars.md).106107## Seconds and milliseconds108109Absolute durations are for things that are not musical: "wait two seconds", "a 15 ms pre-delay". When an absolute duration is used for waiting, ramping or scheduling, it is converted to beats with the tempo of the master clock at that moment.110111```orixdj112fx.reverb.predelay = 20ms          // an effect time in milliseconds113wait 2s                            // 4.27 beats at 128 BPM114```115116Some effect parameters are defined in milliseconds (`fx.reverb.predelay`, `fx.compressor.attack`) and others in beats (`fx.delay.time`, `fx.gate.rate`). Both accept any duration; a duration of the other kind is converted with the current tempo when the parameter is set, then limited to the range of the parameter.117118```orixdj119fx.delay.time = 1/2beat            // native unit: beats120fx.delay.time = 250ms              // converted to beats with the current tempo121fx.compressor.attack = 5ms         // native unit: milliseconds122```123124## Percent125126`50%` is the number `0.5`. It reads well on controls that go from 0 to 1.127128```orixdj129fx.reverb.mix = 35%130mixer.crossfader = 100%131wait 1 bar132mixer.crossfader = 50%133fx.reverb.mix = 0%134```135136## Traps137138### Spaces in a fraction139140`1/4beat` and `1/4 beat` are the same duration: the unit may follow the fraction directly or after exactly one space. The fraction itself is written tight. `1 / 4 beat` is not a fraction literal; it is the number 1 divided by the duration `4 beat`, which is a type error.141142```orixdj143wait 1/4beat144wait 1/4 beat145```146147### `%`: percentage or remainder148149`%` directly after a number is a percentage, unless it is itself directly followed by a digit, a name or an opening parenthesis; then it is the remainder operator.150151| Written | Read as |152| --- | --- |153| `50%` | 0.5 |154| `50% * 2` | 0.5 × 2 |155| `7 % 4` | remainder of 7 / 4, which is 3 |156| `7%4` | remainder of 7 / 4, which is 3 |157| `count % 4` | remainder (a name is on the left) |158159Put spaces around `%` when you mean the remainder and none before it when you mean percent.160161### A number where a unit is required162163```orixdj-error164wait 4165```166167```text168'wait' needs a duration such as 4beats, 2bars or 500ms, not number. [E-TYPE]169```170171### Mixing units of different types172173`-6dB + 200Hz` is an error; so is `4 beats + 3`. The message names the two types.174175### `s` is seconds176177`2s` is two seconds. There is no unit for samples or for bars written `b`.178179## Converting between units180181| From | To | Use |182| --- | --- | --- |183| number | gain | `db(x)` |184| number | frequency | `hz(x)` |185| number | duration | `beats(x)`, `bars(x)`, `seconds(x)` |186| gain, frequency | number | `toNumber(x)` |187| duration | number of beats | `toBeats(d)` (at the current tempo) |188| duration | number of seconds | `toSeconds(d)` (at the current tempo) |189| linear level 0…1 | gain | assign the number to a gain parameter |190191```orixdj192let barSeconds = toSeconds(1 bar)        // 1.875 at 128 BPM193let beatsInTenSeconds = toBeats(10s)     // 21.33 at 128 BPM194print(barSeconds, beatsInTenSeconds)195```196197## How values are displayed198199The console and the logs show values in a readable form: `-6 dB`, `-inf dB` for -60 dB and below, `800 Hz`, `12 kHz`, `4 beats`, `0.25 s`, `Deck A`.200201## Related202203- [Types](types.md)204- [Beats and Bars](beats-and-bars.md)205- [Timing](timing.md)206- [Language Syntax](syntax.md)207- [Effects Commands](effects-api.md)208- [Error Handling](errors.md)209
Files main
Menu

Theme