找回密码
 注册用户
查看: 168|回复: 0

[RMMV] 【搬运】OGG-Opus循环标识识别修复

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-6-2 22:43:14 | 显示全部楼层 |阅读模式



RPG Maker MV 无法识别 OGG 中新的 OPUS 音频循环标准,本脚本重写 WebAudio._readOgg 方法来查找循环标记

脚本:
  1. //=================================================================
  2. //Fugahagens Opus MV Loop Tag Compatibility.
  3. //FugsOpusMV.js version .01
  4. //For use with RPG Maker MV 1.63
  5. //=================================================================
  6. //"use strict"
  7. /*:
  8. * @target MV 1.63
  9. * @plugindesc v.01 Opus MV Loop Tag Compatibility
  10. * 更多脚本请访问 www.hknmtt.com
  11. * @author Fugahagen
  12. *
  13. * ========================================================================
  14. * Full Description
  15. * ========================================================================
  16. * RPG Maker MV 无法识别 OGG 中新的 OPUS 音频循环标准,本脚本重写 WebAudio._readOgg
  17. * 方法来查找循环标记。
  18. *
  19. * *Note: Opus 在编辑器中仍无法预览,但至少他可以在游戏中循环了!
  20. * =======================================================
  21. * Credits
  22. * =======================================================
  23. * 如果喜欢的话,可以在游戏中署名 "Fugahagen".
  24. *
  25. * =======================================================
  26. * License: The MIT License
  27. * =======================================================
  28. * Copyright 2024 Fugahagen
  29. * This plugin is released under MIT license.
  30. * http://opensource.org/licenses/mit-license.php
  31. * If you violate the license agreement your mother will
  32. * die in her sleep tonight! All protections nulled!
  33. */
  34. (function () {
  35.   WebAudio.prototype._readOgg = function (array) {
  36.     var index = 0;
  37.     while (index < array.length) {
  38.       if (this._readFourCharacters(array, index) === "OggS") {
  39.         index += 26;
  40.         // console.log(index, "index");
  41.         var vorbisHeaderFound = false;
  42.         var numSegments = array[index++];
  43.         // console.log("numSegments-------", numSegments);
  44.         var segments = [];
  45.         for (var i = 0; i < numSegments; i++) {
  46.           segments.push(array[index++]);
  47.         }
  48.         // console.log("segments", segments);
  49.         for (i = 0; i < numSegments; i++) {
  50.           if (this._readFourCharacters(array, index + 1) === "vorb") {
  51.             var headerType = array[index];
  52.             // console.log("---headerType vorbis", headerType);
  53.             if (headerType === 1) {
  54.               this._sampleRate = this._readLittleEndian(array, index + 12);
  55.               // console.log("_sampleRate vorbis", this._sampleRate);
  56.             }
  57.             if (headerType === 3) {
  58.               this._readMetaData(array, index, segments[i]);
  59.               // console.log("headerType 3 vorbis", headerType);
  60.             }
  61.             vorbisHeaderFound = true;
  62.             // console.log("vorbisHeaderFound segments", segments, headerType);
  63.           } else if (this._readFourCharacters(array, index) === "Opus") {
  64.             var headerType = array[index];
  65.             // console.log("---headerType opus", headerType, "index", index);
  66.             if (headerType === 79) {
  67.               if (this._sampleRate === 0) {
  68.                 this._sampleRate = this._readLittleEndian(array, index + 12);
  69.               }
  70.               // console.log("index in if", index);
  71.               // console.log("_sampleRate opus", this._sampleRate);
  72.               // console.log("segments[i]", segments[i]);
  73.               this._readMetaData(array, index, segments[i]);
  74.               // console.log("headerType = 79", headerType, "index:", index);
  75.             }
  76.             vorbisHeaderFound = true;
  77.           }
  78.           index += segments[i];
  79.         }
  80.         if (!vorbisHeaderFound) {
  81.           break;
  82.         }
  83.       } else {
  84.         break;
  85.       }
  86.     }
  87.   };

  88.   // WebAudio.prototype._readMetaData = function (array, index, size) {
  89.   //   for (var i = index; i < index + size - 10; i++) {
  90.   //     if (this._readFourCharacters(array, i) === "LOOP") {
  91.   //       console.log("FOUND LOOP in index", i);
  92.   //       var text = "";
  93.   //       while (array[i] > 0) {
  94.   //         text += String.fromCharCode(array[i++]);
  95.   //       }
  96.   //       if (text.match(/LOOPSTART=([0-9]+)/)) {
  97.   //         this._loopStart = parseInt(RegExp.$1);
  98.   //         console.log("text=", text);
  99.   //       }
  100.   //       if (text.match(/LOOPLENGTH=([0-9]+)/)) {
  101.   //         this._loopLength = parseInt(RegExp.$1);
  102.   //         console.log("text=", text);
  103.   //       }
  104.   //       if (text == "LOOPSTART" || text == "LOOPLENGTH") {
  105.   //         var text2 = "";
  106.   //         i += 16;
  107.   //         while (array[i] > 0) {
  108.   //           text2 += String.fromCharCode(array[i++]);
  109.   //           console.log("text2=", text2);
  110.   //         }
  111.   //         if (text == "LOOPSTART") {
  112.   //           this._loopStart = parseInt(text2);
  113.   //           console.log("text2=", text2);
  114.   //         } else {
  115.   //           this._loopLength = parseInt(text2);
  116.   //           console.log("text2=", text2);
  117.   //         }
  118.   //       }
  119.   //     }
  120.   //   }
  121.   // };
  122. })();
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2024-10-23 13:32 , Processed in 0.091409 second(s), 19 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表