Exemple #1
0
    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);
    }
Exemple #2
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);
                }
            }
Exemple #3
0
            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);
            }
Exemple #4
0
            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;
            }
Exemple #5
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);
     }
 }
Exemple #6
0
 public static void Toogle(ref SampleFlags aSet, SampleFlags aFlag)
 {
     aSet ^= aFlag;
 }
Exemple #7
0
 public static bool HasFlag(ref SampleFlags aSet, SampleFlags aFlag)
 {
     return((aSet & aFlag) == aFlag);
 }
Exemple #8
0
 public static void UnSet(ref SampleFlags aSet, SampleFlags aFlag)
 {
     aSet &= ~aFlag;
 }
Exemple #9
0
 public static void Set(ref SampleFlags aSet, SampleFlags aFlag)
 {
     aSet |= aFlag;
 }
Exemple #10
0
 private byte[] FlagsToBytes(SampleFlags test)
 {
     return(BitConverter.GetBytes((int)test));
 }