Compare commits

...

10 commits

Author SHA1 Message Date
Matthew Hodgson 125e130f61 lost stuff from the MIDI hackathon 2014-11-28 01:02:50 +00:00
Matthew Hodgson 7779ecc10d last minute uncommitted changes, apparently 2014-11-28 01:02:50 +00:00
manuroe 1d6621c31c Code for the video demo:
Fixed log duration. Renable partition multilines
2014-10-19 10:28:40 +02:00
Matthew Hodgson 6b99662184 fiddle log function 2014-10-19 08:55:47 +01:00
manuroe 453a4f8f8b Fixed runtime errors 2014-10-19 09:08:27 +02:00
Matthew Hodgson 4f58d41c15 support for chords & rests 2014-10-19 07:52:59 +01:00
manuroe acb76032b7 Added MIDI.js and VexFlow libs 2014-10-19 08:47:39 +02:00
manuroe bc9350dbb5 Go on with hacking midi: load all messages for all rooms. So that, we have the full midi partition with the notes for computing the tempo. 2014-10-19 08:44:03 +02:00
manuroe e09dd47f4d MIDI event handler 2014-10-19 08:06:45 +02:00
manuroe e15a168152 Room with music tab 2014-10-19 08:01:33 +02:00
30 changed files with 27316 additions and 2 deletions

136
scripts/midi_to_matrix.pl Executable file
View file

@ -0,0 +1,136 @@
#!/opt/local/bin/perl
use strict;
use warnings;
use Data::Dumper;
use IO::Async::Loop;
use Net::Async::Matrix;
use Net::Pcap;
use Data::HexDump;
use JSON;
use Music::Chord::Namer qw/chordname/;
$| = 1;
our $notes = {};
our $notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
our $room;
my $loop = IO::Async::Loop->new;
my $matrix = Net::Async::Matrix->new(
server => "echo-matrix:8008",
on_log => sub { warn "log: @_\n" },
on_room_new => sub {
my ($matrix, $new_room) = @_;
warn "[Matrix] have a room ID: " . $new_room->room_id . "\n";
$room = $new_room if ($new_room->room_id eq '!GaUcuyvZyXfoqmQTNR:echo-matrix');
},
on_error => sub {
print STDERR "Matrix failure: @_\n";
},
);
$loop->add( $matrix );
$matrix->login(
# XXX: password is broke
user_id => 'matthew',
access_token => 'QG1hdHRoZXc6ZWNoby1tYXRyaXg..ZVZbCQuOmnhwakNnOt',
)->get;
$matrix->join_room( '#midi:echo-matrix' )->get;
# ->on_done(sub {
# print Dumper([@_]);
# ($room) = @_;
# warn "joined $room";
# } )->get;
$matrix->start();
my $err = '';
my $dev = "en1";
my $pcap = pcap_open_live($dev, 1024, 0, 100, \$err);
die $err if $err;
my ($net, $mask);
pcap_lookupnet($dev, \$net, \$mask, \$err);
die $err if $err;
my $filter_str = "src host 10.12.76.65 and udp and port 5005";
my $filter;
if (pcap_compile($pcap, \$filter, $filter_str, 1, $net) == -1) {
die "Unable to compile filter string '$filter_str'\n";
}
pcap_setfilter($pcap, $filter);
while (1) {
pcap_dispatch($pcap, -1, \&process_packet, "");
#print ".\n";
}
pcap_close($pcap);
sub handle_event {
my ($event) = @_;
print to_json($event, { pretty => 1 });
if ($event->{state} eq 'on') {
$notes->{$event->{note}} = 1;
}
else {
delete $notes->{$event->{note}};
}
if (scalar keys %$notes >= 3) {
my $chord = (chordname(map { $notenames->[$_ % 12] } sort keys %$notes))[0];
print "$chord\n";
$room->send_message( $chord )->get;
}
# HACK HACK HACK HACK
$room->_do_POST_json( "/send/org.matrix.midi", $event )->get;
}
sub process_packet {
my ($user_data, $header, $packet) = @_;
my ($ether, $ip, $udp, $rtp_byte, $payload, $seqnum, $ts, $ssrc, @midi)
= unpack("a14a20a8CCSNNC*", $packet);
return if ($rtp_byte == 0xff);
#print HexDump $packet;
my $midilen;
if ($midi[0] & 0x80) { # long header
$midilen = (($midi[0] & 0x0f) << 8) | $midi[1];
shift @midi;
shift @midi;
}
else { # short header
$midilen = ($midi[0] & 0x0f);
shift @midi;
}
my $midiparsed = 0;
my $state = ($midi[0] >> 4 == 0x9 ? "on" : "off");
my $channel = ($midi[0] & 0x0f) + 1;
shift (@midi); $midiparsed++;
while ($midiparsed < $midilen) {
my ($event) = {
midi_ts => $ts,
note => $midi[0],
channel => $channel,
state => ($midi[1] == 0 ? "off" : $state),
velocity => $midi[1],
};
handle_event($event);
shift (@midi); $midiparsed++;
shift (@midi); $midiparsed++;
if (scalar @midi) {
$ts += shift @midi; $midiparsed++;
}
}
}

View file

