Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/abcjs-basic-min.js
#	dist/abcjs-basic.js
#	dist/abcjs-basic.js.map
#	src/synth/create-synth.js
  • Loading branch information
paulrosen committed Feb 13, 2022
2 parents fc327c5 + e7eb6c6 commit 80c8780
Show file tree
Hide file tree
Showing 12 changed files with 2,944 additions and 2,937 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16.10.0

RUN npm install -g npm@8.4.1
RUN npm install -g npm@8.5.0

RUN mkdir /srv/app && chown node:node /srv/app

Expand Down
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version 6.0.0-beta.39

## Bugs

* Add some info to the return of the prime() method

* Fix iOS not playing because audioContext doesn't stay running

# Version 6.0.0-beta.38

## Bugs
Expand Down
4 changes: 2 additions & 2 deletions dist/abcjs-basic-min.js

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions dist/abcjs-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15367,29 +15367,28 @@ function CreateSynth() {
self.debugCallback("creationTime = " + Math.floor((activeAudioContext().currentTime - startTime) * 1000) + "ms");
}

function resolveData(me) {
var duration = me && me.audioBuffers && me.audioBuffers.length > 0 ? me.audioBuffers[0].duration : 0;
return {
status: activeAudioContext().state,
duration: duration
};
}

Promise.all(allPromises).then(function () {
// Safari iOS can mess with the audioContext state, so resume if needed.
if (activeAudioContext().state === "suspended") {
activeAudioContext().resume().then(function () {
resolve({
status: "ok",
seconds: 0
});
resolve(resolveData(self));
});
} else if (activeAudioContext().state === "interrupted") {
activeAudioContext().suspend().then(function () {
activeAudioContext().resume().then(function () {
resolve({
status: "ok",
seconds: 0
});
resolve(resolveData(self));
});
});
} else {
resolve({
status: "ok",
seconds: 0
});
resolve(resolveData(self));
}
});
});
Expand Down Expand Up @@ -28150,7 +28149,7 @@ module.exports = unhighlight;
\********************/
/***/ (function(module) {

var version = '6.0.0-beta.38';
var version = '6.0.0-beta.39';
module.exports = version;

/***/ })
Expand Down
2 changes: 1 addition & 1 deletion dist/abcjs-basic.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/abcjs-plugin-min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion docs/audio/synthesized-sound.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ This creates the actual buffer - it doesn't require a network connection since a

After calling this, everything is setup so you can freely call the rest of the functions to control how the audio works.

This returns a promise that is `{ status: audioContextStatus, duration: lengthInSecondsOfAudio }`

Note that normally the status will be "running". On iOS, though, it can sometimes be either "suspended" or "interrupted". It might require user intervention to resolve this.

#### Example
```javascript
synth.init(...).then(() => {
synth.prime(() => {
synth.prime().then((response) => {
console.log(response.status)
...
});
});
Expand Down
5 changes: 3 additions & 2 deletions examples/basic-synth.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
// console.log(response); // this contains the list of notes that were loaded.
// midiBuffer.prime actually builds the output buffer.
return midiBuffer.prime();
}).then(function () {
statusDiv.innerHTML += "<div>Audio object has been primed</div>";
}).then(function (response) {
statusDiv.innerHTML += "<div>Audio object has been primed (" + response.duration + " seconds).</div>";
statusDiv.innerHTML += "<div>status = " + response.status + "</div>"
// At this point, everything slow has happened. midiBuffer.start will return very quickly and will start playing very quickly without lag.
midiBuffer.start();
statusDiv.innerHTML += "<div>Audio started</div>";
Expand Down
Loading

0 comments on commit 80c8780

Please sign in to comment.