theHarmonicAlgorithm-3.1.0: Real-time harmonic progression generation for TidalCycles live performance
Safe HaskellNone
LanguageGHC2021

Harmonic.Framework.Builder.Modifiers

Description

Every name here is a pure record construction or update over GenConfig: the family entrypoints (gen/genE/genP/genJ and their verbosity primes), the regeneration entrypoints (genFrom family), and the modifier chain (cue, len, entropy, tonal, attempt, …). No IO beyond the deferred cue draw, no music theory — execution lives behind seek in the facade.

Synopsis

Documentation

defaultGenConfig :: GenConfig Source #

Default generation configuration.

cue:     random root, major triad — but an uncued run resolves its cue
         context-aware at run time: inside the tonal context for gen /
         genE / grid (tonalStartCue),
         from the stratum for genP, from the Change graph for genJ
len:     4
seek:    "*" (all composers)
entropy: 0.2
tonal:   hContext (chromatic)

gen :: GenConfig Source #

Generation config with header + grid output (default).

s <- seek "*" $ gen
s <- seek "*" $ cue start $ tonal ctx $ len 4 $ entropy 0.3 $ gen

gen' :: GenConfig Source #

Generation config with compact musical summary.

gen'' :: GenConfig Source #

Generation config with verbose diagnostic traces.

genGrid :: GenConfig Source #

Static grid: repeats the cue chord for len bars. No database access.

s <- seek "*" $ cue start $ len 4 $ genGrid

genGrid' :: GenConfig Source #

genGrid with compact musical summary.

genGrid'' :: GenConfig Source #

genGrid with verbose diagnostic traces.

genE :: GenConfig Source #

The genE paradigm: polytonal three-layer generation. The T layer is a foundation walk byte-identical to gen (all R constraints apply to it alone — the foundation owns the bass); the S/M layers are partner triad chains, each a corpus-valid walk of its own, sharing exactly 2 pitch classes with the foundation per bar and unioning to exactly 5. The traversal chooses freely per bar between the two admitted geometries — common-dyad (every layer pair sounds 4 tones) and base-anchored (pairs with the foundation sound 4, S+M sounds the pentad). Partners honour key/roots/overtones but never direction specs or strata machinery. Combine layers at the pattern surface via the Layer selectors (TS/TM/SM/TSM/PT). Cues are triadic.

s <- seek "*" $ len 8 $ entropy 0.3 $ genE'

genE' :: GenConfig Source #

genE with compact musical summary (per-bar layer table).

genE'' :: GenConfig Source #

genE with verbose diagnostic traces (adds partner pool/tier trace).

genJ :: GenConfig Source #

Generate over the jazz (Change) graph: the genJ family. Same modifier chain as gen (seek "*" $ cue start $ len 8 $ entropy 0.3 $ genJ); the seek spec resolves against BOTH corpora (see Harmonic.Framework.Builder.JazzGen for the full semantics: jazz names blend, classical names steer via the steer dial, "*" walks the whole corpus, "none" is refused — the jazz graph has no offline mode). Progressions carry variable-arity chords (3-6 tones) straight from the corpus vocabulary, stamped FJazz so genFrom regenerates them jazz-natively and attempt ranks them against the Change graph. tonal constraints apply through the same R filter as every family; a step they empty is relaxed with a notice (there is deliberately no fallback pool).

genJ' :: GenConfig Source #

genJ with Standard per-step trace (walk steps, pool sizes, picks).

genJ'' :: GenConfig Source #

genJ with Verbose trace (adds seek resolution and steer notices).

genFrom :: ProgressionContext -> Int -> Int -> GenConfig Source #

Regenerate a range of bars within an existing progression. The cue is inferred from the bar before the start position (wrapping). A cue override applies to every family EXCEPT FStrata: the strata regen must seed from the source's own bar to keep the walk-graph seam valid, so it ignores the override.

FAMILY-AWARE: regeneration produces states of the family the source progression already is — families never mix. The one downgrade is deliberate: hand-built extended (FExtended) sources regenerate as triads (with a printed notice), so the result re-infers as mixed material rather than pretending the fusion family still exists.

  • pcProvenance = Just _ — strata-aware path: regenerates all three layers + provenance in lockstep, with one-step lookahead at the e → e+1 seam to keep the spliced bar sequence walk-graph valid under allowedNext.
  • FPoly (genE source) — polytonal path: regenerates the foundation range plus both partner chains, seeded from the kept partner bars before the range; the S/M labelling of the source is preserved (chains are never reordered by a partial regen).
  • uniform 4-note hand-built material — regenerated bars come back as plain triads with a printed notice.
  • uniform 3-note (gen source) — plain triad regen.
  • hand-mixed cardinalities — regenerated as plain triads with a printed notice (hand-mixed material is the human aberration channel; regen does not amplify it).

s' <- seek "*" $ entropy 0.3 $ genFrom s 2 3 s' <- seek "*" $ cue start $ genFrom s 2 3 -- override inferred cue s' <- seek "*" $ len 6 $ genFrom s 2 3 -- expand range s' <- seek "*" $ genFrom' s 2 3 -- Standard per-step trace s' <- seek "*" $ genFrom'' s 2 3 -- Verbose trace (+ scoreboard with attempt)

genFrom' :: ProgressionContext -> Int -> Int -> GenConfig Source #

Standard-verbosity alias of genFrom. Mirrors gen', genP' and genI'.

genFrom'' :: ProgressionContext -> Int -> Int -> GenConfig Source #

Verbose-verbosity alias of genFrom. Mirrors gen'', genP'' and genI''.

cue :: CadenceState -> GenConfig -> GenConfig Source #

Set starting state.