@ -440,7 +440,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
// will be available (as opposite to the global /initialSync done at startup)
if (!isStateEvent) { // Do not consider state events
if (event.event_id && eventMap[event.event_id]) {
console.log("discarding duplicate event: " + JSON.stringify(event, undefined, 4));
//console.log("discarding duplicate event: " + JSON.stringify(event, undefined, 4));
return;
}
else {
@ -481,6 +481,12 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
case 'm.room.topic':
handleRoomTopic(event, isLiveEvent, isStateEvent);
break;
case 'org.matrix.midi':
MidiEventHandler.handleEvent(event, isLiveEvent);
break;
default:
console.log("Unable to handle event type " + event.type);
console.log(JSON.stringify(event, undefined, 4));

View file

@ -107,7 +107,7 @@ angular.module('eventStreamService', [])
// Initial sync: get all information and the last 30 messages of all rooms of the user
// 30 messages should be enough to display a full page of messages in a room
// without requiring to make an additional request
matrixService.initialSync(30, false).then(
matrixService.initialSync(1, false).then(
function(response) {
var rooms = response.data.rooms;
for (var i = 0; i < rooms.length; ++i) {

View file

@ -0,0 +1,311 @@
/*
Copyright 2014 matrix.org
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
var MidiEventHandler = {
midiQueue: [],
startTime: 0,
vexTabString: "",
chord: {
start_midi_ts: 0,
end_midi_ts: 0,
notes: {},
},
currentMeasureTime: 0,
perLine: -1,
pastMidiEventsInWrongOrder: [],
init: function (eventHandlerService) {
// During initialSync, handleEvent is called for each event from latest events to the past.
// Need to reorder them.
var self = this;
eventHandlerService.waitForInitialSyncCompletion().then(
function() {
for (var i = self.pastMidiEventsInWrongOrder.length - 1; i >= 0; i--) {
self.handleEvent(self.pastMidiEventsInWrongOrder[i], true);
}
}
);
},
reset: function() {
this.vexTabString = "";
this.currentMeasureTime = 0;
this.perLine = -1;
this.ready = false;
this.beat = 0;
this.intial4Timings = [];
this.renderer = new Vex.Flow.Renderer($('#boo')[0],
Vex.Flow.Renderer.Backends.CANVAS);
this.artist = new Vex.Flow.Artist(10, 10, 750, {scale: 0.8});
this.vextab = new Vex.Flow.VexTab(this.artist);
// key is the note string, value its midi_ts value when it went to ON
this.notesON = {};
},
/*
vextab.parse("tabstave notation=true tablature=false \n\
notes 4-5-6/3 ## =|: 5-4-2/3 2/2 =:|\n\
\n\
tabstave notation=true tablature=false\n\
notes C-D-E/4 #0# =:: C-D-E-F/4 =|=");
artist.render(renderer);
*/
setReady: function() {
this.ready = true;
this.render();
},
getLogDuration: function(duration) {
var fraction = duration / this.beat;
//console.log(fraction);
// log2(4) = 2 # 4 beats == whole bar == w
// log2(2) = 1 # 2 beats == half = h
// log2(1) = 0
return Math.floor(Math.log2(fraction));
},
renderChord: function(duration, rest) {
var musicFraction;
var logDuration = this.getLogDuration(duration);
var trashIt = false; // Flag to ignore artefact(???)
switch (logDuration) {
case 2:
musicFraction = "w";
break;
case 1:
musicFraction = "h";
break;
case 0:
musicFraction = "q";
break;
// quantise to quavers for now
case -1:
musicFraction = "8";
break;
case -2:
musicFraction = "16";
break;
case -3:
musicFraction = "32";
break;
default:
console.log("## Ignored note");
// Too short, ignore it
trashIt = true;
break;
}
// Matthew is about to fix it
if (trashIt) return;
this.currentMeasureTime += duration / this.beat;
var s = ":" + musicFraction + " ";
if (rest) {
s += "##";
}
else {
var notes = [];
for (var note in this.chord.notes) {
if (this.chord.notes.hasOwnProperty(note)) {
notes.push(note);
}
}
if (notes.length > 1) {
s += "(";
for (var i = 0; i < notes.length; i++) {
s += notes[i];
if (i < notes.length - 1) s+= ".";
}
s += ")";
}
else {
s += notes[0];
}
}
this.addNote(s);
},
handleEvent: function(event, isLiveEvent) {
if(!isLiveEvent) {
this.pastMidiEventsInWrongOrder.push(event);
return;
}
if (0 === this.beat)
{
// We do not know the beat yeat
// Wait for 4 notes to compute the tempo
if ("on" === event.content.state) {
this.intial4Timings.push(parseInt(event.content.midi_ts));
if (4 === this.intial4Timings.length) {
// un beat: duree d'un temps
this.beat = (this.intial4Timings[3] - this.intial4Timings[0]) / 3;
console.log("## beat: " + this.beat);
}
}
return;
}
var vexNote = this.getVexNote( this.getMidiNote(event.content.note) );
if ("on" === event.content.state) {
var midi_ts = parseInt(event.content.midi_ts);
this.notesON[vexNote] = midi_ts;
if (event.content.midi_ts - this.chord.start_midi_ts < 300) { // empirically
// just add it to the current chord we're building up.
this.chord.notes[vexNote]++;
}
else {
// render the last note/chord
this.renderChord(this.chord.end_midi_ts - this.chord.start_midi_ts, false);
// check if it's been so long since the last note that we should do a rest.
var logDuration = this.getLogDuration(midi_ts - this.chord.end_midi_ts);
//console.log((midi_ts - this.chord.end_midi_ts) + " -> " + logDuration);
if (logDuration >= 1) {
this.renderChord(midi_ts - this.chord.end_midi_ts, true);
}
// start a new chord
this.chord.notes = {};
this.chord.notes[vexNote]++;
this.chord.start_midi_ts = midi_ts;
this.chord.end_midi_ts = 0;
}
}
else if (this.notesON[vexNote]) // note is turning off.
{
// How long the note lasts
this.chord.end_midi_ts = parseInt(event.content.midi_ts);
delete this.notesON[vexNote];
// TODO: optimisation: we could render this note now if we know there are no others sounding...
}
},
addNote: function (vexNote) {
if (-1 === this.perLine)
{
// Create a new line
if ("" !== this.vexTabString) {
// Add a line break with the previous line
this.vexTabString += "\n";
}
this.vexTabString += "tabstave notation=true tablature=false clef=treble time=C\nnotes ";
this.perLine = 0;
}
this.vexTabString += vexNote;
console.log(this.currentMeasureTime);
if (this.currentMeasureTime >= 4) {
this.perLine = this.perLine + 1;
if (this.perLine <= 3) {
this.vexTabString += " | ";
}
else {
// Break the line
this.vexTabString += "\n";
this.perLine = -1;
}
this.currentMeasureTime = 0;
}
else {
this.vexTabString += " ";
}
if (this.ready) {
this.render();
}
},
getVexNote: function(midiNote) {
return midiNote;
// TODO: manage this
var vexNote;
if (2 === midiNote.length) {
if (this.vexTabString.endsWith('#')) {
vexNote = midiNote[0] + 'n/' + midiNote[1];
}
else
{
vexNote = midiNote[0] + '/' + midiNote[1];
}
}
return vexNote;
},
getMidiNote: function(midiNoteNumber) {
var noteString = [ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" ];
var octave = Math.floor(midiNoteNumber / 12) - 1;
var noteIndex = (midiNoteNumber % 12);
return noteString[noteIndex] + "/" + octave;
},
render: function() {
console.log("####\n" + this.vexTabString);
this.vextab.reset();
this.artist.reset();
this.vextab.parse(this.vexTabString);
this.artist.render(this.renderer);
}
};

67
webclient/inc/Base64.js Executable file
View file

@ -0,0 +1,67 @@
// http://ntt.cc/2008/01/19/base64-encoder-decoder-with-javascript.html
// window.atob and window.btoa
(function (window) {
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
window.btoa || (window.btoa = function encode64(input) {
input = escape(input);
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return output;
});
window.atob || (window.atob = function(input) {
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
var base64test = /[^A-Za-z0-9\+\/\=]/g;
if (base64test.exec(input)) {
alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + "Expect errors in decoding.");
}
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
do {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return unescape(output);
});
}(this));

View file

@ -0,0 +1,29 @@
Software License Agreement (BSD License)
Copyright (c) 2007, Scott Schiller (schillmania.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of schillmania.com nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission from schillmania.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,104 @@
/** @license
SoundManager 2: JavaScript Sound for the Web
----------------------------------------------
http://schillmania.com/projects/soundmanager2/
Copyright (c) 2007, Scott Schiller. All rights reserved.
Code provided under the BSD License:
http://schillmania.com/projects/soundmanager2/license.txt
V2.97a.20111220
*/
(function(G){function W(W,la){function l(b){return function(a){var d=this._t;return!d||!d._a?(d&&d.sID?c._wD(k+"ignoring "+a.type+": "+d.sID):c._wD(k+"ignoring "+a.type),null):b.call(this,a)}}this.flashVersion=8;this.debugMode=!0;this.debugFlash=!1;this.consoleOnly=this.useConsole=!0;this.waitForWindowLoad=!1;this.bgColor="#ffffff";this.useHighPerformance=!1;this.html5PollingInterval=this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock=
!1;this.useHTML5Audio=!0;this.html5Test=/^(probably|maybe)$/i;this.preferFlash=!0;this.noSWFCache=!1;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};
this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,
duration:null};this.movieID="sm2-container";this.id=la||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20111220";this.movieURL=this.version=null;this.url=W||null;this.altURL=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,
movieStar:!1};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};var ma;try{ma="undefined"!==typeof Audio&&"undefined"!==typeof(new Audio).canPlayType}catch(fb){ma=!1}this.hasHTML5=ma;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=
!1;var Ea,c=this,i=null,k="HTML5::",u,p=navigator.userAgent,j=G,O=j.location.href.toString(),h=document,na,X,m,B=[],oa=!0,w,P=!1,Q=!1,n=!1,y=!1,Y=!1,o,Za=0,R,v,pa,H,I,Z,Fa,qa,E,$,aa,J,ra,sa,ba,ca,K,Ga,ta,$a=["log","info","warn","error"],Ha,da,Ia,S=null,ua=null,q,va,L,Ja,ea,fa,wa,s,ga=!1,xa=!1,Ka,La,Ma,ha=0,T=null,ia,z=null,Na,ja,U,C,ya,za,Oa,r,Pa=Array.prototype.slice,F=!1,t,ka,Qa,A,Ra,Aa=p.match(/(ipad|iphone|ipod)/i),ab=p.match(/firefox/i),bb=p.match(/droid/i),D=p.match(/msie/i),cb=p.match(/webkit/i),
V=p.match(/safari/i)&&!p.match(/chrome/i),db=p.match(/opera/i),Ba=p.match(/(mobile|pre\/|xoom)/i)||Aa,Ca=!O.match(/usehtml5audio/i)&&!O.match(/sm2\-ignorebadua/i)&&V&&!p.match(/silk/i)&&p.match(/OS X 10_6_([3-7])/i),Sa="undefined"!==typeof console&&"undefined"!==typeof console.log,Da="undefined"!==typeof h.hasFocus?h.hasFocus():null,M=V&&"undefined"===typeof h.hasFocus,Ta=!M,Ua=/(mp3|mp4|mpa)/i,N=h.location?h.location.protocol.match(/http/i):null,Va=!N?"http://":"",Wa=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,
Xa="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),eb=RegExp("\\.("+Xa.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!N;this._global_a=null;if(Ba&&(c.useHTML5Audio=!0,c.preferFlash=!1,Aa))F=c.ignoreFlash=!0;this.supported=this.ok=function(){return z?n&&!y:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return u(c)||h[c]||j[c]};this.createSound=function(b){function a(){f=ea(f);c.sounds[e.id]=new Ea(e);c.soundIDs.push(e.id);
return c.sounds[e.id]}var d,f=null,e=d=null;d="soundManager.createSound(): "+q(!n?"notReady":"notOK");if(!n||!c.ok())return wa(d),!1;2===arguments.length&&(b={id:arguments[0],url:arguments[1]});f=v(b);f.url=ia(f.url);e=f;e.id.toString().charAt(0).match(/^[0-9]$/)&&c._wD("soundManager.createSound(): "+q("badID",e.id),2);c._wD("soundManager.createSound(): "+e.id+" ("+e.url+")",1);if(s(e.id,!0))return c._wD("soundManager.createSound(): "+e.id+" exists",1),c.sounds[e.id];if(ja(e))d=a(),c._wD("Loading sound "+
e.id+" via HTML5"),d._setup_html5(e);else{if(8<m){if(null===e.isMovieStar)e.isMovieStar=e.serverURL||(e.type?e.type.match(Wa):!1)||e.url.match(eb);e.isMovieStar&&c._wD("soundManager.createSound(): using MovieStar handling");if(e.isMovieStar){if(e.usePeakData)o("noPeak"),e.usePeakData=!1;1<e.loops&&o("noNSLoop")}}e=fa(e,"soundManager.createSound(): ");d=a();if(8===m)i._createSound(e.id,e.loops||1,e.usePolicyFile);else if(i._createSound(e.id,e.url,e.usePeakData,e.useWaveformData,e.useEQData,e.isMovieStar,
e.isMovieStar?e.bufferTime:!1,e.loops||1,e.serverURL,e.duration||null,e.autoPlay,!0,e.autoLoad,e.usePolicyFile),!e.serverURL)d.connected=!0,e.onconnect&&e.onconnect.apply(d);!e.serverURL&&(e.autoLoad||e.autoPlay)&&d.load(e)}!e.serverURL&&e.autoPlay&&d.play();return d};this.destroySound=function(b,a){if(!s(b))return!1;var d=c.sounds[b],f;d._iO={};d.stop();d.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,1);break}a||d.destruct(!0);delete c.sounds[b];return!0};this.load=
function(b,a){return!s(b)?!1:c.sounds[b].load(a)};this.unload=function(b){return!s(b)?!1:c.sounds[b].unload()};this.onposition=this.onPosition=function(b,a,d,f){return!s(b)?!1:c.sounds[b].onposition(a,d,f)};this.clearOnPosition=function(b,a,d){return!s(b)?!1:c.sounds[b].clearOnPosition(a,d)};this.start=this.play=function(b,a){if(!n||!c.ok())return wa("soundManager.play(): "+q(!n?"notReady":"notOK")),!1;if(!s(b)){a instanceof Object||(a={url:a});return a&&a.url?(c._wD('soundManager.play(): attempting to create "'+
b+'"',1),a.id=b,c.createSound(a).play()):!1}return c.sounds[b].play(a)};this.setPosition=function(b,a){return!s(b)?!1:c.sounds[b].setPosition(a)};this.stop=function(b){if(!s(b))return!1;c._wD("soundManager.stop("+b+")",1);return c.sounds[b].stop()};this.stopAll=function(){var b;c._wD("soundManager.stopAll()",1);for(b in c.sounds)c.sounds.hasOwnProperty(b)&&c.sounds[b].stop()};this.pause=function(b){return!s(b)?!1:c.sounds[b].pause()};this.pauseAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};
this.resume=function(b){return!s(b)?!1:c.sounds[b].resume()};this.resumeAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){return!s(b)?!1:c.sounds[b].togglePause()};this.setPan=function(b,a){return!s(b)?!1:c.sounds[b].setPan(a)};this.setVolume=function(b,a){return!s(b)?!1:c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;"string"!==typeof b&&(b=null);if(b){if(!s(b))return!1;c._wD('soundManager.mute(): Muting "'+b+'"');return c.sounds[b].mute()}c._wD("soundManager.mute(): Muting all sounds");
for(a=c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();return c.muted=!0};this.muteAll=function(){c.mute()};this.unmute=function(b){"string"!==typeof b&&(b=null);if(b){if(!s(b))return!1;c._wD('soundManager.unmute(): Unmuting "'+b+'"');return c.sounds[b].unmute()}c._wD("soundManager.unmute(): Unmuting all sounds");for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute();c.muted=!1;return!0};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){return!s(b)?!1:c.sounds[b].toggleMute()};
this.getMemoryUse=function(){var c=0;i&&8!==m&&(c=parseInt(i._getMemoryUse(),10));return c};this.disable=function(b){var a;"undefined"===typeof b&&(b=!1);if(y)return!1;y=!0;o("shutdown",1);for(a=c.soundIDs.length;a--;)Ha(c.sounds[c.soundIDs[a]]);R(b);r.remove(j,"load",I);return!0};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=U({type:b}));return!z||a?a:b?!!(8<m&&b.match(Wa)||b.match(c.mimePattern)):null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=U({url:b}));return!z||a?a:b?!!b.match(c.filePattern):
null};this.canPlayLink=function(b){return"undefined"!==typeof b.type&&b.type&&c.canPlayMIME(b.type)?!0:c.canPlayURL(b.href)};this.getSoundById=function(b,a){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");var d=c.sounds[b];!d&&!a&&c._wD('"'+b+'" is an invalid sound ID.',2);return d};this.onready=function(b,a){if(b&&b instanceof Function)return n&&c._wD(q("queue","onready")),a||(a=j),pa("onready",b,a),H(),!0;throw q("needFunction","onready");};this.ontimeout=function(b,a){if(b&&
b instanceof Function)return n&&c._wD(q("queue","ontimeout")),a||(a=j),pa("ontimeout",b,a),H({type:"ontimeout"}),!0;throw q("needFunction","ontimeout");};this._wD=this._writeDebug=function(b,a,d){var f,e;if(!c.debugMode)return!1;"undefined"!==typeof d&&d&&(b=b+" | "+(new Date).getTime());if(Sa&&c.useConsole){d=$a[a];if("undefined"!==typeof console[d])console[d](b);else console.log(b);if(c.consoleOnly)return!0}try{f=u("soundmanager-debug");if(!f)return!1;e=h.createElement("div");if(0===++Za%2)e.className=
"sm2-alt";a="undefined"===typeof a?0:parseInt(a,10);e.appendChild(h.createTextNode(b));if(a){if(2<=a)e.style.fontWeight="bold";if(3===a)e.style.color="#ff3333"}f.insertBefore(e,f.firstChild)}catch(i){}return!0};this._debug=function(){var b,a;o("currentObj",1);for(b=0,a=c.soundIDs.length;b<a;b++)c.sounds[c.soundIDs[b]]._debug()};this.reboot=function(){c._wD("soundManager.reboot()");c.soundIDs.length&&c._wD("Destroying "+c.soundIDs.length+" SMSound objects...");var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();
try{if(D)ua=i.innerHTML;S=i.parentNode.removeChild(i);c._wD("Flash movie removed.")}catch(d){o("badRemove",2)}ua=S=z=null;c.enabled=sa=n=ga=xa=P=Q=y=c.swfLoaded=!1;c.soundIDs=c.sounds=[];i=null;for(b in B)if(B.hasOwnProperty(b))for(a=B[b].length;a--;)B[b][a].fired=!1;c._wD("soundManager: Rebooting...");j.setTimeout(c.beginDelayedInit,20)};this.getMoviePercent=function(){return i&&"undefined"!==typeof i.PercentLoaded?i.PercentLoaded():null};this.beginDelayedInit=function(){Y=!0;J();setTimeout(function(){if(xa)return!1;
ca();aa();return xa=!0},20);Z()};this.destruct=function(){c._wD("soundManager.destruct()");c.disable(!0)};Ea=function(b){var a=this,d,f,e,h,g,Ya,j=!1,x=[],l=0,n,r,p=null,t=null,u=null;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=v(b);this.pan=this.options.pan;this.volume=this.options.volume;this.isHTML5=!1;this._a=null;this.id3={};this._debug=function(){if(c.debugMode){var b=null,e=[],d,f;for(b in a.options)null!==a.options[b]&&(a.options[b]instanceof Function?(d=a.options[b].toString(),
d=d.replace(/\s\s+/g," "),f=d.indexOf("{"),e.push(" "+b+": {"+d.substr(f+1,Math.min(Math.max(d.indexOf("\n")-1,64),64)).replace(/\n/g,"")+"... }")):e.push(" "+b+": "+a.options[b]));c._wD("SMSound() merged options: {\n"+e.join(", \n")+"\n}")}};this._debug();this.load=function(b){var d=null;if("undefined"!==typeof b)a._iO=v(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,p&&p!==a.url)o("manURL"),a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;a._iO.url=
ia(a._iO.url);c._wD("SMSound.load(): "+a._iO.url,1);if(a._iO.url===a.url&&0!==a.readyState&&2!==a.readyState)return o("onURL",1),3===a.readyState&&a._iO.onload&&a._iO.onload.apply(a,[!!a.duration]),a;b=a._iO;p=a.url;a.loaded=!1;a.readyState=1;a.playState=0;if(ja(b))d=a._setup_html5(b),d._called_load?c._wD(k+"ignoring request to load again: "+a.sID):(c._wD(k+"load: "+a.sID),a._html5_canplay=!1,a._a.autobuffer="auto",a._a.preload="auto",d.load(),d._called_load=!0,b.autoPlay&&a.play());else try{a.isHTML5=
!1,a._iO=fa(ea(b)),b=a._iO,8===m?i._load(a.sID,b.url,b.stream,b.autoPlay,b.whileloading?1:0,b.loops||1,b.usePolicyFile):i._load(a.sID,b.url,!!b.stream,!!b.autoPlay,b.loops||1,!!b.autoLoad,b.usePolicyFile)}catch(e){o("smError",2),w("onload",!1),K({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:!0})}return a};this.unload=function(){0!==a.readyState&&(c._wD('SMSound.unload(): "'+a.sID+'"'),a.isHTML5?(h(),a._a&&(a._a.pause(),ya(a._a))):8===m?i._unload(a.sID,"about:blank"):i._unload(a.sID),d());return a};this.destruct=
function(b){c._wD('SMSound.destruct(): "'+a.sID+'"');if(a.isHTML5){if(h(),a._a)a._a.pause(),ya(a._a),F||e(),a._a._t=null,a._a=null}else a._iO.onfailure=null,i._destroySound(a.sID);b||c.destroySound(a.sID,!0)};this.start=this.play=function(b,d){var e,d=void 0===d?!0:d;b||(b={});a._iO=v(b,a._iO);a._iO=v(a._iO,a.options);a._iO.url=ia(a._iO.url);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()||(c._wD("SMSound.play(): Netstream not connected yet - setting autoPlay"),a.setAutoPlay(!0)),
a;ja(a._iO)&&(a._setup_html5(a._iO),g());if(1===a.playState&&!a.paused)if(e=a._iO.multiShot)c._wD('SMSound.play(): "'+a.sID+'" already playing (multi-shot)',1);else return c._wD('SMSound.play(): "'+a.sID+'" already playing (one-shot)',1),a;if(a.loaded)c._wD('SMSound.play(): "'+a.sID+'"');else if(0===a.readyState){c._wD('SMSound.play(): Attempting to load "'+a.sID+'"',1);if(!a.isHTML5)a._iO.autoPlay=!0;a.load(a._iO)}else{if(2===a.readyState)return c._wD('SMSound.play(): Could not load "'+a.sID+'" - exiting',
2),a;c._wD('SMSound.play(): "'+a.sID+'" is loading - attempting to play..',1)}if(!a.isHTML5&&9===m&&0<a.position&&a.position===a.duration)c._wD('SMSound.play(): "'+a.sID+'": Sound at end, resetting to position:0'),b.position=0;if(a.paused&&a.position&&0<a.position)c._wD('SMSound.play(): "'+a.sID+'" is resuming from paused state',1),a.resume();else{a._iO=v(b,a._iO);if(null!==a._iO.from&&null!==a._iO.to&&0===a.instanceCount&&0===a.playState&&!a._iO.serverURL){e=function(){a._iO=v(b,a._iO);a.play(a._iO)};
if(a.isHTML5&&!a._html5_canplay)return c._wD('SMSound.play(): Beginning load of "'+a.sID+'" for from/to case'),a.load({_oncanplay:e}),!1;if(!a.isHTML5&&!a.loaded&&(!a.readyState||2!==a.readyState))return c._wD('SMSound.play(): Preloading "'+a.sID+'" for from/to case'),a.load({onload:e}),!1;a._iO=r()}c._wD('SMSound.play(): "'+a.sID+'" is starting to play');(!a.instanceCount||a._iO.multiShotEvents||!a.isHTML5&&8<m&&!a.getAutoPlay())&&a.instanceCount++;0===a.playState&&a._iO.onposition&&Ya(a);a.playState=
1;a.paused=!1;a.position="undefined"!==typeof a._iO.position&&!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=fa(ea(a._iO));a._iO.onplay&&d&&(a._iO.onplay.apply(a),j=!0);a.setVolume(a._iO.volume,!0);a.setPan(a._iO.pan,!0);a.isHTML5?(g(),e=a._setup_html5(),a.setPosition(a._iO.position),e.play()):i._start(a.sID,a._iO.loops||1,9===m?a._iO.position:a._iO.position/1E3)}return a};this.stop=function(c){var b=a._iO;if(1===a.playState){a._onbufferchange(0);a._resetOnPosition(0);a.paused=!1;if(!a.isHTML5)a.playState=
0;n();b.to&&a.clearOnPosition(b.to);if(a.isHTML5){if(a._a)c=a.position,a.setPosition(0),a.position=c,a._a.pause(),a.playState=0,a._onTimer(),h()}else i._stop(a.sID,c),b.serverURL&&a.unload();a.instanceCount=0;a._iO={};b.onstop&&b.onstop.apply(a)}return a};this.setAutoPlay=function(b){c._wD("sound "+a.sID+" turned autoplay "+(b?"on":"off"));a._iO.autoPlay=b;a.isHTML5||(i._setAutoPlay(a.sID,b),b&&!a.instanceCount&&1===a.readyState&&(a.instanceCount++,c._wD("sound "+a.sID+" incremented instance count to "+
a.instanceCount)))};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){void 0===b&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a._resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a)if(a._html5_canplay){if(a._a.currentTime!==b){c._wD("setPosition("+b+"): setting position");try{a._a.currentTime=b,(0===a.playState||a.paused)&&a._a.pause()}catch(e){c._wD("setPosition("+b+"): setting position failed: "+
e.message,2)}}}else c._wD("setPosition("+b+"): delaying, sound not ready")}else b=9===m?a.position:b,a.readyState&&2!==a.readyState&&i._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(!0);return a};this.pause=function(b){if(a.paused||0===a.playState&&1!==a.readyState)return a;c._wD("SMSound.pause()");a.paused=!0;a.isHTML5?(a._setup_html5().pause(),h()):(b||void 0===b)&&i._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){var b=a._iO;if(!a.paused)return a;
c._wD("SMSound.resume()");a.paused=!1;a.playState=1;a.isHTML5?(a._setup_html5().play(),g()):(b.isMovieStar&&!b.serverURL&&a.setPosition(a.position),i._pause(a.sID));j&&b.onplay?(b.onplay.apply(a),j=!0):b.onresume&&b.onresume.apply(a);return a};this.togglePause=function(){c._wD("SMSound.togglePause()");if(0===a.playState)return a.play({position:9===m&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,c){"undefined"===typeof b&&(b=0);"undefined"===
typeof c&&(c=!1);a.isHTML5||i._setPan(a.sID,b);a._iO.pan=b;if(!c)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){"undefined"===typeof b&&(b=100);"undefined"===typeof d&&(d=!1);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else i._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume=b;return a};this.mute=function(){a.muted=!0;if(a.isHTML5){if(a._a)a._a.muted=!0}else i._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=
!1;var b="undefined"!==typeof a._iO.volume;if(a.isHTML5){if(a._a)a._a.muted=!1}else i._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=this.onPosition=function(b,c,d){x.push({position:b,method:c,scope:"undefined"!==typeof d?d:a,fired:!1});return a};this.clearOnPosition=function(a,b){var c,a=parseInt(a,10);if(isNaN(a))return!1;for(c=0;c<x.length;c++)if(a===x[c].position&&(!b||b===x[c].method))x[c].fired&&l--,
x.splice(c,1)};this._processOnPosition=function(){var b,c;b=x.length;if(!b||!a.playState||l>=b)return!1;for(;b--;)if(c=x[b],!c.fired&&a.position>=c.position)c.fired=!0,l++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(a){var b,c;b=x.length;if(!b)return!1;for(;b--;)if(c=x[b],c.fired&&a<=c.position)c.fired=!1,l--;return!0};r=function(){var b=a._iO,d=b.from,e=b.to,f,g;g=function(){c._wD(a.sID+': "to" time of '+e+" reached.");a.clearOnPosition(e,g);a.stop()};f=function(){c._wD(a.sID+
': playing "from" '+d);if(null!==e&&!isNaN(e))a.onPosition(e,g)};if(null!==d&&!isNaN(d))b.position=d,b.multiShot=!1,f();return b};Ya=function(){var b=a._iO.onposition;if(b)for(var c in b)if(b.hasOwnProperty(c))a.onPosition(parseInt(c,10),b[c])};n=function(){var b=a._iO.onposition;if(b)for(var c in b)b.hasOwnProperty(c)&&a.clearOnPosition(parseInt(c,10))};g=function(){a.isHTML5&&Ka(a)};h=function(){a.isHTML5&&La(a)};d=function(){x=[];l=0;j=!1;a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=
null;a.bytesTotal=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.eqData=[];a.eqData.left=[];a.eqData.right=[];a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null};d();this._onTimer=function(b){var c,d=!1,e={};if(a._hasTimer||b){if(a._a&&(b||(0<a.playState||1===a.readyState)&&!a.paused)){c=a._get_html5_duration();
if(c!==t)t=c,a.duration=c,d=!0;a.durationEstimate=a.duration;c=1E3*a._a.currentTime||0;c!==u&&(u=c,d=!0);(d||b)&&a._whileplaying(c,e,e,e,e);return d}return!1}};this._get_html5_duration=function(){var b=a._iO,c=a._a?1E3*a._a.duration:b?b.duration:void 0;return c&&!isNaN(c)&&Infinity!==c?c:b?b.duration:null};this._setup_html5=function(b){var b=v(a._iO,b),e=decodeURI,g=F?c._global_a:a._a,h=e(b.url),i=g&&g._t?g._t.instanceOptions:null;if(g){if(g._t&&(!F&&h===e(p)||F&&i.url===b.url&&(!p||p===i.url)))return g;
c._wD("setting new URL on existing object: "+h+(p?", old URL: "+p:""));F&&g._t&&g._t.playState&&b.url!==i.url&&g._t.stop();d();g.src=b.url;p=a.url=b.url;g._called_load=!1}else{c._wD("creating HTML5 Audio() element with URL: "+h);g=new Audio(b.url);g._called_load=!1;if(bb)g._called_load=!0;if(F)c._global_a=g}a.isHTML5=!0;a._a=g;g._t=a;f();g.loop=1<b.loops?"loop":"";b.autoLoad||b.autoPlay?a.load():(g.autobuffer=!1,g.preload="none");g.loop=1<b.loops?"loop":"";return g};f=function(){if(a._a._added_events)return!1;
var b;c._wD(k+"adding event listeners: "+a.sID);a._a._added_events=!0;for(b in A)A.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,A[b],!1);return!0};e=function(){var b;c._wD(k+"removing event listeners: "+a.sID);a._a._added_events=!1;for(b in A)A.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,A[b],!1)};this._onload=function(b){var d,b=!!b;c._wD(d+'"'+a.sID+'"'+(b?" loaded.":" failed to load? - "+a.url),b?1:2);d="SMSound._onload(): ";!b&&!a.isHTML5&&(!0===c.sandbox.noRemote&&c._wD(d+q("noNet"),
1),!0===c.sandbox.noLocal&&c._wD(d+q("noLocal"),1));a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0);a._iO.onload&&a._iO.onload.apply(a,[b]);return!0};this._onbufferchange=function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&(c._wD("SMSound._onbufferchange(): "+b),a._iO.onbufferchange.apply(a));return!0};this._onsuspend=function(){a._iO.onsuspend&&(c._wD("SMSound._onsuspend()"),a._iO.onsuspend.apply(a));return!0};this._onfailure=
function(b,d,e){a.failures++;c._wD('SMSound._onfailure(): "'+a.sID+'" count '+a.failures);if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,d,e);else c._wD("SMSound._onfailure(): ignoring")};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)n(),a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},h();if((!a.instanceCount||a._iO.multiShotEvents)&&b)c._wD('SMSound._onfinish(): "'+
a.sID+'"'),b.apply(a)}};this._whileloading=function(b,c,d,e){var f=a._iO;a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(d);a.bufferLength=e;if(f.isMovieStar)a.durationEstimate=a.duration;else if(a.durationEstimate=f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10),void 0===a.durationEstimate)a.durationEstimate=a.duration;3!==a.readyState&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,d,e,f){var g=a._iO;if(isNaN(b)||
null===b)return!1;a.position=b;a._processOnPosition();if(!a.isHTML5&&8<m){if(g.usePeakData&&"undefined"!==typeof c&&c)a.peakData={left:c.leftPeak,right:c.rightPeak};if(g.useWaveformData&&"undefined"!==typeof d&&d)a.waveformData={left:d.split(","),right:e.split(",")};if(g.useEQData&&"undefined"!==typeof f&&f&&f.leftEQ&&(b=f.leftEQ.split(","),a.eqData=b,a.eqData.left=b,"undefined"!==typeof f.rightEQ&&f.rightEQ))a.eqData.right=f.rightEQ.split(",")}1===a.playState&&(!a.isHTML5&&8===m&&!a.position&&a.isBuffering&&
a._onbufferchange(0),g.whileplaying&&g.whileplaying.apply(a));return!0};this._onmetadata=function(b,d){c._wD('SMSound._onmetadata(): "'+this.sID+'" metadata received.');var e={},f,g;for(f=0,g=b.length;f<g;f++)e[b[f]]=d[f];a.metadata=e;a._iO.onmetadata&&a._iO.onmetadata.apply(a)};this._onid3=function(b,d){c._wD('SMSound._onid3(): "'+this.sID+'" ID3 data received.');var e=[],f,g;for(f=0,g=b.length;f<g;f++)e[b[f]]=d[f];a.id3=v(a.id3,e);a._iO.onid3&&a._iO.onid3.apply(a)};this._onconnect=function(b){b=
1===b;c._wD('SMSound._onconnect(): "'+a.sID+'"'+(b?" connected.":" failed to connect? - "+a.url),b?1:2);if(a.connected=b)a.failures=0,s(a.sID)&&(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._ondataerror=function(b){0<a.playState&&(c._wD("SMSound._ondataerror(): "+b),a._iO.ondataerror&&a._iO.ondataerror.apply(a))}};ba=function(){return h.body||h._docElement||h.getElementsByTagName("div")[0]};u=function(b){return h.getElementById(b)};
v=function(b,a){var d={},f,e;for(f in b)b.hasOwnProperty(f)&&(d[f]=b[f]);f="undefined"===typeof a?c.defaultOptions:a;for(e in f)f.hasOwnProperty(e)&&"undefined"===typeof d[e]&&(d[e]=f[e]);return d};r=function(){function b(a){var a=Pa.call(a),b=a.length;c?(a[1]="on"+a[1],3<b&&a.pop()):3===b&&a.push(!1);return a}function a(a,b){var g=a.shift(),h=[f[b]];if(c)g[h](a[0],a[1]);else g[h].apply(g,a)}var c=j.attachEvent,f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};
return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();A={abort:l(function(){c._wD(k+"abort: "+this._t.sID)}),canplay:l(function(){var b=this._t;if(b._html5_canplay)return!0;b._html5_canplay=!0;c._wD(k+"canplay: "+b.sID+", "+b.url);b._onbufferchange(0);var a=!isNaN(b.position)?b.position/1E3:null;if(b.position&&this.currentTime!==a){c._wD(k+"canplay: setting position to "+a);try{this.currentTime=a}catch(d){c._wD(k+"setting position failed: "+d.message,2)}}b._iO._oncanplay&&
b._iO._oncanplay()}),load:l(function(){var b=this._t;b.loaded||(b._onbufferchange(0),b._whileloading(b.bytesTotal,b.bytesTotal,b._get_html5_duration()),b._onload(!0))}),emptied:l(function(){c._wD(k+"emptied: "+this._t.sID)}),ended:l(function(){var b=this._t;c._wD(k+"ended: "+b.sID);b._onfinish()}),error:l(function(){c._wD(k+"error: "+this.error.code);this._t._onload(!1)}),loadeddata:l(function(){var b=this._t,a=b.bytesTotal||1;c._wD(k+"loadeddata: "+this._t.sID);if(!b._loaded&&!V)b.duration=b._get_html5_duration(),
b._whileloading(a,a,b._get_html5_duration()),b._onload(!0)}),loadedmetadata:l(function(){c._wD(k+"loadedmetadata: "+this._t.sID)}),loadstart:l(function(){c._wD(k+"loadstart: "+this._t.sID);this._t._onbufferchange(1)}),play:l(function(){c._wD(k+"play: "+this._t.sID+", "+this._t.url);this._t._onbufferchange(0)}),playing:l(function(){c._wD(k+"playing: "+this._t.sID);this._t._onbufferchange(0)}),progress:l(function(b){var a=this._t;if(a.loaded)return!1;var d,f,e;e=0;var h="progress"===b.type;f=b.target.buffered;
var g=b.loaded||0,i=b.total||1;if(f&&f.length){for(d=f.length;d--;)e=f.end(d)-f.start(d);g=e/b.target.duration;if(h&&1<f.length){e=[];f=f.length;for(d=0;d<f;d++)e.push(b.target.buffered.start(d)+"-"+b.target.buffered.end(d));c._wD(k+"progress: timeRanges: "+e.join(", "))}h&&!isNaN(g)&&c._wD(k+"progress: "+a.sID+": "+Math.floor(100*g)+"% loaded")}isNaN(g)||(a._onbufferchange(0),a._whileloading(g,i,a._get_html5_duration()),g&&i&&g===i&&A.load.call(this,b))}),ratechange:l(function(){c._wD(k+"ratechange: "+
this._t.sID)}),suspend:l(function(b){var a=this._t;c._wD(k+"suspend: "+a.sID);A.progress.call(this,b);a._onsuspend()}),stalled:l(function(){c._wD(k+"stalled: "+this._t.sID)}),timeupdate:l(function(){this._t._onTimer()}),waiting:l(function(){var b=this._t;c._wD(k+"waiting: "+b.sID);b._onbufferchange(1)})};ja=function(b){return!b.serverURL&&(b.type?U({type:b.type}):U({url:b.url})||c.html5Only)};ya=function(b){if(b)b.src=ab?"":"about:blank"};U=function(b){function a(a){return c.preferFlash&&t&&!c.ignoreFlash&&
"undefined"!==typeof c.flash[a]&&c.flash[a]}if(!c.useHTML5Audio||!c.hasHTML5)return!1;var d=b.url||null,b=b.type||null,f=c.audioFormats,e;if(b&&"undefined"!==c.html5[b])return c.html5[b]&&!a(b);if(!C){C=[];for(e in f)f.hasOwnProperty(e)&&(C.push(e),f[e].related&&(C=C.concat(f[e].related)));C=RegExp("\\.("+C.join("|")+")(\\?.*)?$","i")}e=d?d.toLowerCase().match(C):null;if(!e||!e.length)if(b)d=b.indexOf(";"),e=(-1!==d?b.substr(0,d):b).substr(6);else return!1;else e=e[1];if(e&&"undefined"!==typeof c.html5[e])return c.html5[e]&&
!a(e);b="audio/"+e;d=c.html5.canPlayType({type:b});return(c.html5[e]=d)&&c.html5[b]&&!a(b)};Oa=function(){function b(b){var d,e,f=!1;if(!a||"function"!==typeof a.canPlayType)return!1;if(b instanceof Array){for(d=0,e=b.length;d<e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=!0,c.html5[b[d]]=!0,c.flash[b[d]]=!(!c.preferFlash||!t||!b[d].match(Ua));return f}b=a&&"function"===typeof a.canPlayType?a.canPlayType(b):!1;return!(!b||!b.match(c.html5Test))}if(!c.useHTML5Audio||"undefined"===
typeof Audio)return!1;var a="undefined"!==typeof Audio?db?new Audio(null):new Audio:null,d,f={},e,h;e=c.audioFormats;for(d in e)if(e.hasOwnProperty(d)&&(f[d]=b(e[d].type),f["audio/"+d]=f[d],c.flash[d]=c.preferFlash&&!c.ignoreFlash&&d.match(Ua)?!0:!1,e[d]&&e[d].related))for(h=e[d].related.length;h--;)f["audio/"+e[d].related[h]]=f[d],c.html5[e[d].related[h]]=f[d],c.flash[e[d].related[h]]=f[d];f.canPlayType=a?b:null;c.html5=v(c.html5,f);return!0};$={notReady:"Not loaded yet - wait for soundManager.onload()/onready()",
notOK:"Audio support is not available.",domError:"soundManager::createMovie(): appendChild/innerHTML call failed. DOM not ready or other error.",spcWmode:"soundManager::createMovie(): Removing wmode, preventing known SWF loading issue(s)",swf404:"soundManager: Verify that %s is a valid path.",tryDebug:"Try soundManager.debugFlash = true for more security details (output goes to SWF.)",checkSWF:"See SWF output for more debug info.",localFail:"soundManager: Non-HTTP page ("+h.location.protocol+" URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/",
waitFocus:"soundManager: Special case: Waiting for focus-related event..",waitImpatient:"soundManager: Getting impatient, still waiting for Flash%s...",waitForever:"soundManager: Waiting indefinitely for Flash (will recover if unblocked)...",needFunction:"soundManager: Function object expected for %s",badID:'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',currentObj:"--- soundManager._debug(): Current sound objects ---",waitEI:"soundManager::initMovie(): Waiting for ExternalInterface call from Flash..",
waitOnload:"soundManager: Waiting for window.onload()",docLoaded:"soundManager: Document already loaded",onload:"soundManager::initComplete(): calling soundManager.onload()",onloadOK:"soundManager.onload() complete",init:"soundManager::init()",didInit:"soundManager::init(): Already called?",flashJS:"soundManager: Attempting to call Flash from JS..",secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html",
badRemove:"Warning: Failed to remove flash movie.",noPeak:"Warning: peakData features unsupported for movieStar formats",shutdown:"soundManager.disable(): Shutting down",queue:"soundManager: Queueing %s handler",smFail:"soundManager: Failed to initialise.",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",fbTimeout:"No flash response, applying .swf_timedout CSS..",fbLoaded:"Flash loaded",fbHandler:"soundManager::flashBlockHandler()",manURL:"SMSound.load(): Using manually-assigned URL",
onURL:"soundManager.load(): current URL already assigned.",badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:"Note: Setting stream:false so looping can work (flash 8 limitation)",noNSLoop:"Note: Looping not implemented for MovieStar formats",needfl9:"Note: Switching to flash 9, required for MP4 formats.",mfTimeout:"Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case",mfOn:"mobileFlash::enabling on-screen flash repositioning",policy:"Enabling usePolicyFile for data access"};
q=function(){var b=Pa.call(arguments),a=b.shift(),a=$&&$[a]?$[a]:"",c,f;if(a&&b&&b.length)for(c=0,f=b.length;c<f;c++)a=a.replace("%s",b[c]);return a};ea=function(b){if(8===m&&1<b.loops&&b.stream)o("as2loop"),b.stream=!1;return b};fa=function(b,a){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))c._wD((a||"")+q("policy")),b.usePolicyFile=!0;return b};wa=function(b){"undefined"!==typeof console&&"undefined"!==typeof console.warn?console.warn(b):c._wD(b)};na=function(){return!1};
Ha=function(b){for(var a in b)b.hasOwnProperty(a)&&"function"===typeof b[a]&&(b[a]=na)};da=function(b){"undefined"===typeof b&&(b=!1);if(y||b)o("smFail",2),c.disable(b)};Ia=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");b=(b&&-1!==b.lastIndexOf("/")?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(b+="?ts="+(new Date).getTime());return b};qa=function(){m=parseInt(c.flashVersion,
10);if(8!==m&&9!==m)c._wD(q("badFV",m,8)),c.flashVersion=m=8;var b=c.debugMode||c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!c.html5Only&&c.audioFormats.mp4.required&&9>m)c._wD(q("needfl9")),c.flashVersion=m=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===m?" (AS3/Flash 9)":" (AS2/Flash 8)");8<m?(c.defaultOptions=v(c.defaultOptions,c.flash9Options),c.features.buffering=!0,c.defaultOptions=v(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+Xa.join("|")+
")(\\?.*)?$","i"),c.features.movieStar=!0):c.features.movieStar=!1;c.filePattern=c.filePatterns[8!==m?"flash9":"flash8"];c.movieURL=(8===m?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=8<m};Ga=function(b,a){if(!i)return!1;i._setPolling(b,a)};ta=function(){if(c.debugURLParam.test(O))c.debugMode=!0;if(u(c.debugID))return!1;var b,a,d,f;if(c.debugMode&&!u(c.debugID)&&(!Sa||!c.useConsole||!c.consoleOnly)){b=h.createElement("div");
b.id=c.debugID+"-toggle";a={position:"fixed",bottom:"0px",right:"0px",width:"1.2em",height:"1.2em",lineHeight:"1.2em",margin:"2px",textAlign:"center",border:"1px solid #999",cursor:"pointer",background:"#fff",color:"#333",zIndex:10001};b.appendChild(h.createTextNode("-"));b.onclick=Ja;b.title="Toggle SM2 debug console";if(p.match(/msie 6/i))b.style.position="absolute",b.style.cursor="hand";for(f in a)a.hasOwnProperty(f)&&(b.style[f]=a[f]);a=h.createElement("div");a.id=c.debugID;a.style.display=c.debugMode?
"block":"none";if(c.debugMode&&!u(b.id)){try{d=ba(),d.appendChild(b)}catch(e){throw Error(q("domError")+" \n"+e.toString());}d.appendChild(a)}}};s=this.getSoundById;o=function(b,a){return b?c._wD(q(b),a):""};if(O.indexOf("sm2-debug=alert")+1&&c.debugMode)c._wD=function(b){G.alert(b)};Ja=function(){var b=u(c.debugID),a=u(c.debugID+"-toggle");if(!b)return!1;oa?(a.innerHTML="+",b.style.display="none"):(a.innerHTML="-",b.style.display="block");oa=!oa};w=function(b,a,c){if("undefined"!==typeof sm2Debugger)try{sm2Debugger.handleEvent(b,
a,c)}catch(f){}return!0};L=function(){var b=[];c.debugMode&&b.push("sm2_debug");c.debugFlash&&b.push("flash_debug");c.useHighPerformance&&b.push("high_performance");return b.join(" ")};va=function(){var b=q("fbHandler"),a=c.getMoviePercent(),d={type:"FLASHBLOCK"};if(c.html5Only)return!1;if(c.ok()){if(c.didFlashBlock&&c._wD(b+": Unblocked"),c.oMC)c.oMC.className=[L(),"movieContainer","swf_loaded"+(c.didFlashBlock?" swf_unblocked":"")].join(" ")}else{if(z)c.oMC.className=L()+" movieContainer "+(null===
a?"swf_timedout":"swf_error"),c._wD(b+": "+q("fbTimeout")+(a?" ("+q("fbLoaded")+")":""));c.didFlashBlock=!0;H({type:"ontimeout",ignoreInit:!0,error:d});K(d)}};pa=function(b,a,c){"undefined"===typeof B[b]&&(B[b]=[]);B[b].push({method:a,scope:c||null,fired:!1})};H=function(b){b||(b={type:"onready"});if(!n&&b&&!b.ignoreInit||"ontimeout"===b.type&&c.ok())return!1;var a={success:b&&b.ignoreInit?c.ok():!y},d=b&&b.type?B[b.type]||[]:[],f=[],e,h=[a],g=z&&c.useFlashBlock&&!c.ok();if(b.error)h[0].error=b.error;
for(a=0,e=d.length;a<e;a++)!0!==d[a].fired&&f.push(d[a]);if(f.length){c._wD("soundManager: Firing "+f.length+" "+b.type+"() item"+(1===f.length?"":"s"));for(a=0,e=f.length;a<e;a++)if(f[a].scope?f[a].method.apply(f[a].scope,h):f[a].method.apply(this,h),!g)f[a].fired=!0}return!0};I=function(){j.setTimeout(function(){c.useFlashBlock&&va();H();c.onload instanceof Function&&(o("onload",1),c.onload.apply(j),o("onloadOK",1));c.waitForWindowLoad&&r.add(j,"load",I)},1)};ka=function(){if(void 0!==t)return t;
var b=!1,a=navigator,c=a.plugins,f,e=j.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&&a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=!0);else if("undefined"!==typeof e){try{f=new e("ShockwaveFlash.ShockwaveFlash")}catch(h){}b=!!f}return t=b};Na=function(){var b,a;if(Aa&&p.match(/os (1|2|3_0|3_1)/i)){c.hasHTML5=!1;c.html5Only=!0;if(c.oMC)c.oMC.style.display="none";return!1}if(c.useHTML5Audio){if(!c.html5||
!c.html5.canPlayType)return c._wD("SoundManager: No HTML5 Audio() support detected."),c.hasHTML5=!1,!0;c.hasHTML5=!0;if(Ca&&(c._wD("soundManager::Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - "+(!t?" would use flash fallback for MP3/MP4, but none detected.":"will use flash fallback for MP3/MP4, if available"),1),ka()))return!0}else return!0;for(a in c.audioFormats)if(c.audioFormats.hasOwnProperty(a)&&(c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)||
c.flash[a]||c.flash[c.audioFormats[a].type]))b=!0;c.ignoreFlash&&(b=!1);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!b;return!c.html5Only};ia=function(b){var a,d,f=0;if(b instanceof Array){for(a=0,d=b.length;a<d;a++)if(b[a]instanceof Object){if(c.canPlayMIME(b[a].type)){f=a;break}}else if(c.canPlayURL(b[a])){f=a;break}if(b[f].url)b[f]=b[f].url;return b[f]}return b};Ka=function(b){if(!b._hasTimer)b._hasTimer=!0,!Ba&&c.html5PollingInterval&&(null===T&&0===ha&&(T=G.setInterval(Ma,c.html5PollingInterval)),
ha++)};La=function(b){if(b._hasTimer)b._hasTimer=!1,!Ba&&c.html5PollingInterval&&ha--};Ma=function(){var b;if(null!==T&&!ha)return G.clearInterval(T),T=null,!1;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].isHTML5&&c.sounds[c.soundIDs[b]]._hasTimer&&c.sounds[c.soundIDs[b]]._onTimer()};K=function(b){b="undefined"!==typeof b?b:{};c.onerror instanceof Function&&c.onerror.apply(j,[{type:"undefined"!==typeof b.type?b.type:null}]);"undefined"!==typeof b.fatal&&b.fatal&&c.disable()};Qa=function(){if(!Ca||
!ka())return!1;var b=c.audioFormats,a,d;for(d in b)if(b.hasOwnProperty(d)&&("mp3"===d||"mp4"===d))if(c._wD("soundManager: Using flash fallback for "+d+" format"),c.html5[d]=!1,b[d]&&b[d].related)for(a=b[d].related.length;a--;)c.html5[b[d].related[a]]=!1};this._setSandboxType=function(b){var a=c.sandbox;a.type=b;a.description=a.types["undefined"!==typeof a.types[b]?b:"unknown"];c._wD("Flash security sandbox type: "+a.type);if("localWithFile"===a.type)a.noRemote=!0,a.noLocal=!1,o("secNote",2);else if("localWithNetwork"===
a.type)a.noRemote=!1,a.noLocal=!0;else if("localTrusted"===a.type)a.noRemote=!1,a.noLocal=!1};this._externalInterfaceOK=function(b,a){if(c.swfLoaded)return!1;var d,f=(new Date).getTime();c._wD("soundManager::externalInterfaceOK()"+(b?" (~"+(f-b)+" ms)":""));w("swf",!0);w("flashtojs",!0);c.swfLoaded=!0;M=!1;Ca&&Qa();if(!a||a.replace(/\+dev/i,"")!==c.versionNumber.replace(/\+dev/i,""))return d='soundManager: Fatal: JavaScript file build "'+c.versionNumber+'" does not match Flash SWF build "'+a+'" at '+
c.url+". Ensure both are up-to-date.",setTimeout(function(){throw Error(d);},0),!1;D?setTimeout(X,100):X()};ca=function(b,a){function d(){c._wD("-- SoundManager 2 "+c.version+(!c.html5Only&&c.useHTML5Audio?c.hasHTML5?" + HTML5 audio":", no HTML5 audio support":"")+(!c.html5Only?(c.useHighPerformance?", high performance mode, ":", ")+((c.flashPollingInterval?"custom ("+c.flashPollingInterval+"ms)":"normal")+" polling")+(c.wmode?", wmode: "+c.wmode:"")+(c.debugFlash?", flash debug mode":"")+(c.useFlashBlock?
", flashBlock mode":""):"")+" --",1)}function f(a,b){return'<param name="'+a+'" value="'+b+'" />'}if(P&&Q)return!1;if(c.html5Only)return qa(),d(),c.oMC=u(c.movieID),X(),Q=P=!0,!1;var e=a||c.url,i=c.altURL||e,g;g=ba();var j,m,k=L(),l,n=null,n=(n=h.getElementsByTagName("html")[0])&&n.dir&&n.dir.match(/rtl/i),b="undefined"===typeof b?c.id:b;qa();c.url=Ia(N?e:i);a=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(p.match(/msie 8/i)||!D&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))o("spcWmode"),
c.wmode=null;g={name:b,id:b,src:a,width:"auto",height:"auto",quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Va+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)g.FlashVars="debug=1";c.wmode||delete g.wmode;if(D)e=h.createElement("div"),m=['<object id="'+b+'" data="'+a+'" type="'+g.type+'" title="'+g.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+
Va+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+g.width+'" height="'+g.height+'">',f("movie",a),f("AllowScriptAccess",c.allowScriptAccess),f("quality",g.quality),c.wmode?f("wmode",c.wmode):"",f("bgcolor",c.bgColor),f("hasPriority","true"),c.debugFlash?f("FlashVars",g.FlashVars):"","</object>"].join("");else for(j in e=h.createElement("embed"),g)g.hasOwnProperty(j)&&e.setAttribute(j,g[j]);ta();k=L();if(g=ba())if(c.oMC=u(c.movieID)||h.createElement("div"),
c.oMC.id){l=c.oMC.className;c.oMC.className=(l?l+" ":"movieContainer")+(k?" "+k:"");c.oMC.appendChild(e);if(D)j=c.oMC.appendChild(h.createElement("div")),j.className="sm2-object-box",j.innerHTML=m;Q=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+k;j=k=null;if(!c.useFlashBlock)if(c.useHighPerformance)k={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"};else if(k={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},n)k.left=Math.abs(parseInt(k.left,
10))+"px";if(cb)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(l in k)k.hasOwnProperty(l)&&(c.oMC.style[l]=k[l]);try{D||c.oMC.appendChild(e);g.appendChild(c.oMC);if(D)j=c.oMC.appendChild(h.createElement("div")),j.className="sm2-object-box",j.innerHTML=m;Q=!0}catch(r){throw Error(q("domError")+" \n"+r.toString());}}P=!0;d();c._wD("soundManager::createMovie(): Trying to load "+a+(!N&&c.altURL?" (alternate URL)":""),1);return!0};aa=function(){if(c.html5Only)return ca(),!1;if(i)return!1;i=c.getMovie(c.id);
if(!i)S?(D?c.oMC.innerHTML=ua:c.oMC.appendChild(S),S=null,P=!0):ca(c.id,c.url),i=c.getMovie(c.id);i&&o("waitEI");c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return!0};Z=function(){setTimeout(Fa,1E3)};Fa=function(){if(ga)return!1;ga=!0;r.remove(j,"load",Z);if(M&&!Da)return o("waitFocus"),!1;var b;n||(b=c.getMoviePercent(),c._wD(q("waitImpatient",100===b?" (SWF loaded)":0<b?" (SWF "+b+"% loaded)":"")));setTimeout(function(){b=c.getMoviePercent();n||(c._wD("soundManager: No Flash response within expected time.\nLikely causes: "+
(0===b?"Loading "+c.movieURL+" may have failed (and/or Flash "+m+"+ not present?), ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash?" "+q("checkSWF"):""),2),!N&&b&&(o("localFail",2),c.debugFlash||o("tryDebug",2)),0===b&&c._wD(q("swf404",c.url)),w("flashtojs",!1,": Timed out"+N?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!n&&Ta&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?(c.useFlashBlock&&va(),o("waitForever")):da(!0):0===c.flashLoadTimeout?o("waitForever"):
da(!0))},c.flashLoadTimeout)};E=function(){function b(){r.remove(j,"focus",E);r.remove(j,"load",E)}if(Da||!M)return b(),!0;Da=Ta=!0;c._wD("soundManager::handleFocus()");V&&M&&r.remove(j,"mousemove",E);ga=!1;b();return!0};Ra=function(){var b,a=[];if(c.useHTML5Audio&&c.hasHTML5){for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]+(!c.html5[b]&&t&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&t?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required?
"required, ":"")+"and no flash support)":""));c._wD("-- SoundManager 2: HTML5 support tests ("+c.html5Test+"): "+a.join(", ")+" --",1)}};R=function(b){if(n)return!1;if(c.html5Only)return c._wD("-- SoundManager 2: loaded --"),n=!0,I(),w("onload",!0),!0;var a;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())n=!0,y&&(a={type:!t&&z?"NO_FLASH":"INIT_TIMEOUT"});c._wD("-- SoundManager 2 "+(y?"failed to load":"loaded")+" ("+(y?"security/load error":"OK")+") --",1);if(y||b){if(c.useFlashBlock&&
c.oMC)c.oMC.className=L()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error");H({type:"ontimeout",error:a});w("onload",!1);K(a);return!1}w("onload",!0);if(c.waitForWindowLoad&&!Y)return o("waitOnload"),r.add(j,"load",I),!1;c.waitForWindowLoad&&Y&&o("docLoaded");I();return!0};X=function(){o("init");if(n)return o("didInit"),!1;if(c.html5Only){if(!n)r.remove(j,"load",c.beginDelayedInit),c.enabled=!0,R();return!0}aa();try{o("flashJS"),i._externalInterfaceTest(!1),Ga(!0,c.flashPollingInterval||
(c.useHighPerformance?10:50)),c.debugMode||i._disableDebug(),c.enabled=!0,w("jstoflash",!0),c.html5Only||r.add(j,"unload",na)}catch(b){return c._wD("js/flash exception: "+b.toString()),w("jstoflash",!1),K({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),da(!0),R(),!1}R();r.remove(j,"load",c.beginDelayedInit);return!0};J=function(){if(sa)return!1;sa=!0;ta();var b=O.toLowerCase(),a=null,a=null,d="undefined"!==typeof console&&"undefined"!==typeof console.log;if(-1!==b.indexOf("sm2-usehtml5audio="))a="1"===b.charAt(b.indexOf("sm2-usehtml5audio=")+
18),d&&console.log((a?"Enabling ":"Disabling ")+"useHTML5Audio via URL parameter"),c.useHTML5Audio=a;if(-1!==b.indexOf("sm2-preferflash="))a="1"===b.charAt(b.indexOf("sm2-preferflash=")+16),d&&console.log((a?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),c.preferFlash=a;if(!t&&c.hasHTML5)c._wD("SoundManager: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode.")),c.useHTML5Audio=!0,c.preferFlash=!1;Oa();c.html5.usingFlash=Na();z=c.html5.usingFlash;Ra();if(!t&&
z)c._wD("SoundManager: Fatal error: Flash is needed to play some required formats, but is not available."),c.flashLoadTimeout=1;h.removeEventListener&&h.removeEventListener("DOMContentLoaded",J,!1);aa();return!0};za=function(){"complete"===h.readyState&&(J(),h.detachEvent("onreadystatechange",za));return!0};ra=function(){Y=!0;r.remove(j,"load",ra)};ka();r.add(j,"focus",E);r.add(j,"load",E);r.add(j,"load",Z);r.add(j,"load",ra);V&&M&&r.add(j,"mousemove",E);h.addEventListener?h.addEventListener("DOMContentLoaded",
J,!1):h.attachEvent?h.attachEvent("onreadystatechange",za):(w("onload",!1),K({type:"NO_DOM2_EVENTS",fatal:!0}));"complete"===h.readyState&&setTimeout(J,100)}var la=null;if("undefined"===typeof SM2_DEFER||!SM2_DEFER)la=new W;G.SoundManager=W;G.soundManager=la})(window);

