Skip to content

Commit

Permalink
M2M1
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Nov 3, 2023
1 parent 0abc4eb commit 3ef5975
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# JZZ-gui-Player

MIDI Player GUI for browsers
## MIDI Player GUI for browsers
Supports MIDI 1.0 SMF and MIDI 2.0 Clips

![Firefox](https://jazz-soft.github.io/img/firefox.jpg)
![Chrome](https://jazz-soft.github.io/img/chrome.jpg)
Expand Down Expand Up @@ -97,7 +98,8 @@ Please check the [**API Reference**](https://jazz-soft.net/doc/JZZ/midiplayer.ht
<script>
var player = new JZZ.gui.Player('player');
var data = ... // load MIDI file as a string or a buffer
player.load(new JZZ.MIDI.SMF(data));
player.load(new JZZ.MIDI.SMF(data)); // MIDI 1.0, or
// player.load(new JZZ.MIDI.Clip(data)); // MIDI 2.0
player.play();
</script>
```
Expand Down
11 changes: 7 additions & 4 deletions javascript/JZZ.gui.Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@
var _floating = 0;
function Player(x, y) {
if (!(this instanceof Player)) return new Player(x, y);
this._m2m1 = new JZZ.M2M1();
this._connect(this._m2m1);
var arg = {
at: undefined,
x: undefined,
Expand Down Expand Up @@ -468,7 +470,7 @@
self._out = this;
self._outname = this.name();
self.midiBtn.title(self._outname);
self._connect(this);
self._m2m1.connect(this);
self._waiting = false;
self.onSelect(self._outname);
if (self._playing) {
Expand Down Expand Up @@ -640,11 +642,11 @@
self._closeselect();
if (self._out) {
if (self._playing) for (var c = 0; c < 16; c++) self._out._receive(JZZ.MIDI.allSoundOff(c));
self._disconnect(self._out);
self._m2m1.disconnect(self._out);
self._out.close();
}
self._out = this;
self._connect(this);
self._m2m1.connect(this);
self.midiBtn.title(self._outname);
self.onSelect(self._outname);
setTimeout(function() { self.onSelect(self._outname); }, 0);
Expand Down Expand Up @@ -796,12 +798,13 @@
Player.prototype.disconnect = function(port) {
if (port == this) {
this._conn = false;
if (this._out) this._disconnect(this._out);
if (this._out) this._m2m1.disconnect(this._out);
this._outname = undefined;
this.midiBtn.disable();
}
else {
this._disconnect(port);
this._connect(this._m2m1);
}
};
Player.prototype.connected = function() { return this._outname; };
Expand Down
Loading

0 comments on commit 3ef5975

Please sign in to comment.