s <- seek "*" $ cue start $ gen

len :: Int -> GenConfig -> GenConfig Source #

Set progression length (number of chords).

s <- seek "*" $ len 8 $ gen

entropy :: Double -> GenConfig -> GenConfig Source #

Set entropy (>= 0) — the gamma sampler targets rank entropy * 10 in the scored pool, so 0 usually takes the top candidate, 0.5 wanders around the 5th, 1 around the 10th; values above 1 reach deeper still.

s <- seek "*" $ entropy 0.5 $ gen

steer :: Double -> GenConfig -> GenConfig Source #

Set the genJ classical-steer boost strength (default 3.0). Applies only when the seek spec names classical composers: a jazz candidate containing one of the steer blend's top recommended triads has its score multiplied by up to (1 + strength). 0 disables steering influence entirely. Initial calibration — tune by ear.

s <- seek "debussy" $ steer 6 $ len 8 $ genJ'

attempt :: Int -> Int -> GenConfig -> GenConfig Source #

Run multi-attempt rank-and-select generation: produce up to maxAttempts candidate progressions, stop early once viableTarget viable attempts (all bars ModeOk) have been collected, then return the highest-scoring one. Scoring blends root motion, voice leading, and mode validity via defaultWeightsOffline.

s <- seek "*" $ attempt 3 24 $ entropy 0.4 $ gen -- best of up to 24

Polytonal (genE) attempts rank differently, because they are three progressions rather than one: each layer is scored in its own right (half the weight on the foundation, a quarter on each partner) and a divergence axis rewards the layers standing apart — the point of the family. See PolyScore. Raising maxAttempts raises both the quality and the divergence of what comes back.

Defaults are attempt 1 1 — i.e. the modifier is a no-op when omitted, preserving legacy single-pass behaviour.

viability :: Double -> GenConfig -> GenConfig Source #

Set the viability quality floor used by attempt. An attempt is viable iff psModeValidity >= 1.0 (structural invariant) and totalScore >= floor. Default is 0.5; passing 0.0 recovers the original structural-only viability.

s <- seek "*" $ viability 0.65 $ attempt 3 24 $ gen

Tune downward if attempt N K frequently fails to collect N viable within K (raise K or lower the floor); tune upward if K is being hit consistently with mediocre-quality picks (lower K or raise the floor).

tonal :: HarmonicContext -> GenConfig -> GenConfig Source #

Set harmonic context (R constraints).

s <- seek "*" $ tonal (hcKey "0#" $ hContext) $ gen

relStrata :: String -> GenConfig -> GenConfig Source #

Per-bar position within the dynamically-changing active tristrata. Elements ∈ {1,2,3} cycle circularly. Sets _gcLenOverride to the parsed list length so _gcLen doesn't need to be set explicitly; len applied later clears the override (last-writer-wins).

s <- seek "none" $ relStrata "1 1 2 2 3 3" $ genVI -- 6 bars

absStrata :: String -> GenConfig -> GenConfig Source #

Per-bar absolute strata label across all tristratas. Elements are Roman numerals I..XI cycling circularly. Sets _gcLenOverride to the parsed list length.

s <- seek "none" $ absStrata "I V X" $ genI -- 3 bars

sameBoost :: Double -> GenConfig -> GenConfig Source #

Override the same-strata continuity boost multiplier. Values below 1.0 favour candidates whose strata matches the previous bar's. Default 0.90. Pass 1.0 to disable the bias.

s <- seek "none" $ sameBoost 0.5 $ genVI -- strong same-strata pull

flipBoost :: Double -> GenConfig -> GenConfig Source #

Override the flip-flop boost multiplier (candidates matching the grandparent strata when the current /= previous). Default 0.80.

triBoost :: Double -> GenConfig -> GenConfig Source #

Override the same-tristrata continuity boost multiplier. Values below 1.0 favour candidates whose active tristrata matches the previous bar's. Default 0.70 (strongest of the three).

genP :: StrataLabel -> GenConfig Source #

Strata-first generation entrypoint. Seeded by a StrataLabel; produces a ProgressionContext with distinct triad, strata, and mode layers and pcProvenance = Just ….

Uncued, the starting chord is drawn from inside the stratum itself — a five-tone set admits few triads, and the ordinary whole-corpus cue almost never lands in one. A cue you pass with cue is honoured as given; one that escapes the stratum is reported with the triads that would have fitted, rather than silently replaced.

s <- seek "none" $ len 6 $ genP VI s <- seek "none" $ cue start $ len 6 $ genP VI

genP' :: StrataLabel -> GenConfig Source #

Standard-verbosity variant of genP.

genP'' :: StrataLabel -> GenConfig Source #

Verbose-verbosity variant of genP.

genI :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genII :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genIII :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genIV :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genV :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genVI :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genVII :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genVIII :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genIX :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genX :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genXI :: GenConfig Source #

Silent-verbosity genP aliases, one per Roman numeral — genI pins the starting tristrata to I, genII to II, and so on through genXI.

s <- seek "*" $ attempt 3 12 $ entropy 0.4 $ genI

Three verbosities throughout, by the usual prime convention: genI silent, genI' standard, genI'' verbose.

genI' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genII' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genIII' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genIV' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genV' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genVI' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genVII' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genVIII' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genIX' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genX' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genXI' :: GenConfig Source #

Standard-verbosity Roman numeral aliases: per-step musical context plus the grid. See genI.

genI'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genII'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genIII'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genIV'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genV'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genVI'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genVII'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genVIII'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genIX'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genX'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.

genXI'' :: GenConfig Source #

Verbose-verbosity Roman numeral aliases: full traces, the grid, and the multi-attempt scoreboard when paired with attempt. See genI.