Class AiffFileWriter
This class writes audio data to a .aif file on disk
public class AiffFileWriter : Stream, IDisposable, IAsyncDisposable
- Inheritance
-
AiffFileWriter
- Implements
- Inherited Members
Constructors
AiffFileWriter(Stream, WaveFormat)
AiffFileWriter that actually writes to a stream
public AiffFileWriter(Stream outStream, WaveFormat format)
Parameters
outStream
StreamStream to be written to
format
WaveFormatWave format to use
AiffFileWriter(string, WaveFormat)
Creates a new AiffFileWriter
public AiffFileWriter(string filename, WaveFormat format)
Parameters
filename
stringThe filename to write to
format
WaveFormatThe Wave Format of the output data
Properties
CanRead
Returns false: Cannot read from a AiffFileWriter
public override bool CanRead { get; }
Property Value
CanSeek
Returns false: Cannot seek within a AiffFileWriter
public override bool CanSeek { get; }
Property Value
CanWrite
Returns true: Can write to a AiffFileWriter
public override bool CanWrite { get; }
Property Value
Filename
The aiff file name or null if not applicable
public string Filename { get; }
Property Value
Length
Number of bytes of audio in the data chunk
public override long Length { get; }
Property Value
Position
Gets the Position in the AiffFile (i.e. number of bytes written so far)
public override long Position { get; set; }
Property Value
WaveFormat
WaveFormat of this aiff file
public WaveFormat WaveFormat { get; }
Property Value
Methods
CreateAiffFile(string, WaveStream)
Creates an Aiff file by reading all the data from a WaveProvider BEWARE: the WaveProvider MUST return 0 from its Read method when it is finished, or the Aiff File will grow indefinitely.
public static void CreateAiffFile(string filename, WaveStream sourceProvider)
Parameters
filename
stringThe filename to use
sourceProvider
WaveStreamThe source WaveProvider
Dispose(bool)
Actually performs the close,making sure the header contains the correct data
protected override void Dispose(bool disposing)
Parameters
disposing
boolTrue if called from
Dispose
~AiffFileWriter()
Finaliser - should only be called if the user forgot to close this AiffFileWriter
protected ~AiffFileWriter()
Flush()
Ensures data is written to disk
public override void Flush()
Read(byte[], int, int)
Read is not supported for a AiffFileWriter
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
Seek(long, SeekOrigin)
Seek is not supported for a AiffFileWriter
public override long Seek(long offset, SeekOrigin origin)
Parameters
offset
longorigin
SeekOrigin
Returns
SetLength(long)
SetLength is not supported for AiffFileWriter
public override void SetLength(long value)
Parameters
value
long
UpdateHeader(BinaryWriter)
Updates the header with file size information
protected virtual void UpdateHeader(BinaryWriter writer)
Parameters
writer
BinaryWriter
Write(byte[], int, int)
Appends bytes to the AiffFile (assumes they are already in the correct format)
public override void Write(byte[] data, int offset, int count)
Parameters
data
byte[]the buffer containing the wave data
offset
intthe offset from which to start writing
count
intthe number of bytes to write
WriteSample(float)
Writes a single sample to the Aiff file
public void WriteSample(float sample)
Parameters
sample
floatthe sample to write (assumed floating point with 1.0f as max value)
WriteSamples(short[], int, int)
Writes 16 bit samples to the Aiff file
public void WriteSamples(short[] samples, int offset, int count)
Parameters
samples
short[]The buffer containing the 16 bit samples
offset
intThe offset from which to start writing
count
intThe number of 16 bit samples to write
WriteSamples(float[], int, int)
Writes 32 bit floating point samples to the Aiff file They will be converted to the appropriate bit depth depending on the WaveFormat of the AIF file
public void WriteSamples(float[] samples, int offset, int count)