@hraness/dawg 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/DAWG.md +338 -51
  3. package/README.md +4 -4
  4. package/core/chords.ts +492 -4
  5. package/core/diff.ts +5 -0
  6. package/core/expression.ts +143 -6
  7. package/core/fx.ts +258 -6
  8. package/core/granular.ts +91 -0
  9. package/core/instruments.ts +161 -0
  10. package/core/keys.ts +573 -4
  11. package/core/resonators.ts +291 -3
  12. package/core/score.ts +349 -3
  13. package/core/sdk/print.ts +78 -3
  14. package/core/sdk/v1.ts +1320 -36
  15. package/core/sections.ts +12 -4
  16. package/core/strings.ts +237 -2
  17. package/core/winds.ts +652 -0
  18. package/guides/automation.md +1 -0
  19. package/guides/chords.md +3 -1
  20. package/guides/effects.md +3 -2
  21. package/guides/media.md +1 -1
  22. package/guides/performance.md +3 -0
  23. package/guides/resample.md +26 -0
  24. package/guides/sounds.md +7 -6
  25. package/package.json +1 -1
  26. package/src/agent/agent.ts +8 -2
  27. package/src/agent/chord-tools.ts +153 -1
  28. package/src/agent/expression-tools.ts +91 -0
  29. package/src/agent/ops.ts +4 -1
  30. package/src/agent/preview-tool.ts +2 -1
  31. package/src/agent/resample-tool.ts +131 -0
  32. package/src/agent/tools.ts +200 -15
  33. package/src/agent/xcb-agent.ts +8 -2
  34. package/src/audio/arrange.ts +21 -0
  35. package/src/audio/dsp/envelope.ts +161 -0
  36. package/src/audio/dsp/shift.ts +256 -0
  37. package/src/audio/effects/chain.ts +18 -3
  38. package/src/audio/effects/common.ts +14 -0
  39. package/src/audio/effects/convolution.ts +106 -1
  40. package/src/audio/effects/gaze.ts +354 -0
  41. package/src/audio/engine.ts +46 -5
  42. package/src/audio/fit.ts +45 -0
  43. package/src/audio/granular.ts +352 -21
  44. package/src/audio/instrument-check.ts +9 -5
  45. package/src/audio/instruments.ts +32 -3
  46. package/src/audio/keys/electric.ts +420 -0
  47. package/src/audio/keys/engine.ts +143 -19
  48. package/src/audio/keys/organ.ts +1335 -0
  49. package/src/audio/keys/piano.ts +50 -6
  50. package/src/audio/keys/sympathetic.ts +127 -0
  51. package/src/audio/live-worker.ts +3 -1
  52. package/src/audio/live.ts +136 -9
  53. package/src/audio/preview.ts +15 -1
  54. package/src/audio/resample.ts +285 -0
  55. package/src/audio/resonators.ts +10 -2
  56. package/src/audio/sampler.ts +168 -21
  57. package/src/audio/samples.ts +26 -1
  58. package/src/audio/strings/body.ts +29 -16
  59. package/src/audio/strings/bow.ts +656 -0
  60. package/src/audio/strings/engine.ts +266 -20
  61. package/src/audio/strings/measure.test-helpers.ts +2 -0
  62. package/src/audio/wav.ts +119 -19
  63. package/src/audio/winds/engine.ts +302 -0
  64. package/src/audio/winds/filters.ts +153 -0
  65. package/src/audio/winds/pitch.ts +104 -0
  66. package/src/audio/winds/trim.ts +80 -0
  67. package/src/audio/winds/trims.ts +917 -0
  68. package/src/audio/winds/voice.ts +479 -0
  69. package/src/commands/expression.ts +103 -22
  70. package/src/commands/fx.ts +4 -1
  71. package/src/commands/granular.ts +7 -2
  72. package/src/commands/help.ts +91 -8
  73. package/src/commands/keys.ts +287 -11
  74. package/src/commands/modal.ts +67 -4
  75. package/src/commands/resample.ts +281 -0
  76. package/src/commands/rig.ts +5 -1
  77. package/src/commands/sample.ts +49 -2
  78. package/src/commands/shift.ts +119 -0
  79. package/src/commands/string.ts +28 -2
  80. package/src/commands/strum.ts +473 -0
  81. package/src/commands/wind.ts +244 -0
  82. package/src/main.ts +129 -7
  83. package/src/project/check.ts +5 -1
  84. package/src/render.ts +16 -0
  85. package/src/session/presence.ts +16 -3
  86. package/src/tui/audition.ts +1 -1
  87. package/src/tui/menu.ts +637 -35
  88. package/src/tui/modal-menu.ts +34 -7
  89. package/src/tui/performance-menu.ts +42 -0
  90. package/src/tui/play-chords.ts +104 -3
  91. package/src/tui/play-mode.ts +1 -0
  92. package/src/tui/play-session.ts +34 -9
  93. package/src/tui/wind-menu.ts +144 -0
