smplr 0.16.4 → 0.17.1
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 +18 -0
- package/dist/index.d.mts +318 -357
- package/dist/index.d.ts +318 -357
- package/dist/index.js +1908 -1583
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1900 -1581
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -114,6 +114,23 @@ const piano = await new SplendidGrandPiano(context).load;
|
|
|
114
114
|
|
|
115
115
|
⚠️ In versions lower than 0.8.0 a `loaded()` function was exposed instead.
|
|
116
116
|
|
|
117
|
+
#### Load progress
|
|
118
|
+
|
|
119
|
+
Track how many samples have loaded via the `onLoadProgress` option or the `loadProgress` getter:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
const piano = new SplendidGrandPiano(context, {
|
|
123
|
+
onLoadProgress: ({ loaded, total }) => {
|
|
124
|
+
console.log(`${loaded} / ${total} samples loaded`);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Or poll at any time:
|
|
129
|
+
console.log(piano.loadProgress); // { loaded: 12, total: 48 }
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`total` is known before loading starts, so you can display a determinate progress bar.
|
|
133
|
+
|
|
117
134
|
#### Shared configuration options
|
|
118
135
|
|
|
119
136
|
All instruments share some configuration options that are passed as second argument of the constructor. As it name implies, all fields are optional:
|
|
@@ -124,6 +141,7 @@ All instruments share some configuration options that are passed as second argum
|
|
|
124
141
|
- `disableScheduler`: disable internal scheduler. `false` by default.
|
|
125
142
|
- `scheduleLookaheadMs`: the lookahead of the scheduler. If the start time of the note is less than current time plus this lookahead time, the note will be started. 200ms by default.
|
|
126
143
|
- `scheduleIntervalMs`: the interval of the scheduler. 50ms by default.
|
|
144
|
+
- `onLoadProgress`: a function called after each sample buffer is decoded. Receives `{ loaded, total }` where `total` is the full count known before loading starts.
|
|
127
145
|
- `onStart`: a function that is called when starting a note. It receives the note started as parameter. Bear in mind that the time this function is called is not precise, and it's determined by lookahead.
|
|
128
146
|
- `onEnded`: a function that is called when the note ends. It receives the started note as parameter.
|
|
129
147
|
|