mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Fix audioClip converting
This commit is contained in:
parent
a0c2a7bdfe
commit
13f37ec260
18
AssetStudio/Math/Clamp.cs
Normal file
18
AssetStudio/Math/Clamp.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public static partial class MathHelper
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static float Clamp(float value, float minValue, float maxValue)
|
||||||
|
{
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
return Math.Max(minValue, Math.Min(value, maxValue));
|
||||||
|
#else
|
||||||
|
return Math.Clamp(value, minValue, maxValue);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2866,11 +2866,7 @@ namespace AssetStudioGUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
FMODtimerLabel.Text = $"{ms / 1000 / 60:00}:{ms / 1000 % 60:00}.{ms / 10 % 100:00} / {FMODlenms / 1000 / 60:00}:{FMODlenms / 1000 % 60:00}.{FMODlenms / 10 % 100:00}";
|
FMODtimerLabel.Text = $"{ms / 1000 / 60:00}:{ms / 1000 % 60:00}.{ms / 10 % 100:00} / {FMODlenms / 1000 / 60:00}:{FMODlenms / 1000 % 60:00}.{FMODlenms / 10 % 100:00}";
|
||||||
#if NETFRAMEWORK
|
FMODprogressBar.Value = (int)AssetStudio.MathHelper.Clamp(ms * 1000f / FMODlenms, 0, 1000);
|
||||||
FMODprogressBar.Value = (int)Math.Max(0, Math.Min(ms * 1000f / FMODlenms, 1000));
|
|
||||||
#else
|
|
||||||
FMODprogressBar.Value = (int)Math.Clamp(ms * 1000f / FMODlenms, 0, 1000);
|
|
||||||
#endif
|
|
||||||
FMODstatusLabel.Text = paused ? "Paused " : playing ? "Playing" : "Stopped";
|
FMODstatusLabel.Text = paused ? "Paused " : playing ? "Playing" : "Stopped";
|
||||||
|
|
||||||
if (system.hasHandle() && channel.hasHandle())
|
if (system.hasHandle() && channel.hasHandle())
|
||||||
|
@ -148,7 +148,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
pcmFloatSample[j] = Marshal.ReadByte(srcPtr, i + j);
|
pcmFloatSample[j] = Marshal.ReadByte(srcPtr, i + j);
|
||||||
}
|
}
|
||||||
var pcm16Sample = (short)(BitConverter.ToSingle(pcmFloatSample, 0) * 32767);
|
var pcm16Sample = (short)MathHelper.Clamp(BitConverter.ToSingle(pcmFloatSample, 0) * short.MaxValue, short.MinValue, short.MaxValue);
|
||||||
destBuffer[offset] = (byte)(pcm16Sample & 255);
|
destBuffer[offset] = (byte)(pcm16Sample & 255);
|
||||||
destBuffer[offset + 1] = (byte)(pcm16Sample >> 8);
|
destBuffer[offset + 1] = (byte)(pcm16Sample >> 8);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user