|
8 | 8 | <div id="app" style="height: 100vh"> |
9 | 9 | <!-- Webamp will attempt to center itself within this div --> |
10 | 10 | </div> |
11 | | - <script src="https://unpkg.com/webamp@1.5.0/built/webamp.bundle.min.js"></script> |
12 | | - <script src="https://unpkg.com/butterchurn@2.6.7/lib/butterchurn.min.js"></script> |
13 | | - <script src="https://unpkg.com/butterchurn-presets@2.4.7/lib/butterchurnPresets.min.js"></script> |
14 | | - <script> |
15 | | - const Webamp = window.Webamp; |
| 11 | + <script type="module"> |
| 12 | + /** |
| 13 | + * Webamp now includes an ESModule build, so you can import it directly. I |
| 14 | + * haven't validated full backwards compatibility with all the ways people |
| 15 | + * can import Webamp, so I haven't shipped this as the default build yet, |
| 16 | + * but it's on NPM as: `webamp@0.0.0-next-361ce79`. |
| 17 | + * |
| 18 | + * Changelog since the version you have can be found here: |
| 19 | + * https://github.com/captbaritone/webamp/blob/master/packages/webamp/CHANGELOG.md |
| 20 | + */ |
| 21 | + import Webamp from "https://unpkg.com/webamp@next"; |
| 22 | + |
| 23 | + /** |
| 24 | + * Butterchurn is not being actively maintained, but it is still works |
| 25 | + * great. Before it went into maintenance mode Jordan Berg (different |
| 26 | + * Jordan) cut a beta release of a version with the faster/more secure |
| 27 | + * eel->Wasm compiler that I wrote, so we use `butterchurn@3.0.0-beta.3`. |
| 28 | + * |
| 29 | + * Blog post about the eel->Wasm compiler here: |
| 30 | + * https://jordaneldredge.com/blog/speeding-up-winamps-music-visualizer-with-webassembly/ |
| 31 | + * |
| 32 | + * This version is still using AMD modules, so it will write the export to |
| 33 | + * `window.butterchurn`. This is a pretty chunky files, so you way want to |
| 34 | + * find a way to lazy load it inside `importButterchurn` below. |
| 35 | + * Unfortunately, it's not an ES module, so I wasn't able to call |
| 36 | + * `import()` on it without some kind of bundler. |
| 37 | + */ |
| 38 | + import "https://unpkg.com/butterchurn@3.0.0-beta.3/dist/butterchurn.min.js"; |
| 39 | + const butterchurn = window.butterchurn; |
| 40 | + |
| 41 | + /** |
| 42 | + * This module, `butterchurn-presets@3.0.0-beta.4` contains a curated set |
| 43 | + * of awesome Butterchurn presets that have been packaged up to work with |
| 44 | + * the new compiler. This module is also packaged as an AMD module, so |
| 45 | + * when imported without a bundler it will write the export to `window`. I |
| 46 | + * think the package was never that thoughtfully built, so the export name |
| 47 | + * is, confusingly `window.base`. If that's a problem, using a bundler |
| 48 | + * might help. |
| 49 | + * |
| 50 | + * As audio plays, Webamp will randomly cycle through these presets with a |
| 51 | + * cool transition effect. You can also press "l" while the Milkdrop |
| 52 | + * window is open to open Milkdrop's preset selection menu. |
| 53 | + */ |
| 54 | + import "https://unpkg.com/butterchurn-presets@3.0.0-beta.4/dist/base.js"; |
| 55 | + const butterchurnPresets = window.base.default; |
| 56 | + |
16 | 57 | const webamp = new Webamp({ |
17 | 58 | initialTracks: [ |
18 | 59 | { |
|
28 | 69 | }, |
29 | 70 | ], |
30 | 71 | __butterchurnOptions: { |
31 | | - importButterchurn: () => Promise.resolve(window.butterchurn), |
| 72 | + importButterchurn: () => Promise.resolve(butterchurn), |
32 | 73 | getPresets: () => { |
33 | | - const presets = window.butterchurnPresets.getPresets(); |
34 | | - return Object.keys(presets).map((name) => { |
35 | | - return { |
36 | | - name, |
37 | | - butterchurnPresetObject: presets[name], |
38 | | - }; |
| 74 | + return Object.entries(butterchurnPresets).map(([name, preset]) => { |
| 75 | + return { name, butterchurnPresetObject: preset }; |
39 | 76 | }); |
40 | 77 | }, |
41 | 78 | butterchurnOpen: true, |
|
0 commit comments