【搬运】OGG-Opus循环标识识别修复
RPG Maker MV 无法识别 OGG 中新的 OPUS 音频循环标准,本脚本重写 WebAudio._readOgg 方法来查找循环标记
脚本:
//=================================================================
//Fugahagens Opus MV Loop Tag Compatibility.
//FugsOpusMV.js version .01
//For use with RPG Maker MV 1.63
//=================================================================
//"use strict"
/*:
* @target MV 1.63
* @plugindesc v.01 Opus MV Loop Tag Compatibility
* 更多脚本请访问 www.hknmtt.com
* @author Fugahagen
*
* ========================================================================
* Full Description
* ========================================================================
* RPG Maker MV 无法识别 OGG 中新的 OPUS 音频循环标准,本脚本重写 WebAudio._readOgg
* 方法来查找循环标记。
*
* *Note: Opus 在编辑器中仍无法预览,但至少他可以在游戏中循环了!
* =======================================================
* Credits
* =======================================================
* 如果喜欢的话,可以在游戏中署名 "Fugahagen".
*
* =======================================================
* License: The MIT License
* =======================================================
* Copyright 2024 Fugahagen
* This plugin is released under MIT license.
* http://opensource.org/licenses/mit-license.php
* If you violate the license agreement your mother will
* die in her sleep tonight! All protections nulled!
*/
(function () {
WebAudio.prototype._readOgg = function (array) {
var index = 0;
while (index < array.length) {
if (this._readFourCharacters(array, index) === "OggS") {
index += 26;
// console.log(index, "index");
var vorbisHeaderFound = false;
var numSegments = array;
// console.log("numSegments-------", numSegments);
var segments = [];
for (var i = 0; i < numSegments; i++) {
segments.push(array);
}
// console.log("segments", segments);
for (i = 0; i < numSegments; i++) {
if (this._readFourCharacters(array, index + 1) === "vorb") {
var headerType = array;
// console.log("---headerType vorbis", headerType);
if (headerType === 1) {
this._sampleRate = this._readLittleEndian(array, index + 12);
// console.log("_sampleRate vorbis", this._sampleRate);
}
if (headerType === 3) {
this._readMetaData(array, index, segments);
// console.log("headerType 3 vorbis", headerType);
}
vorbisHeaderFound = true;
// console.log("vorbisHeaderFound segments", segments, headerType);
} else if (this._readFourCharacters(array, index) === "Opus") {
var headerType = array;
// console.log("---headerType opus", headerType, "index", index);
if (headerType === 79) {
if (this._sampleRate === 0) {
this._sampleRate = this._readLittleEndian(array, index + 12);
}
// console.log("index in if", index);
// console.log("_sampleRate opus", this._sampleRate);
// console.log("segments", segments);
this._readMetaData(array, index, segments);
// console.log("headerType = 79", headerType, "index:", index);
}
vorbisHeaderFound = true;
}
index += segments;
}
if (!vorbisHeaderFound) {
break;
}
} else {
break;
}
}
};
// WebAudio.prototype._readMetaData = function (array, index, size) {
// for (var i = index; i < index + size - 10; i++) {
// if (this._readFourCharacters(array, i) === "LOOP") {
// console.log("FOUND LOOP in index", i);
// var text = "";
// while (array > 0) {
// text += String.fromCharCode(array);
// }
// if (text.match(/LOOPSTART=(+)/)) {
// this._loopStart = parseInt(RegExp.$1);
// console.log("text=", text);
// }
// if (text.match(/LOOPLENGTH=(+)/)) {
// this._loopLength = parseInt(RegExp.$1);
// console.log("text=", text);
// }
// if (text == "LOOPSTART" || text == "LOOPLENGTH") {
// var text2 = "";
// i += 16;
// while (array > 0) {
// text2 += String.fromCharCode(array);
// console.log("text2=", text2);
// }
// if (text == "LOOPSTART") {
// this._loopStart = parseInt(text2);
// console.log("text2=", text2);
// } else {
// this._loopLength = parseInt(text2);
// console.log("text2=", text2);
// }
// }
// }
// }
// };
})();
页:
[1]