From a6178e991ca0299c5bae56921f43c359aba215c7 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 16 Oct 2025 13:23:40 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B6=88=E7=81=ADEssgee=E4=B8=ADGameBoy/DM?= =?UTF-8?q?G=E7=9A=84=E9=9F=B3=E8=A7=86=E9=A2=91GC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Essgee.Unity/Emulation/Audio/DMGAudio.cs | 19 ++++- .../Essgee.Unity/Emulation/Utilities.cs | 11 ++- .../Emulation/Video/Nintendo/CGBVideo.cs | 2 +- .../Emulation/Video/Nintendo/DMGVideo.cs | 76 ++++++++++++++++--- 4 files changed, 94 insertions(+), 14 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.cs index 5ff4e81d..cba87ca7 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.cs @@ -296,6 +296,8 @@ namespace Essgee.Emulation.Audio sampleCycleCount = frameCycleCount = 0; } + //独立声明,不在函数内部 + private bool[] channelEnableFlags = new bool[4]; public void Step(int clockCyclesInStep) { if (!isSoundHwEnabled) return; @@ -385,10 +387,25 @@ namespace Essgee.Emulation.Audio // new bool[] { !channel1ForceEnable, !channel2ForceEnable, !channel3ForceEnable, !channel4ForceEnable }, // mixedSampleBuffer.ToArray()); + //有GC + //EnqueueSamplesEventArgs eventArgs = EnqueueSamplesEventArgs.Create( + // numChannels, + // channelSampleBuffer, + // new bool[] { !channel1ForceEnable, !channel2ForceEnable, !channel3ForceEnable, !channel4ForceEnable }, + // mixedSampleBuffer, + // mixedSampleBuffer_writePos); + + + // 在函数中使用 + channelEnableFlags[0] = !channel1ForceEnable; + channelEnableFlags[1] = !channel2ForceEnable; + channelEnableFlags[2] = !channel3ForceEnable; + channelEnableFlags[3] = !channel4ForceEnable; + EnqueueSamplesEventArgs eventArgs = EnqueueSamplesEventArgs.Create( numChannels, channelSampleBuffer, - new bool[] { !channel1ForceEnable, !channel2ForceEnable, !channel3ForceEnable, !channel4ForceEnable }, + channelEnableFlags, mixedSampleBuffer, mixedSampleBuffer_writePos); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Utilities.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Utilities.cs index b07a169f..1727d4e8 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Utilities.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Utilities.cs @@ -44,7 +44,16 @@ namespace Essgee.Emulation buffer[address + 3] = 0xFF; } - public static void RGBCGBtoBGRA8888(int color, ref byte[] buffer, int address) + //public static void RGBCGBtoBGRA8888(int color, ref byte[] buffer, int address) + //{ + // /* https://byuu.net/video/color-emulation -- "LCD emulation: Game Boy Color" */ + // byte r = (byte)((color >> 0) & 0x1F), g = (byte)((color >> 5) & 0x1F), b = (byte)((color >> 10) & 0x1F); + // buffer[address + 0] = (byte)(Math.Min(960, (r * 6) + (g * 4) + (b * 22)) >> 2); + // buffer[address + 1] = (byte)(Math.Min(960, (g * 24) + (b * 8)) >> 2); + // buffer[address + 2] = (byte)(Math.Min(960, (r * 26) + (g * 4) + (b * 2)) >> 2); + // buffer[address + 3] = 0xFF; + //} + public static void RGBCGBtoBGRA8888(int color, ref byte* buffer, int address) { /* https://byuu.net/video/color-emulation -- "LCD emulation: Game Boy Color" */ byte r = (byte)((color >> 0) & 0x1F), g = (byte)((color >> 5) & 0x1F), b = (byte)((color >> 10) & 0x1F); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/CGBVideo.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/CGBVideo.cs index 51fda27c..adbcfe87 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/CGBVideo.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/CGBVideo.cs @@ -346,7 +346,7 @@ namespace Essgee.Emulation.Video.Nintendo WriteColorToFramebuffer(c, ((y * displayActiveWidth) + (x % displayActiveWidth)) * 4); } - private void WriteColorToFramebuffer(ushort c, int address) + private unsafe void WriteColorToFramebuffer(ushort c, int address) { RGBCGBtoBGRA8888(c, ref outputFramebuffer, address); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs index f75d4e47..6e307eb2 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs @@ -8,7 +8,7 @@ using static Essgee.Emulation.CPU.SM83; namespace Essgee.Emulation.Video.Nintendo { - public class DMGVideo : IVideo + public unsafe class DMGVideo : IVideo { protected const int displayActiveWidth = 160; protected const int displayActiveHeight = 144; @@ -109,7 +109,48 @@ namespace Essgee.Emulation.Video.Nintendo protected byte[,] screenUsageFlags, screenUsageSpriteXCoords, screenUsageSpriteSlots; protected int cycleCount, cycleDotPause, currentScanline; - protected byte[] outputFramebuffer; + //protected byte[] outputFramebuffer; + + #region //指针化 outputFramebuffer + byte[] outputFramebuffer_src; + protected GCHandle outputFramebuffer_handle; + public byte* outputFramebuffer; + public int outputFramebufferLength; + public bool outputFramebuffer_IsNull => outputFramebuffer == null; + public byte[] outputFramebuffer_set + { + set + { + outputFramebuffer_handle.ReleaseGCHandle(); + outputFramebuffer_src = value; + outputFramebufferLength = value.Length; + outputFramebuffer_src.GetObjectPtr(ref outputFramebuffer_handle, ref outputFramebuffer); + } + } + #endregion + + + #region //指针化 outputFramebufferCopy + byte[] outputFramebufferCopy_src; + GCHandle outputFramebufferCopy_handle; + public byte* outputFramebufferCopy; + public int outputFramebufferCopyLength; + public bool outputFramebufferCopy_IsNull => outputFramebufferCopy == null; + private IntPtr outputFramebufferCopy_IntPtr; + public byte[] outputFramebufferCopy_set + { + set + { + outputFramebufferCopy_handle.ReleaseGCHandle(); + outputFramebufferCopy_src = value; + outputFramebufferCopyLength = value.Length; + outputFramebufferCopy_src.GetObjectPtr(ref outputFramebufferCopy_handle, ref outputFramebufferCopy); + outputFramebufferCopy_IntPtr = outputFramebufferCopy_handle.AddrOfPinnedObject(); + } + } + #endregion + + protected int clockCyclesPerLine; @@ -247,7 +288,10 @@ namespace Essgee.Emulation.Video.Nintendo screenUsageFlags = new byte[displayActiveWidth, displayActiveHeight]; screenUsageSpriteXCoords = new byte[displayActiveWidth, displayActiveHeight]; screenUsageSpriteSlots = new byte[displayActiveWidth, displayActiveHeight]; - outputFramebuffer = new byte[numDisplayPixels * 4]; + //outputFramebuffer = new byte[numDisplayPixels * 4]; + outputFramebuffer_set = new byte[numDisplayPixels * 4]; + + outputFramebufferCopy_set = new byte[numDisplayPixels * 4]; for (var y = 0; y < displayActiveHeight; y++) SetLine(y, 0xFF, 0xFF, 0xFF); @@ -398,7 +442,8 @@ namespace Essgee.Emulation.Video.Nintendo } - GCHandle? lasyRenderHandle; + GCHandle? lastRenderHandle; + protected virtual void EndHBlank() { /* End of scanline reached */ @@ -423,16 +468,25 @@ namespace Essgee.Emulation.Video.Nintendo /* Submit screen for rendering */ - // 固定数组,防止垃圾回收器移动它 - var bitmapcolorRect_handle = GCHandle.Alloc(outputFramebuffer.Clone() as byte[], GCHandleType.Pinned); - // 获取数组的指针 - IntPtr mFrameDataPtr = bitmapcolorRect_handle.AddrOfPinnedObject(); + //// 固定数组,防止垃圾回收器移动它 + //var bitmapcolorRect_handle = GCHandle.Alloc(outputFramebuffer_src.Clone() as byte[], GCHandleType.Pinned); + //// 获取数组的指针 + //IntPtr mFrameDataPtr = bitmapcolorRect_handle.AddrOfPinnedObject(); + + + for (int i = 0; i < outputFramebufferLength; i++) + { + outputFramebufferCopy[i] = outputFramebuffer[i]; + } + IntPtr mFrameDataPtr = outputFramebufferCopy_IntPtr; + var eventArgs = RenderScreenEventArgs.Create(displayActiveWidth, displayActiveHeight, mFrameDataPtr); OnRenderScreen(eventArgs); eventArgs.Release(); - if (lasyRenderHandle != null) - lasyRenderHandle.Value.Free(); - lasyRenderHandle = bitmapcolorRect_handle; + + //if (lastRenderHandle.HasValue) + // lastRenderHandle.Value.Free(); + //lastRenderHandle = bitmapcolorRect_handle; //OnRenderScreen(new RenderScreenEventArgs(displayActiveWidth, displayActiveHeight, outputFramebuffer.Clone() as byte[])); } From 5cb474d41a2049337ca9bee6ab3388bfcd2c7ab3 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 16 Oct 2025 15:00:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=80=E4=BA=9BEssgee=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Emulation/Audio/DMGAudio.Square.cs | 40 +++++++++++++++---- .../Emulation/Machines/GameBoy.cs | 11 +++-- .../Emulation/Video/Nintendo/DMGVideo.cs | 35 +++++++++++----- 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.Square.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.Square.cs index b20478ea..fe255c89 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.Square.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Audio/DMGAudio.Square.cs @@ -6,13 +6,36 @@ namespace Essgee.Emulation.Audio { public class Square : IDMGAudioChannel { - static readonly bool[,] dutyCycleTable = new bool[,] + //static readonly bool[,] dutyCycleTable = new bool[,] + // { + // { false, false, false, false, false, false, false, true, }, // 00000001 12.5% + // { true, false, false, false, false, false, false, true, }, // 10000001 25% + // { true, false, false, false, false, true, true, true, }, // 10000111 50% + // { false, true, true, true, true, true, true, false, } // 01111110 75% + //}; + + // 1. 初始化 - 假设原始数组是 4行 x 8列 + private const int Rows = 4; + private const int Cols = 8; + private readonly bool[] _dutyCycleTable1D = new bool[Rows * Cols] { - { false, false, false, false, false, false, false, true, }, // 00000001 12.5% - { true, false, false, false, false, false, false, true, }, // 10000001 25% - { true, false, false, false, false, true, true, true, }, // 10000111 50% - { false, true, true, true, true, true, true, false, } // 01111110 75% - }; + // 第一行 (索引 0-7) + false, false, false, false, false, false, false, true, + // 第二行 (索引 8-15) + true, false, false, false, false, false, false, true, + // 第三行 (索引 16-23) + true, false, false, false, false, true, true, true, + // 第四行 (索引 24-31) + false, true, true, true, true, true, true, false + }; + + // 2. 访问方法 - 替代原来的 dutyCycleTable[row, col] + public bool GetValue(int row, int col) + { + // 重要的边界检查(在稳定后可通过条件编译移除以极致优化) + // if (row < 0 || row >= Rows || col < 0 || col >= Cols) return false; + return _dutyCycleTable1D[row * Cols + col]; + } // NR10/20 byte sweepPeriodReload, sweepShift; @@ -143,7 +166,10 @@ namespace Essgee.Emulation.Audio dutyCounter %= 8; } - OutputVolume = isDacEnabled && dutyCycleTable[dutyCycle, dutyCounter] ? volume : 0; + //OutputVolume = isDacEnabled && dutyCycleTable[dutyCycle, dutyCounter] ? volume : 0; + + //改为一维数组访问 + OutputVolume = isDacEnabled && _dutyCycleTable1D[dutyCycle * Cols + dutyCounter] ? volume : 0; } private void Trigger() diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/GameBoy.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/GameBoy.cs index cefb4099..d772d4b4 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/GameBoy.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/GameBoy.cs @@ -445,9 +445,11 @@ namespace Essgee.Emulation.Machines public void RunStep() { - var clockCyclesInStep = cpu.Step(); - - for (var s = 0; s < clockCyclesInStep / 4; s++) + int clockCyclesInStep = cpu.Step(); + int loopCount = clockCyclesInStep / 4; // 除法计算移出循环 + // 在循环外检查 cartridge 是否为空,避免每次循环都检查 + bool hasCartridge = cartridge != null; + for (var s = 0; s < loopCount; s++) { HandleTimerOverflow(); UpdateCycleCounter((ushort)(clockCycleCount + 4)); @@ -456,7 +458,8 @@ namespace Essgee.Emulation.Machines video.Step(4); audio.Step(4); - cartridge?.Step(4); + if(hasCartridge) + cartridge.Step(4); currentMasterClockCyclesInFrame += 4; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs index 6e307eb2..bf6b7ee0 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Video/Nintendo/DMGVideo.cs @@ -93,14 +93,26 @@ namespace Essgee.Emulation.Video.Nintendo protected bool statIrqSignal, vBlankReady; protected int[] spritesOnLine; - readonly byte[][] colorValuesBgr = new byte[][] + // readonly byte[][] colorValuesBgr = new byte[][] + // { + // /* B G R */ + // new byte[] { 0xF8, 0xF8, 0xF8 }, /* White */ + // new byte[] { 0x9B, 0x9B, 0x9B }, /* Light gray */ + // new byte[] { 0x3E, 0x3E, 0x3E }, /* Dark gray */ + // new byte[] { 0x1F, 0x1F, 0x1F }, /* Black */ + //}; + + + //取值范例 colorValuesBgr[colorIndex * 3 + channelIndex]; + const byte colorValuesBgr_singleLen = 3; + // 转换后的一维数组 + readonly byte[] colorValuesBgr = new byte[] { - /* B G R */ - new byte[] { 0xF8, 0xF8, 0xF8 }, /* White */ - new byte[] { 0x9B, 0x9B, 0x9B }, /* Light gray */ - new byte[] { 0x3E, 0x3E, 0x3E }, /* Dark gray */ - new byte[] { 0x1F, 0x1F, 0x1F }, /* Black */ - }; + /* White */ 0xF8, 0xF8, 0xF8, + /* Light gray */0x9B, 0x9B, 0x9B, + /* Dark gray */ 0x3E, 0x3E, 0x3E, + /* Black */ 0x1F, 0x1F, 0x1F + }; protected const byte screenUsageEmpty = 0; protected const byte screenUsageBackground = 1 << 0; @@ -719,9 +731,12 @@ namespace Essgee.Emulation.Video.Nintendo protected virtual void WriteColorToFramebuffer(byte c, int address) { - outputFramebuffer[address + 0] = colorValuesBgr[c & 0x03][0]; - outputFramebuffer[address + 1] = colorValuesBgr[c & 0x03][1]; - outputFramebuffer[address + 2] = colorValuesBgr[c & 0x03][2]; + //outputFramebuffer[address + 0] = colorValuesBgr[c & 0x03][0]; + //outputFramebuffer[address + 1] = colorValuesBgr[c & 0x03][1]; + //outputFramebuffer[address + 2] = colorValuesBgr[c & 0x03][2]; + outputFramebuffer[address + 0] = colorValuesBgr[(c & 0x03) * 3 + 0]; + outputFramebuffer[address + 1] = colorValuesBgr[(c & 0x03) * 3 + 1]; + outputFramebuffer[address + 2] = colorValuesBgr[(c & 0x03) * 3 + 2]; outputFramebuffer[address + 3] = 0xFF; } From be8b64f630782b1348e00ab239e7ada73e03e34d Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 16 Oct 2025 15:49:08 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=8C=E5=96=84AudioDSP=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E8=AE=BE=E7=BD=AE=E9=87=87=E6=A0=B7=E7=8E=87=EF=BC=8C?= =?UTF-8?q?Essgee=E8=AE=BE=E7=BD=AE=E6=AD=A3=E7=A1=AE=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UEssgeeInterface/UEGSoundPlayer.cs | 2 +- .../AppMain/Emulator/NesEmulator/AudioProvider.cs | 2 +- .../StoicGooseInterface/SGSoundPlayer.cs | 2 +- .../Assets/Script/AppMain/MonoCom/AudioMgr.cs | 14 ++++++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgeeInterface/UEGSoundPlayer.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgeeInterface/UEGSoundPlayer.cs index 449f660d..8d445e57 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgeeInterface/UEGSoundPlayer.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgeeInterface/UEGSoundPlayer.cs @@ -34,7 +34,7 @@ public class UEGSoundPlayer : MonoBehaviour, AxiAudioPull private void OnEnable() { - App.audioMgr.RegisterStream(nameof(UEssgee), AudioSettings.outputSampleRate, this); + App.audioMgr.RegisterStream(nameof(UEssgee), sampleRate, this); } void OnDisable() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/AudioProvider.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/AudioProvider.cs index e4b95a87..3ce01c65 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/AudioProvider.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/AudioProvider.cs @@ -37,7 +37,7 @@ namespace AxibugEmuOnline.Client private void OnEnable() { - App.audioMgr.RegisterStream(nameof(NesEmulator), AudioSettings.outputSampleRate, this); + App.audioMgr.RegisterStream(nameof(NesEmulator), null, this); } void OnDisable() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/StoicGooseInterface/SGSoundPlayer.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/StoicGooseInterface/SGSoundPlayer.cs index 1445b1e9..c42d2a3e 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/StoicGooseInterface/SGSoundPlayer.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/StoicGooseInterface/SGSoundPlayer.cs @@ -47,7 +47,7 @@ public class SGSoundPlayer : MonoBehaviour, AxiAudioPull private void OnEnable() { - App.audioMgr.RegisterStream(nameof(UStoicGoose), AudioSettings.outputSampleRate, this); + App.audioMgr.RegisterStream(nameof(UStoicGoose), null, this); } void OnDisable() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs index e0da865c..1283c426 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs @@ -78,7 +78,7 @@ namespace AxibugEmuOnline.Client //函数仅处理设备变化的情况,非设备变化不再本函数处理,避免核心采样率变化和本处循环调用 if (deviceWasChanged) { - ResetAudioCfg(); + ResetAudioCfg(AudioSettings.outputSampleRate); //AudioConfiguration config = AudioSettings.GetConfiguration(); //AudioSettings.Reset(config); //TODO 重新播放音效,但是DSP不用,若有UI BGM,后续 这里加重播 @@ -119,20 +119,22 @@ namespace AxibugEmuOnline.Client /// /// 通道标识符 (e.g., "NES", "MAME") /// 该通道的原始采样率 - public void RegisterStream(string channelId, int inputSampleRate, AxiAudioPull audioPullHandle) + public void RegisterStream(string channelId, int? inputSampleRate, AxiAudioPull audioPullHandle) { _audioStreams = null; - _audioStreams = new AudioStreamData(channelId, inputSampleRate, audioPullHandle); - ResetAudioCfg(); + _audioStreams = new AudioStreamData(channelId, + inputSampleRate.HasValue ? inputSampleRate.Value : AudioSettings.outputSampleRate + , audioPullHandle); + ResetAudioCfg(inputSampleRate); } - private void ResetAudioCfg() + private void ResetAudioCfg(int? inputSampleRate) { // 获取当前音频配置 AudioConfiguration config = AudioSettings.GetConfiguration(); // 设置目标音频配置 - config.sampleRate = 48000; // 采样率为 44100Hz + config.sampleRate = inputSampleRate.HasValue ? inputSampleRate.Value : 48000; // 采样率为 44100Hz config.numRealVoices = 32; // 设置最大音频源数量(可选) config.numVirtualVoices = 512; // 设置虚拟音频源数量(可选) config.dspBufferSize = 1024; // 设置 DSP 缓冲区大小(可选) From b10e54c8469fe05b8877fbeef3f1833c807d1132 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 16 Oct 2025 16:55:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=8E=BB=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs index efd87ec2..caa455ce 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs @@ -300,13 +300,13 @@ namespace AxibugEmuOnline.Client.ClientCore { case E_LogType.Debug: case E_LogType.Info: - Debug.Log("[AxiNet]:" + msg); + Debug.Log(msg); break; case E_LogType.Warning: - Debug.LogWarning("[AxiNet]:" + msg); + Debug.LogWarning(msg); break; case E_LogType.Error: - Debug.LogError("[AxiNet]:" + msg); + Debug.LogError(msg); break; } } From 94ba08617fc54bce61b69b34981e72cda9200dc3 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 16 Oct 2025 16:55:55 +0800 Subject: [PATCH 5/5] =?UTF-8?q?Android=E8=AE=BE=E7=BD=AELeft=E5=92=8CRight?= =?UTF-8?q?=E4=B8=A4=E7=A7=8D=E6=A8=AA=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSettings/ProjectSettings.asset | 122 ++++++++++++++++-- 1 file changed, 110 insertions(+), 12 deletions(-) diff --git a/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset b/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset index 05218d76..dd678322 100644 --- a/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset +++ b/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset @@ -12,7 +12,7 @@ PlayerSettings: targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: AlienTechnology + companyName: axibug productName: AxibugEmuOnline.Client defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} @@ -59,8 +59,8 @@ PlayerSettings: iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 iosUseCustomAppBackgroundBehavior: 0 - allowedAutorotateToPortrait: 1 - allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToPortrait: 0 + allowedAutorotateToPortraitUpsideDown: 0 allowedAutorotateToLandscapeRight: 1 allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 @@ -141,7 +141,8 @@ PlayerSettings: visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 bundleVersion: 1.0 - preloadedAssets: [] + preloadedAssets: + - {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -163,7 +164,7 @@ PlayerSettings: androidMaxAspectRatio: 2.1 androidMinAspectRatio: 1 applicationIdentifier: - Android: com.AlienTechnology.AxibugEmuOnline.Client + Android: com.axibug.AxibugEmuOnline.Client Standalone: com.AlienTechnology.AxibugEmuOnline.Client buildNumber: Standalone: 0 @@ -381,6 +382,103 @@ PlayerSettings: m_Height: 36 m_Kind: 1 m_SubKind: + - m_BuildTarget: iPhone + m_Icons: + - m_Textures: [] + m_Width: 180 + m_Height: 180 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 167 + m_Height: 167 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 152 + m_Height: 152 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 76 + m_Height: 76 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 87 + m_Height: 87 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 60 + m_Height: 60 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 20 + m_Height: 20 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 1024 + m_Height: 1024 + m_Kind: 4 + m_SubKind: App Store m_BuildTargetBatching: [] m_BuildTargetShaderSettings: [] m_BuildTargetGraphicsJobs: [] @@ -697,7 +795,7 @@ PlayerSettings: additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: - Android: 0 + Android: 1 Standalone: 1 il2cppCompilerConfiguration: {} il2cppCodeGeneration: {} @@ -732,15 +830,15 @@ PlayerSettings: m_RenderingPath: 1 m_MobileRenderingPath: 1 metroPackageName: AxibugEmuOnline.Client - metroPackageVersion: - metroCertificatePath: + metroPackageVersion: 1.0.0.0 + metroCertificatePath: Assets/WSATestCertificate.pfx metroCertificatePassword: - metroCertificateSubject: - metroCertificateIssuer: - metroCertificateNotAfter: 0000000000000000 + metroCertificateSubject: AlienTechnology + metroCertificateIssuer: AlienTechnology + metroCertificateNotAfter: 80590dc13f48dd01 metroApplicationDescription: AxibugEmuOnline.Client wsaImages: {} - metroTileShortName: + metroTileShortName: AxibugEmuOnline.Client metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0