49a502e647
- 头几拍会抖动一下,导致对不上拍子
103 lines
2.5 KiB
C#
103 lines
2.5 KiB
C#
using System.IO;
|
|
|
|
namespace OCES.Audio
|
|
{
|
|
/// <summary>
|
|
/// 替换策略类型
|
|
/// </summary>
|
|
public enum KillMode
|
|
{
|
|
Oldest, // 打断最早开始的
|
|
Newest, // 打断最新开始的
|
|
}
|
|
|
|
/// <summary>
|
|
/// 混音分组
|
|
/// </summary>
|
|
public enum MixingType
|
|
{
|
|
Sfx = 0,
|
|
Voice,
|
|
Accented,
|
|
}
|
|
|
|
/// <summary>
|
|
/// 声音容器类型
|
|
/// </summary>
|
|
public enum ContainerType
|
|
{
|
|
Random = 0,
|
|
Sequence,
|
|
Blend,
|
|
}
|
|
|
|
public enum BlendCrossFadeType
|
|
{
|
|
Exponential = 0,
|
|
Linear,
|
|
Logarithmic,
|
|
}
|
|
|
|
public enum AlignMode
|
|
{
|
|
Immediate,
|
|
Beat,
|
|
Bar,
|
|
}
|
|
|
|
public enum ActiveSoundState
|
|
{
|
|
Pending, // 已进入调度,但还没真正播放
|
|
Playing, // 已经开始播放
|
|
Finished,
|
|
}
|
|
|
|
public interface IBinarySerializable
|
|
{
|
|
void DeSerialize(BinaryReader reader);
|
|
void Serialize(BinaryWriter writer);
|
|
}
|
|
|
|
// ─────────────────────────────────────────────
|
|
// 辅助接口,让泛型方法同时处理 MusicPath 和 AmbiencePath
|
|
// ─────────────────────────────────────────────
|
|
|
|
public interface IPathEntry
|
|
{
|
|
uint Id { get; }
|
|
string Path { get; }
|
|
uint ContainerId { get; }
|
|
int Priority { get; }
|
|
}
|
|
|
|
public interface ITransitionConfig
|
|
{
|
|
float FadeOutOffset { get; }
|
|
float FadeOutTime { get; }
|
|
float FadeInOffset { get; }
|
|
float FadeInTime { get; }
|
|
}
|
|
|
|
public partial class MusicTransition : ITransitionConfig { }
|
|
public partial class AmbienceTransition : ITransitionConfig { }
|
|
|
|
|
|
public partial class MusicPath : IPathEntry { }
|
|
public partial class AmbiencePath : IPathEntry { }
|
|
|
|
public partial class MusicContainerConfig
|
|
{
|
|
/// <summary>
|
|
/// 解析拍号字符串(如 "4/4", "3/4"),返回每小节拍数。
|
|
/// </summary>
|
|
public static int GetBeatsPerBar(string timeSig)
|
|
{
|
|
if (string.IsNullOrEmpty(timeSig)) return 4;
|
|
string[] parts = timeSig.Split('/');
|
|
if (parts.Length >= 1 && int.TryParse(parts[0], out int beats))
|
|
return beats;
|
|
return 4;
|
|
}
|
|
}
|
|
}
|