---
title: "Write Broadcast WAV BEXT metadata in C#"
url: https://recursiveai.org/onemedia/cookbook/write-broadcast-wave-bext-metadata/
description: "Write Broadcast WAV BEXT metadata in C# with OneMedia, then reopen the file to read the description, originator, and sample-based time reference."
version: "1.0.2"
---

# Write Broadcast WAV BEXT metadata in C#

**OneMedia** is a free, open-source media library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMedia) · [GitHub](https://github.com/recursive-ai-oss/onemedia-csharp) · [Docs](https://recursiveai.org/onemedia/docs/) · [Download example (.zip)](https://recursiveai.org/onemedia/cookbook/write-broadcast-wave-bext-metadata/write-broadcast-wave-bext-metadata.zip)

Set `WavMuxOptions.Bext` to store recording details in a Broadcast Wave file.

```shell
dotnet add package RecursiveAI.OneMedia
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMedia;
using RecursiveAI.OneMedia.Riff;

var options = new WavMuxOptions
{
    Bext = new BextChunk
    {
        Description = "Scene 12, take 4",
        Originator = "Studio A",
        TimeReference = 96000
    }
};
const int rate = 48000;
const string path = "take.wav";
using (var mux = WavMuxer.CreateFile(
    path, options, overwrite: true))
{
    mux.AddTrack(new MediaTrack
    {
        Index = 0, Kind = TrackKind.Audio,
        Codec = CodecId.Pcm, Timescale = rate,
        Audio = new AudioTrackInfo(rate, 1, 16)
    });
    // One second of 16-bit mono silence.
    byte[] pcm = new byte[rate * 2];
    var start = new MediaTime(0, rate);
    var duration = new MediaTime(rate, rate);
    var packet = new PacketInfo(
        0, start, start, duration, PacketAttributes.Keyframe,
        ByteRange.None, pcm.Length);
    mux.WritePacket(packet, pcm);
    mux.Finish();
}
Console.WriteLine($"Wrote {path}");
```

Unzip [the example](https://recursiveai.org/onemedia/cookbook/write-broadcast-wave-bext-metadata/write-broadcast-wave-bext-metadata.zip), then `dotnet run`.

The snippet generates one second of 16-bit mono silence at 48 kHz, writes or replaces `take.wav`, and prints `Wrote take.wav`. No input file is needed.

## The full program

The download reopens the WAV after `Finish()` and prints the three fields stored in the `bext` chunk.

```csharp
using RecursiveAI.OneMedia;
using RecursiveAI.OneMedia.Riff;
using RecursiveAI.OneMedia.Tags;

var options = new WavMuxOptions
{
    Bext = new BextChunk
    {
        Description = "Scene 12, take 4",
        Originator = "Studio A",
        TimeReference = 96000
    }
};
const int rate = 48000;
const string path = "take.wav";
using (var mux = WavMuxer.CreateFile(
    path, options, overwrite: true))
{
    mux.AddTrack(new MediaTrack
    {
        Index = 0, Kind = TrackKind.Audio,
        Codec = CodecId.Pcm, Timescale = rate,
        Audio = new AudioTrackInfo(rate, 1, 16)
    });
    // One second of 16-bit mono silence.
    byte[] pcm = new byte[rate * 2];
    var start = new MediaTime(0, rate);
    var duration = new MediaTime(rate, rate);
    var packet = new PacketInfo(
        0, start, start, duration, PacketAttributes.Keyframe,
        ByteRange.None, pcm.Length);
    mux.WritePacket(packet, pcm);
    mux.Finish();
}
Console.WriteLine($"Wrote {path}");

using var file = Media.Open(path);
var tags = file.Native;
Console.WriteLine(
    $"Description: {tags[TagSystems.Bext, "Description"]?.Text}");
Console.WriteLine(
    $"Originator: {tags[TagSystems.Bext, "Originator"]?.Text}");
Console.WriteLine(
    $"Time reference: {tags[TagSystems.Bext, "TimeReference"]?.Number}");
```

```text
Wrote take.wav
Description: Scene 12, take 4
Originator: Studio A
Time reference: 96000
```

If a BEXT text field contains non-ASCII characters or is too long, the muxer throws `ArgumentException` instead of truncating it.

## Variations

**Write the recording date and time.** Add these entries to the `BextChunk` initializer (put a comma after `TimeReference = 96000`):

```csharp
OriginationDate = new DateOnly(2026, 11, 29),
OriginationTime = new TimeOnly(0, 0, 2)
```

They are stored separately from `TimeReference`.

## Related recipes

- [Convert PCM AIFF to WAV](https://recursiveai.org/onemedia/cookbook/convert-aiff-to-wav/)
- [Read audio file tags and duration](https://recursiveai.org/onemedia/cookbook/get-audio-file-tags-duration/)

## The short answer

Pass a `BextChunk` in `WavMuxOptions.Bext`. Add the PCM track, write the samples as packets, and call `Finish()`. To read the stored fields, open the result with `Media.Open` and look them up under `TagSystems.Bext` on `file.Native`.

## What is a Broadcast WAV file?

Broadcast Wave Format (BWF) extends WAVE with a broadcast audio extension chunk, whose four-byte identifier is `bext`. The [EBU specification](https://tech.ebu.ch/publications/tech3285) defines fields such as the recording description, who originated the file, and where its first sample belongs on a timeline. The audio still goes in the `data` chunk. The one-second clip here uses straight mono PCM; the broadcast metadata doesn’t change any of its samples.

`TimeReference` counts sample periods from midnight to the first sample. At 48 kHz, `96000` represents two seconds, even though the clip itself is only one second long. Don’t give the packet a two-second timestamp to set this field; the packet starts at the beginning of the file, and the two-second placement is recorded separately in `bext`.

## How do you put metadata in a WAV file?

Use `Bext` for the fields a Broadcast Wave workflow expects. For example, `Description` can identify a take and `Originator` can name the studio. In OneMedia those fields must be ASCII and fit within 256 and 32 bytes respectively. General-purpose text tags can go in `LIST INFO` instead; they are separate from `bext`, so an application looking for BWF’s `Originator` won’t find it there.

The recipe creates a new WAV from uncompressed PCM, not a new encoding of an MP3. `WavMuxer` needs an output it can seek on to write the final chunk lengths; `CreateFile` gives it one. See the [WAV muxer docs](https://recursiveai.org/onemedia/docs/muxing-wav/) for optional chunks and supported PCM layouts.

## How do you see the metadata of a WAV file?

Read the native tag system rather than looking for a matching label in a list of common tags. `Description` and `Originator` are `.Text`; `TimeReference` is `.Number`. The null-conditional lookups in the full program print nothing after the label if the corresponding field is absent. That’s useful when checking files from multiple recorders: a `.wav` extension alone doesn’t tell you whether the recording carries BEXT metadata.
