Class WavUtils
Wav utils.
Inherited Members
Namespace: Acoustics.Tools.Wav
Assembly: Acoustics.Tools.dll
Syntax
public static class WavUtils
Fields
| Improve this Doc View SourceBitsPerByte
Bites per byte.
Declaration
public static readonly short BitsPerByte
Field Value
Type | Description |
---|---|
Int16 |
MaxBitsPerSample
Maximum bits per sample.
Declaration
public static readonly short MaxBitsPerSample
Field Value
Type | Description |
---|---|
Int16 |
Methods
| Improve this Doc View SourceReadFrame(Stream, Int16, Int16)
Read a single frame.
Declaration
public static short[] ReadFrame(this Stream wavSource, short numberOfChannels, short bitsPerSample)
Parameters
Type | Name | Description |
---|---|---|
Stream | wavSource | The wav source. |
Int16 | numberOfChannels | The number Of Channels. |
Int16 | bitsPerSample | The bits Per Sample. |
Returns
Type | Description |
---|---|
Int16[] | One sample per channel. |
ReadSamples(Stream, WavAudioInfo)
Read first channel samples as doubles. Set the SampleStream position before using this method.
Declaration
public static double[] ReadSamples(this Stream wavSource, WavAudioInfo wavInfo)
Parameters
Type | Name | Description |
---|---|---|
Stream | wavSource | The wav source. |
Wav |
wavInfo | The wav info. |
Returns
Type | Description |
---|---|
Double[] | Samples of first channel. |
Skip(BinaryReader, Int32)
Skip count
bytes.
Declaration
public static void Skip(this BinaryReader reader, int count)
Parameters
Type | Name | Description |
---|---|---|
Binary |
reader | The reader. |
Int32 | count | The count. |
Skip(Stream, Int32)
Skip count
bytes.
Declaration
public static void Skip(this Stream reader, int count)
Parameters
| Improve this Doc View SourceSplitChannels(BinaryReader, Int16, Int16, Int32)
Splits the channels of a binary sequence.
Declaration
public static short[][] SplitChannels(BinaryReader binaryReader, short numberOfChannels, short bitsPerSample, int numberOfFrames)
Parameters
Type | Name | Description |
---|---|---|
Binary |
binaryReader | The binary reader which contains the binary sequence. |
Int16 | numberOfChannels | The number of channels. |
Int16 | bitsPerSample | The bits per sample. |
Int32 | numberOfFrames | The number of frames. |
Returns
Type | Description |
---|---|
Int16[][] | The samples arranged by channel and frame. |
SplitChannels(Stream, WavAudioInfo, Nullable<TimeSpan>)
Get samples per channel. The first channel (mono if it is the only channel) is usually the left.
Declaration
public static double[][] SplitChannels(this Stream wavSource, WavAudioInfo wavInfo, TimeSpan? duration)
Parameters
Type | Name | Description |
---|---|---|
Stream | wavSource | The wav Source. |
Wav |
wavInfo | The wav Info. |
Nullable<Time |
duration | The duration. |
Returns
Type | Description |
---|---|
Double[][] | Samples divided into channels. |
Exceptions
Type | Condition |
---|---|
Not |
Bits per sample other than 8 and 16. |
StreamCopy(Stream, Stream)
Copy one stream to another.
Declaration
public static void StreamCopy(this Stream source, Stream target)
Parameters
Examples
using (FileStream iFile = new FileStream(...))
using (FileStream oFile = new FileStream(...))
using (DeflateStream oZip = new DeflateStream(outFile, CompressionMode.Compress))
StreamCopy(iFile, oZip);
Depending on what you are actually trying to do, you'd chain the streams differently. This also uses relatively little memory, because only the data being operated upon is in memory.