euterpe 0.0.0-stage → 0.1.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 (208) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -2
  3. package/assets/samples/README.md +4 -0
  4. package/assets/samples/click/C0.mp3 +0 -0
  5. package/assets/samples/click/Cs0.mp3 +0 -0
  6. package/assets/samples/drums/C0.mp3 +0 -0
  7. package/assets/samples/drums/Cs0.mp3 +0 -0
  8. package/assets/samples/drums/D0.mp3 +0 -0
  9. package/assets/samples/drums/Ds0.mp3 +0 -0
  10. package/assets/samples/piano/A0.mp3 +0 -0
  11. package/assets/samples/piano/A1.mp3 +0 -0
  12. package/assets/samples/piano/A2.mp3 +0 -0
  13. package/assets/samples/piano/A3.mp3 +0 -0
  14. package/assets/samples/piano/A4.mp3 +0 -0
  15. package/assets/samples/piano/A5.mp3 +0 -0
  16. package/assets/samples/piano/A6.mp3 +0 -0
  17. package/assets/samples/piano/As0.mp3 +0 -0
  18. package/assets/samples/piano/As1.mp3 +0 -0
  19. package/assets/samples/piano/As2.mp3 +0 -0
  20. package/assets/samples/piano/As3.mp3 +0 -0
  21. package/assets/samples/piano/As4.mp3 +0 -0
  22. package/assets/samples/piano/As5.mp3 +0 -0
  23. package/assets/samples/piano/As6.mp3 +0 -0
  24. package/assets/samples/piano/B0.mp3 +0 -0
  25. package/assets/samples/piano/B1.mp3 +0 -0
  26. package/assets/samples/piano/B2.mp3 +0 -0
  27. package/assets/samples/piano/B3.mp3 +0 -0
  28. package/assets/samples/piano/B4.mp3 +0 -0
  29. package/assets/samples/piano/B5.mp3 +0 -0
  30. package/assets/samples/piano/B6.mp3 +0 -0
  31. package/assets/samples/piano/C0.mp3 +0 -0
  32. package/assets/samples/piano/C1.mp3 +0 -0
  33. package/assets/samples/piano/C2.mp3 +0 -0
  34. package/assets/samples/piano/C3.mp3 +0 -0
  35. package/assets/samples/piano/C4.mp3 +0 -0
  36. package/assets/samples/piano/C5.mp3 +0 -0
  37. package/assets/samples/piano/C6.mp3 +0 -0
  38. package/assets/samples/piano/C7.mp3 +0 -0
  39. package/assets/samples/piano/Cs0.mp3 +0 -0
  40. package/assets/samples/piano/Cs1.mp3 +0 -0
  41. package/assets/samples/piano/Cs2.mp3 +0 -0
  42. package/assets/samples/piano/Cs3.mp3 +0 -0
  43. package/assets/samples/piano/Cs4.mp3 +0 -0
  44. package/assets/samples/piano/Cs5.mp3 +0 -0
  45. package/assets/samples/piano/Cs6.mp3 +0 -0
  46. package/assets/samples/piano/D0.mp3 +0 -0
  47. package/assets/samples/piano/D1.mp3 +0 -0
  48. package/assets/samples/piano/D2.mp3 +0 -0
  49. package/assets/samples/piano/D3.mp3 +0 -0
  50. package/assets/samples/piano/D4.mp3 +0 -0
  51. package/assets/samples/piano/D5.mp3 +0 -0
  52. package/assets/samples/piano/D6.mp3 +0 -0
  53. package/assets/samples/piano/Ds0.mp3 +0 -0
  54. package/assets/samples/piano/Ds1.mp3 +0 -0
  55. package/assets/samples/piano/Ds2.mp3 +0 -0
  56. package/assets/samples/piano/Ds3.mp3 +0 -0
  57. package/assets/samples/piano/Ds4.mp3 +0 -0
  58. package/assets/samples/piano/Ds5.mp3 +0 -0
  59. package/assets/samples/piano/Ds6.mp3 +0 -0
  60. package/assets/samples/piano/E0.mp3 +0 -0
  61. package/assets/samples/piano/E1.mp3 +0 -0
  62. package/assets/samples/piano/E2.mp3 +0 -0
  63. package/assets/samples/piano/E3.mp3 +0 -0
  64. package/assets/samples/piano/E4.mp3 +0 -0
  65. package/assets/samples/piano/E5.mp3 +0 -0
  66. package/assets/samples/piano/E6.mp3 +0 -0
  67. package/assets/samples/piano/F0.mp3 +0 -0
  68. package/assets/samples/piano/F1.mp3 +0 -0
  69. package/assets/samples/piano/F2.mp3 +0 -0
  70. package/assets/samples/piano/F3.mp3 +0 -0
  71. package/assets/samples/piano/F4.mp3 +0 -0
  72. package/assets/samples/piano/F5.mp3 +0 -0
  73. package/assets/samples/piano/F6.mp3 +0 -0
  74. package/assets/samples/piano/Fs0.mp3 +0 -0
  75. package/assets/samples/piano/Fs1.mp3 +0 -0
  76. package/assets/samples/piano/Fs2.mp3 +0 -0
  77. package/assets/samples/piano/Fs3.mp3 +0 -0
  78. package/assets/samples/piano/Fs4.mp3 +0 -0
  79. package/assets/samples/piano/Fs5.mp3 +0 -0
  80. package/assets/samples/piano/Fs6.mp3 +0 -0
  81. package/assets/samples/piano/G0.mp3 +0 -0
  82. package/assets/samples/piano/G1.mp3 +0 -0
  83. package/assets/samples/piano/G2.mp3 +0 -0
  84. package/assets/samples/piano/G3.mp3 +0 -0
  85. package/assets/samples/piano/G4.mp3 +0 -0
  86. package/assets/samples/piano/G5.mp3 +0 -0
  87. package/assets/samples/piano/G6.mp3 +0 -0
  88. package/assets/samples/piano/Gs0.mp3 +0 -0
  89. package/assets/samples/piano/Gs1.mp3 +0 -0
  90. package/assets/samples/piano/Gs2.mp3 +0 -0
  91. package/assets/samples/piano/Gs3.mp3 +0 -0
  92. package/assets/samples/piano/Gs4.mp3 +0 -0
  93. package/assets/samples/piano/Gs5.mp3 +0 -0
  94. package/assets/samples/piano/Gs6.mp3 +0 -0
  95. package/assets/samples/upright_bass/A0.mp3 +0 -0
  96. package/assets/samples/upright_bass/A1.mp3 +0 -0
  97. package/assets/samples/upright_bass/A2.mp3 +0 -0
  98. package/assets/samples/upright_bass/A3.mp3 +0 -0
  99. package/assets/samples/upright_bass/As0.mp3 +0 -0
  100. package/assets/samples/upright_bass/As1.mp3 +0 -0
  101. package/assets/samples/upright_bass/As2.mp3 +0 -0
  102. package/assets/samples/upright_bass/As3.mp3 +0 -0
  103. package/assets/samples/upright_bass/B0.mp3 +0 -0
  104. package/assets/samples/upright_bass/B1.mp3 +0 -0
  105. package/assets/samples/upright_bass/B2.mp3 +0 -0
  106. package/assets/samples/upright_bass/B3.mp3 +0 -0
  107. package/assets/samples/upright_bass/C0.mp3 +0 -0
  108. package/assets/samples/upright_bass/C1.mp3 +0 -0
  109. package/assets/samples/upright_bass/C2.mp3 +0 -0
  110. package/assets/samples/upright_bass/C3.mp3 +0 -0
  111. package/assets/samples/upright_bass/Cs0.mp3 +0 -0
  112. package/assets/samples/upright_bass/Cs1.mp3 +0 -0
  113. package/assets/samples/upright_bass/Cs2.mp3 +0 -0
  114. package/assets/samples/upright_bass/Cs3.mp3 +0 -0
  115. package/assets/samples/upright_bass/D0.mp3 +0 -0
  116. package/assets/samples/upright_bass/D1.mp3 +0 -0
  117. package/assets/samples/upright_bass/D2.mp3 +0 -0
  118. package/assets/samples/upright_bass/D3.mp3 +0 -0
  119. package/assets/samples/upright_bass/Ds0.mp3 +0 -0
  120. package/assets/samples/upright_bass/Ds1.mp3 +0 -0
  121. package/assets/samples/upright_bass/Ds2.mp3 +0 -0
  122. package/assets/samples/upright_bass/Ds3.mp3 +0 -0
  123. package/assets/samples/upright_bass/E0.mp3 +0 -0
  124. package/assets/samples/upright_bass/E1.mp3 +0 -0
  125. package/assets/samples/upright_bass/E2.mp3 +0 -0
  126. package/assets/samples/upright_bass/E3.mp3 +0 -0
  127. package/assets/samples/upright_bass/F0.mp3 +0 -0
  128. package/assets/samples/upright_bass/F1.mp3 +0 -0
  129. package/assets/samples/upright_bass/F2.mp3 +0 -0
  130. package/assets/samples/upright_bass/F3.mp3 +0 -0
  131. package/assets/samples/upright_bass/Fs0.mp3 +0 -0
  132. package/assets/samples/upright_bass/Fs1.mp3 +0 -0
  133. package/assets/samples/upright_bass/Fs2.mp3 +0 -0
  134. package/assets/samples/upright_bass/Fs3.mp3 +0 -0
  135. package/assets/samples/upright_bass/G0.mp3 +0 -0
  136. package/assets/samples/upright_bass/G1.mp3 +0 -0
  137. package/assets/samples/upright_bass/G2.mp3 +0 -0
  138. package/assets/samples/upright_bass/G3.mp3 +0 -0
  139. package/assets/samples/upright_bass/Gs0.mp3 +0 -0
  140. package/assets/samples/upright_bass/Gs1.mp3 +0 -0
  141. package/assets/samples/upright_bass/Gs2.mp3 +0 -0
  142. package/assets/samples/upright_bass/Gs3.mp3 +0 -0
  143. package/cli/index.js +137 -0
  144. package/cli/serve.js +65 -0
  145. package/cli/smoke.js +128 -0
  146. package/package.json +90 -4
  147. package/schema/config.schema.json +231 -0
  148. package/schema/players.schema.json +49 -0
  149. package/schema/widgets.schema.json +184 -0
  150. package/src/App.vue +28 -0
  151. package/src/agent.js +48 -0
  152. package/src/components/AudioMeter.vue +132 -0
  153. package/src/components/BPMSlider.vue +140 -0
  154. package/src/components/ChromaChart.vue +193 -0
  155. package/src/components/HorizontalSlider.vue +85 -0
  156. package/src/components/Keyboard.vue +389 -0
  157. package/src/components/LiveCanvas.vue +324 -0
  158. package/src/components/Mixer.vue +277 -0
  159. package/src/components/Monitor.vue +191 -0
  160. package/src/components/PianoRoll.vue +239 -0
  161. package/src/components/Score.vue +667 -0
  162. package/src/components/Settings.vue +566 -0
  163. package/src/components/Slider.vue +115 -0
  164. package/src/components/TextBox.vue +99 -0
  165. package/src/components/VerticalSlider.vue +77 -0
  166. package/src/css/app.css +106 -0
  167. package/src/css/audioMeter.css +99 -0
  168. package/src/css/keyboard.css +176 -0
  169. package/src/css/main.css +297 -0
  170. package/src/css/mixerDat.css +88 -0
  171. package/src/css/score.css +155 -0
  172. package/src/css/variables.css +41 -0
  173. package/src/css/vectorBar.css +98 -0
  174. package/src/index.js +62 -0
  175. package/src/store/index.js +33 -0
  176. package/src/store/modules/global-settings.js +95 -0
  177. package/src/store/modules/note-buffers.js +463 -0
  178. package/src/store/modules/samplers.js +258 -0
  179. package/src/store/modules/tick-number.js +111 -0
  180. package/src/utils/NoteEvent.js +163 -0
  181. package/src/utils/beaming.js +31 -0
  182. package/src/utils/dataStructures.js +111 -0
  183. package/src/utils/handle.js +131 -0
  184. package/src/utils/helpers.js +71 -0
  185. package/src/utils/instruments.js +88 -0
  186. package/src/utils/liveCanvas.js +356 -0
  187. package/src/utils/liveCanvasState.js +99 -0
  188. package/src/utils/math.js +125 -0
  189. package/src/utils/music.js +30 -0
  190. package/src/utils/sessionExport.js +104 -0
  191. package/src/utils/spelling.js +120 -0
  192. package/src/utils/types.js +83 -0
  193. package/src/views/Euterpe.vue +2090 -0
  194. package/src/worker/agentWorker.js +429 -0
  195. package/src/worker/audioIn.js +66 -0
  196. package/src/worker/audioOut.js +163 -0
  197. package/src/worker/clock.js +38 -0
  198. package/src/worker/context.js +216 -0
  199. package/src/worker/player-worklet.js +70 -0
  200. package/src/worker/recorder-worklet.js +56 -0
  201. package/src/worker/resampler.js +82 -0
  202. package/src/worker/ringbuf-classic.js +612 -0
  203. package/types/agent.d.ts +322 -0
  204. package/types/config.d.ts +1084 -0
  205. package/types/index.d.ts +41 -0
  206. package/types/vite.d.ts +19 -0
  207. package/vite/index.js +223 -0
  208. package/vite/validate.js +110 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2026 Christodoulos Benetatos, Yongyi Zang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,115 @@
