takomusic 3.1.0 → 5.0.0

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 (196) hide show
  1. package/README.md +89 -59
  2. package/dist/__tests__/evaluator.test.d.ts +2 -0
  3. package/dist/__tests__/evaluator.test.d.ts.map +1 -0
  4. package/dist/__tests__/evaluator.test.js +648 -0
  5. package/dist/__tests__/evaluator.test.js.map +1 -0
  6. package/dist/__tests__/helpers/testUtils.d.ts +64 -0
  7. package/dist/__tests__/helpers/testUtils.d.ts.map +1 -0
  8. package/dist/__tests__/helpers/testUtils.js +178 -0
  9. package/dist/__tests__/helpers/testUtils.js.map +1 -0
  10. package/dist/__tests__/lexer.test.d.ts +2 -0
  11. package/dist/__tests__/lexer.test.d.ts.map +1 -0
  12. package/dist/__tests__/lexer.test.js +414 -0
  13. package/dist/__tests__/lexer.test.js.map +1 -0
  14. package/dist/__tests__/parser.test.d.ts +2 -0
  15. package/dist/__tests__/parser.test.d.ts.map +1 -0
  16. package/dist/__tests__/parser.test.js +579 -0
  17. package/dist/__tests__/parser.test.js.map +1 -0
  18. package/dist/__tests__/stdlib.test.d.ts +2 -0
  19. package/dist/__tests__/stdlib.test.d.ts.map +1 -0
  20. package/dist/__tests__/stdlib.test.js +551 -0
  21. package/dist/__tests__/stdlib.test.js.map +1 -0
  22. package/dist/__tests__/typecheck.test.d.ts +2 -0
  23. package/dist/__tests__/typecheck.test.d.ts.map +1 -0
  24. package/dist/__tests__/typecheck.test.js +314 -0
  25. package/dist/__tests__/typecheck.test.js.map +1 -0
  26. package/dist/__tests__/v3.compiler.test.js +1 -1
  27. package/dist/__tests__/v3.compiler.test.js.map +1 -1
  28. package/dist/__tests__/v4.compiler.test.d.ts +2 -0
  29. package/dist/__tests__/v4.compiler.test.d.ts.map +1 -0
  30. package/dist/__tests__/v4.compiler.test.js +192 -0
  31. package/dist/__tests__/v4.compiler.test.js.map +1 -0
  32. package/dist/ast.d.ts +128 -5
  33. package/dist/ast.d.ts.map +1 -1
  34. package/dist/browser/index.d.ts +70 -0
  35. package/dist/browser/index.d.ts.map +1 -0
  36. package/dist/browser/index.js +336 -0
  37. package/dist/browser/index.js.map +1 -0
  38. package/dist/browser/virtualFs.d.ts +56 -0
  39. package/dist/browser/virtualFs.d.ts.map +1 -0
  40. package/dist/browser/virtualFs.js +3186 -0
  41. package/dist/browser/virtualFs.js.map +1 -0
  42. package/dist/cli/colors.d.ts +47 -0
  43. package/dist/cli/colors.d.ts.map +1 -0
  44. package/dist/cli/colors.js +92 -0
  45. package/dist/cli/colors.js.map +1 -0
  46. package/dist/cli/commands/build.d.ts.map +1 -1
  47. package/dist/cli/commands/build.js +61 -6
  48. package/dist/cli/commands/build.js.map +1 -1
  49. package/dist/cli/commands/check.d.ts.map +1 -1
  50. package/dist/cli/commands/check.js +22 -12
  51. package/dist/cli/commands/check.js.map +1 -1
  52. package/dist/cli/commands/fmt.d.ts +2 -0
  53. package/dist/cli/commands/fmt.d.ts.map +1 -0
  54. package/dist/cli/commands/fmt.js +115 -0
  55. package/dist/cli/commands/fmt.js.map +1 -0
  56. package/dist/cli/commands/init.js +4 -4
  57. package/dist/cli/commands/install.d.ts +2 -0
  58. package/dist/cli/commands/install.d.ts.map +1 -0
  59. package/dist/cli/commands/install.js +201 -0
  60. package/dist/cli/commands/install.js.map +1 -0
  61. package/dist/cli/commands/lsp.d.ts +2 -0
  62. package/dist/cli/commands/lsp.d.ts.map +1 -0
  63. package/dist/cli/commands/lsp.js +15 -0
  64. package/dist/cli/commands/lsp.js.map +1 -0
  65. package/dist/cli/commands/render.js +2 -2
  66. package/dist/cli/commands/repl.d.ts +2 -0
  67. package/dist/cli/commands/repl.d.ts.map +1 -0
  68. package/dist/cli/commands/repl.js +338 -0
  69. package/dist/cli/commands/repl.js.map +1 -0
  70. package/dist/cli/commands/watch.d.ts +2 -0
  71. package/dist/cli/commands/watch.d.ts.map +1 -0
  72. package/dist/cli/commands/watch.js +220 -0
  73. package/dist/cli/commands/watch.js.map +1 -0
  74. package/dist/cli/errorHandler.d.ts +16 -0
  75. package/dist/cli/errorHandler.d.ts.map +1 -1
  76. package/dist/cli/errorHandler.js +50 -3
  77. package/dist/cli/errorHandler.js.map +1 -1
  78. package/dist/cli/index.js +29 -3
  79. package/dist/cli/index.js.map +1 -1
  80. package/dist/cli/richFormatter.d.ts +29 -0
  81. package/dist/cli/richFormatter.d.ts.map +1 -0
  82. package/dist/cli/richFormatter.js +157 -0
  83. package/dist/cli/richFormatter.js.map +1 -0
  84. package/dist/cli/sourceSnippet.d.ts +51 -0
  85. package/dist/cli/sourceSnippet.d.ts.map +1 -0
  86. package/dist/cli/sourceSnippet.js +291 -0
  87. package/dist/cli/sourceSnippet.js.map +1 -0
  88. package/dist/compiler.d.ts +1 -1
  89. package/dist/compiler.d.ts.map +1 -1
  90. package/dist/compiler.js +148 -9
  91. package/dist/compiler.js.map +1 -1
  92. package/dist/diagnostics.d.ts +64 -1
  93. package/dist/diagnostics.d.ts.map +1 -1
  94. package/dist/diagnostics.js +67 -2
  95. package/dist/diagnostics.js.map +1 -1
  96. package/dist/errors.d.ts +70 -21
  97. package/dist/errors.d.ts.map +1 -1
  98. package/dist/errors.js +189 -54
  99. package/dist/errors.js.map +1 -1
  100. package/dist/evaluator.d.ts +23 -7
  101. package/dist/evaluator.d.ts.map +1 -1
  102. package/dist/evaluator.js +911 -19
  103. package/dist/evaluator.js.map +1 -1
  104. package/dist/export/index.d.ts +5 -0
  105. package/dist/export/index.d.ts.map +1 -0
  106. package/dist/export/index.js +5 -0
  107. package/dist/export/index.js.map +1 -0
  108. package/dist/export/musicxml.d.ts +21 -0
  109. package/dist/export/musicxml.d.ts.map +1 -0
  110. package/dist/export/musicxml.js +518 -0
  111. package/dist/export/musicxml.js.map +1 -0
  112. package/dist/formatter.d.ts +17 -0
  113. package/dist/formatter.d.ts.map +1 -0
  114. package/dist/formatter.js +456 -0
  115. package/dist/formatter.js.map +1 -0
  116. package/dist/import/index.d.ts +5 -0
  117. package/dist/import/index.d.ts.map +1 -0
  118. package/dist/import/index.js +5 -0
  119. package/dist/import/index.js.map +1 -0
  120. package/dist/import/midi.d.ts +28 -0
  121. package/dist/import/midi.d.ts.map +1 -0
  122. package/dist/import/midi.js +589 -0
  123. package/dist/import/midi.js.map +1 -0
  124. package/dist/index.d.ts +4 -4
  125. package/dist/index.js +4 -4
  126. package/dist/ir.d.ts +36 -2
  127. package/dist/ir.d.ts.map +1 -1
  128. package/dist/lexer.d.ts +5 -1
  129. package/dist/lexer.d.ts.map +1 -1
  130. package/dist/lexer.js +60 -6
  131. package/dist/lexer.js.map +1 -1
  132. package/dist/lsp/server.d.ts +11 -0
  133. package/dist/lsp/server.d.ts.map +1 -0
  134. package/dist/lsp/server.js +595 -0
  135. package/dist/lsp/server.js.map +1 -0
  136. package/dist/normalize.d.ts.map +1 -1
  137. package/dist/normalize.js +16 -1
  138. package/dist/normalize.js.map +1 -1
  139. package/dist/package/manager.d.ts +87 -0
  140. package/dist/package/manager.d.ts.map +1 -0
  141. package/dist/package/manager.js +267 -0
  142. package/dist/package/manager.js.map +1 -0
  143. package/dist/parser.d.ts +25 -1
  144. package/dist/parser.d.ts.map +1 -1
  145. package/dist/parser.js +663 -36
  146. package/dist/parser.js.map +1 -1
  147. package/dist/runtime.d.ts +35 -2
  148. package/dist/runtime.d.ts.map +1 -1
  149. package/dist/runtime.js +3 -0
  150. package/dist/runtime.js.map +1 -1
  151. package/dist/schema/validator.js +1 -1
  152. package/dist/scope.d.ts +5 -0
  153. package/dist/scope.d.ts.map +1 -1
  154. package/dist/scope.js +46 -2
  155. package/dist/scope.js.map +1 -1
  156. package/dist/suggestions.d.ts +37 -0
  157. package/dist/suggestions.d.ts.map +1 -0
  158. package/dist/suggestions.js +129 -0
  159. package/dist/suggestions.js.map +1 -0
  160. package/dist/temp_render.tako.score.json +11655 -0
  161. package/dist/token.d.ts +20 -0
  162. package/dist/token.d.ts.map +1 -1
  163. package/dist/token.js +34 -0
  164. package/dist/token.js.map +1 -1
  165. package/dist/typecheck.d.ts.map +1 -1
  166. package/dist/typecheck.js +473 -55
  167. package/dist/typecheck.js.map +1 -1
  168. package/dist/utils/stdlib.d.ts +1 -1
  169. package/dist/utils/stdlib.d.ts.map +1 -1
  170. package/dist/utils/stdlib.js +7 -0
  171. package/dist/utils/stdlib.js.map +1 -1
  172. package/dist/validation.d.ts.map +1 -1
  173. package/dist/validation.js +56 -3
  174. package/dist/validation.js.map +1 -1
  175. package/dist/value-codec.d.ts.map +1 -1
  176. package/dist/value-codec.js +76 -0
  177. package/dist/value-codec.js.map +1 -1
  178. package/docs/schemas/IR_V3.schema.json +727 -0
  179. package/docs/schemas/IR_V4.schema.json +873 -0
  180. package/docs/schemas/PROFILE_V3.schema.json +100 -0
  181. package/lib/articulations.mf +284 -0
  182. package/lib/core.mf +489 -8
  183. package/lib/curves.mf +266 -1
  184. package/lib/drums.mf +1 -1
  185. package/lib/dynamics.mf +266 -0
  186. package/lib/ornament.mf +652 -0
  187. package/lib/pedal.mf +142 -0
  188. package/lib/random.mf +1 -1
  189. package/lib/result.mf +78 -0
  190. package/lib/rhythm.mf +977 -0
  191. package/lib/theory.mf +1035 -1
  192. package/lib/time.mf +1 -1
  193. package/lib/transform.mf +3 -3
  194. package/lib/tuning.mf +503 -0
  195. package/lib/vocal.mf +155 -15
  196. package/package.json +6 -3
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # TakoMusic (Tako v3)
1
+ # TakoMusic (v4)
2
2
 
