diff --git a/Qwilight/Compiler/BMSCompiler.cs b/Qwilight/Compiler/BMSCompiler.cs index 4feabca..f7ef794 100644 --- a/Qwilight/Compiler/BMSCompiler.cs +++ b/Qwilight/Compiler/BMSCompiler.cs @@ -804,7 +804,7 @@ var audioFilePath = Utility.GetFilePath(Path.Combine(NoteFile.EntryItem.EntryPath, data), Utility.FileFormatFlag.Audio); if (!string.IsNullOrEmpty(audioFilePath)) { - bmsIDAudioItemMap[property.Substring(3, 2)] = AudioSystem.Instance.Load(audioFilePath, defaultComputer, 1F, data); + bmsIDAudioItemMap[property.Substring(3, 2)] = AudioSystem.Instance.Load(audioFilePath, defaultComputer, 1F); } } catch @@ -881,7 +881,8 @@ bmsIDAudioItemMap.TryGetValue(bmsID, out var audioItem); var audioNote = new AudioNote { - AudioItem = audioItem + AudioItem = audioItem, + BMSID = bmsID }; bmsIDHandledItemMap.TryGetValue(bmsID, out mediaItem); var hasContents = defaultComputer.LoadedMedia; diff --git a/Qwilight/Compiler/BaseCompiler.cs b/Qwilight/Compiler/BaseCompiler.cs index 9afa41c..10fa76c 100644 --- a/Qwilight/Compiler/BaseCompiler.cs +++ b/Qwilight/Compiler/BaseCompiler.cs @@ -577,7 +577,7 @@ var audioNoteSaltComputer = new Random(defaultComputer.ModeComponentValue.Salt); foreach (var (wait, audioNotes) in defaultComputer.WaitAudioNoteMap.ToArray()) { - defaultComputer.WaitAudioNoteMap[wait] = audioNotes.Select(audioNote => new AudioNote() + defaultComputer.WaitAudioNoteMap[wait] = audioNotes.Select(audioNote => new AudioNote { AudioItem = audioNote.AudioItem, Length = audioNote.Length, diff --git a/Qwilight/Compute/DefaultCompute.cs b/Qwilight/Compute/DefaultCompute.cs index 07e6e7c..65b6c2f 100644 --- a/Qwilight/Compute/DefaultCompute.cs +++ b/Qwilight/Compute/DefaultCompute.cs @@ -1672,7 +1672,7 @@ var audioItemValue = audioItem.Value; if (LoopingCounter <= waitModified + (audioLength ?? audioItemValue.Length)) { - var bmsID = audioItemValue.BMSID; + var bmsID = audioNote.BMSID; StopLastEqualAudioItem(bmsID); lock (LoadedCSX) { @@ -1682,7 +1682,8 @@ { AudioItem = audioItemValue, AudioLevyingPosition = (uint)(LoopingCounter - waitModified + audioNote.AudioLevyingPosition), - Length = audioLength != null ? (uint?)(waitModified + audioLength - LoopingCounter) : null + Length = audioLength != null ? (uint?)(waitModified + audioLength - LoopingCounter) : null, + BMSID = bmsID }, AudioSystem.MainAudio, AudioMultiplier, IsCounterWave, this); if (!string.IsNullOrEmpty(bmsID)) { @@ -2703,7 +2704,7 @@ var lastEventPosition = IsInEvents ? _eventPositions.Last() : LoopingCounter; if (lastEventPosition < LoopingCounter + audioItemValue.Length) { - var bmsID = audioItemValue.BMSID; + var bmsID = audioNote.BMSID; StopLastEqualAudioItem(bmsID); lock (LoadedCSX) { @@ -2714,7 +2715,8 @@ AudioItem = audioItem, Length = audioNote.Length, AudioLevyingPosition = (uint)(audioNote.AudioLevyingPosition + lastEventPosition - LoopingCounter), - Salt = audioNote.Salt + Salt = audioNote.Salt, + BMSID = bmsID }, AudioSystem.InputAudio, AudioMultiplier, IsCounterWave, this, 0.0, inputPower); if (!string.IsNullOrEmpty(bmsID)) { @@ -2744,7 +2746,7 @@ var lastEventPosition = IsInEvents ? _eventPositions.Last() : LoopingCounter; if (lastEventPosition < LoopingCounter + (audioNote.Length ?? audioItemValue.Length)) { - var bmsID = audioItemValue.BMSID; + var bmsID = audioNote.BMSID; StopLastEqualAudioItem(bmsID); lock (LoadedCSX) { @@ -2755,7 +2757,8 @@ AudioItem = audioItem, Length = audioNote.Length, AudioLevyingPosition = (uint)(audioNote.AudioLevyingPosition + lastEventPosition - LoopingCounter), - Salt = audioNote.Salt + Salt = audioNote.Salt, + BMSID = bmsID }, AudioSystem.InputAudio, AudioMultiplier, IsCounterWave, this, 0.0, inputPower); note.AudioChannels.Add(audioChannel); if (!string.IsNullOrEmpty(bmsID)) diff --git a/Qwilight/Note/BaseNote.cs b/Qwilight/Note/BaseNote.cs index 0c5a750..bd9cace 100644 --- a/Qwilight/Note/BaseNote.cs +++ b/Qwilight/Note/BaseNote.cs @@ -17,6 +17,8 @@ public double LogicalY { get; set; } + public string BMSID { get; init; } + public int ID { get; set; } public double Wait { get; set; } diff --git a/Qwilight/System/AudioSystem/AudioItem.cs b/Qwilight/System/AudioSystem/AudioItem.cs index 608236e..5e5bdc8 100644 --- a/Qwilight/System/AudioSystem/AudioItem.cs +++ b/Qwilight/System/AudioSystem/AudioItem.cs @@ -8,8 +8,6 @@ public Sound AudioData { get; set; } - public string BMSID { get; set; } - public float AudioVolume { get; set; } public uint Length { get; set; } diff --git a/Qwilight/System/AudioSystem/AudioNote.cs b/Qwilight/System/AudioSystem/AudioNote.cs index ec8ba46..74ab11a 100644 --- a/Qwilight/System/AudioSystem/AudioNote.cs +++ b/Qwilight/System/AudioSystem/AudioNote.cs @@ -9,5 +9,12 @@ public uint AudioLevyingPosition { get; init; } public int Salt { get; init; } + + public string BMSID { get; init; } + + public AudioNote() + { + + } } } diff --git a/Qwilight/System/AudioSystem/AudioSystem.cs b/Qwilight/System/AudioSystem/AudioSystem.cs index dc87f85..4393dfe 100644 --- a/Qwilight/System/AudioSystem/AudioSystem.cs +++ b/Qwilight/System/AudioSystem/AudioSystem.cs @@ -197,7 +197,7 @@ { if (File.Exists(filePath)) { - DefaultAudioItemMap[$"{nameof(AudioSystem)}://{filePath}"] = Load(filePath, null, 1F, null, true); + DefaultAudioItemMap[$"{nameof(AudioSystem)}://{filePath}"] = Load(filePath, null, 1F, true); } } catch @@ -935,13 +935,13 @@ } } - public AudioItem Load(string audioFilePath, IAudioContainer audioContainer, float audioVolume, string bmsID = null, bool isLooping = false) + public AudioItem Load(string audioFilePath, IAudioContainer audioContainer, float audioVolume, bool isLooping = false) { using var rms = PoolSystem.Instance.GetDataFlow(File.ReadAllBytes(audioFilePath)); - return Load(rms, audioContainer, audioVolume, bmsID, isLooping); + return Load(rms, audioContainer, audioVolume, isLooping); } - public AudioItem Load(Stream s, IAudioContainer audioContainer, float audioVolume, string bmsID = null, bool isLooping = false) + public AudioItem Load(Stream s, IAudioContainer audioContainer, float audioVolume, bool isLooping = false) { var hash = Utility.GetID128(s); var audioItem = new AudioItem(); @@ -969,7 +969,6 @@ { if (_targetSystem.createSound(ms.GetBuffer(), LoadingAudioModes | (isLooping ? MODE.LOOP_NORMAL : MODE.LOOP_OFF), ref audioInfo, out var audioData) == RESULT.OK) { - audioItem.BMSID = bmsID; audioItem.System = _targetSystem.handle; audioItem.AudioData = audioData; audioItem.AudioVolume = audioVolume; diff --git a/Qwilight/System/BaseUI/BaseUI.cs b/Qwilight/System/BaseUI/BaseUI.cs index c8e4b48..2fb4811 100644 --- a/Qwilight/System/BaseUI/BaseUI.cs +++ b/Qwilight/System/BaseUI/BaseUI.cs @@ -731,7 +731,7 @@ try { var audioFilePath = Path.Combine(QwilightComponent.AssetsEntryPath, "System 16", "Audio", "1221.mp3"); - _audioItemMap[audioFilePath] = AudioSystem.Instance.Load(audioFilePath, this, 1F, null, true); + _audioItemMap[audioFilePath] = AudioSystem.Instance.Load(audioFilePath, this, 1F, true); } catch { @@ -745,7 +745,7 @@ try { var audioFilePath = Path.Combine(QwilightComponent.AssetsEntryPath, "System 16", "Audio", "1225.mp3"); - _audioItemMap[audioFilePath] = AudioSystem.Instance.Load(audioFilePath, this, 1F, null, true); + _audioItemMap[audioFilePath] = AudioSystem.Instance.Load(audioFilePath, this, 1F, true); } catch { @@ -1379,7 +1379,7 @@ { using (rms) { - _audioItemMap[justFileName] = AudioSystem.Instance.Load(rms, this, 1F, null, QwilightComponent.GetLoopingAudioComputer().IsMatch(justFileName)); + _audioItemMap[justFileName] = AudioSystem.Instance.Load(rms, this, 1F, QwilightComponent.GetLoopingAudioComputer().IsMatch(justFileName)); } } catch @@ -1394,7 +1394,7 @@ { using (rms) { - _defaultAudioItemMap[$"{nameof(BaseUI)}://{justFileName}"] = AudioSystem.Instance.Load(rms, this, 1F, null, true); + _defaultAudioItemMap[$"{nameof(BaseUI)}://{justFileName}"] = AudioSystem.Instance.Load(rms, this, 1F, true); } } catch @@ -1410,6 +1410,7 @@ using (rms) { var hash = Utility.GetID128(rms); + fileName = fileName.Replace("\"", string.Empty); var hashMediaFilePath = Path.Combine(QwilightComponent.MediaEntryPath, $"{hash}{Path.GetExtension(fileName)}"); if (!File.Exists(hashMediaFilePath)) { @@ -1609,6 +1610,7 @@ var etc = paintProperty.Etc; paintProperty.HandledMediaItems = (GetMultipleMediaFilePathsComputer().IsMatch(etc) ? etc.Substring(etc.IndexOf('[') + 1, etc.LastIndexOf(']') - 1).Split(',').Select(text => text.Trim()) : [etc]).Select(mediaFileName => { + mediaFileName = mediaFileName.Replace("\"", string.Empty); if (handledMediaValues.TryGetValue(mediaFileName, out var handledMediaItem)) { return handledMediaItem; diff --git a/Qwilight/System/UI/UI.cs b/Qwilight/System/UI/UI.cs index 8d7f726..3f2d82f 100644 --- a/Qwilight/System/UI/UI.cs +++ b/Qwilight/System/UI/UI.cs @@ -295,7 +295,7 @@ } if (wasHandled) { - AudioSystem.Instance.Handle(new AudioNote + AudioSystem.Instance.Handle(new() { AudioLevyingPosition = pausableAudioHandler?.GetAudioPosition() ?? 0U, AudioItem = audioItem @@ -1438,7 +1438,7 @@ { using (s) { - audioValues[fileName] = AudioSystem.Instance.Load(s, this, 1F, null, QwilightComponent.GetLoopingAudioComputer().IsMatch(justFileName)); + audioValues[fileName] = AudioSystem.Instance.Load(s, this, 1F, QwilightComponent.GetLoopingAudioComputer().IsMatch(justFileName)); } } catch