1
- # Temporary Holding Version
1
+ # Euterpe
2
+
3
+ A browser framework for real-time interactive music agents. A person plays (laptop keyboard, MIDI keyboard or microphone) and your agent answers, in the browser, with no server. You write the agent: its hooks in JavaScript and a few YAML files. Euterpe does the rest: MIDI and audio input, the clock and quantization, samplers and audio output, and the UI (score, piano roll, keyboard, Settings widgets).
4
+
5
+ [Website](https://euterpeframework.org) · [Demos](https://euterpeframework.org/guide/demos) · [Paper (JAES 2023)](https://doi.org/10.17743/jaes.2022.0117) · [Source](https://github.com/xribene/Euterpe)
6
+
7
+ ## Start a project
8
+
9
+ ```bash
10
+ npm create euterpe@latest my-agent
11
+ cd my-agent
12
+ npm install
13
+ npm run dev
14
+ ```
15
+
16
+ Templates: `empty`, `copycat`, `call-response` and `synth` (MIDI in, audio out). Each project comes with an `AGENTS.md` that documents the whole API, for you and for coding agents.
17
+
18
+ ## An agent
19
+
20
+ ```js
21
+ // agent/hooks.js
22
+ import {defineAgent} from 'euterpe/agent';
23
+
24
+ let sounding = null; // the note the agent is playing
25
+
26
+ export default defineAgent({
27
+ // every 16th note (config.yaml: gridBased): play the user's note an octave up, two ticks later
28
+ processClockEvent({userQuantizedNotes}, ctx) {
29
+ const {NOTE_ON, NOTE_HOLD} = ctx.types.noteType;
30
+ const onset = userQuantizedNotes.find((note) => note.type === NOTE_ON);
31
+ const held = userQuantizedNotes.some((note) => note.type === NOTE_HOLD);
32
+ const notes = [];
33
+ if (sounding !== null && (onset || !held)) {
34
+ notes.push(ctx.noteOff(sounding, {tick: 2}));
35
+ sounding = null;
36
+ }
37
+ if (onset) {
38
+ sounding = onset.midi + 12;
39
+ notes.push(ctx.noteOn(sounding, {tick: 2, velocity: onset.velocity}));
40
+ }
41
+ return notes;
42
+ },
43
+ });
44
+ ```
45
+
46
+ ```js
47
+ // vite.config.js
48
+ import {defineConfig} from 'vite';
49
+ import euterpe from 'euterpe/vite';
50
+
51
+ export default defineConfig({plugins: [euterpe()]});
52
+ ```
53
+
54
+ The agent runs in a Web Worker, so models (TF.js, onnxruntime-web, your own WebGPU or WASM code) never block the UI. Its hooks:
55
+
56
+ | Hook | When it runs |
57
+ |---|---|
58
+ | `loadAlgorithm(ctx)` | once, at startup |
59
+ | `processClockEvent(clock, ctx)` | every tick of the grid |
60
+ | `processNoteEvent(note, ctx)` | every user note, in free time |
61
+ | `processAudioBuffer(frame, ctx)` | every microphone frame |
62
+ | `renderAudio(frames, ctx)` | audio output |
63
+ | `updateParameter(change, ctx)` | a Settings widget changed |
64
+
65
+ `agent/config.yaml`, `widgets.yaml` and `players.yaml` choose the interaction mode, the clock, the UI and the instruments. They're validated against the JSON schemas in `schema/` at dev and build time.
66
+
67
+ ## What's in the package
68
+
69
+ | Export / command | What it is |
70
+ |---|---|
71
+ | `euterpe/vite` | The Vite plugin. It loads the agent and its YAML, serves and copies the instrument samples, and sets the cross-origin isolation headers. |
72
+ | `euterpe/agent` | `defineAgent`, `NoteEvent`, small helpers and the type enums |
73
+ | `npx euterpe smoke [--build]` | A headless-browser check: the page is isolated, the agent is ready, the clock ticks, the agent answers a phrase, and there are no errors |
74
+ | `npx euterpe eject` | Copies Euterpe into the project, to change it freely |
75
+
76
+ TypeScript types ship in `types/`, including the YAML config types (generated from the schemas).
77
+
78
+ ## Deploying
79
+
80
+ A built project (`npm run build`, then `dist/`) is a static site. It must be served with these headers:
81
+
82
+ ```text
83
+ Cross-Origin-Opener-Policy: same-origin
84
+ Cross-Origin-Embedder-Policy: require-corp
85
+ ```
86
+
87
+ Euterpe uses SharedArrayBuffer between the page, the agent worker and the audio thread. The templates include `netlify.toml` and `vercel.json` with these headers.
88
+
89
+ ## Requirements
90
+
91
+ Node 18+, Vite 5. Chrome (or another Chromium browser) is recommended. `playwright-core` is optional, and only needed for `euterpe smoke`.
92
+
93
+ ## Citation
94
+
95
+ If you use Euterpe in your research, please cite:
96
+
97
+ > Y. Zang, C. Benetatos, and Z. Duan, "Euterpe: A Web Framework for Interactive Music Systems," *Journal of the Audio Engineering Society*, vol. 71, no. 11, pp. 738–752, 2023. doi:[10.17743/jaes.2022.0117](https://doi.org/10.17743/jaes.2022.0117)
98
+
99
+ ```bibtex
100
+ @article{zang2023euterpe,
101
+ author = {Zang, Yongyi and Benetatos, Christodoulos and Duan, Zhiyao},
102
+ title = {Euterpe: A Web Framework for Interactive Music Systems},
103
+ journal = {Journal of the Audio Engineering Society},
104
+ volume = {71},
105
+ number = {11},
106
+ pages = {738--752},
107
+ year = {2023},
108
+ doi = {10.17743/jaes.2022.0117}
109
+ }
110
+ ```
111
+
112
+ ## Licence
113
+
114
+ MIT, © Christodoulos Benetatos and Yongyi Zang.
2
115
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
@@ -0,0 +1,4 @@
1
+ # Instrument samples
2
+
3
+ Piano, drums, upright bass and click, recorded by Christodoulos Benetatos and laid out for Tone.js's `Sampler`
4
+ (one file per sampled note). Released under the MIT licence of this package (`../../LICENSE`).
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file