|
/* This class has been written by
* Corinna John (Hannover, Germany)
* cj@binary-universe.net
*
* You may do with this code whatever you like,
* except selling it or claiming any rights/ownership.
*
* Please send me a little feedback about what you're
* using this code for and what changes you'd like to
* see in later versions.
*/
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace WaveMixer {
/// <summary>Format header information of a RIFF Wave file.</summary>
[StructLayout(LayoutKind.Sequential)]
public class WaveFormat {
private short wFormatTag;
private short nChannels;
private int nSamplesPerSec;
private int nAvgBytesPerSec;
private short nBlockAlign;
private short wBitsPerSample;
private short cbSize;
/// <summary>wFormatTag header field.</summary>
public short FormatTag
{
get { return wFormatTag; }
set { wFormatTag = value; }
}
/// <summary>nChannels header field.</summary>
public short Channels
{
get { return nChannels; }
set { nChannels = value; }
}
/// <summary>nSamplesPerSec header field.</summary>
public int SamplesPerSec
{
get { return nSamplesPerSec; }
set { nSamplesPerSec = value; }
}
/// <summary>nAvgBytesPerSec header field.</summary>
public int AvgBytesPerSec
{
get { return nAvgBytesPerSec; }
set { nAvgBytesPerSec = value; }
}
/// <summary>nBlockAlign header field.</summary>
public short BlockAlign
{
get{ return nBlockAlign; }
set { nBlockAlign = value; }
}
/// <summary>wBitsPerSample header field.</summary>
public short BitsPerSample
{
get { return wBitsPerSample; }
set { wBitsPerSample = value; }
}
/// <summary>cbSize header field.</summary>
public short Size
{
get { return cbSize; }
set { cbSize = value; }
}
/// <summary>Constructor.</summary>
public WaveFormat()
{
//default constructor
}
/// <summary>Constructor.</summary>
/// <param name="samplesPerSec">Number of samples per second.</param>
/// <param name="bitsPerSample">Number of bits per sample.</param>
/// <param name="channels">Number of channels.</param>
public WaveFormat(int samplesPerSec, short bitsPerSample, short channels)
{
wFormatTag = (short)WaveFormats.Pcm;
nChannels = channels;
nSamplesPerSec = samplesPerSec;
wBitsPerSample = bitsPerSample;
cbSize = 0;
nBlockAlign = (short)(channels * (bitsPerSample / 8));
nAvgBytesPerSec = samplesPerSec * nBlockAlign;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.