Skip to content

feat(@score/dsl): theory.ts — transpose(), relativeMinor(), dominantOf(), parallelMajor(), modeOf() (t240) #130

@bwyard

Description

@bwyard

Summary

Add five music theory utility functions to packages/dsl/src/theory.ts. These are used in song files to build progressions, transpose ideas, and explore harmonic relationships without memorising interval tables.

Expected API

import { scale, chord, transpose, relativeMinor, dominantOf } from '@score/dsl'

// Transpose a note or array of notes by semitones
transpose('A2', 7)           // → 'E3'
transpose(['C3','E3','G3'], 5) // → ['F3','A3','C4']

// Relative minor of a major key
relativeMinor('C')   // → 'A'
relativeMinor('G')   // → 'E'

// Dominant (V chord root) of a key
dominantOf('C')      // → 'G'
dominantOf('Am')     // → 'E'

// Parallel major of a minor key (same root, major mode)
parallelMajor('Am')  // → 'A'

// Mode of a scale
modeOf('C', 2)       // → 'D Dorian'
modeOf('C', 5)       // → 'G Mixolydian'

Where to make the change

  • packages/dsl/src/theory.ts — add the five functions
  • packages/dsl/src/index.ts — export them
  • packages/gui/src/renderer/types/score-dsl.d.ts — ambient declarations for Monaco

Notes

  • All functions are pure — same input, same output, no side effects
  • transpose should handle note strings like 'A2', 'C#3', 'Bb4'
  • Must ship with unit tests covering edge cases (sharps, flats, octave boundaries)
  • TSDoc required on all five exports

Good first issue — pure functions, well-defined music theory rules, no engine wiring needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions