Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
sunyatasattva committed Apr 12, 2016
2 parents 57baeb2 + d1fc7c3 commit e793c7b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.1.2 — 2016.04.12

### Fixes
* Fixes an error introduced in new versions of Safari through latest patch.

### [Full changelog](https://github.com/sunyatasattva/overtones/compare/1.1.0...1.1.2)

## 1.1.1 — 2016.04.10

### Changes
Expand Down
37 changes: 22 additions & 15 deletions assets/js/lib/webkit-audiocontext-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,54 @@
* Patch to port old implementation of `webkitAudioContext`
* to standards based `audioContext`.
*
* Props to Lajos György Mészáros <[email protected]> for this patch.
* Props to Lajos György Mészáros <[email protected]> for this patch,
* although some edits were needed to make it work.
* @see https://github.com/meszaros-lajos-gyorgy/meszaros-lajos-gyorgy.github.io/blob/master/microtonal/monochord/js/webkit-audio-context-patch.js
*/

/* globals OscillatorNode */

"use strict";

module.exports = function(){
var AudioContext,
OscillatorNode,
oldStart,
oldStop;

if( !window.hasOwnProperty("AudioContext") &&
window.hasOwnProperty("webkitAudioContext") ){
var a = window.AudioContext = window.webkitAudioContext;
AudioContext = window.AudioContext = window.webkitAudioContext;
OscillatorNode = window.OscillatorNode;

if(!a.prototype.hasOwnProperty("createGain")){
a.prototype.createGain = a.prototype.createGainNode;
if(!AudioContext.prototype.hasOwnProperty("createGain")){
AudioContext.prototype.createGain = AudioContext.prototype.createGainNode;
}

if(!OscillatorNode.prototype.hasOwnProperty("start")){
OscillatorNode.prototype.start = OscillatorNode.prototype.noteOn;
}

// make the first parameter optional for firefox <30
var oldStart = OscillatorNode.prototype.start;
OscillatorNode.prototype.start = function(t){
oldStart(t || 0);
oldStart = OscillatorNode.prototype.start;
OscillatorNode.prototype.start = function(t = 0){
oldStart.call(this, t);
};

if(!OscillatorNode.prototype.hasOwnProperty("stop")){
OscillatorNode.prototype.stop = OscillatorNode.prototype.noteOff;
}

// make the first parameter optional for firefox <30
var oldStop = OscillatorNode.prototype.stop;
OscillatorNode.prototype.stop = function(t){
oldStop(t || 0);
oldStop = OscillatorNode.prototype.stop;
OscillatorNode.prototype.stop = function(t = 0){
oldStop.call(this, t);
};

Object.defineProperty(OscillatorNode.prototype, "type", {
get : function(){
get: function() {
return ["sine", "square", "sawtooth", "triangle", "custom"][this.type];
},
set : function(type){
this.type = OscillatorNode.prototype[type.toUpperCase()];
set: function(type) {
this.type = OscillatorNode.prototype[type.toUpperCase()] || type;
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h2>Options</h2>

<footer>
<button href="#" id="help">?</button>
<p class="credits">Designed and crafted with joy by <a href="https://facebook.com/sunyatasattva">Marco Lucio Giannotta</a> and <a href="https://www.facebook.com/skye.lofvander">Skye Løfvander</a>. <span class="version">Version <a href="https://github.com/sunyatasattva/overtones/releases/">1.1.1</a></span></p>
<p class="credits">Designed and crafted with joy by <a href="https://facebook.com/sunyatasattva">Marco Lucio Giannotta</a> and <a href="https://www.facebook.com/skye.lofvander">Skye Løfvander</a>. <span class="version">Version <a href="https://github.com/sunyatasattva/overtones/releases/">1.1.2</a></span></p>
<div class="social">
<!--=include components/_facebook.html -->
<!--=include components/_twitter.html -->
Expand Down

0 comments on commit e793c7b

Please sign in to comment.