Class WavReader
Wave Reader.
Implements
Inherited Members
Namespace: Acoustics.Tools.Wav
Assembly: Acoustics.Tools.dll
Syntax
public class WavReader : IDisposable
Constructors
| Improve this Doc View SourceWavReader(Byte[])
Initializes a new instance of the WavReader class.
Declaration
public WavReader(byte[] wavData)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | wavData | The wav data. |
WavReader(Double[], Int32, Int32, Int32)
Initializes a new instance of the WavReader class. This method assumes channel samples are interleaved!.
Declaration
public WavReader(double[] rawData, int channels, int bitsPerSample, int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
Double[] | rawData | The raw data with interleaved samples from each channel. |
Int32 | channels | The channels. |
Int32 | bitsPerSample | The bits per sample. |
Int32 | sampleRate | The sample rate. |
WavReader(FileInfo)
Declaration
public WavReader(FileInfo file)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | file |
WavReader(String)
Declaration
public WavReader(string path)
Parameters
Type | Name | Description |
---|---|---|
String | path |
Fields
| Improve this Doc View SourceWavFileExtension
Wav file extension.
Declaration
public const string WavFileExtension = ".wav"
Field Value
Type | Description |
---|---|
String |
Properties
| Improve this Doc View SourceBitsPerSample
Gets or sets BitsPerSample as if were a single channel.
Declaration
public int BitsPerSample { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
BlockAlign
Gets or sets BlockAlign - the number of bytes in each sample for all channels.
Declaration
public int BlockAlign { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
BlockCount
Gets BlockCount - the number of blocks of data (each channel has one sample). Defined in http://www-mmsp.ece.mcgill.ca/documents/audioformats/wave/wave.html.
Declaration
public int BlockCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
BytesPerSecond
Declaration
public uint BytesPerSecond { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Channels
Gets or sets Channels.
Declaration
public int Channels { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Epsilon
Gets the Epsilon (smallest distinguishable value) for this format.
Declaration
public double Epsilon { get; }
Property Value
Type | Description |
---|---|
Double |
ExactDurationSeconds
Gets the ExactDurationSeconds of the data. This calculation should be accurate down to the nanosecond. Note this is a new value and SHOULD NOT be used for any real calculations.
Declaration
public decimal ExactDurationSeconds { get; }
Property Value
Type | Description |
---|---|
Decimal |
Format
Declaration
public WavReader.WaveFormat Format { get; }
Property Value
Type | Description |
---|---|
WavReader.WaveFormat |
Item[Int32, Int32]
Gets or sets values from samples.
Declaration
public double this[int index, int channel] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The sample to operate on. |
Int32 | channel | The channel to operate on. |
Property Value
Type | Description |
---|---|
Double | A sample for the selected index and channel. |
Length
Gets the total number of samples for each channel. An alias for BlockCount.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
SampleRate
Gets or sets SampleRate.
Declaration
public int SampleRate { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Samples
Gets the samples.
Declaration
public double[] Samples { get; }
Property Value
Type | Description |
---|---|
Double[] |
Time
Gets Time - the duration of the data. NOTE: this value has been rounded to the nearest millisecond! See ExactDurationSeconds for a precise value.
Declaration
public TimeSpan Time { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
ValidBitsPerSample
Gets ValidBitsPerSample. Only set when Format is WAVE_FORMAT_EXTENSIBLE. wValidBitsPerSample specifies the precision of the sample in bits.
Declaration
public ushort? ValidBitsPerSample { get; }
Property Value
Type | Description |
---|---|
Nullable<UInt16> |
Methods
| Improve this Doc View SourceCalculateEpsilonForRescaledInteger(Int32)
Calculates the smallest possible representable value for an integer of size bitDepth
hat has been rescaled to the range [-1,1].
Declaration
public static double CalculateEpsilonForRescaledInteger(int bitDepth)
Parameters
Type | Name | Description |
---|---|---|
Int32 | bitDepth | The bit depth of the integer the range was represented in before rescaling. |
Returns
Type | Description |
---|---|
Double | The smallest distinguishable value for data that was stored as an integer before rescaling. |
CalculateMaximumAmplitude()
Calculate maximum amplitude of audio.
Declaration
public virtual double CalculateMaximumAmplitude()
Returns
Type | Description |
---|---|
Double | Maximum Amplitude. |
Dispose()
Dispose this WavReader.
Declaration
public void Dispose()
GetChannel(Int32)
Get the zero-indexed channel data from channel c
.
Declaration
public double[] GetChannel(int c)
Parameters
Type | Name | Description |
---|---|---|
Int32 | c | The zero-indexed channel to get. |
Returns
Type | Description |
---|---|
Double[] | the requested channel. |
SubSample(Int32)
Sub-samples audio. Obsolete - we recommend you resample with ffmpeg/SoX.
Declaration
[Obsolete("Does not remove high frequency artifacts")]
public void SubSample(int interval)
Parameters
Type | Name | Description |
---|---|---|
Int32 | interval | Keeps every |