3
3
  TakoMusic is a music composition DSL that evaluates to a neutral `Score` IR and renders via external plugins.
4
- The v3 design keeps the language core backend-agnostic and pushes sound binding to Render Profiles.
4
+ The language core is backend-agnostic and pushes sound binding to Render Profiles.
5
5
 
6
6
  ## Highlights
7
7
 
@@ -9,114 +9,144 @@ The v3 design keeps the language core backend-agnostic and pushes sound binding
9
9
  - Rational time model (Dur/Pos) without ticks
10
10
  - Abstract sounds + render profiles decouple composition from output
11
11
  - Renderer Plugin protocol: `capabilities` / `validate` / `render`
12
+ - Web Playground with real-time audio preview
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Install
18
+ npm install -g takomusic
19
+
20
+ # Build a single file (no config needed)
21
+ mf build song.mf
22
+
23
+ # Or initialize a project
24
+ mf init
25
+ mf build
26
+ mf render
27
+ ```
28
+
29
+ ## Demo Song
30
+
31
+ Check out `examples/cyberpunk_drive.mf` - a complete synthwave track demonstrating TakoMusic's capabilities:
32
+
33
+ - 64 bars, 8 tracks, 128 BPM
34
+ - Drums, bass, arpeggios, pads, and lead melody
35
+ - Uses std:core, std:transform, std:theory, std:drums
36
+
37
+ ```bash
38
+ # Build and render the demo
39
+ mf build examples/cyberpunk_drive.mf
40
+ mf render examples/cyberpunk_drive.mf.score.json -p profiles/midi.mf.profile.json
41
+ ```
12
42
 
13
43
  ## Documentation
14
44
 
45
+ **Web Documentation**: https://takomusic.pages.dev (includes Playground)
46
+
47
+ Local documentation:
15
48
  - Language spec: `docs/LANGUAGE.md`
16
49
  - Core DSL & built-ins: `docs/BUILTINS.md`
17
50
  - Standard library: `docs/STDLIB.md`
18
51
  - Rendering and plugins: `docs/RENDERING.md`
19
52
  - Schemas: `docs/SCHEMAS.md`
20
- - Plan: `PLAN.md`
21
-
22
- ## Status
23
-
24
- The v3 core compiler/evaluator, IR normalization, and renderer plugin host are implemented. `mf render` requires an external renderer plugin to be installed.
25
53
 
26
54
  ## Example (.mf)
27
55
 
28
56
  ```tako