View file

@ -0,0 +1,77 @@
/** @license
*
* SoundManager 2: JavaScript Sound for the Web
* ----------------------------------------------
* http://schillmania.com/projects/soundmanager2/
*
* Copyright (c) 2007, Scott Schiller. All rights reserved.
* Code provided under the BSD License:
* http://schillmania.com/projects/soundmanager2/license.txt
*
* V2.97a.20111220
*/
(function(J){function R(R,ea){function l(b){return function(a){var c=this._t;return!c||!c._a?null:b.call(this,a)}}this.flashVersion=8;this.debugFlash=this.debugMode=!1;this.consoleOnly=this.useConsole=!0;this.waitForWindowLoad=!1;this.bgColor="#ffffff";this.useHighPerformance=!1;this.html5PollingInterval=this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock=!1;this.useHTML5Audio=!0;this.html5Test=/^(probably|maybe)$/i;this.preferFlash=
!0;this.noSWFCache=!1;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,
onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.movieID="sm2-container";this.id=ea||"sm2movie";
this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20111220";this.movieURL=this.version=null;this.url=R||null;this.altURL=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={};var fa;try{fa="undefined"!==typeof Audio&&
"undefined"!==typeof(new Audio).canPlayType}catch(Xa){fa=!1}this.hasHTML5=fa;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Aa,c=this,h=null,S,p=navigator.userAgent,j=J,ga=j.location.href.toString(),k=document,ha,T,i,v=[],K=!1,L=!1,m=!1,w=!1,ia=!1,M,q,ja,C,D,U,Ba,ka,A,V,E,la,ma,na,W,F,Ca,oa,Da,X,Ea,N=null,pa=null,G,qa,H,Y,Z,ra,o,$=!1,sa=!1,Fa,Ga,Ha,aa=0,O=null,ba,s=null,Ia,ca,P,x,ta,ua,Ja,n,Ra=Array.prototype.slice,B=!1,r,da,Ka,u,La,va=p.match(/(ipad|iphone|ipod)/i),
Sa=p.match(/firefox/i),Ta=p.match(/droid/i),y=p.match(/msie/i),Ua=p.match(/webkit/i),Q=p.match(/safari/i)&&!p.match(/chrome/i),Va=p.match(/opera/i),wa=p.match(/(mobile|pre\/|xoom)/i)||va,xa=!ga.match(/usehtml5audio/i)&&!ga.match(/sm2\-ignorebadua/i)&&Q&&!p.match(/silk/i)&&p.match(/OS X 10_6_([3-7])/i),ya="undefined"!==typeof k.hasFocus?k.hasFocus():null,I=Q&&"undefined"===typeof k.hasFocus,Ma=!I,Na=/(mp3|mp4|mpa)/i,za=k.location?k.location.protocol.match(/http/i):null,Oa=!za?"http://":"",Pa=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,
Qa="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Wa=RegExp("\\.("+Qa.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!za;this._global_a=null;if(wa&&(c.useHTML5Audio=!0,c.preferFlash=!1,va))B=c.ignoreFlash=!0;this.supported=this.ok=function(){return s?m&&!w:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(b){return S(b)||k[b]||j[b]};this.createSound=function(b){function a(){e=Y(e);c.sounds[d.id]=new Aa(d);c.soundIDs.push(d.id);
return c.sounds[d.id]}var e=null,f=null,d=null;if(!m||!c.ok())return ra(void 0),!1;2===arguments.length&&(b={id:arguments[0],url:arguments[1]});e=q(b);e.url=ba(e.url);d=e;if(o(d.id,!0))return c.sounds[d.id];if(ca(d))f=a(),f._setup_html5(d);else{if(8<i){if(null===d.isMovieStar)d.isMovieStar=d.serverURL||(d.type?d.type.match(Pa):!1)||d.url.match(Wa);if(d.isMovieStar&&d.usePeakData)d.usePeakData=!1}d=Z(d,void 0);f=a();if(8===i)h._createSound(d.id,d.loops||1,d.usePolicyFile);else if(h._createSound(d.id,
d.url,d.usePeakData,d.useWaveformData,d.useEQData,d.isMovieStar,d.isMovieStar?d.bufferTime:!1,d.loops||1,d.serverURL,d.duration||null,d.autoPlay,!0,d.autoLoad,d.usePolicyFile),!d.serverURL)f.connected=!0,d.onconnect&&d.onconnect.apply(f);!d.serverURL&&(d.autoLoad||d.autoPlay)&&f.load(d)}!d.serverURL&&d.autoPlay&&f.play();return f};this.destroySound=function(b,a){if(!o(b))return!1;var e=c.sounds[b],f;e._iO={};e.stop();e.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,
1);break}a||e.destruct(!0);delete c.sounds[b];return!0};this.load=function(b,a){return!o(b)?!1:c.sounds[b].load(a)};this.unload=function(b){return!o(b)?!1:c.sounds[b].unload()};this.onposition=this.onPosition=function(b,a,e,f){return!o(b)?!1:c.sounds[b].onposition(a,e,f)};this.clearOnPosition=function(b,a,e){return!o(b)?!1:c.sounds[b].clearOnPosition(a,e)};this.start=this.play=function(b,a){if(!m||!c.ok())return ra("soundManager.play(): "+G(!m?"notReady":"notOK")),!1;if(!o(b)){a instanceof Object||
(a={url:a});return a&&a.url?(a.id=b,c.createSound(a).play()):!1}return c.sounds[b].play(a)};this.setPosition=function(b,a){return!o(b)?!1:c.sounds[b].setPosition(a)};this.stop=function(b){return!o(b)?!1:c.sounds[b].stop()};this.stopAll=function(){for(var b in c.sounds)c.sounds.hasOwnProperty(b)&&c.sounds[b].stop()};this.pause=function(b){return!o(b)?!1:c.sounds[b].pause()};this.pauseAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};this.resume=function(b){return!o(b)?
!1:c.sounds[b].resume()};this.resumeAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){return!o(b)?!1:c.sounds[b].togglePause()};this.setPan=function(b,a){return!o(b)?!1:c.sounds[b].setPan(a)};this.setVolume=function(b,a){return!o(b)?!1:c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;"string"!==typeof b&&(b=null);if(b)return!o(b)?!1:c.sounds[b].mute();for(a=c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();return c.muted=!0};
this.muteAll=function(){c.mute()};this.unmute=function(b){"string"!==typeof b&&(b=null);if(b)return!o(b)?!1:c.sounds[b].unmute();for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute();c.muted=!1;return!0};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){return!o(b)?!1:c.sounds[b].toggleMute()};this.getMemoryUse=function(){var b=0;h&&8!==i&&(b=parseInt(h._getMemoryUse(),10));return b};this.disable=function(b){var a;"undefined"===typeof b&&(b=!1);if(w)return!1;w=!0;for(a=c.soundIDs.length;a--;)Da(c.sounds[c.soundIDs[a]]);
M(b);n.remove(j,"load",D);return!0};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=P({type:b}));return!s||a?a:b?!!(8<i&&b.match(Pa)||b.match(c.mimePattern)):null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=P({url:b}));return!s||a?a:b?!!b.match(c.filePattern):null};this.canPlayLink=function(b){return"undefined"!==typeof b.type&&b.type&&c.canPlayMIME(b.type)?!0:c.canPlayURL(b.href)};this.getSoundById=function(b){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");return c.sounds[b]};
this.onready=function(b,a){if(b&&b instanceof Function)return a||(a=j),ja("onready",b,a),C(),!0;throw G("needFunction","onready");};this.ontimeout=function(b,a){if(b&&b instanceof Function)return a||(a=j),ja("ontimeout",b,a),C({type:"ontimeout"}),!0;throw G("needFunction","ontimeout");};this._wD=this._writeDebug=function(){return!0};this._debug=function(){};this.reboot=function(){var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();try{if(y)pa=h.innerHTML;N=h.parentNode.removeChild(h)}catch(e){}pa=
N=s=null;c.enabled=ma=m=$=sa=K=L=w=c.swfLoaded=!1;c.soundIDs=c.sounds=[];h=null;for(b in v)if(v.hasOwnProperty(b))for(a=v[b].length;a--;)v[b][a].fired=!1;j.setTimeout(c.beginDelayedInit,20)};this.getMoviePercent=function(){return h&&"undefined"!==typeof h.PercentLoaded?h.PercentLoaded():null};this.beginDelayedInit=function(){ia=!0;E();setTimeout(function(){if(sa)return!1;W();V();return sa=!0},20);U()};this.destruct=function(){c.disable(!0)};Aa=function(b){var a=this,e,f,d,g,z,j,k=!1,t=[],l=0,n,p,
m=null,r=null,s=null;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=q(b);this.pan=this.options.pan;this.volume=this.options.volume;this.isHTML5=!1;this._a=null;this.id3={};this._debug=function(){};this.load=function(b){var c=null;if("undefined"!==typeof b)a._iO=q(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,m&&m!==a.url)a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;a._iO.url=ba(a._iO.url);if(a._iO.url===a.url&&0!==a.readyState&&
2!==a.readyState)return 3===a.readyState&&a._iO.onload&&a._iO.onload.apply(a,[!!a.duration]),a;b=a._iO;m=a.url;a.loaded=!1;a.readyState=1;a.playState=0;if(ca(b)){if(c=a._setup_html5(b),!c._called_load)a._html5_canplay=!1,a._a.autobuffer="auto",a._a.preload="auto",c.load(),c._called_load=!0,b.autoPlay&&a.play()}else try{a.isHTML5=!1,a._iO=Z(Y(b)),b=a._iO,8===i?h._load(a.sID,b.url,b.stream,b.autoPlay,b.whileloading?1:0,b.loops||1,b.usePolicyFile):h._load(a.sID,b.url,!!b.stream,!!b.autoPlay,b.loops||
1,!!b.autoLoad,b.usePolicyFile)}catch(d){F({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:!0})}return a};this.unload=function(){0!==a.readyState&&(a.isHTML5?(g(),a._a&&(a._a.pause(),ta(a._a))):8===i?h._unload(a.sID,"about:blank"):h._unload(a.sID),e());return a};this.destruct=function(b){if(a.isHTML5){if(g(),a._a)a._a.pause(),ta(a._a),B||d(),a._a._t=null,a._a=null}else a._iO.onfailure=null,h._destroySound(a.sID);b||c.destroySound(a.sID,!0)};this.start=this.play=function(b,c){var d,c=void 0===c?!0:c;b||(b=
{});a._iO=q(b,a._iO);a._iO=q(a._iO,a.options);a._iO.url=ba(a._iO.url);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()||a.setAutoPlay(!0),a;ca(a._iO)&&(a._setup_html5(a._iO),z());if(1===a.playState&&!a.paused&&(d=a._iO.multiShot,!d))return a;if(!a.loaded)if(0===a.readyState){if(!a.isHTML5)a._iO.autoPlay=!0;a.load(a._iO)}else if(2===a.readyState)return a;if(!a.isHTML5&&9===i&&0<a.position&&a.position===a.duration)b.position=0;if(a.paused&&a.position&&0<a.position)a.resume();
else{a._iO=q(b,a._iO);if(null!==a._iO.from&&null!==a._iO.to&&0===a.instanceCount&&0===a.playState&&!a._iO.serverURL){d=function(){a._iO=q(b,a._iO);a.play(a._iO)};if(a.isHTML5&&!a._html5_canplay)return a.load({_oncanplay:d}),!1;if(!a.isHTML5&&!a.loaded&&(!a.readyState||2!==a.readyState))return a.load({onload:d}),!1;a._iO=p()}(!a.instanceCount||a._iO.multiShotEvents||!a.isHTML5&&8<i&&!a.getAutoPlay())&&a.instanceCount++;0===a.playState&&a._iO.onposition&&j(a);a.playState=1;a.paused=!1;a.position="undefined"!==
typeof a._iO.position&&!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=Z(Y(a._iO));a._iO.onplay&&c&&(a._iO.onplay.apply(a),k=!0);a.setVolume(a._iO.volume,!0);a.setPan(a._iO.pan,!0);a.isHTML5?(z(),d=a._setup_html5(),a.setPosition(a._iO.position),d.play()):h._start(a.sID,a._iO.loops||1,9===i?a._iO.position:a._iO.position/1E3)}return a};this.stop=function(b){var c=a._iO;if(1===a.playState){a._onbufferchange(0);a._resetOnPosition(0);a.paused=!1;if(!a.isHTML5)a.playState=0;n();c.to&&a.clearOnPosition(c.to);
if(a.isHTML5){if(a._a)b=a.position,a.setPosition(0),a.position=b,a._a.pause(),a.playState=0,a._onTimer(),g()}else h._stop(a.sID,b),c.serverURL&&a.unload();a.instanceCount=0;a._iO={};c.onstop&&c.onstop.apply(a)}return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5||(h._setAutoPlay(a.sID,b),b&&!a.instanceCount&&1===a.readyState&&a.instanceCount++)};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){void 0===b&&(b=0);var c=a.isHTML5?Math.max(b,0):Math.min(a.duration||
a._iO.duration,Math.max(b,0));a.position=c;b=a.position/1E3;a._resetOnPosition(a.position);a._iO.position=c;if(a.isHTML5){if(a._a&&a._html5_canplay&&a._a.currentTime!==b)try{a._a.currentTime=b,(0===a.playState||a.paused)&&a._a.pause()}catch(d){}}else b=9===i?a.position:b,a.readyState&&2!==a.readyState&&h._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(!0);return a};this.pause=function(b){if(a.paused||0===a.playState&&1!==a.readyState)return a;a.paused=!0;a.isHTML5?(a._setup_html5().pause(),
g()):(b||void 0===b)&&h._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){var b=a._iO;if(!a.paused)return a;a.paused=!1;a.playState=1;a.isHTML5?(a._setup_html5().play(),z()):(b.isMovieStar&&!b.serverURL&&a.setPosition(a.position),h._pause(a.sID));k&&b.onplay?(b.onplay.apply(a),k=!0):b.onresume&&b.onresume.apply(a);return a};this.togglePause=function(){if(0===a.playState)return a.play({position:9===i&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();
return a};this.setPan=function(b,c){"undefined"===typeof b&&(b=0);"undefined"===typeof c&&(c=!1);a.isHTML5||h._setPan(a.sID,b);a._iO.pan=b;if(!c)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){"undefined"===typeof b&&(b=100);"undefined"===typeof d&&(d=!1);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else h._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume=b;return a};this.mute=function(){a.muted=!0;if(a.isHTML5){if(a._a)a._a.muted=
!0}else h._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=!1;var b="undefined"!==typeof a._iO.volume;if(a.isHTML5){if(a._a)a._a.muted=!1}else h._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=this.onPosition=function(b,c,d){t.push({position:b,method:c,scope:"undefined"!==typeof d?d:a,fired:!1});return a};this.clearOnPosition=function(a,b){var c,a=parseInt(a,10);if(isNaN(a))return!1;for(c=0;c<t.length;c++)if(a===
t[c].position&&(!b||b===t[c].method))t[c].fired&&l--,t.splice(c,1)};this._processOnPosition=function(){var b,c;b=t.length;if(!b||!a.playState||l>=b)return!1;for(;b--;)if(c=t[b],!c.fired&&a.position>=c.position)c.fired=!0,l++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(a){var b,c;b=t.length;if(!b)return!1;for(;b--;)if(c=t[b],c.fired&&a<=c.position)c.fired=!1,l--;return!0};p=function(){var b=a._iO,c=b.from,d=b.to,e,f;f=function(){a.clearOnPosition(d,f);a.stop()};e=
function(){if(null!==d&&!isNaN(d))a.onPosition(d,f)};if(null!==c&&!isNaN(c))b.position=c,b.multiShot=!1,e();return b};j=function(){var b=a._iO.onposition;if(b)for(var c in b)if(b.hasOwnProperty(c))a.onPosition(parseInt(c,10),b[c])};n=function(){var b=a._iO.onposition;if(b)for(var c in b)b.hasOwnProperty(c)&&a.clearOnPosition(parseInt(c,10))};z=function(){a.isHTML5&&Fa(a)};g=function(){a.isHTML5&&Ga(a)};e=function(){t=[];l=0;k=!1;a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=
null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.eqData=[];a.eqData.left=[];a.eqData.right=[];a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null};e();this._onTimer=function(b){var c,d=!1,e={};if(a._hasTimer||b){if(a._a&&(b||(0<a.playState||1===a.readyState)&&!a.paused)){c=a._get_html5_duration();
if(c!==r)r=c,a.duration=c,d=!0;a.durationEstimate=a.duration;c=1E3*a._a.currentTime||0;c!==s&&(s=c,d=!0);(d||b)&&a._whileplaying(c,e,e,e,e);return d}return!1}};this._get_html5_duration=function(){var b=a._iO,c=a._a?1E3*a._a.duration:b?b.duration:void 0;return c&&!isNaN(c)&&Infinity!==c?c:b?b.duration:null};this._setup_html5=function(b){var b=q(a._iO,b),d=decodeURI,g=B?c._global_a:a._a,h=d(b.url),z=g&&g._t?g._t.instanceOptions:null;if(g){if(g._t&&(!B&&h===d(m)||B&&z.url===b.url&&(!m||m===z.url)))return g;
B&&g._t&&g._t.playState&&b.url!==z.url&&g._t.stop();e();g.src=b.url;m=a.url=b.url;g._called_load=!1}else{g=new Audio(b.url);g._called_load=!1;if(Ta)g._called_load=!0;if(B)c._global_a=g}a.isHTML5=!0;a._a=g;g._t=a;f();g.loop=1<b.loops?"loop":"";b.autoLoad||b.autoPlay?a.load():(g.autobuffer=!1,g.preload="none");g.loop=1<b.loops?"loop":"";return g};f=function(){if(a._a._added_events)return!1;var b;a._a._added_events=!0;for(b in u)u.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,u[b],!1);return!0};d=
function(){var b;a._a._added_events=!1;for(b in u)u.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,u[b],!1)};this._onload=function(b){b=!!b;a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0);a._iO.onload&&a._iO.onload.apply(a,[b]);return!0};this._onbufferchange=function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return!0};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a);return!0};
this._onfailure=function(b,c,d){a.failures++;if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,c,d)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)n(),a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},g();(!a.instanceCount||a._iO.multiShotEvents)&&b&&b.apply(a)}};this._whileloading=function(b,c,d,e){var f=a._iO;a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(d);a.bufferLength=
e;if(f.isMovieStar)a.durationEstimate=a.duration;else if(a.durationEstimate=f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10),void 0===a.durationEstimate)a.durationEstimate=a.duration;3!==a.readyState&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,d,e,f){var g=a._iO;if(isNaN(b)||null===b)return!1;a.position=b;a._processOnPosition();if(!a.isHTML5&&8<i){if(g.usePeakData&&"undefined"!==typeof c&&c)a.peakData={left:c.leftPeak,
right:c.rightPeak};if(g.useWaveformData&&"undefined"!==typeof d&&d)a.waveformData={left:d.split(","),right:e.split(",")};if(g.useEQData&&"undefined"!==typeof f&&f&&f.leftEQ&&(b=f.leftEQ.split(","),a.eqData=b,a.eqData.left=b,"undefined"!==typeof f.rightEQ&&f.rightEQ))a.eqData.right=f.rightEQ.split(",")}1===a.playState&&(!a.isHTML5&&8===i&&!a.position&&a.isBuffering&&a._onbufferchange(0),g.whileplaying&&g.whileplaying.apply(a));return!0};this._onmetadata=function(b,c){var d={},e,f;for(e=0,f=b.length;e<
f;e++)d[b[e]]=c[e];a.metadata=d;a._iO.onmetadata&&a._iO.onmetadata.apply(a)};this._onid3=function(b,c){var d=[],e,f;for(e=0,f=b.length;e<f;e++)d[b[e]]=c[e];a.id3=q(a.id3,d);a._iO.onid3&&a._iO.onid3.apply(a)};this._onconnect=function(b){b=1===b;if(a.connected=b)a.failures=0,o(a.sID)&&(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._ondataerror=function(){0<a.playState&&a._iO.ondataerror&&a._iO.ondataerror.apply(a)}};na=function(){return k.body||
k._docElement||k.getElementsByTagName("div")[0]};S=function(b){return k.getElementById(b)};q=function(b,a){var e={},f,d;for(f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);f="undefined"===typeof a?c.defaultOptions:a;for(d in f)f.hasOwnProperty(d)&&"undefined"===typeof e[d]&&(e[d]=f[d]);return e};n=function(){function b(a){var a=Ra.call(a),b=a.length;c?(a[1]="on"+a[1],3<b&&a.pop()):3===b&&a.push(!1);return a}function a(a,b){var h=a.shift(),k=[f[b]];if(c)h[k](a[0],a[1]);else h[k].apply(h,a)}var c=j.attachEvent,
f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();u={abort:l(function(){}),canplay:l(function(){var b=this._t;if(b._html5_canplay)return!0;b._html5_canplay=!0;b._onbufferchange(0);var a=!isNaN(b.position)?b.position/1E3:null;if(b.position&&this.currentTime!==a)try{this.currentTime=a}catch(c){}b._iO._oncanplay&&b._iO._oncanplay()}),load:l(function(){var b=this._t;b.loaded||
(b._onbufferchange(0),b._whileloading(b.bytesTotal,b.bytesTotal,b._get_html5_duration()),b._onload(!0))}),emptied:l(function(){}),ended:l(function(){this._t._onfinish()}),error:l(function(){this._t._onload(!1)}),loadeddata:l(function(){var b=this._t,a=b.bytesTotal||1;if(!b._loaded&&!Q)b.duration=b._get_html5_duration(),b._whileloading(a,a,b._get_html5_duration()),b._onload(!0)}),loadedmetadata:l(function(){}),loadstart:l(function(){this._t._onbufferchange(1)}),play:l(function(){this._t._onbufferchange(0)}),
playing:l(function(){this._t._onbufferchange(0)}),progress:l(function(b){var a=this._t;if(a.loaded)return!1;var c,f=0,d=b.target.buffered;c=b.loaded||0;var g=b.total||1;if(d&&d.length){for(c=d.length;c--;)f=d.end(c)-d.start(c);c=f/b.target.duration}isNaN(c)||(a._onbufferchange(0),a._whileloading(c,g,a._get_html5_duration()),c&&g&&c===g&&u.load.call(this,b))}),ratechange:l(function(){}),suspend:l(function(b){var a=this._t;u.progress.call(this,b);a._onsuspend()}),stalled:l(function(){}),timeupdate:l(function(){this._t._onTimer()}),
waiting:l(function(){this._t._onbufferchange(1)})};ca=function(b){return!b.serverURL&&(b.type?P({type:b.type}):P({url:b.url})||c.html5Only)};ta=function(b){if(b)b.src=Sa?"":"about:blank"};P=function(b){function a(a){return c.preferFlash&&r&&!c.ignoreFlash&&"undefined"!==typeof c.flash[a]&&c.flash[a]}if(!c.useHTML5Audio||!c.hasHTML5)return!1;var e=b.url||null,b=b.type||null,f=c.audioFormats,d;if(b&&"undefined"!==c.html5[b])return c.html5[b]&&!a(b);if(!x){x=[];for(d in f)f.hasOwnProperty(d)&&(x.push(d),
f[d].related&&(x=x.concat(f[d].related)));x=RegExp("\\.("+x.join("|")+")(\\?.*)?$","i")}d=e?e.toLowerCase().match(x):null;if(!d||!d.length)if(b)e=b.indexOf(";"),d=(-1!==e?b.substr(0,e):b).substr(6);else return!1;else d=d[1];if(d&&"undefined"!==typeof c.html5[d])return c.html5[d]&&!a(d);b="audio/"+d;e=c.html5.canPlayType({type:b});return(c.html5[d]=e)&&c.html5[b]&&!a(b)};Ja=function(){function b(b){var d,e,f=!1;if(!a||"function"!==typeof a.canPlayType)return!1;if(b instanceof Array){for(d=0,e=b.length;d<
e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=!0,c.html5[b[d]]=!0,c.flash[b[d]]=!(!c.preferFlash||!r||!b[d].match(Na));return f}b=a&&"function"===typeof a.canPlayType?a.canPlayType(b):!1;return!(!b||!b.match(c.html5Test))}if(!c.useHTML5Audio||"undefined"===typeof Audio)return!1;var a="undefined"!==typeof Audio?Va?new Audio(null):new Audio:null,e,f={},d,g;d=c.audioFormats;for(e in d)if(d.hasOwnProperty(e)&&(f[e]=b(d[e].type),f["audio/"+e]=f[e],c.flash[e]=c.preferFlash&&!c.ignoreFlash&&
e.match(Na)?!0:!1,d[e]&&d[e].related))for(g=d[e].related.length;g--;)f["audio/"+d[e].related[g]]=f[e],c.html5[d[e].related[g]]=f[e],c.flash[d[e].related[g]]=f[e];f.canPlayType=a?b:null;c.html5=q(c.html5,f);return!0};G=function(){};Y=function(b){if(8===i&&1<b.loops&&b.stream)b.stream=!1;return b};Z=function(b){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))b.usePolicyFile=!0;return b};ra=function(){};ha=function(){return!1};Da=function(b){for(var a in b)b.hasOwnProperty(a)&&
"function"===typeof b[a]&&(b[a]=ha)};X=function(b){"undefined"===typeof b&&(b=!1);(w||b)&&c.disable(b)};Ea=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");b=(b&&-1!==b.lastIndexOf("/")?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(b+="?ts="+(new Date).getTime());return b};ka=function(){i=parseInt(c.flashVersion,10);if(8!==i&&9!==i)c.flashVersion=i=8;var b=c.debugMode||
c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!c.html5Only&&c.audioFormats.mp4.required&&9>i)c.flashVersion=i=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===i?" (AS3/Flash 9)":" (AS2/Flash 8)");8<i?(c.defaultOptions=q(c.defaultOptions,c.flash9Options),c.features.buffering=!0,c.defaultOptions=q(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+Qa.join("|")+")(\\?.*)?$","i"),c.features.movieStar=!0):c.features.movieStar=!1;c.filePattern=c.filePatterns[8!==
i?"flash9":"flash8"];c.movieURL=(8===i?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=8<i};Ca=function(b,a){if(!h)return!1;h._setPolling(b,a)};oa=function(){if(c.debugURLParam.test(ga))c.debugMode=!0};o=this.getSoundById;H=function(){var b=[];c.debugMode&&b.push("sm2_debug");c.debugFlash&&b.push("flash_debug");c.useHighPerformance&&b.push("high_performance");return b.join(" ")};qa=function(){G("fbHandler");var b=c.getMoviePercent(),
a={type:"FLASHBLOCK"};if(c.html5Only)return!1;if(c.ok()){if(c.oMC)c.oMC.className=[H(),"movieContainer","swf_loaded"+(c.didFlashBlock?" swf_unblocked":"")].join(" ")}else{if(s)c.oMC.className=H()+" movieContainer "+(null===b?"swf_timedout":"swf_error");c.didFlashBlock=!0;C({type:"ontimeout",ignoreInit:!0,error:a});F(a)}};ja=function(b,a,c){"undefined"===typeof v[b]&&(v[b]=[]);v[b].push({method:a,scope:c||null,fired:!1})};C=function(b){b||(b={type:"onready"});if(!m&&b&&!b.ignoreInit||"ontimeout"===
b.type&&c.ok())return!1;var a={success:b&&b.ignoreInit?c.ok():!w},e=b&&b.type?v[b.type]||[]:[],f=[],d,a=[a],g=s&&c.useFlashBlock&&!c.ok();if(b.error)a[0].error=b.error;for(b=0,d=e.length;b<d;b++)!0!==e[b].fired&&f.push(e[b]);if(f.length)for(b=0,d=f.length;b<d;b++)if(f[b].scope?f[b].method.apply(f[b].scope,a):f[b].method.apply(this,a),!g)f[b].fired=!0;return!0};D=function(){j.setTimeout(function(){c.useFlashBlock&&qa();C();c.onload instanceof Function&&c.onload.apply(j);c.waitForWindowLoad&&n.add(j,
"load",D)},1)};da=function(){if(void 0!==r)return r;var b=!1,a=navigator,c=a.plugins,f,d=j.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&&a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=!0);else if("undefined"!==typeof d){try{f=new d("ShockwaveFlash.ShockwaveFlash")}catch(g){}b=!!f}return r=b};Ia=function(){var b,a;if(va&&p.match(/os (1|2|3_0|3_1)/i)){c.hasHTML5=!1;c.html5Only=!0;if(c.oMC)c.oMC.style.display=
"none";return!1}if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)return c.hasHTML5=!1,!0;c.hasHTML5=!0;if(xa&&da())return!0}else return!0;for(a in c.audioFormats)if(c.audioFormats.hasOwnProperty(a)&&(c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)||c.flash[a]||c.flash[c.audioFormats[a].type]))b=!0;c.ignoreFlash&&(b=!1);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!b;return!c.html5Only};ba=function(b){var a,e,f=0;if(b instanceof Array){for(a=0,e=b.length;a<e;a++)if(b[a]instanceof
Object){if(c.canPlayMIME(b[a].type)){f=a;break}}else if(c.canPlayURL(b[a])){f=a;break}if(b[f].url)b[f]=b[f].url;return b[f]}return b};Fa=function(b){if(!b._hasTimer)b._hasTimer=!0,!wa&&c.html5PollingInterval&&(null===O&&0===aa&&(O=J.setInterval(Ha,c.html5PollingInterval)),aa++)};Ga=function(b){if(b._hasTimer)b._hasTimer=!1,!wa&&c.html5PollingInterval&&aa--};Ha=function(){var b;if(null!==O&&!aa)return J.clearInterval(O),O=null,!1;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].isHTML5&&c.sounds[c.soundIDs[b]]._hasTimer&&
c.sounds[c.soundIDs[b]]._onTimer()};F=function(b){b="undefined"!==typeof b?b:{};c.onerror instanceof Function&&c.onerror.apply(j,[{type:"undefined"!==typeof b.type?b.type:null}]);"undefined"!==typeof b.fatal&&b.fatal&&c.disable()};Ka=function(){if(!xa||!da())return!1;var b=c.audioFormats,a,e;for(e in b)if(b.hasOwnProperty(e)&&("mp3"===e||"mp4"===e))if(c.html5[e]=!1,b[e]&&b[e].related)for(a=b[e].related.length;a--;)c.html5[b[e].related[a]]=!1};this._setSandboxType=function(){};this._externalInterfaceOK=
function(){if(c.swfLoaded)return!1;(new Date).getTime();c.swfLoaded=!0;I=!1;xa&&Ka();y?setTimeout(T,100):T()};W=function(b,a){function e(a,b){return'<param name="'+a+'" value="'+b+'" />'}if(K&&L)return!1;if(c.html5Only)return ka(),c.oMC=S(c.movieID),T(),L=K=!0,!1;var f=a||c.url,d=c.altURL||f,g;g=na();var h,j,i=H(),l,m=null,m=(m=k.getElementsByTagName("html")[0])&&m.dir&&m.dir.match(/rtl/i),b="undefined"===typeof b?c.id:b;ka();c.url=Ea(za?f:d);a=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":
c.wmode;if(null!==c.wmode&&(p.match(/msie 8/i)||!y&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.wmode=null;g={name:b,id:b,src:a,width:"auto",height:"auto",quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Oa+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)g.FlashVars="debug=1";c.wmode||delete g.wmode;if(y)f=k.createElement("div"),
j=['<object id="'+b+'" data="'+a+'" type="'+g.type+'" title="'+g.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+Oa+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+g.width+'" height="'+g.height+'">',e("movie",a),e("AllowScriptAccess",c.allowScriptAccess),e("quality",g.quality),c.wmode?e("wmode",c.wmode):"",e("bgcolor",c.bgColor),e("hasPriority","true"),c.debugFlash?e("FlashVars",g.FlashVars):"","</object>"].join("");else for(h in f=
k.createElement("embed"),g)g.hasOwnProperty(h)&&f.setAttribute(h,g[h]);oa();i=H();if(g=na())if(c.oMC=S(c.movieID)||k.createElement("div"),c.oMC.id){l=c.oMC.className;c.oMC.className=(l?l+" ":"movieContainer")+(i?" "+i:"");c.oMC.appendChild(f);if(y)h=c.oMC.appendChild(k.createElement("div")),h.className="sm2-object-box",h.innerHTML=j;L=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+i;h=i=null;if(!c.useFlashBlock)if(c.useHighPerformance)i={position:"fixed",width:"8px",height:"8px",bottom:"0px",
left:"0px",overflow:"hidden"};else if(i={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},m)i.left=Math.abs(parseInt(i.left,10))+"px";if(Ua)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(l in i)i.hasOwnProperty(l)&&(c.oMC.style[l]=i[l]);try{y||c.oMC.appendChild(f);g.appendChild(c.oMC);if(y)h=c.oMC.appendChild(k.createElement("div")),h.className="sm2-object-box",h.innerHTML=j;L=!0}catch(n){throw Error(G("domError")+" \n"+n.toString());}}return K=!0};V=function(){if(c.html5Only)return W(),
!1;if(h)return!1;h=c.getMovie(c.id);if(!h)N?(y?c.oMC.innerHTML=pa:c.oMC.appendChild(N),N=null,K=!0):W(c.id,c.url),h=c.getMovie(c.id);c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return!0};U=function(){setTimeout(Ba,1E3)};Ba=function(){if($)return!1;$=!0;n.remove(j,"load",U);if(I&&!ya)return!1;var b;m||(b=c.getMoviePercent());setTimeout(function(){b=c.getMoviePercent();!m&&Ma&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?c.useFlashBlock&&qa():X(!0):0!==c.flashLoadTimeout&&X(!0))},
c.flashLoadTimeout)};A=function(){function b(){n.remove(j,"focus",A);n.remove(j,"load",A)}if(ya||!I)return b(),!0;ya=Ma=!0;Q&&I&&n.remove(j,"mousemove",A);$=!1;b();return!0};La=function(){var b,a=[];if(c.useHTML5Audio&&c.hasHTML5)for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]+(!c.html5[b]&&r&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&r?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required?"required, ":"")+"and no flash support)":""))};
M=function(b){if(m)return!1;if(c.html5Only)return m=!0,D(),!0;var a;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())m=!0,w&&(a={type:!r&&s?"NO_FLASH":"INIT_TIMEOUT"});if(w||b){if(c.useFlashBlock&&c.oMC)c.oMC.className=H()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error");C({type:"ontimeout",error:a});F(a);return!1}if(c.waitForWindowLoad&&!ia)return n.add(j,"load",D),!1;D();return!0};T=function(){if(m)return!1;if(c.html5Only){if(!m)n.remove(j,"load",c.beginDelayedInit),c.enabled=
!0,M();return!0}V();try{h._externalInterfaceTest(!1),Ca(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||h._disableDebug(),c.enabled=!0,c.html5Only||n.add(j,"unload",ha)}catch(b){return F({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),X(!0),M(),!1}M();n.remove(j,"load",c.beginDelayedInit);return!0};E=function(){if(ma)return!1;ma=!0;oa();if(!r&&c.hasHTML5)c.useHTML5Audio=!0,c.preferFlash=!1;Ja();c.html5.usingFlash=Ia();s=c.html5.usingFlash;La();if(!r&&s)c.flashLoadTimeout=1;k.removeEventListener&&
k.removeEventListener("DOMContentLoaded",E,!1);V();return!0};ua=function(){"complete"===k.readyState&&(E(),k.detachEvent("onreadystatechange",ua));return!0};la=function(){ia=!0;n.remove(j,"load",la)};da();n.add(j,"focus",A);n.add(j,"load",A);n.add(j,"load",U);n.add(j,"load",la);Q&&I&&n.add(j,"mousemove",A);k.addEventListener?k.addEventListener("DOMContentLoaded",E,!1):k.attachEvent?k.attachEvent("onreadystatechange",ua):F({type:"NO_DOM2_EVENTS",fatal:!0});"complete"===k.readyState&&setTimeout(E,100)}
var ea=null;if("undefined"===typeof SM2_DEFER||!SM2_DEFER)ea=new R;J.SoundManager=R;J.soundManager=ea})(window);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

