cp-midi-player 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 (40) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +196 -2
  3. package/dist/GeneralUser-GS-LICENSE.txt +47 -0
  4. package/dist/GeneralUser-GS.sf3 +0 -0
  5. package/dist/JetBrainsMono-OFL.txt +93 -0
  6. package/dist/JetBrainsMono-Variable.ttf +0 -0
  7. package/dist/LICENSE +22 -0
  8. package/dist/cp-midi-player.iife.js +1680 -0
  9. package/dist/cp-midi-player.iife.js.map +7 -0
  10. package/dist/cp-midi-player.js +1680 -0
  11. package/dist/cp-midi-player.js.map +7 -0
  12. package/dist/gm-instrument-families.png +0 -0
  13. package/dist/spessasynth_processor.min.js +18 -0
  14. package/dist/types/arrangement-view.d.ts +19 -0
  15. package/dist/types/asset-base.d.ts +11 -0
  16. package/dist/types/audio-sync.d.ts +53 -0
  17. package/dist/types/canonical-midi.d.ts +39 -0
  18. package/dist/types/cp-midi-player.d.ts +62 -0
  19. package/dist/types/download.d.ts +3 -0
  20. package/dist/types/esm.d.ts +6 -0
  21. package/dist/types/gm-programs.d.ts +2 -0
  22. package/dist/types/idle-audio-engines.d.ts +7 -0
  23. package/dist/types/instrument-thumbnails.d.ts +13 -0
  24. package/dist/types/musical-time.d.ts +3 -0
  25. package/dist/types/note-chase.d.ts +17 -0
  26. package/dist/types/piano-roll-seek.d.ts +15 -0
  27. package/dist/types/pitch-range.d.ts +10 -0
  28. package/dist/types/playback-coordinator.d.ts +16 -0
  29. package/dist/types/playback-midi.d.ts +7 -0
  30. package/dist/types/player.d.ts +71 -0
  31. package/dist/types/preset-resolution.d.ts +6 -0
  32. package/dist/types/timeline-ruler.d.ts +7 -0
  33. package/dist/types/track-audibility.d.ts +17 -0
  34. package/dist/types/track-mixer.d.ts +7 -0
  35. package/dist/types/track-preset.d.ts +18 -0
  36. package/dist/types/transport-clock.d.ts +16 -0
  37. package/dist/types/view-window.d.ts +9 -0
  38. package/dist/types/viewer-state.d.ts +28 -0
  39. package/dist/types/worklet-fallback.d.ts +31 -0
  40. package/package.json +63 -4
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Song-Ze Yu
4
+ Copyright (c) 2026 Chih-Pin Tan
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,197 @@
1
- # Temporary Holding Version
1
+ # cp-midi-player
2
2
 
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.
3
+ [![npm](https://img.shields.io/npm/v/cp-midi-player)](https://www.npmjs.com/package/cp-midi-player)
4
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/cp-midi-player/badge)](https://www.jsdelivr.com/package/npm/cp-midi-player)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
+
7
+ Designed for music researchers building demo pages and listening tests.
8
+ Play MIDI and audio in your browser, just like in your DAW.
9
+
10
+ <p align="center">
11
+ <a href="https://tanchihpin0517.github.io/cp-midi-player/">
12
+ <img src="docs/player-modern-five-tracks.png" alt="Five-track MIDI player with modern instrument artwork, notes, and mute, solo and volume controls">
13
+ </a><br>
14
+ <sub>(Click the image to try the live demo.)</sub>
15
+ </p>
16
+
17
+ Add these two lines to your page:
18
+
19
+ ```html
20
+ <script type="module" src="https://cdn.jsdelivr.net/npm/cp-midi-player@latest"></script>
21
+
22
+ <cp-midi-player src="song.mid"></cp-midi-player>
23
+ ```
24
+
25
+ No build step is needed. The player includes a default set of instrument sounds,
26
+ so you do not need to supply a SoundFont to get started.
27
+
28
+ ## Features
29
+
30
+ - Track and piano-roll views.
31
+ - Mute, solo, volume and instrument controls for each MIDI track.
32
+ - Audio recordings and stems that stay in sync with MIDI.
33
+ - WAV export of the current mix.
34
+ - Light and dark themes.
35
+
36
+ ## Usage
37
+
38
+ ### From a CDN
39
+
40
+ ```html
41
+ <script type="module" src="https://cdn.jsdelivr.net/npm/cp-midi-player@latest"></script>
42
+ ```
43
+
44
+ ### From npm
45
+
46
+ ```sh
47
+ npm install cp-midi-player
48
+ ```
49
+
50
+ ```js
51
+ import "cp-midi-player"; // registers <cp-midi-player>
52
+ ```
53
+
54
+ The package has no runtime dependencies. With a bundler (Vite, webpack,
55
+ esbuild), the player loads its worklet, SoundFont, artwork and font from the
56
+ same version on jsDelivr. To serve them yourself, see
57
+ [Self-hosting](#self-hosting).
58
+
59
+ ### Audio tracks
60
+
61
+ ```html
62
+ <cp-midi-player src="song.mid">
63
+ <cp-midi-player-audio src="mix.mp3" label="Mixture"></cp-midi-player-audio>
64
+ <cp-midi-player-audio src="vocals.mp3" label="Vocals stem"></cp-midi-player-audio>
65
+ <cp-midi-player-audio src="bass.mp3" label="Bass stem" offset="0.25"></cp-midi-player-audio>
66
+ </cp-midi-player>
67
+ ```
68
+
69
+ `offset="0.25"` delays a recording by 0.25 seconds; a negative value skips its
70
+ beginning. Add `before-midi-track="1"` to place a recording above the first MIDI
71
+ track. Without it, recordings appear above all MIDI tracks.
72
+
73
+ ## Attributes
74
+
75
+ | attribute | effect |
76
+ |---|---|
77
+ | `src` | MIDI file URL (required) |
78
+ | `view-mode` | `arrangement` (Tracks, default) or `piano-roll` |
79
+ | `theme` | `light` or `dark`; follows the system setting when omitted |
80
+ | `soundfont` | SF2, SF3 or DLS URL; defaults to GeneralUser GS |
81
+ | `file-name` | name shown in messages and used for the exported WAV |
82
+ | `persist-key` | remember mute, solo, volume and view per visitor in `localStorage` |
83
+ | `no-preload` | defer SoundFont loading until first play; otherwise it preloads by default |
84
+ | `preload` | retained for compatibility; preloading is now the default |
85
+ | `asset-base` | folder holding the player's assets; see [Self-hosting](#self-hosting) |
86
+ | `audio`, `audio-label`, `audio-offset` | one recording without a child element |
87
+ | `no-export` | hide the Export WAV button |
88
+ | `soundfont-menu` | show a SoundFont menu so visitors can load their own bank |
89
+ | `no-exclusive` | keep playing when another player on the page starts |
90
+
91
+ Set the player height with CSS: `cp-midi-player { height: 24rem; }`.
92
+
93
+ Players preload their SoundFont when mounted and share the download on the same
94
+ page. Playback still requires a user action. Pass `preloadSoundFont: false` to
95
+ `mount()`, or add `no-preload` to the element, to load only on first play.
96
+
97
+ ## JavaScript
98
+
99
+ ```js
100
+ const player = document.querySelector("cp-midi-player");
101
+
102
+ player.addEventListener("play", () => console.log("playing"));
103
+ player.addEventListener("pause", () => console.log("paused at", player.currentTime));
104
+
105
+ await player.play();
106
+ player.seek(12.5); // seconds
107
+ player.pause();
108
+ player.stop();
109
+ player.duration; // seconds
110
+ ```
111
+
112
+ To render into an element you already have, or to pass bytes instead of URLs,
113
+ use `mount()`:
114
+
115
+ ```js
116
+ import { mount } from "cp-midi-player";
117
+
118
+ const player = mount(document.querySelector("#slot"), {
119
+ src: midiArrayBuffer, // URL or ArrayBuffer
120
+ soundFont: sf2ArrayBuffer, // URL or ArrayBuffer, optional
121
+ fileName: "take-3.mid",
122
+ audioTracks: [{ url: "vocals.mp3", label: "Vocals" }],
123
+ viewMode: "piano-roll"
124
+ });
125
+
126
+ player.destroy();
127
+ ```
128
+
129
+ TypeScript types are included, and `document.querySelector("cp-midi-player")`
130
+ is typed as the player element.
131
+
132
+ ## SoundFonts and assets
133
+
134
+ The included [GeneralUser GS](https://schristiancollins.com/generaluser.php)
135
+ SoundFont downloads on first play (8.4 MB). Use `soundfont` to choose another bank.
136
+ Players share the download; starting one pauses the others by default.
137
+ For large collections, mount players as needed and remove them when finished.
138
+ Audio recordings are decoded into memory, so short excerpts work best.
139
+
140
+ ### Self-hosting
141
+
142
+ To serve everything from your own site (for offline use or a strict content
143
+ security policy), copy `node_modules/cp-midi-player/dist/` to your server
144
+ and load the script from there:
145
+
146
+ ```html
147
+ <script type="module" src="/static/cp-midi-player/cp-midi-player.js"></script>
148
+ ```
149
+
150
+ A script loaded from its own `dist/` folder finds the assets next to itself.
151
+ When the script is bundled into your app instead, point the player at the
152
+ copied folder with the `asset-base` attribute, or once for the whole page:
153
+
154
+ ```js
155
+ import { setDefaultAssetBase } from "cp-midi-player";
156
+ setDefaultAssetBase("/static/cp-midi-player/");
157
+ ```
158
+
159
+ ## Browser support
160
+
161
+ Current Chrome, Edge, Firefox and Safari. Playback uses the Web Audio
162
+ AudioWorklet. Browsers start audio only after a click or key press, so
163
+ playback starts from the player's controls or from your own button.
164
+
165
+ ## Development
166
+
167
+ ```sh
168
+ npm install
169
+ npm test # unit tests
170
+ npm run typecheck
171
+ npm run build # writes dist/
172
+ npx http-server . # then open /demo/
173
+ ```
174
+
175
+ The demo pages load the player from `../dist/`, so run `npm run build` after
176
+ each change and reload.
177
+
178
+ ## Publishing
179
+
180
+ GitHub releases tagged `v<version>` publish to npm and redeploy the demo site
181
+ from the same tag; pushes to `main` leave both alone. Update the package
182
+ version, lockfile and changelog first. The npm Trusted Publisher must point to
183
+ `tanchihpin0517/cp-midi-player`, workflow `publish.yml`, with no environment name.
184
+ The `github-pages` environment must allow deployments from `v*` tags
185
+ (Settings → Environments → github-pages → Deployment branches and tags).
186
+
187
+ ## License
188
+
189
+ MIT. SpessaSynth is Apache-2.0. GeneralUser GS and JetBrains Mono (OFL)
190
+ ship with their license files in `dist/`. The demo's music excerpt is
191
+ CC BY-NC-SA 2.5; see the demo page for credits.
192
+
193
+ ## Credits
194
+
195
+ cp-midi-player originated from
196
+ [midi-realplayer](https://github.com/vaclisinc/midi-realplayer) 0.1.4 by
197
+ Song-Ze (Jimmy) Yu, released under the MIT License.
@@ -0,0 +1,47 @@
1
+ *** GeneralUser GS v2.0.3 ***
2
+ *** License v2.0 ***
3
+
4
+ ** License of the complete work **
5
+ You may use GeneralUser GS without restriction for your own music creation,
6
+ private or commercial. This SoundFont bank is provided to the community free of
7
+ charge. Please feel free to use it in your software projects, and to modify the
8
+ SoundFont bank or its packaging to suit your needs.
9
+
10
+ ** License of contained samples **
11
+ GeneralUser GS inherits the usage rights of the samples contained within, all of
12
+ which allow full use in music production, including the ability to make profit
13
+ from musical recordings created with GeneralUser GS.
14
+
15
+ Many of the samples are original, but some were taken from other banks freely
16
+ (and legally) available on the Internet from various SoundFont websites. Because
17
+ GeneralUser GS originated as a personal project with no intention for
18
+ publication, I cannot be 100% sure where all of the samples originated, although
19
+ I do know that none of them came from commercially published SoundFont packages
20
+ or sample CDs. Regardless, many "free" SoundFonts available on the web may
21
+ indeed contain samples of questionable origin. My understanding of the
22
+ copyrights of all samples is only as good as the information provided by the
23
+ original sources. If you become aware of any restricted samples being used in
24
+ GeneralUser GS, please let me know so I can replace them.
25
+
26
+ This uncertainty may concern you if you intend to use GeneralUser GS in a
27
+ commercial software product. That being said, I have never received any
28
+ complaint regarding sample ownership since I published the original GeneralUser
29
+ GS back in 2000, and as far as I am aware, neither have any of the companies
30
+ creating commercial software products using GeneralUser GS.
31
+
32
+ ** More info **
33
+ If you plan to feature GeneralUser GS on your own website, please do not link
34
+ directly to my download files. Either link to my website, or provide your own
35
+ local copy instead.
36
+
37
+ I hope you enjoy GeneralUser GS! This SoundFont bank is the product of many
38
+ years of hard work.
39
+
40
+ You can find updates to GeneralUser GS and more of my virtual instruments at:
41
+ http://www.schristiancollins.com
42
+
43
+ I can be reached via the contact page on my website here:
44
+ https://www.schristiancollins.com/contact
45
+
46
+ Thank you!
47
+ -~Chris
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
package/dist/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Song-Ze Yu
4
+ Copyright (c) 2026 Chih-Pin Tan
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.