Class WAVSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
WAV sink block for writing uncompressed audio data to WAV (Waveform Audio File Format) files.
public class WAVSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The WAV sink block creates standard WAV files containing uncompressed PCM audio data. WAV is the de facto standard for high-quality audio storage on Windows systems and is widely supported across all platforms. It provides perfect audio fidelity at the cost of larger file sizes compared to compressed formats.
Key Features:
- Uncompressed PCM audio for perfect quality
- Support for various bit depths (8, 16, 24, 32-bit)
- Multiple sample rates (8kHz to 192kHz and beyond)
- Mono, stereo, and multi-channel support
- Standard RIFF/WAV file structure
- Metadata support through INFO chunks
- No quality loss or compression artifacts
Typical Use Cases:
- Professional audio recording and production
- Audio archiving with maximum quality
- Intermediate format for audio processing workflows
- Voice recording for transcription or analysis
- Scientific audio data capture
- Audio mastering and post-production
Technical Specifications:
- Container: RIFF (Resource Interchange File Format)
- Audio format: Linear PCM (uncompressed)
- Bit depths: 8, 16, 24, or 32-bit integer; 32-bit float
- Channels: 1 (mono), 2 (stereo), or more for surround
- Maximum file size: 4GB (due to 32-bit RIFF header)
- Byte order: Little-endian
Limitations: Standard WAV files are limited to 4GB due to the 32-bit file size field in the RIFF header. For larger files, consider using RF64/WAV64 format or splitting into multiple files. The lack of compression means significantly larger file sizes compared to formats like MP3 or AAC.
Constructors
WAVSinkBlock(string)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.WAVSinkBlock class with the specified filename.
public WAVSinkBlock(string filename)Parameters
filenamestring-
The path where the WAV file will be written. The directory must exist. Use the .wav extension for proper file association. The file will be created or overwritten when the pipeline starts.
Properties
Filename
Gets or sets the output filename for the WAV file.
public string Filename { get; set; }Property Value
Input
Gets the audio input pad for this sink.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all available input pads for this sink.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output pad for this sink block.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads for this sink block.
public override MediaBlockPad[] Outputs { get; }Property Value
Type
Gets the media block type identifier for the WAV sink.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the WAV sink pipeline components.
public override bool Build()Returns
- bool
-
trueif the sink was successfully built and the audio input pad was configured;falseif initialization failed or the file couldn't be opened for writing.
Remarks
This method creates the underlying GStreamer WAV encoder and file writer elements. It configures a single audio input pad that accepts PCM audio data in various formats (different sample rates, bit depths, and channel configurations).
CleanUp()
Cleans up resources and finalizes the WAV file.
public void CleanUp()Remarks
This method ensures the WAV file is properly finalized with correct headers, including the accurate file size and data chunk size. It then disposes of the underlying GStreamer elements.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer wrapper element for advanced pipeline integration.
public BaseElement GetCore()Returns
- BaseElement
-
The VisioForge.Core.GStreamer.Base.BaseElement wrapper providing access to the underlying GStreamer WAV encoder element.
GetElement()
Gets the native GStreamer element for direct GStreamer API access.
public Element GetElement()Returns
- Element
-
The underlying Gst.Element representing the WAV encoder, typically 'wavenc' paired with 'filesink' in GStreamer.
GetFilenameOrURL()
Gets the output filename where the WAV file will be written.
public string GetFilenameOrURL()Returns
- string
-
The file path for the WAV output file.
IsAvailable()
Determines whether this media block is available. Correct NuGet SDK redist should be included into your project.
public static bool IsAvailable()Returns
- bool
-
trueif this media block is available; otherwise,false.
SetFilenameOrURL(string)
Sets the output filename for the WAV file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The file path where the WAV file should be written. The directory must exist. Use the .wav extension.
Remarks
This method only updates the filename property. The actual file location cannot be changed once the pipeline is running and writing has begun.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this media block.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The VisioForge.Core.MediaBlocks.MediaBlocksPipeline that owns this sink block, providing access to the pipeline context and logging facilities.
Remarks
This method is called internally by the pipeline during initialization and should not be called directly by user code.