29
57
  import { concat, repeat } from "std:core";
30
- import * as transform from "std:transform";
31
- import * as curves from "std:curves";
32
- import * as vocal from "std:vocal";
33
- import * as drums from "std:drums";
58
+ import { kick, snare, hhc } from "std:drums";
59
+ import { majorTriad, minorTriad } from "std:theory";
34
60
 
35
- fn motif() -> Clip {
61
+ fn drumPart() -> Clip {
36
62
  return clip {
37
- note(C4, q, vel: 0.7);
38
- note(E4, q, vel: 0.72);
39
- note(G4, h, vel: 0.75);
63
+ hit(kick, q, vel: 0.9);
64
+ hit(hhc, e, vel: 0.5);
65
+ hit(hhc, e, vel: 0.5);
66
+ hit(snare, q, vel: 0.85);
67
+ hit(hhc, q, vel: 0.5);
40
68
  };
41
69
  }
42
70
 
43
- fn synthPart() -> Clip {
44
- const up = transform.transpose(motif(), 12);
45
- return concat(motif(), up);
46
- }
47
-
48
- fn vocalPart() -> Clip {
49
- let c = clip {
50
- note(A3, q, vel: 0.75);
51
- note(B3, q, vel: 0.76);
52
- note(C4, h, vel: 0.78);
71
+ fn chords() -> Clip {
72
+ return clip {
73
+ chord(majorTriad(C4), w, vel: 0.6);
74
+ chord(minorTriad(A3), w, vel: 0.6);
75
+ chord(majorTriad(F3), w, vel: 0.6);
76
+ chord(majorTriad(G3), w, vel: 0.6);
53
77
  };
54
-
55
- const lyr = vocal.syllables(["star", "light", vocal.Ext], "en-US");
56
- c = vocal.align(c, lyr);
57
- c = vocal.vibrato(c, depth: 0.2, rate: 5.5);
58
- return vocal.loudness(c, curves.easeInOut(0.2, 0.8, 4), start: 0 / 1, end: q * 4);
59
78
  }
60
79
 
61
80
  export fn main() -> Score {
62
- const section = match (2) {
63
- 1 -> "Intro";
64
- 2 -> "Verse";
65
- else -> "Outro";
66
- };
67
-
68
81
  return score {
69
- meta { title "Starlight"; }
82
+ meta { title "Simple Song"; }
70
83
 
71
84
  meter { 1:1 -> 4/4; }
72
- tempo { 1:1 -> 110bpm; }
73
- marker(1:1, "section", section);
74
-
75
- sound "synth" kind instrument { label "Synth"; range C2..C6; }
76
- sound "lead_vocal" kind vocal { vocal { lang "en-US"; range A3..E5; } }
77
- sound "kit_standard" kind drumKit {
78
- drumKeys { kick; snare; hhc; hho; crash; ride; }
79
- }
85
+ tempo { 1:1 -> 120bpm; }
80
86
 
81
- track "Synth" role Instrument sound "synth" {
82
- place 1:1 repeat(synthPart(), 2);
87
+ sound "piano" kind instrument { range A0..C8; }
88
+ sound "kit" kind drumKit {
89
+ drumKeys { kick; snare; hhc; }
83
90
  }
84
91
 
85
- track "Drums" role Drums sound "kit_standard" {
86
- place 1:1 drums.basicRock(2, q);
92
+ track "Piano" role Instrument sound "piano" {
93
+ place 1:1 repeat(chords(), 2);
87
94
  }
88
95
 
89
- track "Vocal" role Vocal sound "lead_vocal" {
90
- place 1:1 vocalPart();
96
+ track "Drums" role Drums sound "kit" {
97
+ place 1:1 repeat(drumPart(), 8);
91
98
  }
92
99
  };
93
100
  }
94
101
  ```
95
102
 
96
- ## Pipeline (v3)
103
+ ## Pipeline
97
104
 
98
105
  1. Parse `.mf` -> AST
99
106
  2. Resolve/import + typecheck (Pos/Dur separation)
100
107
  3. Evaluate `main()` -> `Score`
101
108
  4. Normalize IR (bar:beat -> absolute Pos)
102
- 5. Emit `score.json` (IR v3)
109
+ 5. Emit `score.json` (IR v4)
103
110
  6. Render via profile + renderer plugin
104
111
 
105
112
  ## CLI
106
113
 
107
- - `mf check` checks the entry `.mf`
108
- - `mf build` writes `.mf.score.json` into `dist`
109
- - `mf render` runs validate + render using `profiles/default.mf.profile.json` (or `--profile`)
114
+ ```bash
115
+ # Check syntax and types
116
+ mf check song.mf
117
+
118
+ # Build single file (no config required)
119
+ mf build song.mf
120
+ mf build song.mf -o output.json
121
+
122
+ # Build project with mfconfig.toml
123
+ mf build
124
+ mf build -w # Watch mode
125
+
126
+ # Render to output format
127
+ mf render score.json -p profile.json
128
+ ```
110
129
 
111
130
  Renderer plugins are external executables; use `--plugin` to override the resolver if needed.
112
131
 
132
+ ## Standard Library
133
+
134
+ | Module | Description |
135
+ |--------|-------------|
136
+ | `std:core` | `concat`, `repeat`, `overlay`, `padTo`, `slice`, `shift` |
137
+ | `std:transform` | `transpose`, `stretch`, `quantize`, `swing`, `humanize` |
138
+ | `std:theory` | Chords, scales, intervals, progressions |
139
+ | `std:curves` | `linear`, `easeInOut`, `piecewise` |
140
+ | `std:drums` | Drum keys and patterns |
141
+ | `std:vocal` | `text`, `align`, `vibrato`, `autoBreath` |
142
+
113
143
  ## Versioning
114
144
 
115
- - Language: v3
116
- - IR schema: `tako.irVersion = 3`
145
+ - Language: v4
146
+ - IR schema: `tako.irVersion = 4`
117
147
  - Profile schema: `tako.profileVersion = 1`
118
148
  - Plugin protocol: `tako.pluginProtocolVersion = 1`
119
149
 
120
150
  ## License
121
151
 
122
- AGPL-3.0
152
+ AGPL-3.0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=evaluator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/evaluator.test.ts"],"names":[],"mappings":""}