421
webclient/inc/WebMIDIAPI.js Executable file
View file

@ -0,0 +1,421 @@
/* Copyright 2013 Chris Wilson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Initialize the MIDI library.
(function (global) {
'use strict';
var midiIO, _requestMIDIAccess, MIDIAccess, _onReady, MIDIPort, MIDIInput, MIDIOutput, _midiProc;
function Promise() {
}
Promise.prototype.then = function(accept, reject) {
this.accept = accept;
this.reject = reject;
}
Promise.prototype.succeed = function(access) {
if (this.accept)
this.accept(access);
}
Promise.prototype.fail = function(error) {
if (this.reject)
this.reject(error);
}
function _JazzInstance() {
this.inputInUse = false;
this.outputInUse = false;
// load the Jazz plugin
var o1 = document.createElement("object");
o1.id = "_Jazz" + Math.random() + "ie";
o1.classid = "CLSID:1ACE1618-1C7D-4561-AEE1-34842AA85E90";
this.activeX = o1;
var o2 = document.createElement("object");
o2.id = "_Jazz" + Math.random();
o2.type="audio/x-jazz";
o1.appendChild(o2);
this.objRef = o2;
var e = document.createElement("p");
e.appendChild(document.createTextNode("This page requires the "));
var a = document.createElement("a");
a.appendChild(document.createTextNode("Jazz plugin"));
a.href = "http://jazz-soft.net/";
e.appendChild(a);
e.appendChild(document.createTextNode("."));
o2.appendChild(e);
var insertionPoint = document.getElementById("MIDIPlugin");
if (!insertionPoint) {
// Create hidden element
var insertionPoint = document.createElement("div");
insertionPoint.id = "MIDIPlugin";
insertionPoint.style.position = "absolute";
insertionPoint.style.visibility = "hidden";
insertionPoint.style.left = "-9999px";
insertionPoint.style.top = "-9999px";
document.body.appendChild(insertionPoint);
}
insertionPoint.appendChild(o1);
if (this.objRef.isJazz)
this._Jazz = this.objRef;
else if (this.activeX.isJazz)
this._Jazz = this.activeX;
else
this._Jazz = null;
if (this._Jazz) {
this._Jazz._jazzTimeZero = this._Jazz.Time();
this._Jazz._perfTimeZero = window.performance.now();
}
}
_requestMIDIAccess = function _requestMIDIAccess() {
var access = new MIDIAccess();
return access._promise;
};
// API Methods
function MIDIAccess() {
this._jazzInstances = new Array();
this._jazzInstances.push( new _JazzInstance() );
this._promise = new Promise;
if (this._jazzInstances[0]._Jazz) {
this._Jazz = this._jazzInstances[0]._Jazz;
window.setTimeout( _onReady.bind(this), 3 );
} else {
window.setTimeout( _onNotReady.bind(this), 3 );
}
};
_onReady = function _onReady() {
if (this._promise)
this._promise.succeed(this);
};
function _onNotReady() {
if (this._promise)
this._promise.fail( { code: 1 } );
};
MIDIAccess.prototype.inputs = function( ) {
if (!this._Jazz)
return null;
var list=this._Jazz.MidiInList();
var inputs = new Array( list.length );
for ( var i=0; i<list.length; i++ ) {
inputs[i] = new MIDIInput( this, list[i], i );
}
return inputs;
}
MIDIAccess.prototype.outputs = function( ) {
if (!this._Jazz)
return null;
var list=this._Jazz.MidiOutList();
var outputs = new Array( list.length );
for ( var i=0; i<list.length; i++ ) {
outputs[i] = new MIDIOutput( this, list[i], i );
}
return outputs;
};
MIDIInput = function MIDIInput( midiAccess, name, index ) {
this._listeners = [];
this._midiAccess = midiAccess;
this._index = index;
this._inLongSysexMessage = false;
this._sysexBuffer = new Uint8Array();
this.id = "" + index + "." + name;
this.manufacturer = "";
this.name = name;
this.type = "input";
this.version = "";
this.onmidimessage = null;
var inputInstance = null;
for (var i=0; (i<midiAccess._jazzInstances.length)&&(!inputInstance); i++) {
if (!midiAccess._jazzInstances[i].inputInUse)
inputInstance=midiAccess._jazzInstances[i];
}
if (!inputInstance) {
inputInstance = new _JazzInstance();
midiAccess._jazzInstances.push( inputInstance );
}
inputInstance.inputInUse = true;
this._jazzInstance = inputInstance._Jazz;
this._input = this._jazzInstance.MidiInOpen( this._index, _midiProc.bind(this) );
};
// Introduced in DOM Level 2:
MIDIInput.prototype.addEventListener = function (type, listener, useCapture ) {
if (type !== "midimessage")
return;
for (var i=0; i<this._listeners.length; i++)
if (this._listeners[i] == listener)
return;
this._listeners.push( listener );
};
MIDIInput.prototype.removeEventListener = function (type, listener, useCapture ) {
if (type !== "midimessage")
return;
for (var i=0; i<this._listeners.length; i++)
if (this._listeners[i] == listener) {
this._listeners.splice( i, 1 ); //remove it
return;
}
};
MIDIInput.prototype.preventDefault = function() {
this._pvtDef = true;
};
MIDIInput.prototype.dispatchEvent = function (evt) {
this._pvtDef = false;
// dispatch to listeners
for (var i=0; i<this._listeners.length; i++)
if (this._listeners[i].handleEvent)
this._listeners[i].handleEvent.bind(this)( evt );
else
this._listeners[i].bind(this)( evt );
if (this.onmidimessage)
this.onmidimessage( evt );
return this._pvtDef;
};
MIDIInput.prototype.appendToSysexBuffer = function ( data ) {
var oldLength = this._sysexBuffer.length;
var tmpBuffer = new Uint8Array( oldLength + data.length );
tmpBuffer.set( this._sysexBuffer );
tmpBuffer.set( data, oldLength );
this._sysexBuffer = tmpBuffer;
};
MIDIInput.prototype.bufferLongSysex = function ( data, initialOffset ) {
var j = initialOffset;
while (j<data.length) {
if (data[j] == 0xF7) {
// end of sysex!
j++;
this.appendToSysexBuffer( data.slice(initialOffset, j) );
return j;
}
j++;
}
// didn't reach the end; just tack it on.
this.appendToSysexBuffer( data.slice(initialOffset, j) );
this._inLongSysexMessage = true;
return j;
};
_midiProc = function _midiProc( timestamp, data ) {
// Have to use createEvent/initEvent because IE10 fails on new CustomEvent. Thanks, IE!
var length = 0;
var i,j;
var isSysexMessage = false;
// Jazz sometimes passes us multiple messages at once, so we need to parse them out
// and pass them one at a time.
for (i=0; i<data.length; i+=length) {
if (this._inLongSysexMessage) {
i = this.bufferLongSysex(data,i);
if ( data[i-1] != 0xf7 ) {
// ran off the end without hitting the end of the sysex message
return;
}
isSysexMessage = true;
} else {
isSysexMessage = false;
switch (data[i] & 0xF0) {
case 0x80: // note off
case 0x90: // note on
case 0xA0: // polyphonic aftertouch
case 0xB0: // control change
case 0xE0: // channel mode
length = 3;
break;
case 0xC0: // program change
case 0xD0: // channel aftertouch
length = 2;
break;
case 0xF0:
switch (data[i]) {
case 0xf0: // variable-length sysex.
i = this.bufferLongSysex(data,i);
if ( data[i-1] != 0xf7 ) {
// ran off the end without hitting the end of the sysex message
return;
}
isSysexMessage = true;
break;
case 0xF1: // MTC quarter frame
case 0xF3: // song select
length = 2;
break;
case 0xF2: // song position pointer
length = 3;
break;
default:
length = 1;
break;
}
break;
}
}
var evt = document.createEvent( "Event" );
evt.initEvent( "midimessage", false, false );
evt.receivedTime = parseFloat( timestamp.toString()) + this._jazzInstance._perfTimeZero;
if (isSysexMessage || this._inLongSysexMessage) {
evt.data = new Uint8Array( this._sysexBuffer );
this._sysexBuffer = new Uint8Array(0);
this._inLongSysexMessage = false;
} else
evt.data = new Uint8Array(data.slice(i, length+i));
this.dispatchEvent( evt );
}
};
MIDIOutput = function MIDIOutput( midiAccess, name, index ) {
this._listeners = [];
this._midiAccess = midiAccess;
this._index = index;
this.id = "" + index + "." + name;
this.manufacturer = "";
this.name = name;
this.type = "output";
this.version = "";
var outputInstance = null;
for (var i=0; (i<midiAccess._jazzInstances.length)&&(!outputInstance); i++) {
if (!midiAccess._jazzInstances[i].outputInUse)
outputInstance=midiAccess._jazzInstances[i];
}
if (!outputInstance) {
outputInstance = new _JazzInstance();
midiAccess._jazzInstances.push( outputInstance );
}
outputInstance.outputInUse = true;
this._jazzInstance = outputInstance._Jazz;
this._jazzInstance.MidiOutOpen(this.name);
};
function _sendLater() {
this.jazz.MidiOutLong( this.data ); // handle send as sysex
}
MIDIOutput.prototype.send = function( data, timestamp ) {
var delayBeforeSend = 0;
if (data.length === 0)
return false;
if (timestamp)
delayBeforeSend = Math.floor( timestamp - window.performance.now() );
if (timestamp && (delayBeforeSend>1)) {
var sendObj = new Object();
sendObj.jazz = this._jazzInstance;
sendObj.data = data;
window.setTimeout( _sendLater.bind(sendObj), delayBeforeSend );
} else {
this._jazzInstance.MidiOutLong( data );
}
return true;
};
//init: create plugin
if (!window.navigator.requestMIDIAccess)
window.navigator.requestMIDIAccess = _requestMIDIAccess;
}(window));
// Polyfill window.performance.now() if necessary.
(function (exports) {
var perf = {}, props;
function findAlt() {
var prefix = ['moz', 'webkit', 'o', 'ms'],
i = prefix.length,
//worst case, we use Date.now()
props = {
value: (function (start) {
return function () {
return Date.now() - start;
};
}(Date.now()))
};
//seach for vendor prefixed version
for (; i >= 0; i--) {
if ((prefix[i] + "Now") in exports.performance) {
props.value = function (method) {
return function () {
exports.performance[method]();
}
}(prefix[i] + "Now");
return props;
}
}
//otherwise, try to use connectionStart
if ("timing" in exports.performance && "connectStart" in exports.performance.timing) {
//this pretty much approximates performance.now() to the millisecond
props.value = (function (start) {
return function() {
Date.now() - start;
};
}(exports.performance.timing.connectStart));
}
return props;
}
//if already defined, bail
if (("performance" in exports) && ("now" in exports.performance))
return;
if (!("performance" in exports))
Object.defineProperty(exports, "performance", {
get: function () {
return perf;
}});
//otherwise, performance is there, but not "now()"
props = findAlt();
Object.defineProperty(exports.performance, "now", props);
}(window));

80
webclient/inc/base64binary.js Executable file
View file

@ -0,0 +1,80 @@
/*
Copyright (c) 2011, Daniel Guerrero
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Daniel Guerrero nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DANIEL GUERRERO BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var Base64Binary = {
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
/* will return a Uint8Array type */
decodeArrayBuffer: function(input) {
var bytes = Math.ceil( (3*input.length) / 4.0);
var ab = new ArrayBuffer(bytes);
this.decode(input, ab);
return ab;
},
decode: function(input, arrayBuffer) {
//get last chars to see if are valid
var lkey1 = this._keyStr.indexOf(input.charAt(input.length-1));
var lkey2 = this._keyStr.indexOf(input.charAt(input.length-1));
var bytes = Math.ceil( (3*input.length) / 4.0);
if (lkey1 == 64) bytes--; //padding chars, so skip
if (lkey2 == 64) bytes--; //padding chars, so skip
var uarray;
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
var j = 0;
if (arrayBuffer)
uarray = new Uint8Array(arrayBuffer);
else
uarray = new Uint8Array(bytes);
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
for (i=0; i<bytes; i+=3) {
//get the 3 octects in 4 ascii chars
enc1 = this._keyStr.indexOf(input.charAt(j++));
enc2 = this._keyStr.indexOf(input.charAt(j++));
enc3 = this._keyStr.indexOf(input.charAt(j++));
enc4 = this._keyStr.indexOf(input.charAt(j++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
uarray[i] = chr1;
if (enc3 != 64) uarray[i+1] = chr2;
if (enc4 != 64) uarray[i+2] = chr3;
}
return uarray;
}
};

24
webclient/inc/jasmid/LICENSE Executable file
View file

@ -0,0 +1,24 @@
Copyright (c) 2010, Matt Westcott & Ben Firshman
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The names of its contributors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

238
webclient/inc/jasmid/midifile.js Executable file
View file

@ -0,0 +1,238 @@
/*
class to parse the .mid file format
(depends on stream.js)
*/
function MidiFile(data) {
function readChunk(stream) {
var id = stream.read(4);
var length = stream.readInt32();
return {
'id': id,
'length': length,
'data': stream.read(length)
};
}
var lastEventTypeByte;
function readEvent(stream) {
var event = {};
event.deltaTime = stream.readVarInt();
var eventTypeByte = stream.readInt8();
if ((eventTypeByte & 0xf0) == 0xf0) {
/* system / meta event */
if (eventTypeByte == 0xff) {
/* meta event */
event.type = 'meta';
var subtypeByte = stream.readInt8();
var length = stream.readVarInt();
switch(subtypeByte) {
case 0x00:
event.subtype = 'sequenceNumber';
if (length != 2) throw "Expected length for sequenceNumber event is 2, got " + length;
event.number = stream.readInt16();
return event;
case 0x01:
event.subtype = 'text';
event.text = stream.read(length);
return event;
case 0x02:
event.subtype = 'copyrightNotice';
event.text = stream.read(length);
return event;
case 0x03:
event.subtype = 'trackName';
event.text = stream.read(length);
return event;
case 0x04:
event.subtype = 'instrumentName';
event.text = stream.read(length);
return event;
case 0x05:
event.subtype = 'lyrics';
event.text = stream.read(length);
return event;
case 0x06:
event.subtype = 'marker';
event.text = stream.read(length);
return event;
case 0x07:
event.subtype = 'cuePoint';
event.text = stream.read(length);
return event;
case 0x20:
event.subtype = 'midiChannelPrefix';
if (length != 1) throw "Expected length for midiChannelPrefix event is 1, got " + length;
event.channel = stream.readInt8();
return event;
case 0x2f:
event.subtype = 'endOfTrack';
if (length != 0) throw "Expected length for endOfTrack event is 0, got " + length;
return event;
case 0x51:
event.subtype = 'setTempo';
if (length != 3) throw "Expected length for setTempo event is 3, got " + length;
event.microsecondsPerBeat = (
(stream.readInt8() << 16)
+ (stream.readInt8() << 8)
+ stream.readInt8()
)
return event;
case 0x54:
event.subtype = 'smpteOffset';
if (length != 5) throw "Expected length for smpteOffset event is 5, got " + length;
var hourByte = stream.readInt8();
event.frameRate = {
0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30
}[hourByte & 0x60];
event.hour = hourByte & 0x1f;
event.min = stream.readInt8();
event.sec = stream.readInt8();
event.frame = stream.readInt8();
event.subframe = stream.readInt8();
return event;
case 0x58:
event.subtype = 'timeSignature';
if (length != 4) throw "Expected length for timeSignature event is 4, got " + length;
event.numerator = stream.readInt8();
event.denominator = Math.pow(2, stream.readInt8());
event.metronome = stream.readInt8();
event.thirtyseconds = stream.readInt8();
return event;
case 0x59:
event.subtype = 'keySignature';
if (length != 2) throw "Expected length for keySignature event is 2, got " + length;
event.key = stream.readInt8(true);
event.scale = stream.readInt8();
return event;
case 0x7f:
event.subtype = 'sequencerSpecific';
event.data = stream.read(length);
return event;
default:
// console.log("Unrecognised meta event subtype: " + subtypeByte);
event.subtype = 'unknown'
event.data = stream.read(length);
return event;
}
event.data = stream.read(length);
return event;
} else if (eventTypeByte == 0xf0) {
event.type = 'sysEx';
var length = stream.readVarInt();
event.data = stream.read(length);
return event;
} else if (eventTypeByte == 0xf7) {
event.type = 'dividedSysEx';
var length = stream.readVarInt();
event.data = stream.read(length);
return event;
} else {
throw "Unrecognised MIDI event type byte: " + eventTypeByte;
}
} else {
/* channel event */
var param1;
if ((eventTypeByte & 0x80) == 0) {
/* running status - reuse lastEventTypeByte as the event type.
eventTypeByte is actually the first parameter
*/
param1 = eventTypeByte;
eventTypeByte = lastEventTypeByte;
} else {
param1 = stream.readInt8();
lastEventTypeByte = eventTypeByte;
}
var eventType = eventTypeByte >> 4;
event.channel = eventTypeByte & 0x0f;
event.type = 'channel';
switch (eventType) {
case 0x08:
event.subtype = 'noteOff';
event.noteNumber = param1;
event.velocity = stream.readInt8();
return event;
case 0x09:
event.noteNumber = param1;
event.velocity = stream.readInt8();
if (event.velocity == 0) {
event.subtype = 'noteOff';
} else {
event.subtype = 'noteOn';
}
return event;
case 0x0a:
event.subtype = 'noteAftertouch';
event.noteNumber = param1;
event.amount = stream.readInt8();
return event;
case 0x0b:
event.subtype = 'controller';
event.controllerType = param1;
event.value = stream.readInt8();
return event;
case 0x0c:
event.subtype = 'programChange';
event.programNumber = param1;
return event;
case 0x0d:
event.subtype = 'channelAftertouch';
event.amount = param1;
return event;
case 0x0e:
event.subtype = 'pitchBend';
event.value = param1 + (stream.readInt8() << 7);
return event;
default:
throw "Unrecognised MIDI event type: " + eventType
/*
console.log("Unrecognised MIDI event type: " + eventType);
stream.readInt8();
event.subtype = 'unknown';
return event;
*/
}
}
}
stream = Stream(data);
var headerChunk = readChunk(stream);
if (headerChunk.id != 'MThd' || headerChunk.length != 6) {
throw "Bad .mid file - header not found";
}
var headerStream = Stream(headerChunk.data);
var formatType = headerStream.readInt16();
var trackCount = headerStream.readInt16();
var timeDivision = headerStream.readInt16();
if (timeDivision & 0x8000) {
throw "Expressing time division in SMTPE frames is not supported yet"
} else {
ticksPerBeat = timeDivision;
}
var header = {
'formatType': formatType,
'trackCount': trackCount,
'ticksPerBeat': ticksPerBeat
}
var tracks = [];
for (var i = 0; i < header.trackCount; i++) {
tracks[i] = [];
var trackChunk = readChunk(stream);
if (trackChunk.id != 'MTrk') {
throw "Unexpected chunk - expected MTrk, got "+ trackChunk.id;
}
var trackStream = Stream(trackChunk.data);
while (!trackStream.eof()) {
var event = readEvent(trackStream);
tracks[i].push(event);
//console.log(event);
}
}
return {
'header': header,
'tracks': tracks
}
}

View file

@ -0,0 +1,96 @@
var clone = function (o) {
if (typeof o != 'object') return (o);
if (o == null) return (o);
var ret = (typeof o.length == 'number') ? [] : {};
for (var key in o) ret[key] = clone(o[key]);
return ret;
};
function Replayer(midiFile, timeWarp, eventProcessor) {
var trackStates = [];
var beatsPerMinute = 120;
var ticksPerBeat = midiFile.header.ticksPerBeat;
for (var i = 0; i < midiFile.tracks.length; i++) {
trackStates[i] = {
'nextEventIndex': 0,
'ticksToNextEvent': (
midiFile.tracks[i].length ?
midiFile.tracks[i][0].deltaTime :
null
)
};
}
var nextEventInfo;
var samplesToNextEvent = 0;
function getNextEvent() {
var ticksToNextEvent = null;
var nextEventTrack = null;
var nextEventIndex = null;
for (var i = 0; i < trackStates.length; i++) {
if (
trackStates[i].ticksToNextEvent != null
&& (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent)
) {
ticksToNextEvent = trackStates[i].ticksToNextEvent;
nextEventTrack = i;
nextEventIndex = trackStates[i].nextEventIndex;
}
}
if (nextEventTrack != null) {
/* consume event from that track */
var nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex];
if (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) {
trackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime;
} else {
trackStates[nextEventTrack].ticksToNextEvent = null;
}
trackStates[nextEventTrack].nextEventIndex += 1;
/* advance timings on all tracks by ticksToNextEvent */
for (var i = 0; i < trackStates.length; i++) {
if (trackStates[i].ticksToNextEvent != null) {
trackStates[i].ticksToNextEvent -= ticksToNextEvent
}
}
return {
"ticksToEvent": ticksToNextEvent,
"event": nextEvent,
"track": nextEventTrack
}
} else {
return null;
}
};
//
var midiEvent;
var temporal = [];
//
function processEvents() {
function processNext() {
if ( midiEvent.event.type == "meta" && midiEvent.event.subtype == "setTempo" ) {
// tempo change events can occur anywhere in the middle and affect events that follow
beatsPerMinute = 60000000 / midiEvent.event.microsecondsPerBeat;
}
if (midiEvent.ticksToEvent > 0) {
var beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;
var secondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);
}
var time = (secondsToGenerate * 1000 * timeWarp) || 0;
temporal.push([ midiEvent, time]);
midiEvent = getNextEvent();
};
//
if (midiEvent = getNextEvent()) {
while(midiEvent) processNext(true);
}
};
processEvents();
return {
"getData": function() {
return clone(temporal);
}
};
};

