Home Manual Reference Source Test

src/pipeline/step1parts.js

  1. import { Step } from "./step.js";
  2. /**
  3. * Step 1: macro-structure as a sequence of parts rho_1 ... rho_m.
  4. * Each rho_i is formally a 9-tuple (lambda, iota, zeta, eta, kappa, mu, pi, psi, omega);
  5. * Step 1 fills the first four (label, bars, numerator, denominator) plus global tempo.
  6. */
  7. export class Step1Parts extends Step {
  8. /**
  9. * @override
  10. * @return {Object[]} UI descriptors: parts (m), tempo, and fields 1-4 per part (rho).
  11. */
  12. schema() {
  13. return SCHEMA;
  14. }
  15. }
  16. /** @private */
  17. const SCHEMA = [
  18. {
  19. name: "parts",
  20. type: "stepper",
  21. label: "Number of Parts",
  22. tooltip: "Number of musical sections (e.g. A-B-A)",
  23. default: 1,
  24. min: 1,
  25. max: 5,
  26. },
  27. {
  28. name: "tempo",
  29. type: "int",
  30. label: "Tempo",
  31. tooltip: "Playback speed (MIDI BPM, always based on quarter notes)",
  32. default: 120,
  33. min: 30,
  34. max: 210,
  35. step: 1,
  36. format: (v) => `${v} <abbr title="Beats Per Minute">BPM</abbr>`,
  37. },
  38. {
  39. name: "part",
  40. type: "nested",
  41. label: "Part",
  42. tooltip: "Same label => copied part",
  43. firstColumn: {
  44. type: "select",
  45. key: "label",
  46. options: ["A", "B", "C", "D", "E"],
  47. },
  48. counter: "parts",
  49. defaults: ["A", "B", "A", "C", "A"].map((label) => ({
  50. label,
  51. bars: { B: 5, C: 6 }[label] ?? 4,
  52. numerator: 4,
  53. denominator: 4,
  54. })),
  55. template: [
  56. {
  57. name: "bars",
  58. type: "int",
  59. label: "Bars",
  60. tooltip: "Number of measures in this part",
  61. default: 4,
  62. min: 2,
  63. max: 16,
  64. },
  65. {
  66. name: "numerator",
  67. type: "int",
  68. label: "Beats/Bar",
  69. tooltip: "e.g. 3 (beats) in 3/4 time",
  70. default: 4,
  71. min: 1,
  72. max: 12,
  73. },
  74. {
  75. name: "denominator",
  76. type: "select",
  77. label: "Beat Value",
  78. tooltip: "e.g. 4 (quarter note) in 3/4 time",
  79. default: 4,
  80. options: [1, 2, 4, 8, 16, 32],
  81. labels: [
  82. "1 (whole note)",
  83. "2 (half note)",
  84. "4 (quarter note)",
  85. "8 (eighth note)",
  86. "16 (sixteenth note)",
  87. "32 (thirty-second note)",
  88. ],
  89. },
  90. ],
  91. },
  92. ];