Changeset 29880

Show
Ignore:
Timestamp:
14.05.2015 15:52:35 (4 years ago)
Author:
davidb
Message:

Audio scriptProcessed made a global variable. Possible on Chrome that this was being garbage collected when a local variable, leading to the audio processing not working when video play pressed

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/respooled/collect/popup-video-respooled/js/in-the-groove.js

    r29867 r29880  
     1"use strict"; 
    12 
    23// https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createScriptProcessor 
     
    45var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); 
    56 
     7//var InTheGroove = true; 
    68var InTheGroove = false; 
    79var MissingTheGroovePending = false; 
     
    1618var prev_input = [0,0]; 
    1719 
     20var tinnyEffectNode = null; 
     21 
    1822$(document).ready(function() { 
    1923    $('#video').on('loadedmetadata', function() { 
    2024 
    21     displayDuration(this.duration);  
     25    //displayDuration(this.duration);    
    2226 
    2327    // Create a MediaElementAudioSourceNode 
    2428    // Feed the HTMLMediaElement into it 
    2529    var source = audioCtx.createMediaElementSource(this); 
    26      
     30    console.log("**** video source = " + source); 
     31 
    2732    // connect the AudioBufferSourceNode to the tinnyEffectNode 
    2833    // and the tinnyEffectNode to the destination, so we can play the 
     
    3035    // pressed 
    3136 
    32     var tinnyEffectNode = audioCtx.createScriptProcessor(bufferSize, 2, 2); 
     37    tinnyEffectNode = audioCtx.createScriptProcessor(bufferSize, 2, 2); 
    3338    tinnyEffectNode.onaudioprocess = function(e) { 
    3439 
     
    4045        for (var i = 0; i < bufferSize; i++) { 
    4146            if (InTheGroove) { 
    42             if (c==0) { 
    43                 output[i] = input[i]; 
    44             } 
    45             else { 
    46                 output[i] = 0; 
    47             } 
     47            output[i] = input[i]; 
    4848            } 
    4949            else { 
     
    5151            output[i] = input[i] - prev_input[c]; 
    5252            } 
     53            //if (i==128) { 
     54            //  console.log("*** input[128] = " + input[i]); 
     55            //} 
     56 
    5357            prev_input[c] = input[i]; 
    5458        }