- Timestamp:
- 2013-10-29T13:27:04+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/web-audio/trunk/js-mad/script/main-jsmad.js
r28388 r28548 26 26 this.playBufferStore = new Array(); 27 27 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 28 56 stream.requestAbsolute(1 * 1024, function() { that.streamCallback(stream) }); 29 57 30 58 } 31 59 32 33 60 JsMadProcessing.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 66 JsMadProcessing.prototype.processingFinished = function() { 67 return this.processing_finished; 68 } 34 69 35 70 JsMadProcessing.prototype.streamCallback = function(stream) { … … 66 101 console.log("*** main-jsmad.js::stream_callback(): hardwiring workflow buffer size to 2048"); 67 102 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; 89 104 90 105 … … 96 111 var speedup_i = 0; 97 112 98 while (speedup_i < speedup_batch_limit) { // Decode 100 frames at a time, before setTimeout break113 while (speedup_i < that.speedup_batch_limit) { // Decode 100 frames at a time, before setTimeout break 99 114 100 115 frame = Mad.Frame.decode(frame, mpeg); … … 169 184 speedup_i++; 170 185 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 171 194 } 172 195 … … 175 198 if (err == "Header decoding failed") { 176 199 console.info("JsMadProcessing::streamCallack() decoded " + i + " frames"); 200 $acc_proc_status.text(" (done)"); 201 that.processing_finished = true; 177 202 } 178 203 else { … … 183 208 184 209 if (more_frames) { 185 setTimeout(arguments.callee, speedup_pause); // even a delay of '0' gives the browser thread a break210 setTimeout(arguments.callee,that.speedup_pause); // even a delay of '0' gives the browser thread a break 186 211 } 187 212 else { … … 194 219 //console.log("Computed song duration: " + song_duration + " secs"); 195 220 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 196 225 } 197 226
Note:
See TracChangeset
for help on using the changeset viewer.