midi-audio-player 1.0.3 → 1.1.0

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 CHANGED
@@ -6,10 +6,10 @@ A lightweight JavaScript MIDI audio player built on top of the Web Audio API usi
6
6
 
7
7
  * MIDI file playback in modern browsers
8
8
  * Built on the Web Audio API
9
- * Uses WebAudioFont for instrument rendering
9
+ * Uses WebAudioFont for preset rendering
10
10
  * Lightweight and dependency-minimal
11
11
  * Simple programmatic API
12
- * CLI tool for instrument/font handling
12
+ * CLI tool for preset/font handling
13
13
 
14
14
  ## Installation
15
15
 
@@ -24,13 +24,16 @@ npm install midi-audio-player
24
24
  ```js
25
25
  import MidiAudioPlayer from 'midi-audio-player';
26
26
 
27
+ const response = await fetch('/examples/data/iwillsurvive.mid');
28
+ const buffer = await response.arrayBuffer();
29
+
27
30
  const player = new MidiAudioPlayer({
28
- volume: 0.02,
29
- instrument: instrumentData,
30
- onEndFile: async () => await this.playNextSong()
31
+ preset: presetData,
32
+ volume: 0.02,
33
+ onEndFile: async () => await this.playNextSong()
31
34
  });
32
35
 
33
- await player.play('binarycontent');
36
+ player.play(buffer);
34
37
  ```
35
38
 
36
39
  ### Control Playback
@@ -43,17 +46,17 @@ player.stop();
43
46
 
44
47
  ### Working with AudioContext
45
48
 
46
- Due to browser autoplay restrictions, you should ensure that your AudioContext is resumed after a user interaction:
49
+ Due to browser autoplay restrictions, you should ensure that your AudioContext is resumed after a user interaction.
47
50
 
48
51
  ## CLI
49
52
 
50
- This package provides a CLI tool for downloading and converting WebAudioFont assets. You need to provide a WebAudioFont ID dans the json file for the destination.
53
+ This package provides a CLI tool for downloading and converting WebAudioFont assets. You need to provide a WebAudioFont ID and the json file for the destination.
51
54
 
52
55
  ```bash
53
- webaudiofont 0000_Chaos_sf2_file dest/instrument.json
56
+ webaudiofont 0000_Chaos_sf2_file dest/preset.json
54
57
  ```
55
58
 
56
- You can find instruments here: [WebAudioFont](https://github.com/surikov/webaudiofont#catalog-of-instruments)
59
+ You can find presets here: [WebAudioFont](https://github.com/surikov/webaudiofont#catalog-of-instruments)
57
60
 
58
61
  ## Browser Compatibility
59
62
 
@@ -81,6 +84,10 @@ Maxime Larrivée-Roy
81
84
 
82
85
  [https://github.com/ZmotriN/midi-audio-player](https://github.com/ZmotriN/midi-audio-player)
83
86
 
84
- ---
85
87
 
86
- If you want, I can also tailor it more toward your Phaser/game use case or add a section comparing it with other MIDI solutions (which can be useful positioning-wise).
88
+ ## Changelog
89
+
90
+ ### Version 1.1.0
91
+ * Complete refactor
92
+ * Optimized WebAudioFont handling
93
+ * Change instrument option to preset