Skip to content

Commit

Permalink
Improved examples, refactoring, fixes.
Browse files Browse the repository at this point in the history
Updated and prettified mobile-friendly examples.
Updated support for latest Omnitone.
ES6 compliance.
General bug fixes.
  • Loading branch information
drewbitllama committed Oct 27, 2017
1 parent e72f2fe commit c04fb7b
Show file tree
Hide file tree
Showing 54 changed files with 2,001 additions and 1,745 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module.exports = {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters#Browser_compatibility
"prefer-rest-params": 0,
}
};
};
27 changes: 8 additions & 19 deletions build/songbird.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,16 +978,7 @@ Listener.prototype.setOrientation = function(forwardX, forwardY, forwardZ,
*/
Listener.prototype.setFromMatrix = function(matrix4) {
// Update ambisonic rotation matrix internally.
this._tempMatrix3[0] = matrix4.elements[0];
this._tempMatrix3[1] = matrix4.elements[1];
this._tempMatrix3[2] = matrix4.elements[2];
this._tempMatrix3[3] = matrix4.elements[4];
this._tempMatrix3[4] = matrix4.elements[5];
this._tempMatrix3[5] = matrix4.elements[6];
this._tempMatrix3[6] = matrix4.elements[8];
this._tempMatrix3[7] = matrix4.elements[9];
this._tempMatrix3[8] = matrix4.elements[10];
this._renderer.setRotationMatrix3(this._tempMatrix3);
this._renderer.setRotationMatrix4(matrix4.elements);

// Extract position from matrix.
this.position[0] = matrix4.elements[12];
Expand Down Expand Up @@ -2319,7 +2310,6 @@ function Source(songbird, options) {
this._attenuation.output.connect(this._directivity.input);
this._directivity.output.connect(this._encoder.input);

this.input.connect(this._encoder.input);
this._encoder.output.connect(songbird._listener.input);

// Assign initial conditions.
Expand Down Expand Up @@ -2361,11 +2351,12 @@ Source.prototype._update = function() {
}
let distance = Math.sqrt(this._dx[0] * this._dx[0] +
this._dx[1] * this._dx[1] + this._dx[2] * this._dx[2]);

// Normalize direction vector.
this._dx[0] /= distance;
this._dx[1] /= distance;
this._dx[2] /= distance;
if (distance > 0) {
// Normalize direction vector.
this._dx[0] /= distance;
this._dx[1] /= distance;
this._dx[2] /= distance;
}

// Compuete angle of direction vector.
let azimuth = Math.atan2(-this._dx[0], this._dx[2]) *
Expand Down Expand Up @@ -5301,7 +5292,7 @@ const HRIRList = [
];


// Base URL.
// Base URL.
const SourceURL = {
GITHUB:
'https://cdn.rawgit.com/GoogleChrome/omnitone/master/build/resources/',
Expand Down Expand Up @@ -6176,7 +6167,6 @@ Omnitone.createFOADecoder = function(context, videoElement, options) {
* @return {FOARenderer}
*/
Omnitone.createFOARenderer = function(context, config) {
console.log(config);
return new FOARenderer(context, config);
};

Expand Down Expand Up @@ -6608,7 +6598,6 @@ function FOARenderer(context, config) {
renderingMode: RenderingMode.AMBISONIC,
};

console.log(config);
if (config.channelMap) {
if (Array.isArray(config.channelMap) && config.channelMap.length === 4) {
this._config.channelMap = config.channelMap;
Expand Down
8 changes: 4 additions & 4 deletions build/songbird.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/Songbird.html
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions doc/Source.html
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="source.js.html">source.js</a>, <a href="source.js.html#line171">line 171</a>
<a href="source.js.html">source.js</a>, <a href="source.js.html#line170">line 170</a>
</li></ul></dd>


Expand Down Expand Up @@ -1984,7 +1984,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/Utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
7 changes: 4 additions & 3 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ <h3>Porting PannerNode projects to Songbird</h3><p>For projects already employin
<pre class="prettyprint source lang-bash"><code>npm install # install dependencies.
npm run build # build a non-minified library.
npm run watch # recompile whenever any source file changes.
npm run build-all # build a minified library and copy static resources.
npm run doc # generate documentation.</code></pre><h2>Testing</h2><p>Songbird uses <a href="https://travis-ci.org/">Travis</a> and
npm run build-all # build a minified library.
npm run build-doc # generate documentation.
npm run eslint # lint code for ES6 compatibility.</code></pre><h2>Testing</h2><p>Songbird uses <a href="https://travis-ci.org/">Travis</a> and
<a href="https://karma-runner.github.io/1.0/index.html">Karma</a> test runner for
continuous integration. To run the test suite locally, clone the repository,
install dependencies and launch the test runner:</p>
Expand Down Expand Up @@ -665,7 +666,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/songbird.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
14 changes: 7 additions & 7 deletions doc/source.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ <h1 class="page-title">Source: source.js</h1>
this._attenuation.output.connect(this._directivity.input);
this._directivity.output.connect(this._encoder.input);

this.input.connect(this._encoder.input);
this._encoder.output.connect(songbird._listener.input);

// Assign initial conditions.
Expand Down Expand Up @@ -221,11 +220,12 @@ <h1 class="page-title">Source: source.js</h1>
}
let distance = Math.sqrt(this._dx[0] * this._dx[0] +
this._dx[1] * this._dx[1] + this._dx[2] * this._dx[2]);

// Normalize direction vector.
this._dx[0] /= distance;
this._dx[1] /= distance;
this._dx[2] /= distance;
if (distance > 0) {
// Normalize direction vector.
this._dx[0] /= distance;
this._dx[1] /= distance;
this._dx[2] /= distance;
}

// Compuete angle of direction vector.
let azimuth = Math.atan2(-this._dx[0], this._dx[2]) *
Expand Down Expand Up @@ -391,7 +391,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Songbird.
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Fri Oct 13 2017 11:59:59 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 27 2017 11:59:57 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit c04fb7b

Please sign in to comment.