Class WavStreamReader
Wave audio Stream wrapper. This class is NOT thread safe.
Inherited Members
Namespace: Acoustics.Tools.Wav
Assembly: Acoustics.Tools.dll
Syntax
public class WavStreamReader : IWavReader, IDisposable
Remarks
useful links: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ http://www.sonicspot.com/guide/wavefiles.html http://codeidol.com/java/swing/Audio/Build-an-Audio-Waveform-Display/
AudioTools WavReader just reads the first channel.
Constructors
| Improve this Doc View SourceWavStreamReader(Byte[])
Initializes a new instance of the Wav
Declaration
public WavStreamReader(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes | Byte array containing audio. |
Exceptions
Type | Condition |
---|---|
Argument |
Argument is null. |
WavStreamReader(FileInfo)
Initializes a new instance of the Wav
Declaration
public WavStreamReader(FileInfo file)
Parameters
Type | Name | Description |
---|---|---|
File |
file | File containing audio. |
Exceptions
Type | Condition |
---|---|
Argument |
|
Argument |
file. |
WavStreamReader(Stream)
Initializes a new instance of the Wav
Declaration
public WavStreamReader(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Stream contaiing audio. |
Exceptions
Type | Condition |
---|---|
Argument |
|
WavStreamReader(String)
Initializes a new instance of the Wav
Declaration
public WavStreamReader(string filePath)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | File containing audio. |
Properties
| Improve this Doc View SourceAudioInfo
Gets Info about the audio stream.
Declaration
public WavAudioInfo AudioInfo { get; }
Property Value
Type | Description |
---|---|
Wav |
Chunks
Gets chunks in wav audio stream.
Declaration
public IEnumerable<WavChunk> Chunks { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Wav |
GetDataChunk
Gets GetDataChunk.
Declaration
public WavChunk GetDataChunk { get; }
Property Value
Type | Description |
---|---|
Wav |
Samples
Gets all samples.
Declaration
public double[] Samples { get; }
Property Value
Type | Description |
---|---|
Double[] |
SampleStream
Gets Samples. Make no assumptions about the position of the stream. Use this.Chunks to position the stream at the start of the chunk you want.
Declaration
public Stream SampleStream { get; }
Property Value
Type | Description |
---|---|
Stream |
Methods
| Improve this Doc View SourceDispose()
Dispose Wave audio stream by disposing underlying Sample stream.
Declaration
public void Dispose()
GetSample(Int64)
Get a single sample. Do not use this method in a loop.
Declaration
public double GetSample(long sampleIndex)
Parameters
Type | Name | Description |
---|---|---|
Int64 | sampleIndex | The sample index (zero-based). |
Returns
Type | Description |
---|---|
Double | Read sample. |
GetSamples(Int64, Int64)
Get samples from the wav stream. Start from firstSampleIndex
(zero indexed),
and read numberOfSamplesToRead
.
Declaration
public double[] GetSamples(long firstSampleIndex, long numberOfSamplesToRead)
Parameters
Type | Name | Description |
---|---|---|
Int64 | firstSampleIndex | The first Sample Index. |
Int64 | numberOfSamplesToRead | The number Of Samples To Read. |
Returns
Type | Description |
---|---|
Double[] |
|
GetSamples(Stream, WavChunk, WavAudioInfo, Int64, Int64)
Get samples from the wav stream. Start from firstSampleIndex
(zero indexed),
and read numberOfSamplesToRead
.
Declaration
public static double[] GetSamples(Stream wavStream, WavChunk dataChunk, WavAudioInfo wavInfo, long firstSampleIndex, long numberOfSamplesToRead)
Parameters
Type | Name | Description |
---|---|---|
Stream | wavStream | The wav Stream. |
Wav |
dataChunk | The data Chunk. |
Wav |
wavInfo | The wav Info. |
Int64 | firstSampleIndex | The first Sample Index. |
Int64 | numberOfSamplesToRead | The number Of Samples To Read. |
Returns
Type | Description |
---|---|
Double[] |
|