comparison core.js @ 2008:fd648345dff9

audioObjects.played member removed, duplicate in audioObjects.metric.wasListenedTo.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Sat, 30 May 2015 10:51:55 +0100
parents 007cee4ea858
children 7c047be322c7
comparison
equal deleted inserted replaced
2007:007cee4ea858 2008:fd648345dff9
475 }; 475 };
476 476
477 this.checkAllPlayed = function() { 477 this.checkAllPlayed = function() {
478 arr = []; 478 arr = [];
479 for (var id=0; id<this.audioObjects.length; id++) { 479 for (var id=0; id<this.audioObjects.length; id++) {
480 if (this.audioObjects[id].played == false) { 480 if (this.audioObjects[id].metric.wasListenedTo == false) {
481 arr.push(this.audioObjects[id].id); 481 arr.push(this.audioObjects[id].id);
482 } 482 }
483 } 483 }
484 return arr; 484 return arr;
485 }; 485 };
511 this.id = id; 511 this.id = id;
512 this.state = 0; // 0 - no data, 1 - ready 512 this.state = 0; // 0 - no data, 1 - ready
513 this.url = null; // Hold the URL given for the output back to the results. 513 this.url = null; // Hold the URL given for the output back to the results.
514 this.metric = new metricTracker(this); 514 this.metric = new metricTracker(this);
515 515
516 this.played = false;
517
518 // Create a buffer and external gain control to allow internal patching of effects and volume leveling. 516 // Create a buffer and external gain control to allow internal patching of effects and volume leveling.
519 this.bufferNode = undefined; 517 this.bufferNode = undefined;
520 this.outputGain = audioContext.createGain(); 518 this.outputGain = audioContext.createGain();
521 519
522 // Default output gain to be zero 520 // Default output gain to be zero
526 this.outputGain.connect(audioEngineContext.outputGain); 524 this.outputGain.connect(audioEngineContext.outputGain);
527 525
528 // the audiobuffer is not designed for multi-start playback 526 // the audiobuffer is not designed for multi-start playback
529 // When stopeed, the buffer node is deleted and recreated with the stored buffer. 527 // When stopeed, the buffer node is deleted and recreated with the stored buffer.
530 this.buffer; 528 this.buffer;
531
532 this.flagAsPlayed = function() { // to be called explicitly when not in loop mode
533 this.played = true;
534 }
535 529
536 this.loopStart = function() { 530 this.loopStart = function() {
537 this.outputGain.gain.value = 1.0; 531 this.outputGain.gain.value = 1.0;
538 this.metric.startListening(audioEngineContext.timer.getTestTime()); 532 this.metric.startListening(audioEngineContext.timer.getTestTime());
539 this.played = true;
540 } 533 }
541 534
542 this.loopStop = function() { 535 this.loopStop = function() {
543 if (this.outputGain.gain.value != 0.0) { 536 if (this.outputGain.gain.value != 0.0) {
544 this.outputGain.gain.value = 0.0; 537 this.outputGain.gain.value = 0.0;
551 this.bufferNode.owner = this; 544 this.bufferNode.owner = this;
552 this.bufferNode.connect(this.outputGain); 545 this.bufferNode.connect(this.outputGain);
553 this.bufferNode.buffer = this.buffer; 546 this.bufferNode.buffer = this.buffer;
554 this.bufferNode.loop = audioEngineContext.loopPlayback; 547 this.bufferNode.loop = audioEngineContext.loopPlayback;
555 this.bufferNode.onended = function() { 548 this.bufferNode.onended = function() {
556 this.owner.metric.stopListening(audioEngineContext.timer.getTestTime()); 549 // Safari does not like using 'this' to reference the calling object!
557 }; 550 this.owner.metric.stopListening(audioEngineContext.timer.getTestTime());
551 };
558 if (this.bufferNode.loop == false) { 552 if (this.bufferNode.loop == false) {
559 this.metric.startListening(audioEngineContext.timer.getTestTime()); 553 this.metric.startListening(audioEngineContext.timer.getTestTime());
560 } 554 }
561 this.bufferNode.start(startTime); 555 this.bufferNode.start(startTime);
562 }; 556 };