| 147 | } |
| 148 | |
| 149 | function connectify(context) { |
| 150 | if (context.__connectified__ === true) return; |
| 151 | |
| 152 | var gain = context.createGain(), |
| 153 | proto = Object.getPrototypeOf(Object.getPrototypeOf(gain)), |
| 154 | oconnect = proto.connect; |
| 155 | |
| 156 | proto.connect = shimConnect; |
| 157 | context.__connectified__ = true; // Prevent overriding connect more than once |
| 158 | |
| 159 | function shimConnect() { |
| 160 | var node = arguments[0]; |
| 161 | arguments[0] = Super.isPrototypeOf ? (Super.isPrototypeOf(node) ? node.input : node) : (node.input || node); |
| 162 | oconnect.apply(this, arguments); |
| 163 | return node; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | function dbToWAVolume(db) { |
| 168 | return Math.max(0, Math.round(100 * Math.pow(2, db / 6)) / 100); |