@@ -120,26 +120,39 @@ export function bodyFor(name: string, size: number): Body {
120
120
  /** Body over `x` in place: direct + modes, then a 10 Hz DC blocker. */
121
121
  export function applyBody(x: Float64Array, body: Body, sr: number): void {
122
122
  if (body.modes.length === 0 && body.direct === 1) return;
123
- const input = Float64Array.from(x);
124
- for (let i = 0; i < x.length; i += 1) x[i] = body.direct * input[i]!;
125
- for (const [f, q, g] of body.modes) {
126
- if (f >= 0.45 * sr) continue;
123
+ // Every mode per sample in one pass, summed in mode order (the same
124
+ // arithmetic as a pass per mode, so the output is bit-identical), with
125
+ // the coefficients in flat arrays: about 7x faster under JSC.
126
+ const live = body.modes.filter(([f]) => f < 0.45 * sr);
127
+ const m = live.length;
128
+ const B0 = new Float64Array(m);
129
+ const A1 = new Float64Array(m);
130
+ const A2 = new Float64Array(m);
131
+ const G = new Float64Array(m);
132
+ const Z1 = new Float64Array(m);
133
+ const Z2 = new Float64Array(m);
134
+ for (let k = 0; k < m; k += 1) {
135
+ const [f, q, g] = live[k]!;
127
136
  const w = (2 * Math.PI * f) / sr;
128
137
  const alpha = Math.sin(w) / (2 * q);
129
138
  const a0 = 1 + alpha;
130
- const b0 = alpha / a0;
131
- const b2 = -alpha / a0;
132
- const a1 = (-2 * Math.cos(w)) / a0;
133
- const a2 = (1 - alpha) / a0;
134
- let z1 = 0;
135
- let z2 = 0;
136
- for (let i = 0; i < x.length; i += 1) {
137
- const xi = input[i]!;
138
- const y = b0 * xi + z1;
139
- z1 = -a1 * y + z2;
140
- z2 = b2 * xi - a2 * y;
141
- x[i] = x[i]! + g * y;
139
+ B0[k] = alpha / a0;
140
+ A1[k] = (-2 * Math.cos(w)) / a0;
141
+ A2[k] = (1 - alpha) / a0;
142
+ G[k] = g;
143
+ }
144
+ const direct = body.direct;
145
+ for (let i = 0; i < x.length; i += 1) {
146
+ const xi = x[i]!;
147
+ let acc = direct * xi;
148
+ for (let k = 0; k < m; k += 1) {
149
+ const b0 = B0[k]!;
150
+ const y = b0 * xi + Z1[k]!;
151
+ Z1[k] = -A1[k]! * y + Z2[k]!;
152
+ Z2[k] = -b0 * xi - A2[k]! * y;
153
+ acc = acc + G[k]! * y;
142
154
  }
155
+ x[i] = acc;
143
156
  }
144
157
  const R = Math.exp((-2 * Math.PI * 10) / sr);
145
158
  let x1 = 0;