orchestre-js 2.0.3 → 2.1.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 -8
- package/dist/Orchestre.js +1 -1
- package/dist/esm/buffer-loader.js +4 -4
- package/dist/esm/event-emitter.js +12 -3
- package/dist/esm/metronome.d.ts +1 -1
- package/dist/esm/metronome.js +2 -2
- package/dist/esm/orchestre.d.ts +5 -4
- package/dist/esm/orchestre.js +33 -32
- package/dist/esm/sound-loop.d.ts +11 -4
- package/dist/esm/sound-loop.js +88 -40
- package/doc/api.md +170 -163
- package/doc/jsdoc2md.json +20 -0
- package/doc/logo-no-shadow.svg +384 -0
- package/doc/logo.png +0 -0
- package/logo.svg +473 -0
- package/package.json +12 -6
- package/src/event-emitter.ts +2 -2
- package/src/metronome.ts +1 -1
- package/src/orchestre.ts +26 -33
- package/src/sound-loop.ts +86 -38
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# Orchestre-JS
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Audio tool to create adaptive and interactive music.
|
|
4
6
|
|
|
5
7
|
[View demo](https://clementrivaille.github.io/orchestre-js/)
|
|
6
8
|
|
|
7
|
-
Orchestre-JS is an audio library for managing
|
|
9
|
+
Orchestre-JS is an audio library for managing music loops with several layers. It can be used to dynamically add and remove instruments in a song, play sounds in rhythm, transitioning through verses, or call events on beats. Orchestre-JS aims to provides a simple way to create dynamic soundtracks for your web games or applications.
|
|
10
|
+
|
|
11
|
+
Orchestre-JS has no external dependencies and uses only the native Web Audio API. It should be compatible with most modern browsers. You can also plug it to custom audio applications (see the [Web Audio API](#using-the-web-audio-api) section).
|
|
8
12
|
|
|
9
|
-
If you want to see the library in action, you can check out those games: [
|
|
13
|
+
If you want to see the library in action, you can check out those games: [Echoes Traveler](https://itooh.itch.io/echoes-traveler), [Blood Not Allowed](https://itooh.itch.io/blood-not-allowed) (made with Twine), and [Step Out](https://itooh.itch.io/step-out).
|
|
10
14
|
If you use Orchestre-JS in your creations, I would be really glad to see them! Feel free to show them to me.
|
|
11
15
|
|
|
12
16
|
## Install
|
|
@@ -123,9 +127,9 @@ And to stop them:
|
|
|
123
127
|
orchestra.stop('guitar');
|
|
124
128
|
```
|
|
125
129
|
|
|
126
|
-
Players will start and stop on the next beat, and automatically stay in rhythm,
|
|
130
|
+
Players will start and stop on the next beat, and automatically stay in rhythm, according to their type (relative or absolute). It's as simple as that!
|
|
127
131
|
|
|
128
|
-
You don't have to
|
|
132
|
+
You don't have to worry if your player is already playing or not. If you call `play` when a player is already active, or stop when it isn't, nothing will happen. Thus you can use `play` and `stop` to make sure the player is in the right state.
|
|
129
133
|
|
|
130
134
|
You can also call the function `toggle`, that just changes the player position between play and stop.
|
|
131
135
|
|
|
@@ -138,6 +142,7 @@ orchestra.toggle('guitar');
|
|
|
138
142
|
- **fade** _(float)_: time constant in seconds for a fade in or fade out. The length of fading is approximately equal to 1.6 times your constant. See [setTargetAtTime](https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/setTargetAtTime) for more details.
|
|
139
143
|
- **now** _(bool)_: if true, sound will start / stop immediately instead of waiting for next beat. This is better used with fading.
|
|
140
144
|
- **once** _(bool)_: for _play_ only. Play sound only once (instead of a loop), then stop.
|
|
145
|
+
- **keep** _(bool)_: for _stop_ only. Keep playing the sound until its completion then stop looping.
|
|
141
146
|
|
|
142
147
|
Finally, you can schedule an action on a player several beats in advance with the following method:
|
|
143
148
|
|
|
@@ -223,7 +228,7 @@ const orchestra = new Orchestre(120, context);
|
|
|
223
228
|
|
|
224
229
|
You can also access the audio context from the `context` property of the orchestra.
|
|
225
230
|
|
|
226
|
-
Players are by default connected to the orchestra's master gain (`orchestre.master`), which is connected to the context's destination.
|
|
231
|
+
Players are by default connected to the orchestra's master gain (`orchestre.master`), which is connected to the context's destination. But if you want to connect them to your own node (for example to add a reverb effect), you can change that with the `destination` parameter.
|
|
227
232
|
|
|
228
233
|
```javascript
|
|
229
234
|
await orchestra.addPlayer(
|
|
@@ -254,6 +259,11 @@ orchestra.disconnect('bass'); // Will disconnect from every nodes
|
|
|
254
259
|
|
|
255
260
|
_Warning_: If a player is not connected to master, it is no longer affected by the `setVolume` method. The best practice is to connect your final node to `orchestre.master` so that it can be affected by the orchestra's volume.
|
|
256
261
|
|
|
262
|
+
```javascript
|
|
263
|
+
orchestra.connect('bass', myAudioNode);
|
|
264
|
+
myAudioNode.connect(orchestra.master);
|
|
265
|
+
```
|
|
266
|
+
|
|
257
267
|
### Metronome
|
|
258
268
|
|
|
259
269
|
Orchestre-JS orchestra uses a metronome to sync all tracks. In most use cases, you don't need to interact with it. You can still access it from the `metronome` property of a created Orchestre.
|
|
@@ -273,7 +283,7 @@ For the simple tasks though (such as counting the position in a bar), I would ad
|
|
|
273
283
|
|
|
274
284
|
[API Documentation](doc/api.md)
|
|
275
285
|
|
|
276
|
-
##
|
|
286
|
+
## Troubleshooting
|
|
277
287
|
|
|
278
|
-
- **My
|
|
279
|
-
- **
|
|
288
|
+
- **My players loop too early / too late**: Make sure that the BPM you provided to your Orchestre matches your song's one, and that you wrote the correct number of beats in your loop in the player's _length_. For example, 4 bars in 4/4 will have a length of 16. Orchestre will use these values to loop your tracks, and ignore their actual length. This allows not only to keep them synchronized to the rhythm, but also to make them overlap if they have reverb or delay at the end.
|
|
289
|
+
- **My audio files don't play:** Make sure that you wrote the correct folder and name in the _url_ property of the player, and that this file is accessible. You can check its download in your browser's devtools. If you see another error in the console, refer to the Web Audio API documentation. Some browser might not accept all formats! You should be safe with .ogg, .wav or .mp3 though.
|