using (BinaryReader b = new BinaryReader(File.Open("file.wav", FileMode.Open)))
{
int pos = 0;
int length = (int)b.BaseStream.Length;
while (pos < length)
{
int v = b.Read();
}
}
Write with BinaryWriter
int[] a = new int[] { 1, 4, 6, 7, 11, 55, 777, 23, 266, 44, 82, 93 };
using (BinaryWriter b = new BinaryWriter(File.Open("file.wav", FileMode.Create)))
{
foreach (int i in a)
{
b.Write(i);
}
}
Note: You have to import System.IO namespace before using BinaryWriter and BinaryReader classes.
Sachin Adsul
Member
1 Points
8 Posts
how to Read and Write .wav file using binaryreader and binarywriter
Jul 10, 2012 04:24 AM|LINK
I have to read and write .wav file using binaryreader and binarywriter.
bbcompent1
All-Star
33873 Points
8776 Posts
Moderator
Re: how to Read and Write .wav file using binaryreader and binarywriter
Jul 10, 2012 11:31 AM|LINK
http://forum.unity3d.com/threads/97818-wav-reading-and-writing
Ruchira
All-Star
44372 Points
7194 Posts
MVP
Re: how to Read and Write .wav file using binaryreader and binarywriter
Jul 11, 2012 09:41 AM|LINK
Hello,
Read with BinaryReader
using (BinaryReader b = new BinaryReader(File.Open("file.wav", FileMode.Open))) { int pos = 0; int length = (int)b.BaseStream.Length; while (pos < length) { int v = b.Read(); } }Write with BinaryWriter
int[] a = new int[] { 1, 4, 6, 7, 11, 55, 777, 23, 266, 44, 82, 93 }; using (BinaryWriter b = new BinaryWriter(File.Open("file.wav", FileMode.Create))) { foreach (int i in a) { b.Write(i); } }Note: You have to import System.IO namespace before using BinaryWriter and BinaryReader classes.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.