Skip to content

Instantly share code, notes, and snippets.

@hoch
Created April 19, 2016 20:20
Show Gist options
  • Save hoch/aad9ad657686d1f492faa8d5dfa2c814 to your computer and use it in GitHub Desktop.
Save hoch/aad9ad657686d1f492faa8d5dfa2c814 to your computer and use it in GitHub Desktop.
DynamicsCompressorNode.reduction polyfill
!function() {
var _isCompressorReductionAudioParam =
typeof (new OfflineAudioContext(1, 1, 44100)).createDynamicsCompressor().reduction
=== 'object';
AudioContext.prototype._createDynamicsCompressor =
AudioContext.prototype.createDynamicsCompressor;
OfflineAudioContext.prototype._createDynamicsCompressor =
OfflineAudioContext.prototype.createDynamicsCompressor;
AudioContext.prototype.createDynamicsCompressor =
OfflineAudioContext.prototype.createDynamicsCompressor = function () {
var compressor = this._createDynamicsCompressor();
if (_isCompressorReductionAudioParam) {
compressor._reduction = compressor.reduction;
Object.defineProperty(compressor, 'reduction', {
get: function () {
return compressor._reduction.value;
}
});
}
return compressor;
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment