SPB Git

Repository Public

units.md 7.3 KB

# Units

In 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.

# All the units

Unit Written Type Meaning
Decibels -12dB gain Level relative to full scale or to the centre of a knob
Hertz 80Hz frequency
Kilohertz 12kHz frequency 1 kHz = 1000 Hz
Beats 1beat, 4beats, 4 beats duration (musical) One beat of the master clock
Bars 1bar, 8bars, 8 bars duration (musical) One bar = 4 beats
Fractions 1/4beat, 3/4beat, 3/2bars duration (musical) Numerator/denominator of a beat or a bar
Milliseconds 250ms duration (absolute)
Seconds 2s, 2sec duration (absolute)
Minutes 1min duration (absolute)
Percent 50% number The number divided by 100
BPM 128bpm number Readability only: 128bpm is 128
Semitones -2st number Readability only: -2st is -2

Units are case-sensitive: dB, Hz, kHz, ms. Anything else after a number is the error E-UNIT.

orixdj-error
wait 5parsecs
text
Unknown unit 'parsecs'. Units: Hz, kHz, dB, beat(s), bar(s), s, ms, min, bpm, st, %. [E-UNIT]

# Writing rules

  1. The unit touches the number. -12dB, 20Hz, 250ms, 50%.
  2. 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.
  3. 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.
  4. Singular and plural are interchangeable. 1beats and 4beat are accepted; write what reads well.

# Decibels

Decibels 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.

Value On a channel fader
0dB Full level
-6dB About half the amplitude
-12dB About a quarter
-60dB Silence

Each control has its own range; the reference lists them. The most used ones:

Control Range
deck.X.volume -60 dB … 0 dB
deck.X.gain (trim) -24 dB … 12 dB
deck.X.eq.low, eq.mid, eq.high -26 dB … 6 dB (-26 dB is a full kill)
mixer.master.volume -60 dB … 6 dB

Decibels add: turning something down by 3 dB twice is turning it down by 6 dB.

orixdj
let step = -3dB
deck.A.eq.high = step + step      // -6 dB
wait 1 bar
deck.A.eq.high = 0dB

A plain number or a percentage given to a gain control is read as a linear fader level (50% is about -6 dB). See Types.

# Hertz

Frequencies describe filter corners and modulation speeds.

Region Roughly
Sub and kick 20 Hz – 120 Hz
Bass and low mids 120 Hz – 500 Hz
Mids 500 Hz – 4 kHz
Highs 4 kHz – 20 kHz

For 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.

orixdj
deck.A.filter.highpass = 300Hz     // remove the bass
wait 2 bars
deck.A.filter.highpass = 20Hz      // off

# Beats and bars

Musical 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.

Written Beats In 4/4 notation
4 bars 16 Four bars
1 bar 4 One bar
2 beats 2 A half note
1 beat 1 A quarter note
1/2beat 0.5 An eighth note
1/4beat 0.25 A sixteenth note
3/4beat 0.75 A dotted eighth
1/3beat 0.333 An eighth-note triplet
3/2bars 6 A bar and a half

More in Beats and Bars.

# Seconds and milliseconds

Absolute 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.

orixdj
fx.reverb.predelay = 20ms          // an effect time in milliseconds
wait 2s                            // 4.27 beats at 128 BPM

Some 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.

orixdj
fx.delay.time = 1/2beat            // native unit: beats
fx.delay.time = 250ms              // converted to beats with the current tempo
fx.compressor.attack = 5ms         // native unit: milliseconds

# Percent

50% is the number 0.5. It reads well on controls that go from 0 to 1.

orixdj
fx.reverb.mix = 35%
mixer.crossfader = 100%
wait 1 bar
mixer.crossfader = 50%
fx.reverb.mix = 0%

# Traps

# Spaces in a fraction

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.

orixdj
wait 1/4beat
wait 1/4 beat

# %: percentage or remainder

% 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.

Written Read as
50% 0.5
50% * 2 0.5 × 2
7 % 4 remainder of 7 / 4, which is 3
7%4 remainder of 7 / 4, which is 3
count % 4 remainder (a name is on the left)

Put spaces around % when you mean the remainder and none before it when you mean percent.

# A number where a unit is required

orixdj-error
wait 4
text
'wait' needs a duration such as 4beats, 2bars or 500ms, not number. [E-TYPE]

# Mixing units of different types

-6dB + 200Hz is an error; so is 4 beats + 3. The message names the two types.

# s is seconds

2s is two seconds. There is no unit for samples or for bars written b.

# Converting between units

From To Use
number gain db(x)
number frequency hz(x)
number duration beats(x), bars(x), seconds(x)
gain, frequency number toNumber(x)
duration number of beats toBeats(d) (at the current tempo)
duration number of seconds toSeconds(d) (at the current tempo)
linear level 0…1 gain assign the number to a gain parameter
orixdj
let barSeconds = toSeconds(1 bar)        // 1.875 at 128 BPM
let beatsInTenSeconds = toBeats(10s)     // 21.33 at 128 BPM
print(barSeconds, beatsInTenSeconds)

# How values are displayed

The 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.

Files main
Menu

Theme