Skip to content

Commit

Permalink
closeAudioContext()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Apr 14, 2024
1 parent c705a91 commit 8624a09
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ by running `npm remove midi-test --save-dev`.

```html
<script src="https://cdn.jsdelivr.net/npm/jzz"></script> // the latest version, or
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script> // any particular version
//...
```

##### CDN (unpkg)

```html
<script src="https://unpkg.com/jzz"></script> // the latest version, or
<script src="https://unpkg.com/[email protected].1"></script> // any particular version
<script src="https://unpkg.com/[email protected].2"></script> // any particular version
//...
```

Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,10 @@ declare namespace JZZ {
*
* https://jazz-soft.net/doc/JZZ/lib.html#getAudioContext */
getAudioContext(): any;
/** Activate and return window.AudioContext
*
* https://jazz-soft.net/doc/JZZ/lib.html#closeAudioContext */
closeAudioContext(): any;
/** Encode string to Base64
*
* https://jazz-soft.net/doc/JZZ/lib.html#toBase64 */
Expand Down
3 changes: 2 additions & 1 deletion javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
})(this, function() {

var _scope = typeof window === 'undefined' ? global : window;
var _version = '1.8.1';
var _version = '1.8.2';
var i, j, k, m, n;

/* istanbul ignore next */
Expand Down Expand Up @@ -3848,6 +3848,7 @@
JZZ.lib.copyMidi2Helpers = _copyUmpHelpers;
JZZ.lib.copyUmpHelpers = _copyUmpHelpers;
JZZ.lib.getAudioContext = function() { _initAudioContext(); return _ac; };
JZZ.lib.closeAudioContext = function() { if (_ac) _ac.close(); _ac = undefined; };
var _b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
JZZ.lib.fromBase64 = function(input) {
var output = '';
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jzz",
"version": "1.8.1",
"version": "1.8.2",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand All @@ -22,15 +22,15 @@
"jazz-midi": "^1.7.9"
},
"devDependencies": {
"eslint": "^8.57.0",
"eslint": "^9.0.0",
"grunt": "^1.6.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
"midi-test": "^1.2.8",
"mocha": "^10.3.0",
"midi-test": "^1.2.9",
"mocha": "^10.4.0",
"nyc": "^15.1.0",
"web-audio-test": "^0.0.7",
"web-midi-test": "^1.2.6"
"web-audio-test": "^0.0.8",
"web-midi-test": "^1.2.7"
},
"runkitExampleFilename": "runkit.js",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions test/engine2.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ var DOM = {
AudioContext: function() {
return {
resume: function() { this.state = 'running'; },
close: function() { this.state = 'closed'; },
createOscillator: function() {
return {
connect: function() {},
Expand Down
1 change: 1 addition & 0 deletions test/engine3.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ window.dispatchEvent = function(evt) { if (document.handle[evt.name]) document.h
window.webkitAudioContext = function() {
return {
resume: function() { this.state = 'running'; },
close: function() { this.state = 'closed'; },
createOscillator: function() { return { connect: function() {}, noteOn: function() {}, noteOff: function() {} }; },
createGainNode: function() { return { connect: function() {}, gain: { setTargetAtTime: function() {} } }; }
};
Expand Down
5 changes: 4 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ module.exports = function(JZZ, PARAMS, DRIVER) {
},

init_web_audio: function() {
it('Init Web Audio', function() {
it('Web Audio', function() {
JZZ.lib.closeAudioContext();
JZZ.lib.getAudioContext();
JZZ.lib.closeAudioContext();
JZZ.lib.getAudioContext();
if (typeof window != 'undefined' && window.dispatchEvent) window.dispatchEvent({ name: 'keydown' });
});
Expand Down
2 changes: 1 addition & 1 deletion web-midi-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"web-midi-api"
],
"dependencies": {
"jzz": "^1.8.1"
"jzz": "^1.8.2"
},
"contributors": [
{
Expand Down

0 comments on commit 8624a09

Please sign in to comment.