# Copyright (c) 2026 Nenad Micic
# SPDX-License-Identifier: Apache-2.0
#
# Scale-lock presets and scoped randomization tables.
# compose.py loads these values once at import.
#
# One statement a line; blank lines and lines starting with # are ignored.
#
#   scale NAME MASK      a scale-lock preset: bit k of MASK (1 to 4095) is the
#                        pitch class root + k, so the root's own class is bit 0
#                        (scale_lock in compose.py; gen_quantize's mask, rotated)
#   preset NAME AMOUNT   a randomize_scoped amount, 0 to 100 percent
#   scope NAME ARG ...   a randomize_scoped scope: the op arguments it moves on
#                        every operator whose field the engine reads (ignored)
#   span ARG UNITS       an additive argument's span at amount 100, in the
#                        record's units: the delta is (2u - 1) x amount / 100 x
#                        UNITS, rounded half up to a whole unit (a, d and r scale
#                        by 2^((2u - 1) x amount / 100) instead; ratio draws from
#                        a given set)
#   field K NAME         field NAME (a recipe tweak) draws from stream K:
#                        append-only, a number never reused or moved, so adding
#                        a field moves no other field's draws
#
# Thirty named scales, encoded as pitch-class masks.

scale major                 2741  # 0,2,4,5,7,9,11
scale minor                 1453  # 0,2,3,5,7,8,10
scale harmonic-minor        2477  # 0,2,3,5,7,8,11
scale melodic-minor         2733  # 0,2,3,5,7,9,11
scale dorian                1709  # 0,2,3,5,7,9,10
scale phrygian              1451  # 0,1,3,5,7,8,10
scale lydian                2773  # 0,2,4,6,7,9,11
scale mixolydian            1717  # 0,2,4,5,7,9,10
scale locrian               1387  # 0,1,3,5,6,8,10
scale major-pentatonic      661   # 0,2,4,7,9
scale minor-pentatonic      1193  # 0,3,5,7,10
scale blues                 1257  # 0,3,5,6,7,10
scale major-blues           669   # 0,2,3,4,7,9
scale whole-tone            1365  # 0,2,4,6,8,10
scale diminished-hw         1755  # 0,1,3,4,6,7,9,10
scale diminished-wh         2925  # 0,2,3,5,6,8,9,11
scale harmonic-major        2485  # 0,2,4,5,7,8,11
scale phrygian-dominant     1459  # 0,1,4,5,7,8,10
scale lydian-dominant       1749  # 0,2,4,6,7,9,10
scale altered               1371  # 0,1,3,4,6,8,10
scale hungarian-minor       2509  # 0,2,3,6,7,8,11
scale double-harmonic       2483  # 0,1,4,5,7,8,11
scale neapolitan-minor      2475  # 0,1,3,5,7,8,11
scale neapolitan-major      2731  # 0,1,3,5,7,9,11
scale hirajoshi             397   # 0,2,3,7,8
scale in-sen                1187  # 0,1,5,7,10
scale suspended-pentatonic  1189  # 0,2,5,7,10
scale bebop-dominant        3765  # 0,2,4,5,7,9,10,11
scale bebop-major           2997  # 0,2,4,5,7,8,9,11
scale chromatic             4095  # 0..11

# Randomization amounts: mild and aggressive.
preset mild 15
preset aggressive 60

# Randomization scopes. 'all' is the union of operators and envelopes.
# Algorithm, filter and matrix randomization are unsupported.
scope operators ratio level index fb vel
scope envelopes a d s r
scope all ratio level index fb vel a d s r

# Randomization spans: level and s 12 dB, index 2 rad, fb 1 rad,
# vel 64, in level_db10, sustain_db10, index_q10, feedback_q10 and vel_sens_q8.
span level 120
span s 120
span index 2048
span fb 1024
span vel 64

# The fields and their streams: the carrier (c), the modulator (m) and a
# routed recipe's operators 2 and 3 (o2, o3).
field 0  c_ratio
field 1  c_level
field 2  c_index
field 3  c_fb
field 4  c_vel
field 5  c_a
field 6  c_d
field 7  c_s
field 8  c_r
field 9  m_ratio
field 10 m_level
field 11 m_index
field 12 m_fb
field 13 m_vel
field 14 m_a
field 15 m_d
field 16 m_s
field 17 m_r
field 18 o2_ratio
field 19 o2_level
field 20 o2_index
field 21 o2_fb
field 22 o2_vel
field 23 o2_a
field 24 o2_d
field 25 o2_s
field 26 o2_r
field 27 o3_ratio
field 28 o3_level
field 29 o3_index
field 30 o3_fb
field 31 o3_vel
field 32 o3_a
field 33 o3_d
field 34 o3_s
field 35 o3_r
