public override byte[] Read_File() { adx_header = new ADX_Header(); // Read the file BinaryReader br = new BinaryReader(File.OpenRead(soundFile)); byte b1 = br.ReadByte(); // 0x80 byte b2 = br.ReadByte(); // 0x00 adx_header.copyright_offset = Helper.Get_ushort(ref br); adx_header.encoding = br.ReadByte(); adx_header.block_size = br.ReadByte(); adx_header.sample_bitdepth = br.ReadByte(); adx_header.channel_count = br.ReadByte(); adx_header.sample_rate = Helper.Get_uint(ref br); adx_header.total_samples = Helper.Get_uint(ref br); adx_header.highpass_frequency = Helper.Get_ushort(ref br); adx_header.version = br.ReadByte(); adx_header.flags = br.ReadByte(); adx_header.unknown = Helper.Get_uint(ref br); switch (adx_header.version) { case 3: adx_header.loop_enabled = Helper.Get_uint(ref br); adx_header.loop_begin_sample_index = Helper.Get_uint(ref br); adx_header.loop_begin_byte_index = Helper.Get_uint(ref br); adx_header.loop_end_sample_index = Helper.Get_uint(ref br); adx_header.loop_end_byte_index = Helper.Get_uint(ref br); break; case 4: br.BaseStream.Position += 0x0C; adx_header.loop_enabled = Helper.Get_uint(ref br); adx_header.loop_begin_sample_index = Helper.Get_uint(ref br); adx_header.loop_begin_byte_index = Helper.Get_uint(ref br); adx_header.loop_end_sample_index = Helper.Get_uint(ref br); adx_header.loop_end_byte_index = Helper.Get_uint(ref br); break; } br.BaseStream.Position = adx_header.copyright_offset - 2; adx_header.copyright = br.ReadChars(6); br.BaseStream.Position = 0; byte[] buffer = br.ReadBytes((int)br.BaseStream.Length); br.Close(); // Save values loop_enabled = Convert.ToBoolean(adx_header.loop_enabled); loop_begin_sample = adx_header.loop_begin_sample_index; loop_end_sample = adx_header.loop_end_sample_index; total_samples = adx_header.total_samples; sample_rate = adx_header.sample_rate; channels = adx_header.channel_count; block_size = adx_header.block_size; sample_bitdepth = adx_header.sample_bitdepth; return(buffer); }
public override byte[] Read_File() { adx_header = new ADX_Header(); // Read the file BinaryReader br = new BinaryReader(File.OpenRead(soundFile)); byte b1 = br.ReadByte(); // 0x80 byte b2 = br.ReadByte(); // 0x00 adx_header.copyright_offset = Helper.Get_ushort(ref br); adx_header.encoding = br.ReadByte(); adx_header.block_size = br.ReadByte(); adx_header.sample_bitdepth = br.ReadByte(); adx_header.channel_count = br.ReadByte(); adx_header.sample_rate = Helper.Get_uint(ref br); adx_header.total_samples = Helper.Get_uint(ref br); adx_header.highpass_frequency = Helper.Get_ushort(ref br); adx_header.version = br.ReadByte(); adx_header.flags = br.ReadByte(); adx_header.unknown = Helper.Get_uint(ref br); switch (adx_header.version) { case 3: adx_header.loop_enabled = Helper.Get_uint(ref br); adx_header.loop_begin_sample_index = Helper.Get_uint(ref br); adx_header.loop_begin_byte_index = Helper.Get_uint(ref br); adx_header.loop_end_sample_index = Helper.Get_uint(ref br); adx_header.loop_end_byte_index = Helper.Get_uint(ref br); break; case 4: br.BaseStream.Position += 0x0C; adx_header.loop_enabled = Helper.Get_uint(ref br); adx_header.loop_begin_sample_index = Helper.Get_uint(ref br); adx_header.loop_begin_byte_index = Helper.Get_uint(ref br); adx_header.loop_end_sample_index = Helper.Get_uint(ref br); adx_header.loop_end_byte_index = Helper.Get_uint(ref br); break; } br.BaseStream.Position = adx_header.copyright_offset - 2; adx_header.copyright = br.ReadChars(6); br.BaseStream.Position = 0; byte[] buffer = br.ReadBytes((int)br.BaseStream.Length); br.Close(); // Save values loop_enabled = Convert.ToBoolean(adx_header.loop_enabled); loop_begin_sample = adx_header.loop_begin_sample_index; loop_end_sample = adx_header.loop_end_sample_index; total_samples = adx_header.total_samples; sample_rate = adx_header.sample_rate; channels = adx_header.channel_count; block_size = adx_header.block_size; sample_bitdepth = adx_header.sample_bitdepth; return buffer; }