69
webclient/inc/jasmid/stream.js Executable file
View file

@ -0,0 +1,69 @@
/* Wrapper for accessing strings through sequential reads */
function Stream(str) {
var position = 0;
function read(length) {
var result = str.substr(position, length);
position += length;
return result;
}
/* read a big-endian 32-bit integer */
function readInt32() {
var result = (
(str.charCodeAt(position) << 24)
+ (str.charCodeAt(position + 1) << 16)
+ (str.charCodeAt(position + 2) << 8)
+ str.charCodeAt(position + 3));
position += 4;
return result;
}
/* read a big-endian 16-bit integer */
function readInt16() {
var result = (
(str.charCodeAt(position) << 8)
+ str.charCodeAt(position + 1));
position += 2;
return result;
}
/* read an 8-bit integer */
function readInt8(signed) {
var result = str.charCodeAt(position);
if (signed && result > 127) result -= 256;
position += 1;
return result;
}
function eof() {
return position >= str.length;
}
/* read a MIDI-style variable-length integer
(big-endian value in groups of 7 bits,
with top bit set to signify that another byte follows)
*/
function readVarInt() {
var result = 0;
while (true) {
var b = readInt8();
if (b & 0x80) {
result += (b & 0x7f);
result <<= 7;
} else {
/* b is the last byte */
return result + b;
}
}
}
return {
'eof': eof,
'read': read,
'readInt32': readInt32,
'readInt16': readInt16,
'readInt8': readInt8,
'readVarInt': readVarInt
}
}

