Ignore:
Timestamp:
2013-10-29T13:27:04+13:00 (10 years ago)
Author:
davidb
Message:

Changes after developing the demo for the SMAM-2013 keynote talk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/web-audio/trunk/js-mad/script/main-jsmad.js

    r28388 r28548  
    2626    this.playBufferStore = new Array();
    2727
     28/*
     29    // default is to operate as fast as possible
     30    if (BrowserDetect.browser == "Firefox") {
     31    this.speedup_batch_limit = 100;
     32    this.speedup_pause = 0;
     33    }
     34    else {
     35    // e.g. Chrome
     36    // => the following values played more nicely with letting DSP playback operate straightaway
     37    //    i.e. when jsmad is still working its way through the frames
     38   
     39    this.speedup_batch_limit = 10;
     40    this.speedup_pause = 2;
     41
     42    //speedup_batch_limit = 100;
     43    //speedup_pause = 0;
     44
     45    //console.log("*** Running JsMadProcessing with: batch limit = " + speedup_batch_limit
     46    //      + ", pause = " + this.speedup_pause + " msecs");
     47    }
     48*/
     49
     50    // Assume slow, unless the user explicitly activates "speed up"
     51    this.speedup_batch_limit = 10;
     52    this.speedup_pause = 1000;
     53
     54    this.processing_finished = false;
     55
    2856    stream.requestAbsolute(1 * 1024, function() { that.streamCallback(stream) });
    2957
    3058}
    3159
    32 
    33 
     60JsMadProcessing.prototype.setSpeedupParams = function(new_batch_limit,new_pause) {
     61    this.speedup_batch_limit = new_batch_limit;
     62    this.speedup_pause       = new_pause;
     63}
     64
     65
     66JsMadProcessing.prototype.processingFinished = function() {
     67    return this.processing_finished;
     68}
    3469
    3570JsMadProcessing.prototype.streamCallback = function(stream) {
     
    66101    console.log("*** main-jsmad.js::stream_callback(): hardwiring workflow buffer size to 2048");
    67102
    68     var speedup_batch_limit;
    69     var speedup_pause;
    70    
    71     if (BrowserDetect.browser == "Firefox") {
    72     speedup_batch_limit = 100;
    73     speedup_pause = 0;
    74     }
    75     else {
    76     // e.g. Chrome
    77     // => the following values played more nicely with letting DSP playback operate straightaway
    78     //    i.e. when jsmad is still working its way through the frames
    79    
    80     speedup_batch_limit = 10;
    81     speedup_pause = 2;
    82 
    83     //speedup_batch_limit = 100;
    84     //speedup_pause = 0;
    85 
    86     console.log("*** Running JsMadProcessing with: batch limit = " + speedup_batch_limit
    87             + ", pause = " + speedup_pause + " msecs");
    88     }
     103    var $acc_proc_status = $('#accProcStatus') || null;
    89104
    90105
     
    96111        var speedup_i = 0;
    97112
    98         while (speedup_i < speedup_batch_limit) { // Decode 100 frames at a time, before setTimeout break
     113        while (speedup_i < that.speedup_batch_limit) { // Decode 100 frames at a time, before setTimeout break
    99114
    100115        frame = Mad.Frame.decode(frame, mpeg);
     
    169184        speedup_i++;
    170185        i++;
     186
     187
     188        if ((i%10)==0) {
     189            if ($acc_proc_status != null) {
     190            $acc_proc_status.text(" (decoded " + i + " frames)");
     191            }
     192        }
     193       
    171194        }
    172195       
     
    175198        if (err == "Header decoding failed") {
    176199        console.info("JsMadProcessing::streamCallack() decoded " + i + " frames");
     200        $acc_proc_status.text(" (done)");
     201        that.processing_finished = true;
    177202        }
    178203        else {
     
    183208
    184209    if (more_frames) {
    185         setTimeout(arguments.callee,speedup_pause); // even a delay of '0' gives the browser thread a break
     210        setTimeout(arguments.callee,that.speedup_pause); // even a delay of '0' gives the browser thread a break
    186211    }
    187212    else {
     
    194219        //console.log("Computed song duration: " + song_duration + " secs");
    195220        console.info("JsMad processing done in " + speedup_duration + " secs (a speed factor of " + speedup_factor + ")");
     221
     222        $acc_proc_status.text(" (done)");
     223        that.processing_finished = true;
     224
    196225    }
    197226       
Note: See TracChangeset for help on using the changeset viewer.