supersonic-scsynth 0.2.2 → 0.2.3
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.
- package/README.md +48 -13
- package/dist/supersonic.js +2 -2
- package/dist/wasm/manifest.json +3 -3
- package/dist/wasm/scsynth-nrt.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@ A WebAssembly port of SuperCollider's scsynth audio synthesis engine for the bro
|
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
10
|
<script type="module">
|
|
11
|
-
import { SuperSonic } from '
|
|
11
|
+
import { SuperSonic } from './dist/supersonic.js';
|
|
12
12
|
|
|
13
13
|
const sonic = new SuperSonic({
|
|
14
|
-
sampleBaseURL: '
|
|
15
|
-
synthdefBaseURL: '
|
|
14
|
+
sampleBaseURL: './dist/samples/',
|
|
15
|
+
synthdefBaseURL: './dist/synthdefs/'
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
await sonic.init();
|
|
@@ -29,11 +29,11 @@ A WebAssembly port of SuperCollider's scsynth audio synthesis engine for the bro
|
|
|
29
29
|
</script>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
**
|
|
32
|
+
**Important:** SuperSonic requires self-hosting (cannot load from CDN). See [CDN Usage](#cdn-usage) below.
|
|
33
33
|
|
|
34
34
|
## Installation
|
|
35
35
|
|
|
36
|
-
**Via npm:**
|
|
36
|
+
**Via npm (for local bundling):**
|
|
37
37
|
```bash
|
|
38
38
|
# Core engine only (~450KB)
|
|
39
39
|
npm install supersonic-scsynth
|
|
@@ -42,15 +42,15 @@ npm install supersonic-scsynth
|
|
|
42
42
|
npm install supersonic-scsynth-bundle
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
**
|
|
45
|
+
**Pre-built distribution (recommended):**
|
|
46
|
+
Download the pre-built package (~35MB with all synthdefs and samples) and serve from your own domain:
|
|
47
|
+
https://samaaron.github.io/supersonic/supersonic-dist.zip
|
|
48
|
+
|
|
49
|
+
Extract to your web server and import as:
|
|
46
50
|
```javascript
|
|
47
|
-
import { SuperSonic } from '
|
|
51
|
+
import { SuperSonic } from './dist/supersonic.js';
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
**Pre-built distribution:**
|
|
51
|
-
Download the 'nightly' build (~35MB with all synthdefs and samples):
|
|
52
|
-
https://samaaron.github.io/supersonic/supersonic-dist.zip
|
|
53
|
-
|
|
54
54
|
## Packages
|
|
55
55
|
|
|
56
56
|
SuperSonic is split into multiple packages:
|
|
@@ -69,8 +69,8 @@ All synthdefs and samples are from [Sonic Pi](https://github.com/sonic-pi-net/so
|
|
|
69
69
|
**Creating an instance:**
|
|
70
70
|
```javascript
|
|
71
71
|
const sonic = new SuperSonic({
|
|
72
|
-
sampleBaseURL: '
|
|
73
|
-
synthdefBaseURL: '
|
|
72
|
+
sampleBaseURL: './dist/samples/',
|
|
73
|
+
synthdefBaseURL: './dist/synthdefs/',
|
|
74
74
|
audioPathMap: { /* optional custom path mappings */ }
|
|
75
75
|
});
|
|
76
76
|
```
|
|
@@ -121,6 +121,41 @@ Cross-Origin-Resource-Policy: cross-origin
|
|
|
121
121
|
|
|
122
122
|
See `example/server.rb` for a reference implementation.
|
|
123
123
|
|
|
124
|
+
## CDN Usage
|
|
125
|
+
|
|
126
|
+
SuperSonic cannot be loaded from a CDN. The core library must be self-hosted on your domain.
|
|
127
|
+
|
|
128
|
+
### Why Self-Hosting is Required
|
|
129
|
+
|
|
130
|
+
SuperSonic uses `SharedArrayBuffer` for real-time audio performance. Browsers require workers that use `SharedArrayBuffer` to come from the same origin as the page. Even with proper COOP/COEP headers, cross-origin workers with shared memory are blocked. This is a fundamental browser security requirement stemming from Spectre attack mitigation.
|
|
131
|
+
|
|
132
|
+
What this means:
|
|
133
|
+
- You cannot use `import { SuperSonic } from 'https://unpkg.com/supersonic/...'`
|
|
134
|
+
- You must download and self-host the core library on your own domain
|
|
135
|
+
- The npm packages exist for convenience but must be bundled and deployed to your server
|
|
136
|
+
|
|
137
|
+
### Synthdefs and Samples Can Use CDN
|
|
138
|
+
|
|
139
|
+
Pre-compiled synthdefs and audio samples can be loaded from CDNs. They're just data files, not workers.
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
// Self-hosted core library
|
|
143
|
+
import { SuperSonic } from './dist/supersonic.js';
|
|
144
|
+
|
|
145
|
+
// CDN-hosted synthdefs and samples work fine
|
|
146
|
+
const sonic = new SuperSonic({
|
|
147
|
+
sampleBaseURL: 'https://unpkg.com/supersonic-scsynth-samples@0.1.6/samples/',
|
|
148
|
+
synthdefBaseURL: 'https://unpkg.com/supersonic-scsynth-synthdefs@0.1.6/synthdefs/'
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
await sonic.init();
|
|
152
|
+
await sonic.loadSynthDefs(['sonic-pi-beep', 'sonic-pi-tb303']);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Hybrid Approach
|
|
156
|
+
|
|
157
|
+
Self-host the SuperSonic core (JS, WASM, workers) with COOP/COEP headers. Use CDN for synthdefs and samples to save bandwidth. See `example/simple-cdn.html` for a working example.
|
|
158
|
+
|
|
124
159
|
## Building from Source
|
|
125
160
|
|
|
126
161
|
**Prerequisites:**
|
package/dist/supersonic.js
CHANGED
|
@@ -2324,7 +2324,7 @@ var SuperSonic = class _SuperSonic {
|
|
|
2324
2324
|
}
|
|
2325
2325
|
if (!this.sampleBaseURL) {
|
|
2326
2326
|
throw new Error(
|
|
2327
|
-
'sampleBaseURL not configured. Please set it in SuperSonic constructor options.\nExample: new SuperSonic({ sampleBaseURL: "https://unpkg.com/supersonic-scsynth-samples@latest/samples/" })\nOr install
|
|
2327
|
+
'sampleBaseURL not configured. Please set it in SuperSonic constructor options.\nExample: new SuperSonic({ sampleBaseURL: "./dist/samples/" })\nOr use CDN: new SuperSonic({ sampleBaseURL: "https://unpkg.com/supersonic-scsynth-samples@latest/samples/" })\nOr install: npm install supersonic-scsynth-samples'
|
|
2328
2328
|
);
|
|
2329
2329
|
}
|
|
2330
2330
|
return this.sampleBaseURL + scPath;
|
|
@@ -2525,7 +2525,7 @@ var SuperSonic = class _SuperSonic {
|
|
|
2525
2525
|
}
|
|
2526
2526
|
if (!this.synthdefBaseURL) {
|
|
2527
2527
|
throw new Error(
|
|
2528
|
-
'synthdefBaseURL not configured. Please set it in SuperSonic constructor options.\nExample: new SuperSonic({ synthdefBaseURL: "https://unpkg.com/supersonic-scsynth-synthdefs@latest/synthdefs/" })\nOr install: npm install supersonic-scsynth-synthdefs'
|
|
2528
|
+
'synthdefBaseURL not configured. Please set it in SuperSonic constructor options.\nExample: new SuperSonic({ synthdefBaseURL: "./dist/synthdefs/" })\nOr use CDN: new SuperSonic({ synthdefBaseURL: "https://unpkg.com/supersonic-scsynth-synthdefs@latest/synthdefs/" })\nOr install: npm install supersonic-scsynth-synthdefs'
|
|
2529
2529
|
);
|
|
2530
2530
|
}
|
|
2531
2531
|
const results = {};
|
package/dist/wasm/manifest.json
CHANGED
|
Binary file
|
package/package.json
CHANGED