86 lines
2.1 KiB
C#
86 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using System.Windows.Forms;
|
|
|
|
namespace CrashDumpSender
|
|
{
|
|
public class WaveFileWriter : IDisposable
|
|
{
|
|
BinaryWriter m_writer;
|
|
|
|
public WaveFileWriter(string filename)
|
|
{
|
|
try
|
|
{
|
|
m_writer = new BinaryWriter(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None));
|
|
}
|
|
catch (SystemException ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public void writeRiffChunck(riffChunk mainfile)
|
|
{
|
|
char[] data = mainfile.sGroupID.ToCharArray();
|
|
m_writer.Write(data);
|
|
m_writer.Write(mainfile.dwFileLength);
|
|
|
|
data = mainfile.sRiffType.ToCharArray();
|
|
m_writer.Write(data);
|
|
}
|
|
|
|
|
|
public void writeFormatHeader(fmtChunk format)
|
|
{
|
|
char[] data = format.sChunkID.ToCharArray();
|
|
m_writer.Write(data);
|
|
m_writer.Write(format.dwChunkSize);
|
|
m_writer.Write(format.wFormatTag);
|
|
m_writer.Write(format.wChannels);
|
|
m_writer.Write(format.dwSamplesPerSec);
|
|
m_writer.Write(format.dwAvgBytesPerSec);
|
|
m_writer.Write(format.wBlockAlign);
|
|
m_writer.Write(format.wBitsPerSample);
|
|
m_writer.Write(format.cbSize);
|
|
}
|
|
|
|
public void writeDataHeader(dataChunk datachunk)
|
|
{
|
|
char[] data = datachunk.sChunkID.ToCharArray();
|
|
m_writer.Write(data);
|
|
m_writer.Write(datachunk.dwChunkSize);
|
|
}
|
|
|
|
|
|
|
|
public void write(byte[] data)
|
|
{
|
|
m_writer.Write(data);
|
|
}
|
|
|
|
public void close()
|
|
{
|
|
m_writer.Close();
|
|
m_writer = null;
|
|
}
|
|
|
|
#region IDisposable Members
|
|
|
|
public void Dispose()
|
|
{
|
|
if (m_writer != null)
|
|
m_writer.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|