public static IEnumerable <SampleFlags> Decompose(SampleFlags aSet) { var i = SampleFlags.First; do { if ((aSet & i) == i) { yield return(i); } i = (SampleFlags)((int)i << 1); }while (i < SampleFlags.All && i > 0); }
public void ReadFile(ArraySegment <byte> data, bool NewVersion) { var offs = data.Offset; Name = IDX.ReadCString(data, 16); Offset = BitConverter.ToInt32(data.Array, offs + 16); Size = BitConverter.ToInt32(data.Array, offs + 20); SampleRate = BitConverter.ToInt32(data.Array, offs + 24); Flags = (SampleFlags)BitConverter.ToInt32(data.Array, offs + 28); if (NewVersion) { ChunkSize = BitConverter.ToInt32(data.Array, offs + 32); } }
internal bool ADPCM2PCM() { if (!Flags.HasFlag(SampleFlags.ADPCM)) { return(false); } Flags &= ~SampleFlags.ADPCM; Flags |= SampleFlags.PCM; Data = WAV.ADPCM2PCM(Data, ChannelCount, ChunkSize); Size = Data.Length; Offset = 0; ChunkSize = 0; return(true); }
internal bool ADPCM2PCM() { if (!Flags.HasFlag(SampleFlags.ADPCM)) { return false; } Flags &= ~SampleFlags.ADPCM; Flags |= SampleFlags.PCM; Data = WAV.ADPCM2PCM(Data, ChannelCount, ChunkSize); Size = Data.Length; Offset = 0; ChunkSize = 0; return true; }
public void ReadFile(ArraySegment<byte> data, bool NewVersion) { var offs = data.Offset; Name = IDX.ReadCString(data, 16); Offset = BitConverter.ToInt32(data.Array, offs + 16); Size = BitConverter.ToInt32(data.Array, offs + 20); SampleRate = BitConverter.ToInt32(data.Array, offs + 24); Flags = (SampleFlags)BitConverter.ToInt32(data.Array, offs + 28); if (NewVersion) { ChunkSize = BitConverter.ToInt32(data.Array, offs + 32); } }
public static void Toogle(ref SampleFlags aSet, SampleFlags aFlag) { aSet ^= aFlag; }
public static bool HasFlag(ref SampleFlags aSet, SampleFlags aFlag) { return((aSet & aFlag) == aFlag); }
public static void UnSet(ref SampleFlags aSet, SampleFlags aFlag) { aSet &= ~aFlag; }
public static void Set(ref SampleFlags aSet, SampleFlags aFlag) { aSet |= aFlag; }
private byte[] FlagsToBytes(SampleFlags test) { return(BitConverter.GetBytes((int)test)); }