Element.prototype.getElementWidth = function() { if (typeof this.clip !== "undefined") { return this.clip.width; } else { if (this.style.pixelWidth) { return this.style.pixelWidth; } else { return this.offsetWidth; } } }; Element.prototype.getElementHeight = function() { if (typeof this.clip !== "undefined") { return this.clip.height; } else { if (this.style.pixelHeight) { return this.style.pixelHeight; } else { return this.offsetHeight; } } }; function isDefined(v) { return typeof v !== "undefined"; } /* // ***** */ /* Move above in to more general header file */ // Useful shorthands var SVG_NS ="http://www.w3.org/2000/svg"; var XLINK_NS = "http://www.w3.org/1999/xlink"; var hasStructuredAudio = false; var hasChromaSelfSimMap = false; var allData = null; var yScaleSimImg = null; var caAlgorithm = null; var duration = null; var webAudioContext = null; //var webAudioSource = null; //var webAudioJSProcessor = null; if (typeof AudioContext == "function") { webAudioContext = new AudioContext(); } else if (typeof webkitAudioContext == "function") { webAudioContext = new webkitAudioContext(); } // Latest Firefox now seems to natively support Web audio, but doesn // seem to play nicely with the work here // => set webAudioContext back to null to force it to use the // original Firefox audio extension var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; if (is_firefox) { webAudioContext = null; } // ****** // * Frequency Player/Plotter part of Hybrid Player // ****** function freqPlayerAudioPlay(event) { console.info("Audio play pressed"); if (audioMode == "stopped") { // Nolonger used (Firefox fails to fire this event on a fresh 'play' once an existing play has finished) // take a fresh snapshot of the transform mode selected in the web page //var transformMode = $('input:radio[name=visualization]:checked').val(); //chromaTransform.setTransformMode(transformMode); } audioMode = "playing"; } function freqPlayerAudioPause() { console.info("Audio pause pressed"); audioMode = "paused"; // if stoping dualPlay leftSong.pause(); rightSong.pause(); baseSong.volume = 1.0; } function freqPlayerAudioEnded() { console.info("Audio play/playlist ended"); audioMode = "stopped"; needsRefresh = true; //console.log("reset freq plot called"); //frequencyPlotter.reset(); } // ****** // * Meandre (server-side) workflow part of Hybrid Player // ****** // // Started when 'play' is pressed // (workflows now in their own folder '$httpCollection/script/meandre-workflow/*.js) // the global variable 'meandreWorkflows' stores which flows are available // ****** // * Structured Audio (CAA) part of Hybrid Player // ****** function caaInit() { // duration information is now available var audio = document.getElementById('rta-audio-element'); duration = audio.duration; if (!isDefined(allData)) { // degenerate case var ground_truth = []; // empty ground truth var numSegs = 4; var gap = duration/numSegs; var label = [ "a", "b" ]; var val = [ 0, 1]; var equal_spacing = []; for (var i=0; i make empty //allData = [ [], JSON.parse(gs.documentMetadata["json_seriesData"]) ]; // Set up position zero as empty "ground truth" data allData = [ [] ]; // **** // The following is actually the XSLT page param // 'p.yScaleSimImg;, which presumably automatically generates // gs.cgiParams.yScaleSimImg (if present). Defaults to 0.5 yScaleSimImg=gs.variables.cgiargYScaleSimImg || 0.5; caAlgorithm=gs.variables.cgiargCAAlgorithm; $(function() { var audio = document.getElementById('rta-audio-element'); audio.addEventListener('loadedmetadata', caaInit, false); audio.addEventListener('MozAudioAvailable', freqPlayerAudioAvailable, false); audio.addEventListener('loadedmetadata', freqPlayerLoadedAudioMetadata, false); audio.addEventListener('play', freqPlayerAudioPlay, false); audio.addEventListener('pause', freqPlayerAudioPause, false); audio.addEventListener('ended', freqPlayerAudioEnded, false); console.log("****### Adding dual play loadmetadata event listeners in hybrid-audio-player.js"); baseSong = document.getElementById("rta-audio-element"); baseSong.addEventListener('loadedmetadata', initPannedPlaybackSampleRate, false); leftSong = document.getElementById("leftsong"); leftSong.addEventListener('MozAudioAvailable', audioAvailableLeft, false); leftSong.addEventListener('loadedmetadata', loadedMetadataLeft, false); rightSong = document.getElementById("rightsong"); rightSong.addEventListener('MozAudioAvailable', audioAvailableRight, false); rightSong.addEventListener('loadedmetadata', loadedMetadataRight, false); var controlMarkerDiv = document.getElementById("controlMarker"); controlMarkerDiv.addEventListener('mousedown', playFromOffsetRTAEvent, false); /* var oControlDiv = controlMarker.previousSibling; console.log("** ocontrol = " + oControlDiv + ", type = " + oControlDiv.nodeType) // skip over any text nodes ... (done this way to cope with browser differences) while (oControlDiv && oControlDiv.nodeType != 1) { oControlDiv = oControlDiv.previousSibling; console.log("** in loop ocontrol = " + oControlDiv + ", type = " + oControlDiv.nodeType) } if (oControlDiv) { oControlDiv.setAttribute("onmousedown","javascript:playFromOffsetRTAEvent(event)"); //oControlDiv.addEventListener('mousedown', playFromOffsetRTAEvent, false); //oControlDiv.addEventListener('mousedown', playFromOffsetRTAEvent, false); } else { console.warn("Warning: failed to find SoundManager2 PagePlayer oControl div"); } */ });