View file

@ -42,6 +42,17 @@
<script src="components/fileInput/file-input-directive.js"></script>
<script src="components/fileUpload/file-upload-service.js"></script>
<script src="components/utilities/utilities-service.js"></script>
<script type='text/javascript' src='js/MIDI.js'></script>
<script src="components/matrix/midi-event-handler.js"></script>
<script src="./inc/Base64.js" type="text/javascript"></script>
<script src="./inc/base64binary.js" type="text/javascript"></script>
<script type='text/javascript' src='js/vextab/underscore-min.js'></script>
<script type='text/javascript' src='js/vextab/vexflow-debug.js'></script>
<script type='text/javascript' src='js/vextab/tabdiv-debug.js'></script>
<script type='text/javascript' src='js/vextab/vextab_parser.js'></script>
</head>
<body>

1280
webclient/js/MIDI.js Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1
webclient/js/vextab/underscore-min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,325 @@
// Generated by CoffeeScript 1.7.1
(function() {
var __slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Vex.Flow.VexTab = (function() {
var L, newError;
VexTab.DEBUG = false;
L = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (Vex.Flow.VexTab.DEBUG) {
return typeof console !== "undefined" && console !== null ? console.log.apply(console, ["(Vex.Flow.VexTab)"].concat(__slice.call(args))) : void 0;
}
};
newError = function(object, msg) {
return new Vex.RERR("ParseError", "" + msg + " in line " + object._l + " column " + object._c);
};
function VexTab(artist) {
this.artist = artist;
this.reset();
}
VexTab.prototype.reset = function() {
this.valid = false;
return this.elements = false;
};
VexTab.prototype.isValid = function() {
return this.valid;
};
VexTab.prototype.getArtist = function() {
return this.artist;
};
VexTab.prototype.parseStaveOptions = function(options) {
var clefs, e, error, notation_option, num_strings, option, params, voices, _i, _len, _ref, _ref1, _ref2;
params = {};
if (options == null) {
return params;
}
notation_option = null;
for (_i = 0, _len = options.length; _i < _len; _i++) {
option = options[_i];
error = function(msg) {
return newError(option, msg);
};
params[option.key] = option.value;
switch (option.key) {
case "notation":
case "tablature":
notation_option = option;
if ((_ref = option.value) !== "true" && _ref !== "false") {
throw error("'" + option.key + "' must be 'true' or 'false'");
}
break;
case "key":
if (!_.has(Vex.Flow.keySignature.keySpecs, option.value)) {
throw error("Invalid key signature '" + option.value + "'");
}
break;
case "clef":
clefs = ["treble", "bass", "tenor", "alto", "percussion", "none"];
if (_ref1 = option.value, __indexOf.call(clefs, _ref1) < 0) {
throw error("'clef' must be one of " + (clefs.join(', ')));
}
break;
case "voice":
voices = ["top", "bottom", "new"];
if (_ref2 = option.value, __indexOf.call(voices, _ref2) < 0) {
throw error("'voice' must be one of " + (voices.join(', ')));
}
break;
case "time":
try {
new Vex.Flow.TimeSignature(option.value);
} catch (_error) {
e = _error;
throw error("Invalid time signature: '" + option.value + "'");
}
break;
case "tuning":
try {
new Vex.Flow.Tuning(option.value);
} catch (_error) {
e = _error;
throw error("Invalid tuning: '" + option.value + "'");
}
break;
case "strings":
num_strings = parseInt(option.value);
if (num_strings < 4 || num_strings > 8) {
throw error("Invalid number of strings: " + num_strings);
}
break;
default:
throw error("Invalid option '" + option.key + "'");
}
}
if (params.notation === "false" && params.tablature === "false") {
throw newError(notation_option, "Both 'notation' and 'tablature' can't be invisible");
}
return params;
};
VexTab.prototype.parseCommand = function(element) {
if (element.command === "bar") {
this.artist.addBar(element.type);
}
if (element.command === "tuplet") {
this.artist.makeTuplets(element.params.tuplet, element.params.notes);
}
if (element.command === "annotations") {
this.artist.addAnnotations(element.params);
}
if (element.command === "rest") {
this.artist.addRest(element.params);
}
if (element.command === "command") {
return this.artist.runCommand(element.params, element._l, element._c);
}
};
VexTab.prototype.parseChord = function(element) {
L("parseChord:", element);
return this.artist.addChord(_.map(element.chord, function(note) {
return _.pick(note, 'time', 'dot', 'fret', 'abc', 'octave', 'string', 'articulation', 'decorator');
}), element.articulation, element.decorator);
};
VexTab.prototype.parseFret = function(note) {
return this.artist.addNote(_.pick(note, 'time', 'dot', 'fret', 'string', 'articulation', 'decorator'));
};
VexTab.prototype.parseABC = function(note) {
return this.artist.addNote(_.pick(note, 'time', 'dot', 'fret', 'abc', 'octave', 'string', 'articulation', 'decorator'));
};
VexTab.prototype.parseStaveElements = function(notes) {
var element, _i, _len, _results;
L("parseStaveElements:", notes);
_results = [];
for (_i = 0, _len = notes.length; _i < _len; _i++) {
element = notes[_i];
if (element.time) {
this.artist.setDuration(element.time, element.dot);
}
if (element.command) {
this.parseCommand(element);
}
if (element.chord) {
this.parseChord(element);
}
if (element.abc) {
_results.push(this.parseABC(element));
} else if (element.fret) {
_results.push(this.parseFret(element));
} else {
_results.push(void 0);
}
}
return _results;
};
VexTab.prototype.parseStaveText = function(text_line) {
var bartext, command, createNote, font, justification, position, smooth, str, text, _i, _len, _results;
if (!_.isEmpty(text_line)) {
this.artist.addTextVoice();
}
position = 0;
justification = "center";
smooth = true;
font = null;
bartext = (function(_this) {
return function() {
return _this.artist.addTextNote("", 0, justification, false, true);
};
})(this);
createNote = (function(_this) {
return function(text) {
var e, ignore_ticks;
ignore_ticks = false;
if (text[0] === "|") {
ignore_ticks = true;
text = text.slice(1);
}
try {
return _this.artist.addTextNote(text, position, justification, smooth, ignore_ticks);
} catch (_error) {
e = _error;
throw newError(str, "Bad text or duration. Did you forget a comma?" + e);
}
};
})(this);
_results = [];
for (_i = 0, _len = text_line.length; _i < _len; _i++) {
str = text_line[_i];
text = str.text.trim();
if (text.match(/\.font=.*/)) {
font = text.slice(6);
_results.push(this.artist.setTextFont(font));
} else if (text[0] === ":") {
_results.push(this.artist.setDuration(text));
} else if (text[0] === ".") {
command = text.slice(1);
switch (command) {
case "center":
case "left":
case "right":
_results.push(justification = command);
break;
case "strict":
_results.push(smooth = false);
break;
case "smooth":
_results.push(smooth = true);
break;
case "bar":
case "|":
_results.push(bartext());
break;
default:
_results.push(position = parseInt(text.slice(1), 10));
}
} else if (text === "|") {
_results.push(bartext());
} else if (text.slice(0, 2) === "++") {
_results.push(this.artist.addTextVoice());
} else {
_results.push(createNote(text));
}
}
return _results;
};
VexTab.prototype.generate = function() {
var e, option, options, stave, _i, _j, _len, _len1, _ref, _ref1, _results;
_ref = this.elements;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
stave = _ref[_i];
switch (stave.element) {
case "stave":
case "tabstave":
this.artist.addStave(stave.element, this.parseStaveOptions(stave.options));
if (stave.notes != null) {
this.parseStaveElements(stave.notes);
}
if (stave.text != null) {
_results.push(this.parseStaveText(stave.text));
} else {
_results.push(void 0);
}
break;
case "voice":
this.artist.addVoice(this.parseStaveOptions(stave.options));
if (stave.notes != null) {
this.parseStaveElements(stave.notes);
}
if (stave.text != null) {
_results.push(this.parseStaveText(stave.text));
} else {
_results.push(void 0);
}
break;
case "options":
options = {};
_ref1 = stave.params;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
option = _ref1[_j];
options[option.key] = option.value;
}
try {
_results.push(this.artist.setOptions(options));
} catch (_error) {
e = _error;
throw newError(stave, e.message);
}
break;
default:
throw newError(stave, "Invalid keyword '" + stave.element + "'");
}
}
return _results;
};
VexTab.prototype.parse = function(code) {
var line, stripped_code;
vextab_parser.parseError = function(message, hash) {
L("VexTab parse error: ", message, hash);
message = "Unexpected text '" + hash.text + "' at line " + hash.loc.first_line + " column " + hash.loc.first_column + ".";
throw new Vex.RERR("ParseError", message);
};
if (code == null) {
throw new Vex.RERR("ParseError", "No code");
}
L("Parsing:\n" + code);
stripped_code = (function() {
var _i, _len, _ref, _results;
_ref = code.split(/\r\n|\r|\n/);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
_results.push(line.trim());
}
return _results;
})();
this.elements = vextab_parser.parse(stripped_code.join("\n"));
if (this.elements) {
this.generate();
this.valid = true;
}
return this.elements;
};
return VexTab;
})();
}).call(this);

File diff suppressed because one or more lines are too long

View file

@ -650,6 +650,10 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
$scope.onInit = function() {
console.log("onInit");
MidiEventHandler.init(eventHandlerService);
MidiEventHandler.reset();
// Does the room ID provided in the URL?
var room_id_or_alias;
if ($routeParams.room_id_or_alias) {
@ -814,6 +818,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
// There are already messages, go to the last message
scrollToBottom(true);
}
MidiEventHandler.setReady();
},
function(error) {
$scope.feedback = "Failed get member list: " + error.data.error;

View file

@ -68,6 +68,9 @@
ng-hide="state.permission_denied"
ng-style="{ 'visibility': state.messages_visibility }"
keep-scroll>
<canvas id="boo" style="width:95%;"></canvas>
<table id="messageTable" infinite-scroll="paginateMore()">
<tr ng-repeat="msg in events.rooms[room_id].messages"
ng-class="(events.rooms[room_id].messages[$index + 1].user_id !== msg.user_id ? 'differentUser' : '') + (msg.user_id === state.user_id ? ' mine' : '')" scroll-item>