2012-09-14 06:19:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
// This file is part of the ANX.Framework and originally taken from
|
|
|
|
|
// the AC.AL OpenAL library, released under the MIT License.
|
|
|
|
|
// For details see: http://acal.codeplex.com/license
|
|
|
|
|
|
|
|
|
|
namespace WaveUtils
|
|
|
|
|
{
|
|
|
|
|
public class WaveInfo
|
|
|
|
|
{
|
|
|
|
|
public List<KeyValuePair<string, byte[]>> UnloadedChunks { get; internal set; }
|
|
|
|
|
public WaveFormat WaveFormat { get; internal set; }
|
|
|
|
|
public byte[] Data { get; internal set; }
|
|
|
|
|
public ALFormat ALFormat { get; internal set; }
|
|
|
|
|
public int SampleRate { get; internal set; }
|
|
|
|
|
public short BitsPerSample { get; internal set; }
|
|
|
|
|
public short BlockAlign { get; internal set; }
|
|
|
|
|
public int Channels { get; internal set; }
|
|
|
|
|
public short ExtSamplesPerBlock { get; internal set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// NOTE: This only works with standard PCM data!
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TimeSpan CalculateDuration()
|
|
|
|
|
{
|
2012-10-04 07:07:18 +00:00
|
|
|
|
float sizeMulBlockAlign = Data.Length / (Channels * 2f);
|
|
|
|
|
return TimeSpan.FromMilliseconds(sizeMulBlockAlign * 1000f / SampleRate);
|
2012-09-14 06:19:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WaveInfo()
|
|
|
|
|
{
|
|
|
|
|
UnloadedChunks = new List<KeyValuePair<string, byte[]>>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|