Skip to content

Commit 61d292b

Browse files
committed
Update README.md
1 parent ce7fdc8 commit 61d292b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ js-synthesizer
55

66
js-synthesizer is a library that generates audio data (frames). [WebAssembly (wasm) version of FluidSynth](https://github.com/jet2jet/fluidsynth-emscripten) is used as a core synthesizer engine.
77

8+
## Demo
9+
10+
https://www.pg-fl.jp/music/js-synthesizer/index.en.htm
11+
812
## Install
913

1014
```
@@ -32,7 +36,7 @@ function loadSynthesizer() {
3236
}
3337
```
3438

35-
When initialized, you can use APIs via `JSSynth` namespace object.
39+
After initialized, you can use APIs via `JSSynth` namespace object.
3640

3741
```js
3842
// Prepare the AudioContext instance
@@ -69,13 +73,13 @@ synth.loadSFont(sfontBuffer).then(function () {
6973

7074
(Above example uses Web Audio API, but you can use `Synthesizer` without Web Audio, by using `render()` method.)
7175

72-
If you prefer to load js-synthesizer as an ES module, you can use `import` statement such as `import * as JSSynth from 'js-synthesizer'`.
76+
js-synthesizer is built as UMD module. If you prefer to load js-synthesizer as a CommonJS / ES module, you can use `import` statement such as `import * as JSSynth from 'js-synthesizer'` by using bundlers (such as webpack).
7377

7478
Notes:
7579

7680
* `js-synthesizer.js` intends the ES2015-supported environment. If you need to run the script without errors on non-ES2015 environment such as IE11 (to notify 'unsupported'), you should load those scripts dynamically, or use transpiler such as babel.
77-
* When just after the scripts loaded, some APIs may fail since libfluidsynth is not ready. To avoid this, you can use the Promise object returned by `JSSynth.waitForReady`.
78-
* libfluidsynth JS file is not `import`-able and its license (LGPL v2.1) is differ from js-synthesizer's (BSD-3-Clause).
81+
* When just after the scripts loaded, some APIs may fail since libfluidsynth is not ready. To avoid this, you can use the Promise object returned by `JSSynth.waitForReady` as above example.
82+
* libfluidsynth JS file is not `import`-able and its license (LGPL v2.1) is different from js-synthesizer's (BSD-3-Clause).
7983

8084
### With AudioWorklet
8185

@@ -118,14 +122,12 @@ self.importScripts('libfluidsynth-2.1.3.js');
118122
self.importScripts('js-synthesizer.js');
119123
```
120124

121-
(You can also load js-synthesizer as an ES Module from the Web Worker.)
122-
123125
Note that since the Web Audio is not supported on the Web Worker, the APIs/methods related to the Web Audio will not work. If you want to use both Web Worker and AudioWorklet, you should implement AudioWorkletProcessor manually as followings:
124126

125127
* main thread -- create AudioWorkletNode and establish connections between Web Worker and AudioWorklet
126-
* You must transfer rendered audio frames from Web Worker to AudioWorklet because AudioWorklet environment does not support creating Web Worker. By creating `MessageChannel` and sending its port instances to Web Worker and AudioWorklet, they can communicate each other directly.
128+
* You need to transfer rendered audio frames from Web Worker to AudioWorklet, but AudioWorklet environment does not support creating Web Worker. By creating `MessageChannel` and sending its port instances to Web Worker and AudioWorklet, they can communicate each other directly.
127129
* Web Worker thread -- render audio frames into raw buffers and send it for AudioWorklet thread
128-
* AudioWorklet thread -- receive audio frames and 'render' it in the `process` method
130+
* AudioWorklet thread -- receive audio frames (and queue) and 'render' it in the `process` method
129131

130132
## API
131133

@@ -137,7 +139,7 @@ These classes implement the interface named `JSSynth.ISynthesizer`.
137139
* Creates the general synthesizer instance. No parameters are available.
138140
* `JSSynth.AudioWorkletNodeSynthesizer` (construct: `new JSSynth.AudioWorkletNodeSynthesizer()`)
139141
* Creates the synthesizer instance communicating AudioWorklet (see above). No parameters are available.
140-
* You must call `createAudioNode` method to use other instance methods.
142+
* You must call `createAudioNode` method first to use other instance methods.
141143

142144
### Creation of Sequencer instance
143145

@@ -150,9 +152,7 @@ The `Sequencer` instance is created only via following methods:
150152

151153
### Using hook / handle MIDI-related event data with user-defined calllback
152154

153-
NOTE: `libfluidsynth-2.0.2.js` (or above) is necessary to use this feature.
154-
155-
From v1.2.0, you can hook MIDI events posted by player. For `JSSynth.Synthesizer` instance, use `hookPlayerMIDIEvents` method as followings:
155+
You can hook MIDI events posted by player. For `JSSynth.Synthesizer` instance, use `hookPlayerMIDIEvents` method as followings:
156156

157157
```js
158158
syn.hookPlayerMIDIEvents(function (s, type, event) {
@@ -201,11 +201,11 @@ syn.hookPlayerMIDIEventsByName('myHookPlayerEvents', { secondSFont: secondSFont
201201
The sequencer also supports 'user-defined client' to handle event data.
202202

203203
* For sequncer instance created by `Synthesizer.createSequencer`, use `Synthesizer.registerSequencerClient` static method.
204-
* You can use `Synthesizer.sendEventNow` static method to event data processed by the synthesizer or another clients.
204+
* You can use `Synthesizer.sendEventNow` static method to send event data, processed by the synthesizer or clients, to another clients/synthesizers.
205205
* For sequncer instance created by `createSequencer` of `AudioWorkletNodeSynthesizer`, use `registerSequencerClientByName` instance method.
206206
* The callback function must be added to 'AudioWorkletGlobalScope' like `hookPlayerMIDIEventsByName`'s callback.
207207
* To re-send event data, use `Synthesizer.sendEventNow` in the worklet. `Synthesizer` constructor is available via `AudioWorkletGlobalScope.JSSynth.Synthesizer`.
208-
* You can rewrite event data passed to the callback, with using `JSSynth.rewriteEventData` (`AudioWorkletGlobalScope.JSSynth.rewriteEventData` for worklet).
208+
* You can rewrite event data passed to the callback, by using `JSSynth.rewriteEventData` (`AudioWorkletGlobalScope.JSSynth.rewriteEventData` for worklet).
209209

210210
### `JSSynth` methods
211211

0 commit comments

Comments
 (0)