Possible fix for infinite audio export
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 654feed001747154f9fc3ac6f1ba11a7
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,33 +1,26 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
using NAudio.Lame;
|
using NAudio.Lame;
|
||||||
using System.IO;
|
|
||||||
using System;
|
|
||||||
using UmaMusumeAudio;
|
using UmaMusumeAudio;
|
||||||
using NAudio.Wave.SampleProviders;
|
using NAudio.Wave.SampleProviders;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
|
|
||||||
public class AudioExporter
|
public class AudioExporter
|
||||||
{
|
{
|
||||||
|
public static IEnumerator ExportAudio(List<UmaWaveStream> a, string path, int index = -1) {
|
||||||
public static void ExportAudio(List<UmaWaveStream> a, string path, int index = -1) {
|
|
||||||
|
|
||||||
var l = new List<ISampleProvider>();
|
var l = new List<ISampleProvider>();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
foreach (var z in a)
|
foreach (var z in a)
|
||||||
{
|
{
|
||||||
var blah = z.ToSampleProvider();
|
l.Add(GetSampleFixedLength(z));
|
||||||
l.Add(blah);
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
var blah = a[index].ToSampleProvider();
|
l.Add(GetSampleFixedLength(a[index]));
|
||||||
l.Add(blah);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var wf = a[0].WaveFormat;
|
var wf = a[0].WaveFormat;
|
||||||
|
|
||||||
var mixer = new MixingSampleProvider(l);
|
var mixer = new MixingSampleProvider(l);
|
||||||
@@ -41,11 +34,26 @@ public class AudioExporter
|
|||||||
|
|
||||||
// Loop to read from the source IWaveProvider and write to the MP3 writer
|
// Loop to read from the source IWaveProvider and write to the MP3 writer
|
||||||
// The Read method returns 0 when there's no more data
|
// The Read method returns 0 when there's no more data
|
||||||
|
int safeguard = 0;
|
||||||
while ((bytesRead = sourceProvider.Read(buffer, 0, buffer.Length)) > 0)
|
while ((bytesRead = sourceProvider.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
{
|
{
|
||||||
writer.Write(buffer, 0, bytesRead);
|
writer.Write(buffer, 0, bytesRead);
|
||||||
|
if(++safeguard % 100 == 0)
|
||||||
|
{
|
||||||
|
if(safeguard % 500 == 0)
|
||||||
|
{
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Possible loop detected! Close UmaViewer if this message continues appearing", UIMessageType.Warning);
|
||||||
|
}
|
||||||
|
yield return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Export complete", UIMessageType.Default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ISampleProvider GetSampleFixedLength(UmaWaveStream sample)
|
||||||
|
{
|
||||||
|
var blah = sample.ToSampleProvider().Take(sample.TotalTime);
|
||||||
|
return blah;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class UISettingsSound : MonoBehaviour
|
|||||||
var path = StandaloneFileBrowser.SaveFilePanel("Save Music MP3 File", Config.Instance.MainPath, $"{TitleText.text}", "mp3");
|
var path = StandaloneFileBrowser.SaveFilePanel("Save Music MP3 File", Config.Instance.MainPath, $"{TitleText.text}", "mp3");
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
AudioExporter.ExportAudio(lists, path, Builder.CurrentLiveSoundAWBIndex);
|
StartCoroutine(AudioExporter.ExportAudio(lists, path, Builder.CurrentLiveSoundAWBIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ PlayerSettings:
|
|||||||
loadStoreDebugModeEnabled: 0
|
loadStoreDebugModeEnabled: 0
|
||||||
visionOSBundleVersion: 1.0
|
visionOSBundleVersion: 1.0
|
||||||
tvOSBundleVersion: 1.0
|
tvOSBundleVersion: 1.0
|
||||||
bundleVersion: 2.1.28
|
bundleVersion: 2.1.29
|
||||||
preloadedAssets: []
|
preloadedAssets: []
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user