Skip to content

Commit

Permalink
Player -- in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jun 16, 2023
1 parent da82ad1 commit adec7b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions javascript/JZZ.midi.STY.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@
for (var k in Player.prototype) if (Player.prototype.hasOwnProperty(k)) self[k] = Player.prototype[k];
return self;
}
Player.prototype.play = function() {
this.playing = true;
};
Player.prototype.stop = function() {
this.playing = false;
};

JZZ.MIDI.STY = STY;
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"grunt-contrib-uglify": "^5.2.2",
"jzz-gui-select": "^1.0.9",
"jzz-midi-gm": "^1.3.3",
"jzz-synth-tiny": "^1.3.5",
"jzz-synth-tiny": "^1.3.6",
"mocha": "^10.2.0",
"nyc": "^15.1.0"
},
Expand Down
17 changes: 16 additions & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h1>Style View</h1>
var div = document.createElement('div');
var playbtn = document.createElement('button');
playbtn.innerHTML = '▶';
playbtn.onclick = play;
div.appendChild(playbtn);
var counter = document.createElement('span');
counter.className = 'cntr';
Expand All @@ -65,11 +66,18 @@ <h1>Style View</h1>
var display = document.createElement('div');
panel.appendChild(display);
var gui;
var player;

var part = [
'Intro A', 'Intro B', 'Intro C', 'Intro D', 'Main A', 'Main B', 'Main C', 'Main D',
'Fill In AA', 'Fill In BB', 'Fill In CC', 'Fill In DD', 'Fill In BA', 'Ending A', 'Ending B', 'Ending C', 'Ending D'
];
function play() {
if (player) {
if (player.playing) player.stop();
else player.play();
}
}
function soon() { alert('Coming soon...'); }
function add_buttons(a) {
var i, b;
Expand Down Expand Up @@ -101,13 +109,20 @@ <h1>Style View</h1>
function load_sty(data) {
try {
var sty = new STY(data);
player = sty.player();
display_sty(sty);
update_controls(sty);
}
catch (err) { alert(err.message); }
}
function display_sty(sty) {
function cleanup() {
display.innerHTML = '';
if (player) {
player.stop();
player = undefined;
}
}
function display_sty(sty) {
gui = new Cell(display, 0, 'Style', sty.name, sty, populate);
gui.expand();
}
Expand Down

0 comments on commit adec7b2

Please sign in to comment.