diff --git a/js/ResourcePack.js b/js/ResourcePack.js index e772f6a..fdfd47c 100644 --- a/js/ResourcePack.js +++ b/js/ResourcePack.js @@ -181,6 +181,16 @@ Respack.prototype.parseImage = function(file) { Respack.prototype.parseXML = function() { var that = this; + if (this._infoFile) { + this._infoFile.getText(function(text) { + text = text.replace(/&/g, '&'); + text = text.replace(/&/g, '&'); + that.parseInfoFile(text); + that._infoFile = null; + that.parseXML(); + }); + return; + } if (this.songs.length > 0) { if (this._songFile) { this._songFile.getText(function(text) { @@ -209,16 +219,6 @@ Respack.prototype.parseXML = function() { }); return; } - if (this._infoFile) { - this._infoFile.getText(function(text) { - text = text.replace(/&/g, '&'); - text = text.replace(/&/g, '&'); - that.parseInfoFile(text); - that._infoFile = null; - that.parseXML(); - }); - return; - } // Finally done! this.file = null; @@ -287,6 +287,11 @@ Respack.prototype.parseSongFile = function(text) { song.buildupRhythm = el.getTag("buildupRhythm"); song.source = el.getTag("source"); + // Because PackShit breaks everything + console.log(this.name); + if(this.name == "PackShit") { + song.forceTrim = true; + } newSongs.push(song); debug(" [I] " + song.name, ": '" + song.title + "' added to songs"); } else { diff --git a/js/SoundManager.js b/js/SoundManager.js index f4171df..e86bf5a 100644 --- a/js/SoundManager.js +++ b/js/SoundManager.js @@ -19,7 +19,8 @@ * THE SOFTWARE. */ -var LAME_DELAY_START = 2258; +// Flash value + MAGIC WEB VALUE +var LAME_DELAY_START = 2258 + 1534; var LAME_DELAY_END = 1000; function SoundManager(core) { @@ -196,9 +197,9 @@ SoundManager.prototype.getAudioCallback = function(song, isBuild) { return; } if(isBuild) { - that.tmpBuild = that.trimMP3(buffer); + that.tmpBuild = that.trimMP3(buffer, song.forceTrim); } else { - that.tmpBuffer = that.trimMP3(buffer); + that.tmpBuffer = that.trimMP3(buffer, song.forceTrim); } that.onSongLoad(song); }; @@ -225,19 +226,26 @@ SoundManager.prototype.onSongLoad = function(song) { } // because MP3 is bad, we nuke silence -SoundManager.prototype.trimMP3 = function(buffer) { - /*var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - if(!isFirefox) { - // Webkit is better than Gecko, clearly +SoundManager.prototype.trimMP3 = function(buffer, forceTrim) { + // Firefox has to trim always, Chrome only on PackShit + var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + // forceTrim is because PackShit breaks everything + if(!(isFirefox || forceTrim)) { return buffer; - }*/ - var ret = this.context.createBuffer(buffer.numberOfChannels, - buffer.length - LAME_DELAY_START - LAME_DELAY_END, buffer.sampleRate); + } + var start = LAME_DELAY_START; + var newLength = buffer.length - LAME_DELAY_START - LAME_DELAY_END; + if(forceTrim && !isFirefox) { + // yes, really + newLength -= 1200; + start += 1200; + } + var ret = this.context.createBuffer(buffer.numberOfChannels, newLength, buffer.sampleRate); for(var i=0; i