Esempio n. 1
0
        public FormatChunkFormat GetFormatData()
        {
            while (!CurrentChunkId.Equals("fmt "))
            {
                NextChunk();
            }
            ;
            binReader.BaseStream.Position = CurrentChunkStart + 8;

            FormatChunkFormat data = new FormatChunkFormat
            {
                ChunkId          = CurrentChunkId,
                ChunkSize        = CurrentChunkSize,
                AudioFormat      = binReader.ReadInt16(),
                NumberOfChannels = binReader.ReadInt16(),
                SampleRate       = binReader.ReadInt32(),
                ByteRate         = binReader.ReadInt32(),
                BlockAlign       = binReader.ReadInt16(),
                BitsPerSample    = binReader.ReadInt16()
            };

            Console.WriteLine("========= FORMAT CHUNK =========");
            Console.WriteLine("0: Chunk id: " + new string(data.ChunkId));
            Console.WriteLine($"4: File size: {data.ChunkSize}");
            Console.WriteLine($"6: Audio format: {data.AudioFormat}");
            Console.WriteLine($"8: Channels: {data.NumberOfChannels}");
            Console.WriteLine($"12: Sample rate: {data.SampleRate}");
            Console.WriteLine($"16: Byte rate: {data.ByteRate}");
            Console.WriteLine($"18: Block alignment: {data.BlockAlign}");
            Console.WriteLine($"20: Bits per sample: {data.BitsPerSample}");
            return(data);
        }
Esempio n. 2
0
        public DataChunkFormat GetAudioData()
        {
            CurrentChunkStart = (int)binReader.BaseStream.Position;
            while (!CurrentChunkId.Equals("data"))
            {
                NextChunk();
            }
            ;
            binReader.BaseStream.Position = CurrentChunkStart;
            DataChunkFormat data = new DataChunkFormat
            {
                ChunkID   = CurrentChunkId,
                ChunkSize = CurrentChunkSize,
                AudioData = binReader.ReadBytes(CurrentChunkSize)
            };

            Console.WriteLine("========= DATA CHUNK =========");
            Console.WriteLine("0: Chunk id: " + data.ChunkID);
            Console.WriteLine($"4: Chunk size: {data.ChunkSize}");
            Console.WriteLine($"8: Chunk Data: {data.AudioData}");
            return(data);
        }