A correctness release, with Native AOT as the theme. NAudio's remaining [StructLayout] interop types — WAVEHDR, ACMSTREAMHEADER and WaveFormat
itself — were passed to native code by value, which CoreCLR pins in place but
the AOT marshaller copies into a per-call temporary. Anything the driver or
codec wrote back was silently discarded, so WaveIn/WaveOut, ACM conversion
(and with it Mp3FileReader and AudioFileReader) and every WASAPI, Media
Foundation and DMO format negotiation were broken in an AOT-published app while
building and running cleanly. Those paths now marshal by hand into stable
unmanaged blocks, and NAudio.WinMM joins the AOT-compatible package set.
The two breaking changes below both fall out of that work. Also fixed are two
3.0.0 regressions — Mp3FileReaderBase seeking on files with a Xing/Info
header, and WdlResamplingSampleProvider losing samples when its source
under-feeds — and a pair of infinite loops in the WAV parser on corrupt files.
Breaking:WaveFormat and its subclasses no longer carry [StructLayout], so Marshal.SizeOf and Marshal.PtrToStructure on them now throw ArgumentException instead of silently returning wrong data under Native AOT (Marshal.SizeOf<WaveFormatExtensible>() returned 22 rather than 40, and a decoded format kept its constructor defaults). NAudio itself stopped marshalling these types in 3.1.0; use ToWaveFormatExBytes, MarshalToPtr or MarshalFromPtr to cross a native boundary (#1432)
Breaking:AudioClient.IsFormatSupported and WasapiPlayer.IsFormatSupported now return the closest-match format as out WaveFormat rather than out WaveFormatExtensible. WASAPI documents this format as either a WAVEFORMATEX or a WAVEFORMATEXTENSIBLE, and the old signature could only represent the latter — a plain format was previously decoded as a WaveFormatExtensible whose base fields were valid but whose extensible fields were meaningless. Callers needing the extensible fields should pattern-match (#1425)
Fixed WaveIn/WaveOut failing under Native AOT with WaveHeaderUnprepared ("The wave header was not prepared"). The WAVEHDR was a [StructLayout] class passed to winmm by value, which CoreCLR pins in place but NativeAOT copies into a per-call temporary, so the driver's WHDR_PREPARED/WHDR_DONE/dwBytesRecorded writes were discarded. It is now a struct in a stable unmanaged block (#1425)
Fixed ACM conversion failing under Native AOT — WaveFormatConversionStream, AcmStream and so Mp3FileReader and AudioFileReader. ACMSTREAMHEADER was a [StructLayout] class passed to msacm32 by value, and the codec keeps private state in the header's reserved fields between acmStreamPrepareHeader, acmStreamConvert and acmStreamUnprepareHeader; the AOT marshaller's per-call copy round-trips only the declared fields, so that state was lost and conversion failed. It is now a struct in a stable unmanaged block, as WAVEHDR already is (#1425)
Fixed WaveFormat.MarshalToPtr and WaveFormat.MarshalFromPtr corrupting any WaveFormat subclass under Native AOT — the AOT marshaller drops the inherited WAVEFORMATEX fields of a class hierarchy, so a WaveFormatExtensible was written with its SubFormat GUID over the sample rate. Every remaining site that sized or wrote a WaveFormat with Marshal.SizeOf/StructureToPtr was converted too: WASAPI (AudioClient), Media Foundation (MFInitMediaTypeFromWaveFormatEx, reachable from MediaFoundationResampler/MediaFoundationEncoder), DMO (DmoMediaType.SetWaveFormat, MediaObject) and ACM (AcmStream, AcmDriver) (#1425)
WaveFormat.MarshalToPtr now always allocates at least the 18 + cbSize bytes it advertises. A WaveFormat subclass that declares extraSize but doesn't write it in Serialize previously produced a block shorter than its own cbSize, which a native consumer would read past (#1425)
Added WaveFormat.ToWaveFormatExBytes(), which renders a WaveFormat as a native WAVEFORMATEX byte array. MarshalToPtr is now a thin wrapper over it, for callers who need an unmanaged block rather than a buffer they already own (#1425)
Added a Serialize override to Mp3WaveFormat, which previously advertised cbSize = 12 but wrote none of its 12 MPEGLAYER3WAVEFORMAT extra bytes (#1425)
WaveFormatExtraData now sizes its buffer from cbSize instead of holding a fixed 100-byte array, so a fmt chunk declaring more than 100 bytes of extra data keeps it rather than having all of it discarded (#482). The fixed size existed only because [MarshalAs(ByValArray, SizeConst = 100)] needed a compile-time length. ExtraData is now exactly ExtraSize bytes long rather than always 100 (#1432)
NAudio.WinMM is now marked IsAotCompatible, and the AOT smoke test covers the winmm WAVEHDR/WAVEFORMATEX paths (#1425)
Fixed Mp3FileReaderBase seeking silently restarting playback from the beginning of the file on MP3s with a Xing/Info header — the lazy frame index was gated on IsLengthExact, which such a header sets without any frame having been scanned. Also fixed seeks landing on the wrong frame when the target fell exactly on a frame boundary, and Xing/Info header frames being indexed as audio (shifting every seek in those files ~26 ms early). A 3.0.0 regression (#1419)
Fixed WdlResamplingSampleProvider losing samples, and eventually returning 0 permanently, when asked for more output than the source could supply — a 3.0.0 regression that broke the common pattern of reading generously from a BufferedWaveProvider-backed capture chain. WdlResampler.ResampleOut also no longer drifts in input-driven (feed) mode when handed fewer samples than ResamplePrepare requested (#1412)
Fixed two infinite loops in the WAV parser triggered by corrupt files declaring a negative chunk size. An RF64 ds64 chunk with a negative dataChunkLength, or a LIST/adtl sub-chunk with a negative size, made the chunk walk advance by zero bytes per iteration and spin at 100% CPU without throwing. Negative and oversized sizes are now rejected where they are read, and an undersized ds64 chunk throws FormatException rather than ArgumentOutOfRangeException (#1428)
Fixed the NAudioConsoleTest WASAPI exclusive-mode quick scan reporting no supported formats at all on devices that support plenty — it built its probe formats with an empty WAVEFORMATEXTENSIBLE channel mask, which drivers such as Realtek reject outright. It now probes with the canonical layout for the channel count, the same mask the library's own format adaptation uses (#1431)
A patch release. The headline fix is packaging: the NAudio and NAudio.Extras
meta-packages now ship a plain net9.0-windows leg, so WinForms and WPF projects
targeting netX.0-windows get the full Windows stack again.
Breaking:AudioFileReader now throws NotSupportedException instead of InvalidOperationException when the cross-platform build is asked for a format it cannot read, and the messages simply state that rather than suggesting an NAudio.Wasapi install that could never have helped (#1407)
Fixed the NAudio and NAudio.Extras meta-packages resolving their portable net9.0 asset on projects targeting a plain netX.0-windows TFM (the WinForms/WPF template default), which silently dropped the entire Windows stack — no WaveOut, WASAPI, Media Foundation, ASIO, DMO or WinForms types, and AudioFileReader throwing "MP3 file reading requires the NAudio.Wasapi package". Both packages now also ship a plain net9.0-windows leg (#1407)
Projects on a plain netX.0-windows TFM may now see CA1416 warnings when calling WASAPI process-loopback capture. The warning is correct — those callers do need an OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041) guard — and was previously hidden because the only Windows asset available already implied that floor (#1407)
Sample and tool apps now roll forward onto newer .NET runtimes, so running them no longer requires the .NET 9 runtime to be installed (#1408)
Fixed AiffFileReader reporting too long a Length and throwing IndexOutOfRangeException when the SSND chunk declares a non-zero offset (#1405)
Fixed AiffFileReader.Read throwing IndexOutOfRangeException when the source stream returns fewer bytes than requested (#1405)
NAudio 3 is a major release. The single NAudio assembly is now split into
focused, independently usable packages; the minimum target framework moves to net9.0; the core is cross-platform and Native-AOT compatible; and several
large new subsystems — a cross-platform effects suite, a software sampler, VST 3
hosting, and ALSA and libsndfile backends — join the library.
Upgrading from NAudio 2?Migrating from NAudio 2 to NAudio 3
walks through every breaking change with before/after code. Most apps need only
re-target to net9.0, rename WaveOutEvent to WaveOut, and adjust custom
providers to the new Span<T>Read signature.
Packages and platform
Minimum target framework is now net9.0 — legacy .NET Framework and .NET Standard 2.0 support is dropped
NAudio is now a set of focused packages: NAudio.Core, NAudio.Midi, NAudio.WinMM, NAudio.Wasapi, NAudio.Asio, NAudio.Dmo, NAudio.WinForms, plus the new NAudio.Effects (shipped in NAudio.Core), NAudio.Sampler, NAudio.Vst3, NAudio.Alsa and NAudio.SoundFile. The NAudio meta-package still pulls the Windows stack together, so existing consumers see no change. See Docs/Architecture/NAudio3AssemblyLayoutPlan.md
NAudio.Core, NAudio.Midi, NAudio.Wasapi, NAudio.Dmo, NAudio.Sampler, NAudio.SoundFile and NAudio.Alsa are Native-AOT compatible (IsAotCompatible=true), enforced in CI by NAudioAotSmokeTest
NAudio.Wasapi targets plain net9.0 (Windows-only at runtime via [SupportedOSPlatform("windows")]), so cross-platform apps can reference it and build on Linux/macOS without EnableWindowsTargeting. The WinRT MIDI backend moved to NAudio.Midi, which now dual-targets net9.0;net9.0-windows10.0.19041.0 (#1384)
The NAudio.Uap package is removed — use WasapiPlayerBuilder / WasapiRecorderBuilder
Packages ship with SourceLink, .snupkg symbol packages and an embedded SPDX SBOM
New capabilities
Each new subsystem has its own tutorial or README; only the headline is listed here.
Audio effects — a cross-platform NAudio.Effects framework: IAudioEffect / EffectSampleProvider / EffectChain with click-free bypass, dry/wet mix and an optional parameter model, plus a broad effect set (EQ and filtering, dynamics, saturation/lo-fi, delay and modulation, reverb including FFT convolution, pitch shifting, and voice-comms AGC/noise suppression). See Docs/AudioEffects.md
Modern WASAPI — high-level WasapiPlayer / WasapiRecorder, built via WasapiPlayerBuilder / WasapiRecorderBuilder: IAudioClient3 low latency, MMCSS thread priority, IAsyncDisposable, zero-copy buffers, per-process loopback capture, automatic stream routing that follows the default endpoint (#942), acoustic-echo-cancellation reference control (#1223), communications mode, raw mode (#476), and resample-free bit-depth/channel adaptation in exclusive and low-latency modes. See Docs/WasapiPlayer.md and Docs/WasapiRecorder.md
Modern ASIO — a new AsioDevice replacing AsioOut: explicit playback/recording/duplex modes, non-contiguous channels, per-channel Span<float> callbacks, driver-reset recovery and per-buffer timing. AsioOut is preserved as a facade. See Docs/AsioMigration.md
Cross-platform audio files — new NAudio.SoundFile package: read and write WAV/AIFF/FLAC/Ogg-Vorbis/Opus/MP3 via a system libsndfile on Windows, Linux and macOS (the first cross-platform FLAC/Vorbis/Opus encoder in NAudio). See Docs/CrossPlatformAudioFilesWithSoundFile.md (#1289)
VST 3 hosting — new NAudio.Vst3 package (Windows-only): discover, load and host VST 3 effects and instruments, with parameters, state and .vstpreset presets, native editor windows, program lists/units, latency compensation, and live/offline MIDI-file playback through the shared MIDI pipeline. See the NAudio.Vst3 README and Docs/Architecture/Vst3Hosting.md. VST is a registered trademark of Steinberg Media Technologies GmbH
Software sampler — new NAudio.Sampler package: polyphonic, cross-platform playback of SoundFont (.sf2) and SFZ instruments and single-sample instruments, rendered as an ISampleProvider (SF2 modulator engine, DAHDSR envelopes, LFOs, modulated filters, reverb/chorus sends, voice stealing, choke groups). See Docs/Sampler.md
Event-based device notifications — MMDeviceEnumerator.CreateNotificationClient() returns an MMDeviceNotificationClient exposing DeviceStateChanged, DeviceAdded, DeviceRemoved, DefaultDeviceChanged and PropertyValueChanged as ordinary events, so callers no longer implement a COM interface or manage CCW lifetime (#1395)
MIDI — NAudio.Midi's portable leg is now cross-platform; new WinRT WinRTMidiIn / WinRTMidiOut and backend-agnostic IMidiInput / IMidiOutput; and a new IMidiInstrument seam (MidiFileSequence / SequencedMidiPlayer / OfflineMidiRenderer / LiveMidiInstrument) giving an end-to-end MIDI-file → audio pipeline that drives the sampler or a hosted VST 3 instrument. MidiFile also reads RIFF-RMID (.rmi) files (#1236) and MidiFile.Export gains a Stream overload, thanks to @MaKiPL (#499)
Sequencing — a portable NAudio.Sequencing namespace in NAudio.Core (tempo and time-signature maps, transport, EventTimeline, swing, and a sample-accurate per-buffer dispatcher) underpinning MIDI-file playback and the sampler. See Docs/Architecture/Sequencing.md
Live capture mixing — new NAudio.Extras helpers CaptureMixerInput and RealtimeCaptureMixer capture and live-mix several sources with different sample rates and channel counts (e.g. microphone + system loopback) into one wall-clock-paced stream. See Docs/MixMicrophoneAndSystemAudio.md (#761)
Reading audio from streams — AudioFileReader and CachedSound gain Stream constructors, detecting WAV/AIFF from the contents and delegating anything else to Media Foundation, so embedded or in-memory audio plays without a temp file (#927, #963). StreamMediaFoundationReader also gains optional contentType / originName hints and Ogg container sniffing (#952)
WAV chunk model — WaveFileReader.Chunks with an IWaveChunkInterpreter<T> extension point and built-in interpreters for cue lists, BWF bext (BroadcastExtension, now read and write, with v2 loudness) and LIST/INFO (InfoMetadata); WaveFileWriter gains AddCue, WriteCueList, WriteBroadcastExtension, arbitrary AddChunk and RF64 promotion via WaveFileWriterOptions (#1013)
Latency reporting — new IWaveLatency interface in NAudio.Core exposing AverageLatency / CurrentLatency for A/V sync and drift detection, implemented across the playback and capture classes (#601)
Sample providers and DSP — new ChannelMixerSampleProvider with ready-made ChannelMixMatrix routings, thanks to @antiduh (#982); a new FftProcessor; Span<T> overloads across the codec/DSP surface; reusable building blocks (EnvelopeFollower, DelayLine, Lfo, Oversampler, LinkwitzRileyCrossover, PartitionedConvolver, …); plus improvements to SmbPitchShiftingSampleProvider (#922), AdsrSampleProvider (#671) and FadeInOutSampleProvider (#1136)
WaveFormatExtensible — new constructors for SubFormat, valid-bits-per-sample and channel mask, readable ValidBitsPerSample / ChannelMask, and a [Flags] Speakers enum for building channel masks (#1325)
WASAPI sessions and devices — AudioSessionControl.SetDuckingPreference(bool) (#760); WasapiPlayer / WasapiRecorder expose DeviceId and DeviceFriendlyName for the active endpoint (#681)
Breaking changes
The full upgrade walkthrough — every breaking change with before/after code — is
in Migrating from NAudio 2 to NAudio 3. The
highest-impact changes:
Minimum target framework is now net9.0 (legacy .NET Framework / .NET Standard 2.0 dropped)
IWaveProvider.Read / ISampleProvider.Read now take a single Span<byte> / Span<float> (was buffer/offset/count) — callers migrate via source.Read(buffer.AsSpan(offset, count)); implementations override the span method
WaveOutEvent is renamed to WaveOut and WaveInEvent to WaveIn (the old names remain as [Obsolete] subclasses). WaveOut / WaveIn now default to event-driven callbacks; the window-based variants are WaveOutWindow / WaveInWindow in NAudio.WinForms, and WaveCallbackInfo / WaveCallbackStrategy are removed
WaveOut.DesiredLatency is replaced by BufferMilliseconds, which sizes each individual buffer rather than the total across all of them. WaveIn's default record format changes from 8 kHz mono to 44.1 kHz stereo
WasapiOut, WasapiCapture and WasapiLoopbackCapture are [Obsolete] in favour of WasapiPlayer / WasapiRecorder (the legacy types still ship and work); WasapiOut's embedded exclusive-mode resampler was removed, though it now adapts bit depth and channels, so only a sample-rate mismatch requires upstream resampling
The low-level IMMNotificationClient interface and MMDeviceEnumerator.RegisterEndpointNotificationCallback / UnregisterEndpointNotificationCallback are now internal — use CreateNotificationClient() and its events. The raw Core Audio and Media Foundation COM interfaces are likewise internal, and PropertyStoreProperty.Value is now object rather than PropVariant
Some types moved package or namespace as part of the split — classic Windows MIDI I/O and winmm types to NAudio.WinMM; the DMO/DirectSound types into the new NAudio.Dmo package; plus smaller moves (AudioVolumeLevel, CaptureState, DmoMp3FrameDecompressor). Meta-package consumers are unaffected
Removed seven members that were already [Obsolete] throughout NAudio 2, each with a direct replacement on the same class: WaveFileWriter.WriteData (both overloads → Write / WriteSamples), WaveFileReader.TryReadFloat (→ ReadNextSampleFrame, which doesn't drop channels on stereo), AcmStream.Convert(int) (→ the overload returning sourceBytesConverted), WaveFormatConversionStream.SourceToDest / DestToSource (unreliable estimates with no replacement — use Position / Length), and AsioAudioAvailableEventArgs.GetAsInterleavedSamples() (→ the overload taking a reusable array, avoiding an allocation per ASIO callback). AsioOut.Volume is kept despite its obsolete notice — it's an IWavePlayer interface member
AudioMediaSubtypes moved from the NAudio.Dmo namespace to NAudio.Wave. It ships in NAudio.Core, so cross-platform code previously needed using NAudio.Dmo; to name the media subtype GUIDs even on Linux without the DMO package; it now sits alongside WaveFormatExtensible
SimpleCompressorStream, ImpulseResponseConvolution and NAudio.Extras.Equalizer were removed — superseded by NAudio.Effects (CompressorEffect, ConvolutionReverbEffect, Equalizer)
CueWaveFileReader, CueWaveFileWriter, BwfWriter and BextChunkInfo were removed, along with WaveFileReader.ExtraChunks / GetChunkData — the unified chunk model on WaveFileReader.Chunks and WaveFileWriter replaces them
MixingWaveProvider32 was removed — it was an untested float-only mixer that offered nothing over MixingSampleProvider. ImaAdpcmWaveFormat was removed — it was a non-functional stub used nowhere
WaveFileWriter / AiffFileWriter no longer dispose a caller-supplied stream, matching the readers' ownership rule; only the filename constructor owns and closes the file. IgnoreDisposeStream is no longer needed when writing to a stream you want to keep (#1040)
Finalizers were removed from MediaFoundationTransform, MediaFoundationEncoder and MediaBuffer, and MediaType is now IDisposable — call Dispose()
Core Audio, Media Foundation and DMO errors now throw CoreAudioException / MediaFoundationException, both subclasses of COMException, so existing catch (COMException) keeps working
Notable bug fixes
The sampler, effects and WASAPI subsystems also saw extensive correctness work during
development. The full per-PR list is on the GitHub Release; the fixes most likely to
affect existing NAudio 2 code are:
WaveFileWriter.WriteSample / WriteSamples: fixed 32-bit WaveFormatExtensible output writing near-silence or corrupt data — both paths ignored the declared SubFormat (#651)
ToSampleProvider() now handles WAVE_FORMAT_EXTENSIBLE PCM and IEEE float sources (e.g. multichannel or >16-bit WAV) instead of throwing Unsupported source encoding (#639); AudioFileReader no longer routes such WAVs through an unnecessary ACM conversion stream
WaveFileReader / AiffFileReader: malformed headers declaring BlockAlign=0 throw InvalidDataException from the constructor rather than DivideByZeroException later (#1254); an oversized data chunk length is clamped to the bytes actually present (#1090); an oversized fmtcbSize no longer throws (#482)
AiffFileReader / AiffFileWriter: 8-bit PCM is now read and written as signed two's-complement per the AIFF spec, fixing DC-shifted/garbled playback (#1178)
BlockAlignReductionStream.Read: a read larger than the 4-second internal buffer no longer silently truncates the stream — e.g. converting a non-PCM WAV via AudioFileReader (#1022)
WaveOut: fixed a race where stopping or disposing faster than the buffer latency could throw a NullReferenceException via PlaybackStopped (#804); DirectSoundOut: fixed a startup race that could collapse playback immediately (#759)
WasapiRecorder, WasapiCapture and WasapiLoopbackCapture: a capture device removed mid-recording no longer crashes the process — RecordingStopped always fires with the originating exception (#672). Silent packets no longer leak the uninitialised WASAPI buffer as a burst of stale audio
Fixed an access violation that could crash the process when an endpoint notification fired after RegisterEndpointNotificationCallback — Windows does not AddRef the client, so the CCW was being collected (#1394)
AudioClient.Dispose is now idempotent and safe against concurrent disposal (#1183); MMDevice.Dispose releases the property store deterministically (#1145); AudioSessionControl supports multiple event clients without leaking (#1263); AudioEndpointVolume.OnVolumeNotification reports the correct channel (#351)
AcmInterop: serialised all msacm32 P/Invokes process-wide, fixing process-killing access violations under concurrent ACM use
ResamplerDmoStream: fixed an infinite loop on Read after seeking and the loss of the resampler tail at end-of-stream (#607, #608); LoopStream.Read no longer spins at 100% CPU when the source can't satisfy a read (#1338)
FastFourierTransform.FFT: fixed drifting high-frequency bins at large FFT sizes by carrying the twiddle-factor recurrence in double precision (#520)
WdlResampler: backported upstream Cockos WDL fixes, including reinterleaving on channel-count change and denormal flushing in the IIR feedback path (#800)
WaveViewer: fixed rendering upside-down (#801, #818) and now renders any source format via ToSampleProvider() (#564)
Mp3FileReader: fixed false sample-rate-change errors near end of file, and more robust frame parsing against album art and trailing metadata; MidiFile preserves running status across meta events
WaveFormat.Serialize: PCM formats now write the canonical 16-byte fmt chunk (#934, #1098)
Hardened Media Foundation and DMO interop against COM ref leaks on error paths (#1293)
Demos and tooling
NAudioDemo and NAudioWpfDemo were substantially reworked against the new APIs, including a rebuilt WASAPI Recorder panel driven by WasapiRecorderBuilder, transport/volume/position controls across the playback panels, and a Graphic EQ panel on NAudio.Effects
The network chat demo is now UDP-only with a bounded jitter buffer and Opus codecs (via Concentus, replacing the vendored NSpeex binary), and gained a tutorial
The documentation site (tutorials plus a generated API reference) is published to GitHub Pages from Docs/ and the source XML comments. Every package's projectUrl and README now point at it; nuget.org still links the GitHub repo via the package's repository metadata
Added DeviceCount and GetCapabilities static methods to WaveOutEvent so output
devices can be enumerated without referencing NAudio.WinForms (#1331, #777)
Fixed WASAPI and Media Foundation interop under Unity's Mono runtime, which marshalled
formatted class parameters as COM interfaces; they are now explicitly marked [MarshalAs(UnmanagedType.LPStruct)] (#1414)
Configuration
📅Schedule: (UTC)
Branch creation
At any time (no schedule defined)
Automerge
At any time (no schedule defined)
🚦Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕Ignore: Close this PR and you won't be reminded about this update again.
If you want to rebase/retry this PR, check this box
This PR contains the following updates:
| Package | Type | Update | Change |
|---|---|---|---|
| [NAudio](https://naudio.github.io/NAudio/) ([source](https://github.com/naudio/NAudio)) | nuget | major | `2.3.0` → `3.1.0` |
---
### Release Notes
<details>
<summary>naudio/NAudio (NAudio)</summary>
### [`v3.1.0`](https://github.com/naudio/NAudio/blob/HEAD/RELEASE_NOTES.md#310-7-Sep-2026)
A correctness release, with Native AOT as the theme. NAudio's remaining
`[StructLayout]` interop types — `WAVEHDR`, `ACMSTREAMHEADER` and `WaveFormat`
itself — were passed to native code by value, which CoreCLR pins in place but
the AOT marshaller copies into a per-call temporary. Anything the driver or
codec wrote back was silently discarded, so `WaveIn`/`WaveOut`, ACM conversion
(and with it `Mp3FileReader` and `AudioFileReader`) and every WASAPI, Media
Foundation and DMO format negotiation were broken in an AOT-published app while
building and running cleanly. Those paths now marshal by hand into stable
unmanaged blocks, and `NAudio.WinMM` joins the AOT-compatible package set.
The two breaking changes below both fall out of that work. Also fixed are two
3.0.0 regressions — `Mp3FileReaderBase` seeking on files with a Xing/Info
header, and `WdlResamplingSampleProvider` losing samples when its source
under-feeds — and a pair of infinite loops in the WAV parser on corrupt files.
- **Breaking:** `WaveFormat` and its subclasses no longer carry `[StructLayout]`, so `Marshal.SizeOf` and `Marshal.PtrToStructure` on them now throw `ArgumentException` instead of silently returning wrong data under Native AOT (`Marshal.SizeOf<WaveFormatExtensible>()` returned 22 rather than 40, and a decoded format kept its constructor defaults). NAudio itself stopped marshalling these types in 3.1.0; use `ToWaveFormatExBytes`, `MarshalToPtr` or `MarshalFromPtr` to cross a native boundary ([#​1432](https://github.com/naudio/NAudio/issues/1432))
- **Breaking:** `AudioClient.IsFormatSupported` and `WasapiPlayer.IsFormatSupported` now return the closest-match format as `out WaveFormat` rather than `out WaveFormatExtensible`. WASAPI documents this format as either a `WAVEFORMATEX` or a `WAVEFORMATEXTENSIBLE`, and the old signature could only represent the latter — a plain format was previously decoded as a `WaveFormatExtensible` whose base fields were valid but whose extensible fields were meaningless. Callers needing the extensible fields should pattern-match ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Fixed `WaveIn`/`WaveOut` failing under Native AOT with `WaveHeaderUnprepared` ("The wave header was not prepared"). The `WAVEHDR` was a `[StructLayout]` class passed to winmm by value, which CoreCLR pins in place but NativeAOT copies into a per-call temporary, so the driver's `WHDR_PREPARED`/`WHDR_DONE`/`dwBytesRecorded` writes were discarded. It is now a struct in a stable unmanaged block ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Fixed ACM conversion failing under Native AOT — `WaveFormatConversionStream`, `AcmStream` and so `Mp3FileReader` and `AudioFileReader`. `ACMSTREAMHEADER` was a `[StructLayout]` class passed to msacm32 by value, and the codec keeps private state in the header's reserved fields between `acmStreamPrepareHeader`, `acmStreamConvert` and `acmStreamUnprepareHeader`; the AOT marshaller's per-call copy round-trips only the declared fields, so that state was lost and conversion failed. It is now a struct in a stable unmanaged block, as `WAVEHDR` already is ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Fixed `WaveFormat.MarshalToPtr` and `WaveFormat.MarshalFromPtr` corrupting any `WaveFormat` subclass under Native AOT — the AOT marshaller drops the inherited `WAVEFORMATEX` fields of a class hierarchy, so a `WaveFormatExtensible` was written with its SubFormat GUID over the sample rate. Every remaining site that sized or wrote a `WaveFormat` with `Marshal.SizeOf`/`StructureToPtr` was converted too: WASAPI (`AudioClient`), Media Foundation (`MFInitMediaTypeFromWaveFormatEx`, reachable from `MediaFoundationResampler`/`MediaFoundationEncoder`), DMO (`DmoMediaType.SetWaveFormat`, `MediaObject`) and ACM (`AcmStream`, `AcmDriver`) ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- `WaveFormat.MarshalToPtr` now always allocates at least the `18 + cbSize` bytes it advertises. A `WaveFormat` subclass that declares `extraSize` but doesn't write it in `Serialize` previously produced a block shorter than its own `cbSize`, which a native consumer would read past ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Added `WaveFormat.ToWaveFormatExBytes()`, which renders a `WaveFormat` as a native WAVEFORMATEX byte array. `MarshalToPtr` is now a thin wrapper over it, for callers who need an unmanaged block rather than a buffer they already own ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Added a `Serialize` override to `Mp3WaveFormat`, which previously advertised `cbSize` = 12 but wrote none of its 12 MPEGLAYER3WAVEFORMAT extra bytes ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- `WaveFormatExtraData` now sizes its buffer from `cbSize` instead of holding a fixed 100-byte array, so a fmt chunk declaring more than 100 bytes of extra data keeps it rather than having all of it discarded ([#​482](https://github.com/naudio/NAudio/issues/482)). The fixed size existed only because `[MarshalAs(ByValArray, SizeConst = 100)]` needed a compile-time length. `ExtraData` is now exactly `ExtraSize` bytes long rather than always 100 ([#​1432](https://github.com/naudio/NAudio/issues/1432))
- `NAudio.WinMM` is now marked `IsAotCompatible`, and the AOT smoke test covers the winmm WAVEHDR/WAVEFORMATEX paths ([#​1425](https://github.com/naudio/NAudio/issues/1425))
- Fixed `Mp3FileReaderBase` seeking silently restarting playback from the beginning of the file on MP3s with a Xing/Info header — the lazy frame index was gated on `IsLengthExact`, which such a header sets without any frame having been scanned. Also fixed seeks landing on the wrong frame when the target fell exactly on a frame boundary, and Xing/Info header frames being indexed as audio (shifting every seek in those files \~26 ms early). A 3.0.0 regression ([#​1419](https://github.com/naudio/NAudio/issues/1419))
- Fixed `WdlResamplingSampleProvider` losing samples, and eventually returning 0 permanently, when asked for more output than the source could supply — a 3.0.0 regression that broke the common pattern of reading generously from a `BufferedWaveProvider`-backed capture chain. `WdlResampler.ResampleOut` also no longer drifts in input-driven (feed) mode when handed fewer samples than `ResamplePrepare` requested ([#​1412](https://github.com/naudio/NAudio/issues/1412))
- Fixed two infinite loops in the WAV parser triggered by corrupt files declaring a negative chunk size. An RF64 `ds64` chunk with a negative `dataChunkLength`, or a `LIST/adtl` sub-chunk with a negative size, made the chunk walk advance by zero bytes per iteration and spin at 100% CPU without throwing. Negative and oversized sizes are now rejected where they are read, and an undersized `ds64` chunk throws `FormatException` rather than `ArgumentOutOfRangeException` ([#​1428](https://github.com/naudio/NAudio/issues/1428))
- Fixed the `NAudioConsoleTest` WASAPI exclusive-mode quick scan reporting no supported formats at all on devices that support plenty — it built its probe formats with an empty `WAVEFORMATEXTENSIBLE` channel mask, which drivers such as Realtek reject outright. It now probes with the canonical layout for the channel count, the same mask the library's own format adaptation uses ([#​1431](https://github.com/naudio/NAudio/issues/1431))
### [`v3.0.1`](https://github.com/naudio/NAudio/blob/HEAD/RELEASE_NOTES.md#301-18-Aug-2026)
A patch release. The headline fix is packaging: the `NAudio` and `NAudio.Extras`
meta-packages now ship a plain `net9.0-windows` leg, so WinForms and WPF projects
targeting `netX.0-windows` get the full Windows stack again.
- **Breaking:** `AudioFileReader` now throws `NotSupportedException` instead of `InvalidOperationException` when the cross-platform build is asked for a format it cannot read, and the messages simply state that rather than suggesting an `NAudio.Wasapi` install that could never have helped ([#​1407](https://github.com/naudio/NAudio/issues/1407))
- Fixed the `NAudio` and `NAudio.Extras` meta-packages resolving their portable `net9.0` asset on projects targeting a plain `netX.0-windows` TFM (the WinForms/WPF template default), which silently dropped the entire Windows stack — no `WaveOut`, WASAPI, Media Foundation, ASIO, DMO or WinForms types, and `AudioFileReader` throwing "MP3 file reading requires the NAudio.Wasapi package". Both packages now also ship a plain `net9.0-windows` leg ([#​1407](https://github.com/naudio/NAudio/issues/1407))
- Projects on a plain `netX.0-windows` TFM may now see `CA1416` warnings when calling WASAPI process-loopback capture. The warning is correct — those callers do need an `OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)` guard — and was previously hidden because the only Windows asset available already implied that floor ([#​1407](https://github.com/naudio/NAudio/issues/1407))
- Sample and tool apps now roll forward onto newer .NET runtimes, so running them no longer requires the .NET 9 runtime to be installed ([#​1408](https://github.com/naudio/NAudio/issues/1408))
- Fixed `AiffFileReader` reporting too long a `Length` and throwing `IndexOutOfRangeException` when the SSND chunk declares a non-zero offset ([#​1405](https://github.com/naudio/NAudio/issues/1405))
- Fixed `AiffFileReader.Read` throwing `IndexOutOfRangeException` when the source stream returns fewer bytes than requested ([#​1405](https://github.com/naudio/NAudio/issues/1405))
### [`v3.0.0`](https://github.com/naudio/NAudio/blob/HEAD/RELEASE_NOTES.md#300-15-Aug-2026)
NAudio 3 is a major release. The single `NAudio` assembly is now split into
focused, independently usable packages; the minimum target framework moves to
`net9.0`; the core is cross-platform and Native-AOT compatible; and several
large new subsystems — a cross-platform effects suite, a software sampler, VST 3
hosting, and ALSA and libsndfile backends — join the library.
**Upgrading from NAudio 2?** [Migrating from NAudio 2 to NAudio 3](Docs/MigratingFromNAudio2.md)
walks through every breaking change with before/after code. Most apps need only
re-target to `net9.0`, rename `WaveOutEvent` to `WaveOut`, and adjust custom
providers to the new `Span<T>` `Read` signature.
##### Packages and platform
- Minimum target framework is now `net9.0` — legacy .NET Framework and .NET Standard 2.0 support is dropped
- `NAudio` is now a set of focused packages: `NAudio.Core`, `NAudio.Midi`, `NAudio.WinMM`, `NAudio.Wasapi`, `NAudio.Asio`, `NAudio.Dmo`, `NAudio.WinForms`, plus the new `NAudio.Effects` (shipped in `NAudio.Core`), `NAudio.Sampler`, `NAudio.Vst3`, `NAudio.Alsa` and `NAudio.SoundFile`. The `NAudio` meta-package still pulls the Windows stack together, so existing consumers see no change. See `Docs/Architecture/NAudio3AssemblyLayoutPlan.md`
- `NAudio.Core`, `NAudio.Midi`, `NAudio.Wasapi`, `NAudio.Dmo`, `NAudio.Sampler`, `NAudio.SoundFile` and `NAudio.Alsa` are Native-AOT compatible (`IsAotCompatible=true`), enforced in CI by `NAudioAotSmokeTest`
- `NAudio.Wasapi` targets plain `net9.0` (Windows-only at runtime via `[SupportedOSPlatform("windows")]`), so cross-platform apps can reference it and build on Linux/macOS without `EnableWindowsTargeting`. The WinRT MIDI backend moved to `NAudio.Midi`, which now dual-targets `net9.0;net9.0-windows10.0.19041.0` ([#​1384](https://github.com/naudio/NAudio/issues/1384))
- The `NAudio.Uap` package is removed — use `WasapiPlayerBuilder` / `WasapiRecorderBuilder`
- Packages ship with SourceLink, `.snupkg` symbol packages and an embedded SPDX SBOM
##### New capabilities
Each new subsystem has its own tutorial or README; only the headline is listed here.
- **Audio effects** — a cross-platform `NAudio.Effects` framework: `IAudioEffect` / `EffectSampleProvider` / `EffectChain` with click-free bypass, dry/wet mix and an optional parameter model, plus a broad effect set (EQ and filtering, dynamics, saturation/lo-fi, delay and modulation, reverb including FFT convolution, pitch shifting, and voice-comms AGC/noise suppression). See [Docs/AudioEffects.md](Docs/AudioEffects.md)
- **Modern WASAPI** — high-level `WasapiPlayer` / `WasapiRecorder`, built via `WasapiPlayerBuilder` / `WasapiRecorderBuilder`: `IAudioClient3` low latency, MMCSS thread priority, `IAsyncDisposable`, zero-copy buffers, per-process loopback capture, automatic stream routing that follows the default endpoint ([#​942](https://github.com/naudio/NAudio/issues/942)), acoustic-echo-cancellation reference control ([#​1223](https://github.com/naudio/NAudio/issues/1223)), communications mode, raw mode ([#​476](https://github.com/naudio/NAudio/issues/476)), and resample-free bit-depth/channel adaptation in exclusive and low-latency modes. See [Docs/WasapiPlayer.md](Docs/WasapiPlayer.md) and [Docs/WasapiRecorder.md](Docs/WasapiRecorder.md)
- **Modern ASIO** — a new `AsioDevice` replacing `AsioOut`: explicit playback/recording/duplex modes, non-contiguous channels, per-channel `Span<float>` callbacks, driver-reset recovery and per-buffer timing. `AsioOut` is preserved as a facade. See [Docs/AsioMigration.md](Docs/AsioMigration.md)
- **Cross-platform audio files** — new `NAudio.SoundFile` package: read and write WAV/AIFF/FLAC/Ogg-Vorbis/Opus/MP3 via a system libsndfile on Windows, Linux and macOS (the first cross-platform FLAC/Vorbis/Opus *encoder* in NAudio). See [Docs/CrossPlatformAudioFilesWithSoundFile.md](Docs/CrossPlatformAudioFilesWithSoundFile.md) ([#​1289](https://github.com/naudio/NAudio/issues/1289))
- **Linux audio** — new `NAudio.Alsa` package: `AlsaOut` (`IWavePlayer`) and `AlsaIn` (`IWaveIn`) plus `AlsaDeviceEnumerator`, backed by `libasound`. See [Docs/PlayAudioFileLinuxAlsa.md](Docs/PlayAudioFileLinuxAlsa.md) and [Docs/RecordAudioFileLinuxAlsa.md](Docs/RecordAudioFileLinuxAlsa.md) ([#​1182](https://github.com/naudio/NAudio/issues/1182))
- **VST 3 hosting** — new `NAudio.Vst3` package (Windows-only): discover, load and host VST 3 effects and instruments, with parameters, state and `.vstpreset` presets, native editor windows, program lists/units, latency compensation, and live/offline MIDI-file playback through the shared MIDI pipeline. See the `NAudio.Vst3` README and `Docs/Architecture/Vst3Hosting.md`. VST is a registered trademark of Steinberg Media Technologies GmbH
- **Software sampler** — new `NAudio.Sampler` package: polyphonic, cross-platform playback of SoundFont (`.sf2`) and SFZ instruments and single-sample instruments, rendered as an `ISampleProvider` (SF2 modulator engine, DAHDSR envelopes, LFOs, modulated filters, reverb/chorus sends, voice stealing, choke groups). See [Docs/Sampler.md](Docs/Sampler.md)
- **Event-based device notifications** — `MMDeviceEnumerator.CreateNotificationClient()` returns an `MMDeviceNotificationClient` exposing `DeviceStateChanged`, `DeviceAdded`, `DeviceRemoved`, `DefaultDeviceChanged` and `PropertyValueChanged` as ordinary events, so callers no longer implement a COM interface or manage CCW lifetime ([#​1395](https://github.com/naudio/NAudio/issues/1395))
- **MIDI** — `NAudio.Midi`'s portable leg is now cross-platform; new WinRT `WinRTMidiIn` / `WinRTMidiOut` and backend-agnostic `IMidiInput` / `IMidiOutput`; and a new `IMidiInstrument` seam (`MidiFileSequence` / `SequencedMidiPlayer` / `OfflineMidiRenderer` / `LiveMidiInstrument`) giving an end-to-end MIDI-file → audio pipeline that drives the sampler or a hosted VST 3 instrument. `MidiFile` also reads RIFF-RMID (`.rmi`) files ([#​1236](https://github.com/naudio/NAudio/issues/1236)) and `MidiFile.Export` gains a `Stream` overload, thanks to [@​MaKiPL](https://github.com/MaKiPL) ([#​499](https://github.com/naudio/NAudio/issues/499))
- **Sequencing** — a portable `NAudio.Sequencing` namespace in `NAudio.Core` (tempo and time-signature maps, transport, `EventTimeline`, swing, and a sample-accurate per-buffer dispatcher) underpinning MIDI-file playback and the sampler. See `Docs/Architecture/Sequencing.md`
- **Live capture mixing** — new `NAudio.Extras` helpers `CaptureMixerInput` and `RealtimeCaptureMixer` capture and live-mix several sources with different sample rates and channel counts (e.g. microphone + system loopback) into one wall-clock-paced stream. See [Docs/MixMicrophoneAndSystemAudio.md](Docs/MixMicrophoneAndSystemAudio.md) ([#​761](https://github.com/naudio/NAudio/issues/761))
- **Reading audio from streams** — `AudioFileReader` and `CachedSound` gain `Stream` constructors, detecting WAV/AIFF from the contents and delegating anything else to Media Foundation, so embedded or in-memory audio plays without a temp file ([#​927](https://github.com/naudio/NAudio/issues/927), [#​963](https://github.com/naudio/NAudio/issues/963)). `StreamMediaFoundationReader` also gains optional `contentType` / `originName` hints and Ogg container sniffing ([#​952](https://github.com/naudio/NAudio/issues/952))
- **WAV chunk model** — `WaveFileReader.Chunks` with an `IWaveChunkInterpreter<T>` extension point and built-in interpreters for cue lists, BWF `bext` (`BroadcastExtension`, now read *and* write, with v2 loudness) and LIST/INFO (`InfoMetadata`); `WaveFileWriter` gains `AddCue`, `WriteCueList`, `WriteBroadcastExtension`, arbitrary `AddChunk` and RF64 promotion via `WaveFileWriterOptions` ([#​1013](https://github.com/naudio/NAudio/issues/1013))
- **Latency reporting** — new `IWaveLatency` interface in `NAudio.Core` exposing `AverageLatency` / `CurrentLatency` for A/V sync and drift detection, implemented across the playback and capture classes ([#​601](https://github.com/naudio/NAudio/issues/601))
- **Sample providers and DSP** — new `ChannelMixerSampleProvider` with ready-made `ChannelMixMatrix` routings, thanks to [@​antiduh](https://github.com/antiduh) ([#​982](https://github.com/naudio/NAudio/issues/982)); a new `FftProcessor`; `Span<T>` overloads across the codec/DSP surface; reusable building blocks (`EnvelopeFollower`, `DelayLine`, `Lfo`, `Oversampler`, `LinkwitzRileyCrossover`, `PartitionedConvolver`, …); plus improvements to `SmbPitchShiftingSampleProvider` ([#​922](https://github.com/naudio/NAudio/issues/922)), `AdsrSampleProvider` ([#​671](https://github.com/naudio/NAudio/issues/671)) and `FadeInOutSampleProvider` ([#​1136](https://github.com/naudio/NAudio/issues/1136))
- **WaveFormatExtensible** — new constructors for SubFormat, valid-bits-per-sample and channel mask, readable `ValidBitsPerSample` / `ChannelMask`, and a `[Flags] Speakers` enum for building channel masks ([#​1325](https://github.com/naudio/NAudio/issues/1325))
- **WASAPI sessions and devices** — `AudioSessionControl.SetDuckingPreference(bool)` ([#​760](https://github.com/naudio/NAudio/issues/760)); `WasapiPlayer` / `WasapiRecorder` expose `DeviceId` and `DeviceFriendlyName` for the active endpoint ([#​681](https://github.com/naudio/NAudio/issues/681))
##### Breaking changes
The full upgrade walkthrough — every breaking change with before/after code — is
in **[Migrating from NAudio 2 to NAudio 3](Docs/MigratingFromNAudio2.md)**. The
highest-impact changes:
- Minimum target framework is now `net9.0` (legacy .NET Framework / .NET Standard 2.0 dropped)
- `IWaveProvider.Read` / `ISampleProvider.Read` now take a single `Span<byte>` / `Span<float>` (was buffer/offset/count) — callers migrate via `source.Read(buffer.AsSpan(offset, count))`; implementations override the span method
- `WaveOutEvent` is renamed to `WaveOut` and `WaveInEvent` to `WaveIn` (the old names remain as `[Obsolete]` subclasses). `WaveOut` / `WaveIn` now default to event-driven callbacks; the window-based variants are `WaveOutWindow` / `WaveInWindow` in `NAudio.WinForms`, and `WaveCallbackInfo` / `WaveCallbackStrategy` are removed
- `WaveOut.DesiredLatency` is replaced by `BufferMilliseconds`, which sizes each individual buffer rather than the total across all of them. `WaveIn`'s default record format changes from 8 kHz mono to 44.1 kHz stereo
- `WasapiOut`, `WasapiCapture` and `WasapiLoopbackCapture` are `[Obsolete]` in favour of `WasapiPlayer` / `WasapiRecorder` (the legacy types still ship and work); `WasapiOut`'s embedded exclusive-mode resampler was removed, though it now adapts bit depth and channels, so only a sample-rate mismatch requires upstream resampling
- The low-level `IMMNotificationClient` interface and `MMDeviceEnumerator.RegisterEndpointNotificationCallback` / `UnregisterEndpointNotificationCallback` are now internal — use `CreateNotificationClient()` and its events. The raw Core Audio and Media Foundation COM interfaces are likewise internal, and `PropertyStoreProperty.Value` is now `object` rather than `PropVariant`
- Some types moved package or namespace as part of the split — classic Windows MIDI I/O and `winmm` types to `NAudio.WinMM`; the DMO/DirectSound types into the new `NAudio.Dmo` package; plus smaller moves (`AudioVolumeLevel`, `CaptureState`, `DmoMp3FrameDecompressor`). Meta-package consumers are unaffected
- Removed seven members that were already `[Obsolete]` throughout NAudio 2, each with a direct replacement on the same class: `WaveFileWriter.WriteData` (both overloads → `Write` / `WriteSamples`), `WaveFileReader.TryReadFloat` (→ `ReadNextSampleFrame`, which doesn't drop channels on stereo), `AcmStream.Convert(int)` (→ the overload returning `sourceBytesConverted`), `WaveFormatConversionStream.SourceToDest` / `DestToSource` (unreliable estimates with no replacement — use `Position` / `Length`), and `AsioAudioAvailableEventArgs.GetAsInterleavedSamples()` (→ the overload taking a reusable array, avoiding an allocation per ASIO callback). `AsioOut.Volume` is kept despite its obsolete notice — it's an `IWavePlayer` interface member
- `AudioMediaSubtypes` moved from the `NAudio.Dmo` namespace to `NAudio.Wave`. It ships in `NAudio.Core`, so cross-platform code previously needed `using NAudio.Dmo;` to name the media subtype GUIDs even on Linux without the DMO package; it now sits alongside `WaveFormatExtensible`
- `SimpleCompressorStream`, `ImpulseResponseConvolution` and `NAudio.Extras.Equalizer` were removed — superseded by `NAudio.Effects` (`CompressorEffect`, `ConvolutionReverbEffect`, `Equalizer`)
- `CueWaveFileReader`, `CueWaveFileWriter`, `BwfWriter` and `BextChunkInfo` were removed, along with `WaveFileReader.ExtraChunks` / `GetChunkData` — the unified chunk model on `WaveFileReader.Chunks` and `WaveFileWriter` replaces them
- `MixingWaveProvider32` was removed — it was an untested float-only mixer that offered nothing over `MixingSampleProvider`. `ImaAdpcmWaveFormat` was removed — it was a non-functional stub used nowhere
- `WaveFileWriter` / `AiffFileWriter` no longer dispose a caller-supplied stream, matching the readers' ownership rule; only the filename constructor owns and closes the file. `IgnoreDisposeStream` is no longer needed when writing to a stream you want to keep ([#​1040](https://github.com/naudio/NAudio/issues/1040))
- Finalizers were removed from `MediaFoundationTransform`, `MediaFoundationEncoder` and `MediaBuffer`, and `MediaType` is now `IDisposable` — call `Dispose()`
- Core Audio, Media Foundation and DMO errors now throw `CoreAudioException` / `MediaFoundationException`, both subclasses of `COMException`, so existing `catch (COMException)` keeps working
##### Notable bug fixes
The sampler, effects and WASAPI subsystems also saw extensive correctness work during
development. The full per-PR list is on the GitHub Release; the fixes most likely to
affect existing NAudio 2 code are:
- `WaveFileWriter.WriteSample` / `WriteSamples`: fixed 32-bit `WaveFormatExtensible` output writing near-silence or corrupt data — both paths ignored the declared SubFormat ([#​651](https://github.com/naudio/NAudio/issues/651))
- `ToSampleProvider()` now handles `WAVE_FORMAT_EXTENSIBLE` PCM and IEEE float sources (e.g. multichannel or >16-bit WAV) instead of throwing `Unsupported source encoding` ([#​639](https://github.com/naudio/NAudio/issues/639)); `AudioFileReader` no longer routes such WAVs through an unnecessary ACM conversion stream
- `WaveFileReader` / `AiffFileReader`: malformed headers declaring `BlockAlign=0` throw `InvalidDataException` from the constructor rather than `DivideByZeroException` later ([#​1254](https://github.com/naudio/NAudio/issues/1254)); an oversized `data` chunk length is clamped to the bytes actually present ([#​1090](https://github.com/naudio/NAudio/issues/1090)); an oversized `fmt` `cbSize` no longer throws ([#​482](https://github.com/naudio/NAudio/issues/482))
- `AiffFileReader` / `AiffFileWriter`: 8-bit PCM is now read and written as signed two's-complement per the AIFF spec, fixing DC-shifted/garbled playback ([#​1178](https://github.com/naudio/NAudio/issues/1178))
- `BlockAlignReductionStream.Read`: a read larger than the 4-second internal buffer no longer silently truncates the stream — e.g. converting a non-PCM WAV via `AudioFileReader` ([#​1022](https://github.com/naudio/NAudio/issues/1022))
- `WaveOut`: fixed a race where stopping or disposing faster than the buffer latency could throw a `NullReferenceException` via `PlaybackStopped` ([#​804](https://github.com/naudio/NAudio/issues/804)); `DirectSoundOut`: fixed a startup race that could collapse playback immediately ([#​759](https://github.com/naudio/NAudio/issues/759))
- `WasapiRecorder`, `WasapiCapture` and `WasapiLoopbackCapture`: a capture device removed mid-recording no longer crashes the process — `RecordingStopped` always fires with the originating exception ([#​672](https://github.com/naudio/NAudio/issues/672)). Silent packets no longer leak the uninitialised WASAPI buffer as a burst of stale audio
- Fixed an access violation that could crash the process when an endpoint notification fired after `RegisterEndpointNotificationCallback` — Windows does not AddRef the client, so the CCW was being collected ([#​1394](https://github.com/naudio/NAudio/issues/1394))
- `AudioClient.Dispose` is now idempotent and safe against concurrent disposal ([#​1183](https://github.com/naudio/NAudio/issues/1183)); `MMDevice.Dispose` releases the property store deterministically ([#​1145](https://github.com/naudio/NAudio/issues/1145)); `AudioSessionControl` supports multiple event clients without leaking ([#​1263](https://github.com/naudio/NAudio/issues/1263)); `AudioEndpointVolume.OnVolumeNotification` reports the correct channel ([#​351](https://github.com/naudio/NAudio/issues/351))
- `AcmInterop`: serialised all `msacm32` P/Invokes process-wide, fixing process-killing access violations under concurrent ACM use
- `ResamplerDmoStream`: fixed an infinite loop on `Read` after seeking and the loss of the resampler tail at end-of-stream ([#​607](https://github.com/naudio/NAudio/issues/607), [#​608](https://github.com/naudio/NAudio/issues/608)); `LoopStream.Read` no longer spins at 100% CPU when the source can't satisfy a read ([#​1338](https://github.com/naudio/NAudio/issues/1338))
- `FastFourierTransform.FFT`: fixed drifting high-frequency bins at large FFT sizes by carrying the twiddle-factor recurrence in double precision ([#​520](https://github.com/naudio/NAudio/issues/520))
- `WdlResampler`: backported upstream Cockos WDL fixes, including reinterleaving on channel-count change and denormal flushing in the IIR feedback path ([#​800](https://github.com/naudio/NAudio/issues/800))
- `WaveViewer`: fixed rendering upside-down ([#​801](https://github.com/naudio/NAudio/issues/801), [#​818](https://github.com/naudio/NAudio/issues/818)) and now renders any source format via `ToSampleProvider()` ([#​564](https://github.com/naudio/NAudio/issues/564))
- `Mp3FileReader`: fixed false sample-rate-change errors near end of file, and more robust frame parsing against album art and trailing metadata; `MidiFile` preserves running status across meta events
- `WaveFormat.Serialize`: PCM formats now write the canonical 16-byte `fmt ` chunk ([#​934](https://github.com/naudio/NAudio/issues/934), [#​1098](https://github.com/naudio/NAudio/issues/1098))
- Hardened Media Foundation and DMO interop against COM ref leaks on error paths ([#​1293](https://github.com/naudio/NAudio/issues/1293))
##### Demos and tooling
- `NAudioDemo` and `NAudioWpfDemo` were substantially reworked against the new APIs, including a rebuilt WASAPI Recorder panel driven by `WasapiRecorderBuilder`, transport/volume/position controls across the playback panels, and a Graphic EQ panel on `NAudio.Effects`
- The network chat demo is now UDP-only with a bounded jitter buffer and Opus codecs (via `Concentus`, replacing the vendored NSpeex binary), and gained a [tutorial](Docs/NetworkChatDemo.md)
- The documentation site (tutorials plus a generated API reference) is published to GitHub Pages from `Docs/` and the source XML comments. Every package's `projectUrl` and README now point at it; nuget.org still links the GitHub repo via the package's `repository` metadata
### [`v2.4.0`](https://github.com/naudio/NAudio/releases/tag/v2.4.0): NAudio 2.4.0
- Added `DeviceCount` and `GetCapabilities` static methods to `WaveOutEvent` so output
devices can be enumerated without referencing `NAudio.WinForms` ([#​1331](https://github.com/naudio/NAudio/issues/1331), [#​777](https://github.com/naudio/NAudio/issues/777))
- Fixed WASAPI and Media Foundation interop under Unity's Mono runtime, which marshalled
formatted class parameters as COM interfaces; they are now explicitly marked
`[MarshalAs(UnmanagedType.LPStruct)]` ([#​1414](https://github.com/naudio/NAudio/issues/1414))
</details>
---
### Configuration
📅 **Schedule**: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMC4zIiwidXBkYXRlZEluVmVyIjoiNDQuODIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
NAudio 3 is a major runtime/audio migration: it raises framework requirements, splits packages, changes provider reads and stream ownership, and reorganizes Windows playback/capture APIs. We are confirmed affected: both exact-head runs restore, then fail compilation because WaveOutEvent is unavailable for the neutral target; tests never run. NAudio also powers microphone/loopback capture, device selection, WAV handling, transcription helpers, and sample playback. Do not merge this dependency-only PR. Implement a deliberate migration, require green builds/tests for both targets, and perform attended Windows recording/playback/device-recovery/transcription checks before an explicit manual merge outside automations. Rollback is 2.3.0; no data migration is involved.
## Weekly high-risk assessment
NAudio 3 is a major runtime/audio migration: it raises framework requirements, splits packages, changes provider reads and stream ownership, and reorganizes Windows playback/capture APIs. We are **confirmed affected**: both exact-head runs restore, then fail compilation because `WaveOutEvent` is unavailable for the neutral target; tests never run. NAudio also powers microphone/loopback capture, device selection, WAV handling, transcription helpers, and sample playback. Do not merge this dependency-only PR. Implement a deliberate migration, require green builds/tests for both targets, and perform attended Windows recording/playback/device-recovery/transcription checks before an **explicit manual merge outside automations**. Rollback is 2.3.0; no data migration is involved.
Weekly high-risk status at 9bb9d2f2ca5d27a39c360b273a9e0c4bc8cefa3: NAudio 3 is not source-compatible here. Exact-head CI fails before tests because common net10.0 code still uses WaveOutEvent, while upstream renamed/split APIs and changed buffer/stream behavior. We are directly affected across sample playback, microphone/WASAPI loopback capture, device enumeration, recording, and transcription helpers. The immediate risk is blocking the next application publish; further risk remains in real Windows audio behavior after compilation is fixed. Recommendation: do not merge. Rebase, implement an explicit NAudio 3 migration with green builds for both targets, then perform attended playback/recording/device-recovery/transcription checks and merge manually outside automations.
Weekly high-risk status at `9bb9d2f2ca5d27a39c360b273a9e0c4bc8cefa3`: NAudio 3 is not source-compatible here. Exact-head CI fails before tests because common `net10.0` code still uses `WaveOutEvent`, while upstream renamed/split APIs and changed buffer/stream behavior. We are directly affected across sample playback, microphone/WASAPI loopback capture, device enumeration, recording, and transcription helpers. The immediate risk is blocking the next application publish; further risk remains in real Windows audio behavior after compilation is fixed. Recommendation: do not merge. Rebase, implement an explicit NAudio 3 migration with green builds for both targets, then perform attended playback/recording/device-recovery/transcription checks and merge manually outside automations.
Weekly recheck — high risk; NAudio3 migration required
Reviewed 8f507151387f9312dc7a8e96bfa570fc3e8ff83b, NAudio2.3.0 →3.1.0. Runs3442 and 3443 restore then fail CS0246 at WorkflowRulesEditorSamplePlaybackQueue.cs:85: WaveOutEvent is unavailable on net10.0. Tests never execute.
Affected: proven build breakage, likely native audio exposure. The application uses real microphone/WASAPI loopback capture, device recovery, playback, WAV recording and speaker snippets. Migration guidance changes packaging/provider reads/packet delivery/stream ownership. WaveOutEvent remains an obsolete Windows alias; it is not universally removed, and renaming alone is not a sufficient fix. New3.1 marshalling/AOT/resampling changes have no direct matched callsites in committed application code.
The current test project targets net10.0: a win-x64 RID and Windows-labeled step do not establish a Windows-specific TFM build. Deliberately migrate, build both target frameworks, run tests, and perform attended capture/playback/device-recovery/transcription checks before explicitly merging outside automations. Rebase against current main before renewed validation; rebase alone cannot fix this incompatibility. Rollback restores2.3.0/prior app while idle, with no identified data migration.
### Weekly recheck — high risk; NAudio3 migration required
Reviewed `8f507151387f9312dc7a8e96bfa570fc3e8ff83b`, NAudio2.3.0 →3.1.0. [Runs3442](https://gitea.schweigert.cloud/Manuel/meeting-assistant/actions/runs/3442) and [3443](https://gitea.schweigert.cloud/Manuel/meeting-assistant/actions/runs/3443) restore then fail CS0246 at WorkflowRulesEditorSamplePlaybackQueue.cs:85: WaveOutEvent is unavailable on net10.0. Tests never execute.
**Affected: proven build breakage, likely native audio exposure.** The application uses real microphone/WASAPI loopback capture, device recovery, playback, WAV recording and speaker snippets. [Migration guidance](https://raw.githubusercontent.com/naudio/NAudio/main/Docs/MigratingFromNAudio2.md) changes packaging/provider reads/packet delivery/stream ownership. WaveOutEvent remains an obsolete Windows alias; it is not universally removed, and renaming alone is not a sufficient fix. New3.1 marshalling/AOT/resampling changes have no direct matched callsites in committed application code.
The current test project targets net10.0: a win-x64 RID and Windows-labeled step do not establish a Windows-specific TFM build. Deliberately migrate, build both target frameworks, run tests, and perform attended capture/playback/device-recovery/transcription checks before explicitly merging outside automations. Rebase against current main before renewed validation; rebase alone cannot fix this incompatibility. Rollback restores2.3.0/prior app while idle, with no identified data migration.
<!-- weekly-2026-09-10 8f507151387f9312dc7a8e96bfa570fc3e8ff83b -->
Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.
You can manually request rebase by checking the rebase/retry box above.
⚠️Warning: custom changes will be lost.
### Edited/Blocked Notification
Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.
You can manually request rebase by checking the rebase/retry box above.
⚠️ **Warning**: custom changes will be lost.
Weekly status — HIGH at d93d758a8f96fdddb43d46bc8f30f43da65e7108: NAudio2.3.0→3.1.0 still fails before tests. Exact-head3714 confirms CS0246 missing WaveOutEvent at WorkflowRulesEditorSamplePlaybackQueue.cs:85 on net10.0. Existing migration assessment stands. Branch contains Manuel’s main merge; Renovate warns regeneration discards custom changes, so preserve it. Implement a deliberate migration, validate both target frameworks and attended Windows capture/playback/device recovery/transcription, then explicitly merge outside automations. Rollback restores2.3.0/prior complete publish while idle; no known data migration.
Weekly status — **HIGH** at `d93d758a8f96fdddb43d46bc8f30f43da65e7108`: NAudio2.3.0→3.1.0 still fails before tests. Exact-head3714 confirms CS0246 missing WaveOutEvent at WorkflowRulesEditorSamplePlaybackQueue.cs:85 on net10.0. Existing migration assessment stands. Branch contains Manuel’s main merge; Renovate warns regeneration discards custom changes, so preserve it. Implement a deliberate migration, validate both target frameworks and attended Windows capture/playback/device recovery/transcription, then explicitly merge outside automations. Rollback restores2.3.0/prior complete publish while idle; no known data migration.
<!-- weekly-2026-09-17 d93d758a8f96fdddb43d46bc8f30f43da65e7108 -->
Attended remediation at exact head fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5: NAudio 3.1's playback dependency is Windows-only. Sample playback and DI now use the Windows implementation only for the Windows target; the neutral build returns an actionable unsupported-build result and honors cancellation. Added a public DI/queue behavior regression plus the matching accepted-spec/docs addendum. Local full suite: 521/521 passed, both target frameworks built, strict meeting-session spec validation passed. Native Windows NAudio 3.1 microphone/loopback capture, silent playback, and clean stop/drain passed. Independent review found no actionable defect.
Resumed 2026-09-17: exact-head push/PR checks 3821 and 3822 are now green. Leave open only for the coordinated merge order: this tested head includes #49, whose outage-failed checks are being rerun. Merge #49 first once its exact-head checks pass, then this PR, followed by #51 → #48 → #53. No forced merge or status override. Rollback is the preceding source/package commit; no data migration.
Attended remediation at exact head `fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5`: NAudio 3.1's playback dependency is Windows-only. Sample playback and DI now use the Windows implementation only for the Windows target; the neutral build returns an actionable unsupported-build result and honors cancellation. Added a public DI/queue behavior regression plus the matching accepted-spec/docs addendum. Local full suite: **521/521 passed**, both target frameworks built, strict meeting-session spec validation passed. Native Windows NAudio 3.1 microphone/loopback capture, silent playback, and clean stop/drain passed. Independent review found no actionable defect.
Resumed 2026-09-17: exact-head push/PR checks [3821](https://gitea.schweigert.cloud/Manuel/meeting-assistant/actions/runs/3821) and [3822](https://gitea.schweigert.cloud/Manuel/meeting-assistant/actions/runs/3822) are now **green**. **Leave open only for the coordinated merge order:** this tested head includes #49, whose outage-failed checks are being rerun. Merge #49 first once its exact-head checks pass, then this PR, followed by #51 → #48 → #53. No forced merge or status override. Rollback is the preceding source/package commit; no data migration.
Completed attended review on 2026-09-18: merged exact head fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5 after the current push and PR checks were green. Separate safe preflight and execute verified the exact head and the merged/closed readback; no force or status override was used.
521/521 local tests, both target frameworks, strict spec validation, independent review, and native NAudio 3.1 capture/playback/stop checks passed. Windows-only sample playback now has the tested neutral-build fallback.
The coordinated stack landed in order #49 → #45 → #51 → #48 → #53. Main is now e011e36ef7febc899c87604c0797572dd7402b99; its Git tree exactly matches the final reviewed and tested b249e5d97716f6f277fbad92df8c99745a1c54c6 tree. The new main CI run 3900 is queued at this comment's timestamp. Local checkout is clean and synced. No workstation application restart or deployment was performed.
Completed attended review on 2026-09-18: **merged exact head `fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5`** after the current push and PR checks were green. Separate safe preflight and execute verified the exact head and the merged/closed readback; no force or status override was used.
521/521 local tests, both target frameworks, strict spec validation, independent review, and native NAudio 3.1 capture/playback/stop checks passed. Windows-only sample playback now has the tested neutral-build fallback.
The coordinated stack landed in order #49 → #45 → #51 → #48 → #53. Main is now `e011e36ef7febc899c87604c0797572dd7402b99`; its Git tree exactly matches the final reviewed and tested `b249e5d97716f6f277fbad92df8c99745a1c54c6` tree. The new [main CI run 3900](https://gitea.schweigert.cloud/Manuel/meeting-assistant/actions/runs/3900) is queued at this comment's timestamp. Local checkout is clean and synced. No workstation application restart or deployment was performed.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This PR contains the following updates:
2.3.0→3.1.0Release Notes
naudio/NAudio (NAudio)
v3.1.0A correctness release, with Native AOT as the theme. NAudio's remaining
[StructLayout]interop types —WAVEHDR,ACMSTREAMHEADERandWaveFormatitself — were passed to native code by value, which CoreCLR pins in place but
the AOT marshaller copies into a per-call temporary. Anything the driver or
codec wrote back was silently discarded, so
WaveIn/WaveOut, ACM conversion(and with it
Mp3FileReaderandAudioFileReader) and every WASAPI, MediaFoundation and DMO format negotiation were broken in an AOT-published app while
building and running cleanly. Those paths now marshal by hand into stable
unmanaged blocks, and
NAudio.WinMMjoins the AOT-compatible package set.The two breaking changes below both fall out of that work. Also fixed are two
3.0.0 regressions —
Mp3FileReaderBaseseeking on files with a Xing/Infoheader, and
WdlResamplingSampleProviderlosing samples when its sourceunder-feeds — and a pair of infinite loops in the WAV parser on corrupt files.
WaveFormatand its subclasses no longer carry[StructLayout], soMarshal.SizeOfandMarshal.PtrToStructureon them now throwArgumentExceptioninstead of silently returning wrong data under Native AOT (Marshal.SizeOf<WaveFormatExtensible>()returned 22 rather than 40, and a decoded format kept its constructor defaults). NAudio itself stopped marshalling these types in 3.1.0; useToWaveFormatExBytes,MarshalToPtrorMarshalFromPtrto cross a native boundary (#1432)AudioClient.IsFormatSupportedandWasapiPlayer.IsFormatSupportednow return the closest-match format asout WaveFormatrather thanout WaveFormatExtensible. WASAPI documents this format as either aWAVEFORMATEXor aWAVEFORMATEXTENSIBLE, and the old signature could only represent the latter — a plain format was previously decoded as aWaveFormatExtensiblewhose base fields were valid but whose extensible fields were meaningless. Callers needing the extensible fields should pattern-match (#1425)WaveIn/WaveOutfailing under Native AOT withWaveHeaderUnprepared("The wave header was not prepared"). TheWAVEHDRwas a[StructLayout]class passed to winmm by value, which CoreCLR pins in place but NativeAOT copies into a per-call temporary, so the driver'sWHDR_PREPARED/WHDR_DONE/dwBytesRecordedwrites were discarded. It is now a struct in a stable unmanaged block (#1425)WaveFormatConversionStream,AcmStreamand soMp3FileReaderandAudioFileReader.ACMSTREAMHEADERwas a[StructLayout]class passed to msacm32 by value, and the codec keeps private state in the header's reserved fields betweenacmStreamPrepareHeader,acmStreamConvertandacmStreamUnprepareHeader; the AOT marshaller's per-call copy round-trips only the declared fields, so that state was lost and conversion failed. It is now a struct in a stable unmanaged block, asWAVEHDRalready is (#1425)WaveFormat.MarshalToPtrandWaveFormat.MarshalFromPtrcorrupting anyWaveFormatsubclass under Native AOT — the AOT marshaller drops the inheritedWAVEFORMATEXfields of a class hierarchy, so aWaveFormatExtensiblewas written with its SubFormat GUID over the sample rate. Every remaining site that sized or wrote aWaveFormatwithMarshal.SizeOf/StructureToPtrwas converted too: WASAPI (AudioClient), Media Foundation (MFInitMediaTypeFromWaveFormatEx, reachable fromMediaFoundationResampler/MediaFoundationEncoder), DMO (DmoMediaType.SetWaveFormat,MediaObject) and ACM (AcmStream,AcmDriver) (#1425)WaveFormat.MarshalToPtrnow always allocates at least the18 + cbSizebytes it advertises. AWaveFormatsubclass that declaresextraSizebut doesn't write it inSerializepreviously produced a block shorter than its owncbSize, which a native consumer would read past (#1425)WaveFormat.ToWaveFormatExBytes(), which renders aWaveFormatas a native WAVEFORMATEX byte array.MarshalToPtris now a thin wrapper over it, for callers who need an unmanaged block rather than a buffer they already own (#1425)Serializeoverride toMp3WaveFormat, which previously advertisedcbSize= 12 but wrote none of its 12 MPEGLAYER3WAVEFORMAT extra bytes (#1425)WaveFormatExtraDatanow sizes its buffer fromcbSizeinstead of holding a fixed 100-byte array, so a fmt chunk declaring more than 100 bytes of extra data keeps it rather than having all of it discarded (#482). The fixed size existed only because[MarshalAs(ByValArray, SizeConst = 100)]needed a compile-time length.ExtraDatais now exactlyExtraSizebytes long rather than always 100 (#1432)NAudio.WinMMis now markedIsAotCompatible, and the AOT smoke test covers the winmm WAVEHDR/WAVEFORMATEX paths (#1425)Mp3FileReaderBaseseeking silently restarting playback from the beginning of the file on MP3s with a Xing/Info header — the lazy frame index was gated onIsLengthExact, which such a header sets without any frame having been scanned. Also fixed seeks landing on the wrong frame when the target fell exactly on a frame boundary, and Xing/Info header frames being indexed as audio (shifting every seek in those files ~26 ms early). A 3.0.0 regression (#1419)WdlResamplingSampleProviderlosing samples, and eventually returning 0 permanently, when asked for more output than the source could supply — a 3.0.0 regression that broke the common pattern of reading generously from aBufferedWaveProvider-backed capture chain.WdlResampler.ResampleOutalso no longer drifts in input-driven (feed) mode when handed fewer samples thanResamplePreparerequested (#1412)ds64chunk with a negativedataChunkLength, or aLIST/adtlsub-chunk with a negative size, made the chunk walk advance by zero bytes per iteration and spin at 100% CPU without throwing. Negative and oversized sizes are now rejected where they are read, and an undersizedds64chunk throwsFormatExceptionrather thanArgumentOutOfRangeException(#1428)NAudioConsoleTestWASAPI exclusive-mode quick scan reporting no supported formats at all on devices that support plenty — it built its probe formats with an emptyWAVEFORMATEXTENSIBLEchannel mask, which drivers such as Realtek reject outright. It now probes with the canonical layout for the channel count, the same mask the library's own format adaptation uses (#1431)v3.0.1A patch release. The headline fix is packaging: the
NAudioandNAudio.Extrasmeta-packages now ship a plain
net9.0-windowsleg, so WinForms and WPF projectstargeting
netX.0-windowsget the full Windows stack again.AudioFileReadernow throwsNotSupportedExceptioninstead ofInvalidOperationExceptionwhen the cross-platform build is asked for a format it cannot read, and the messages simply state that rather than suggesting anNAudio.Wasapiinstall that could never have helped (#1407)NAudioandNAudio.Extrasmeta-packages resolving their portablenet9.0asset on projects targeting a plainnetX.0-windowsTFM (the WinForms/WPF template default), which silently dropped the entire Windows stack — noWaveOut, WASAPI, Media Foundation, ASIO, DMO or WinForms types, andAudioFileReaderthrowing "MP3 file reading requires the NAudio.Wasapi package". Both packages now also ship a plainnet9.0-windowsleg (#1407)netX.0-windowsTFM may now seeCA1416warnings when calling WASAPI process-loopback capture. The warning is correct — those callers do need anOperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)guard — and was previously hidden because the only Windows asset available already implied that floor (#1407)AiffFileReaderreporting too long aLengthand throwingIndexOutOfRangeExceptionwhen the SSND chunk declares a non-zero offset (#1405)AiffFileReader.ReadthrowingIndexOutOfRangeExceptionwhen the source stream returns fewer bytes than requested (#1405)v3.0.0NAudio 3 is a major release. The single
NAudioassembly is now split intofocused, independently usable packages; the minimum target framework moves to
net9.0; the core is cross-platform and Native-AOT compatible; and severallarge new subsystems — a cross-platform effects suite, a software sampler, VST 3
hosting, and ALSA and libsndfile backends — join the library.
Upgrading from NAudio 2? Migrating from NAudio 2 to NAudio 3
walks through every breaking change with before/after code. Most apps need only
re-target to
net9.0, renameWaveOutEventtoWaveOut, and adjust customproviders to the new
Span<T>Readsignature.Packages and platform
net9.0— legacy .NET Framework and .NET Standard 2.0 support is droppedNAudiois now a set of focused packages:NAudio.Core,NAudio.Midi,NAudio.WinMM,NAudio.Wasapi,NAudio.Asio,NAudio.Dmo,NAudio.WinForms, plus the newNAudio.Effects(shipped inNAudio.Core),NAudio.Sampler,NAudio.Vst3,NAudio.AlsaandNAudio.SoundFile. TheNAudiometa-package still pulls the Windows stack together, so existing consumers see no change. SeeDocs/Architecture/NAudio3AssemblyLayoutPlan.mdNAudio.Core,NAudio.Midi,NAudio.Wasapi,NAudio.Dmo,NAudio.Sampler,NAudio.SoundFileandNAudio.Alsaare Native-AOT compatible (IsAotCompatible=true), enforced in CI byNAudioAotSmokeTestNAudio.Wasapitargets plainnet9.0(Windows-only at runtime via[SupportedOSPlatform("windows")]), so cross-platform apps can reference it and build on Linux/macOS withoutEnableWindowsTargeting. The WinRT MIDI backend moved toNAudio.Midi, which now dual-targetsnet9.0;net9.0-windows10.0.19041.0(#1384)NAudio.Uappackage is removed — useWasapiPlayerBuilder/WasapiRecorderBuilder.snupkgsymbol packages and an embedded SPDX SBOMNew capabilities
Each new subsystem has its own tutorial or README; only the headline is listed here.
NAudio.Effectsframework:IAudioEffect/EffectSampleProvider/EffectChainwith click-free bypass, dry/wet mix and an optional parameter model, plus a broad effect set (EQ and filtering, dynamics, saturation/lo-fi, delay and modulation, reverb including FFT convolution, pitch shifting, and voice-comms AGC/noise suppression). See Docs/AudioEffects.mdWasapiPlayer/WasapiRecorder, built viaWasapiPlayerBuilder/WasapiRecorderBuilder:IAudioClient3low latency, MMCSS thread priority,IAsyncDisposable, zero-copy buffers, per-process loopback capture, automatic stream routing that follows the default endpoint (#942), acoustic-echo-cancellation reference control (#1223), communications mode, raw mode (#476), and resample-free bit-depth/channel adaptation in exclusive and low-latency modes. See Docs/WasapiPlayer.md and Docs/WasapiRecorder.mdAsioDevicereplacingAsioOut: explicit playback/recording/duplex modes, non-contiguous channels, per-channelSpan<float>callbacks, driver-reset recovery and per-buffer timing.AsioOutis preserved as a facade. See Docs/AsioMigration.mdNAudio.SoundFilepackage: read and write WAV/AIFF/FLAC/Ogg-Vorbis/Opus/MP3 via a system libsndfile on Windows, Linux and macOS (the first cross-platform FLAC/Vorbis/Opus encoder in NAudio). See Docs/CrossPlatformAudioFilesWithSoundFile.md (#1289)NAudio.Alsapackage:AlsaOut(IWavePlayer) andAlsaIn(IWaveIn) plusAlsaDeviceEnumerator, backed bylibasound. See Docs/PlayAudioFileLinuxAlsa.md and Docs/RecordAudioFileLinuxAlsa.md (#1182)NAudio.Vst3package (Windows-only): discover, load and host VST 3 effects and instruments, with parameters, state and.vstpresetpresets, native editor windows, program lists/units, latency compensation, and live/offline MIDI-file playback through the shared MIDI pipeline. See theNAudio.Vst3README andDocs/Architecture/Vst3Hosting.md. VST is a registered trademark of Steinberg Media Technologies GmbHNAudio.Samplerpackage: polyphonic, cross-platform playback of SoundFont (.sf2) and SFZ instruments and single-sample instruments, rendered as anISampleProvider(SF2 modulator engine, DAHDSR envelopes, LFOs, modulated filters, reverb/chorus sends, voice stealing, choke groups). See Docs/Sampler.mdMMDeviceEnumerator.CreateNotificationClient()returns anMMDeviceNotificationClientexposingDeviceStateChanged,DeviceAdded,DeviceRemoved,DefaultDeviceChangedandPropertyValueChangedas ordinary events, so callers no longer implement a COM interface or manage CCW lifetime (#1395)NAudio.Midi's portable leg is now cross-platform; new WinRTWinRTMidiIn/WinRTMidiOutand backend-agnosticIMidiInput/IMidiOutput; and a newIMidiInstrumentseam (MidiFileSequence/SequencedMidiPlayer/OfflineMidiRenderer/LiveMidiInstrument) giving an end-to-end MIDI-file → audio pipeline that drives the sampler or a hosted VST 3 instrument.MidiFilealso reads RIFF-RMID (.rmi) files (#1236) andMidiFile.Exportgains aStreamoverload, thanks to @MaKiPL (#499)NAudio.Sequencingnamespace inNAudio.Core(tempo and time-signature maps, transport,EventTimeline, swing, and a sample-accurate per-buffer dispatcher) underpinning MIDI-file playback and the sampler. SeeDocs/Architecture/Sequencing.mdNAudio.ExtrashelpersCaptureMixerInputandRealtimeCaptureMixercapture and live-mix several sources with different sample rates and channel counts (e.g. microphone + system loopback) into one wall-clock-paced stream. See Docs/MixMicrophoneAndSystemAudio.md (#761)AudioFileReaderandCachedSoundgainStreamconstructors, detecting WAV/AIFF from the contents and delegating anything else to Media Foundation, so embedded or in-memory audio plays without a temp file (#927, #963).StreamMediaFoundationReaderalso gains optionalcontentType/originNamehints and Ogg container sniffing (#952)WaveFileReader.Chunkswith anIWaveChunkInterpreter<T>extension point and built-in interpreters for cue lists, BWFbext(BroadcastExtension, now read and write, with v2 loudness) and LIST/INFO (InfoMetadata);WaveFileWritergainsAddCue,WriteCueList,WriteBroadcastExtension, arbitraryAddChunkand RF64 promotion viaWaveFileWriterOptions(#1013)IWaveLatencyinterface inNAudio.CoreexposingAverageLatency/CurrentLatencyfor A/V sync and drift detection, implemented across the playback and capture classes (#601)ChannelMixerSampleProviderwith ready-madeChannelMixMatrixroutings, thanks to @antiduh (#982); a newFftProcessor;Span<T>overloads across the codec/DSP surface; reusable building blocks (EnvelopeFollower,DelayLine,Lfo,Oversampler,LinkwitzRileyCrossover,PartitionedConvolver, …); plus improvements toSmbPitchShiftingSampleProvider(#922),AdsrSampleProvider(#671) andFadeInOutSampleProvider(#1136)ValidBitsPerSample/ChannelMask, and a[Flags] Speakersenum for building channel masks (#1325)AudioSessionControl.SetDuckingPreference(bool)(#760);WasapiPlayer/WasapiRecorderexposeDeviceIdandDeviceFriendlyNamefor the active endpoint (#681)Breaking changes
The full upgrade walkthrough — every breaking change with before/after code — is
in Migrating from NAudio 2 to NAudio 3. The
highest-impact changes:
net9.0(legacy .NET Framework / .NET Standard 2.0 dropped)IWaveProvider.Read/ISampleProvider.Readnow take a singleSpan<byte>/Span<float>(was buffer/offset/count) — callers migrate viasource.Read(buffer.AsSpan(offset, count)); implementations override the span methodWaveOutEventis renamed toWaveOutandWaveInEventtoWaveIn(the old names remain as[Obsolete]subclasses).WaveOut/WaveInnow default to event-driven callbacks; the window-based variants areWaveOutWindow/WaveInWindowinNAudio.WinForms, andWaveCallbackInfo/WaveCallbackStrategyare removedWaveOut.DesiredLatencyis replaced byBufferMilliseconds, which sizes each individual buffer rather than the total across all of them.WaveIn's default record format changes from 8 kHz mono to 44.1 kHz stereoWasapiOut,WasapiCaptureandWasapiLoopbackCaptureare[Obsolete]in favour ofWasapiPlayer/WasapiRecorder(the legacy types still ship and work);WasapiOut's embedded exclusive-mode resampler was removed, though it now adapts bit depth and channels, so only a sample-rate mismatch requires upstream resamplingIMMNotificationClientinterface andMMDeviceEnumerator.RegisterEndpointNotificationCallback/UnregisterEndpointNotificationCallbackare now internal — useCreateNotificationClient()and its events. The raw Core Audio and Media Foundation COM interfaces are likewise internal, andPropertyStoreProperty.Valueis nowobjectrather thanPropVariantwinmmtypes toNAudio.WinMM; the DMO/DirectSound types into the newNAudio.Dmopackage; plus smaller moves (AudioVolumeLevel,CaptureState,DmoMp3FrameDecompressor). Meta-package consumers are unaffected[Obsolete]throughout NAudio 2, each with a direct replacement on the same class:WaveFileWriter.WriteData(both overloads →Write/WriteSamples),WaveFileReader.TryReadFloat(→ReadNextSampleFrame, which doesn't drop channels on stereo),AcmStream.Convert(int)(→ the overload returningsourceBytesConverted),WaveFormatConversionStream.SourceToDest/DestToSource(unreliable estimates with no replacement — usePosition/Length), andAsioAudioAvailableEventArgs.GetAsInterleavedSamples()(→ the overload taking a reusable array, avoiding an allocation per ASIO callback).AsioOut.Volumeis kept despite its obsolete notice — it's anIWavePlayerinterface memberAudioMediaSubtypesmoved from theNAudio.Dmonamespace toNAudio.Wave. It ships inNAudio.Core, so cross-platform code previously neededusing NAudio.Dmo;to name the media subtype GUIDs even on Linux without the DMO package; it now sits alongsideWaveFormatExtensibleSimpleCompressorStream,ImpulseResponseConvolutionandNAudio.Extras.Equalizerwere removed — superseded byNAudio.Effects(CompressorEffect,ConvolutionReverbEffect,Equalizer)CueWaveFileReader,CueWaveFileWriter,BwfWriterandBextChunkInfowere removed, along withWaveFileReader.ExtraChunks/GetChunkData— the unified chunk model onWaveFileReader.ChunksandWaveFileWriterreplaces themMixingWaveProvider32was removed — it was an untested float-only mixer that offered nothing overMixingSampleProvider.ImaAdpcmWaveFormatwas removed — it was a non-functional stub used nowhereWaveFileWriter/AiffFileWriterno longer dispose a caller-supplied stream, matching the readers' ownership rule; only the filename constructor owns and closes the file.IgnoreDisposeStreamis no longer needed when writing to a stream you want to keep (#1040)MediaFoundationTransform,MediaFoundationEncoderandMediaBuffer, andMediaTypeis nowIDisposable— callDispose()CoreAudioException/MediaFoundationException, both subclasses ofCOMException, so existingcatch (COMException)keeps workingNotable bug fixes
The sampler, effects and WASAPI subsystems also saw extensive correctness work during
development. The full per-PR list is on the GitHub Release; the fixes most likely to
affect existing NAudio 2 code are:
WaveFileWriter.WriteSample/WriteSamples: fixed 32-bitWaveFormatExtensibleoutput writing near-silence or corrupt data — both paths ignored the declared SubFormat (#651)ToSampleProvider()now handlesWAVE_FORMAT_EXTENSIBLEPCM and IEEE float sources (e.g. multichannel or >16-bit WAV) instead of throwingUnsupported source encoding(#639);AudioFileReaderno longer routes such WAVs through an unnecessary ACM conversion streamWaveFileReader/AiffFileReader: malformed headers declaringBlockAlign=0throwInvalidDataExceptionfrom the constructor rather thanDivideByZeroExceptionlater (#1254); an oversizeddatachunk length is clamped to the bytes actually present (#1090); an oversizedfmtcbSizeno longer throws (#482)AiffFileReader/AiffFileWriter: 8-bit PCM is now read and written as signed two's-complement per the AIFF spec, fixing DC-shifted/garbled playback (#1178)BlockAlignReductionStream.Read: a read larger than the 4-second internal buffer no longer silently truncates the stream — e.g. converting a non-PCM WAV viaAudioFileReader(#1022)WaveOut: fixed a race where stopping or disposing faster than the buffer latency could throw aNullReferenceExceptionviaPlaybackStopped(#804);DirectSoundOut: fixed a startup race that could collapse playback immediately (#759)WasapiRecorder,WasapiCaptureandWasapiLoopbackCapture: a capture device removed mid-recording no longer crashes the process —RecordingStoppedalways fires with the originating exception (#672). Silent packets no longer leak the uninitialised WASAPI buffer as a burst of stale audioRegisterEndpointNotificationCallback— Windows does not AddRef the client, so the CCW was being collected (#1394)AudioClient.Disposeis now idempotent and safe against concurrent disposal (#1183);MMDevice.Disposereleases the property store deterministically (#1145);AudioSessionControlsupports multiple event clients without leaking (#1263);AudioEndpointVolume.OnVolumeNotificationreports the correct channel (#351)AcmInterop: serialised allmsacm32P/Invokes process-wide, fixing process-killing access violations under concurrent ACM useResamplerDmoStream: fixed an infinite loop onReadafter seeking and the loss of the resampler tail at end-of-stream (#607, #608);LoopStream.Readno longer spins at 100% CPU when the source can't satisfy a read (#1338)FastFourierTransform.FFT: fixed drifting high-frequency bins at large FFT sizes by carrying the twiddle-factor recurrence in double precision (#520)WdlResampler: backported upstream Cockos WDL fixes, including reinterleaving on channel-count change and denormal flushing in the IIR feedback path (#800)WaveViewer: fixed rendering upside-down (#801, #818) and now renders any source format viaToSampleProvider()(#564)Mp3FileReader: fixed false sample-rate-change errors near end of file, and more robust frame parsing against album art and trailing metadata;MidiFilepreserves running status across meta eventsWaveFormat.Serialize: PCM formats now write the canonical 16-bytefmtchunk (#934, #1098)Demos and tooling
NAudioDemoandNAudioWpfDemowere substantially reworked against the new APIs, including a rebuilt WASAPI Recorder panel driven byWasapiRecorderBuilder, transport/volume/position controls across the playback panels, and a Graphic EQ panel onNAudio.EffectsConcentus, replacing the vendored NSpeex binary), and gained a tutorialDocs/and the source XML comments. Every package'sprojectUrland README now point at it; nuget.org still links the GitHub repo via the package'srepositorymetadatav2.4.0: NAudio 2.4.0DeviceCountandGetCapabilitiesstatic methods toWaveOutEventso outputdevices can be enumerated without referencing
NAudio.WinForms(#1331, #777)formatted class parameters as COM interfaces; they are now explicitly marked
[MarshalAs(UnmanagedType.LPStruct)](#1414)Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate CLI.
bab03e7fc3to1d6995fb9fWeekly high-risk assessment
NAudio 3 is a major runtime/audio migration: it raises framework requirements, splits packages, changes provider reads and stream ownership, and reorganizes Windows playback/capture APIs. We are confirmed affected: both exact-head runs restore, then fail compilation because
WaveOutEventis unavailable for the neutral target; tests never run. NAudio also powers microphone/loopback capture, device selection, WAV handling, transcription helpers, and sample playback. Do not merge this dependency-only PR. Implement a deliberate migration, require green builds/tests for both targets, and perform attended Windows recording/playback/device-recovery/transcription checks before an explicit manual merge outside automations. Rollback is 2.3.0; no data migration is involved.1d6995fb9fto9bb9d2f2caWeekly high-risk status at
9bb9d2f2ca5d27a39c360b273a9e0c4bc8cefa3: NAudio 3 is not source-compatible here. Exact-head CI fails before tests because commonnet10.0code still usesWaveOutEvent, while upstream renamed/split APIs and changed buffer/stream behavior. We are directly affected across sample playback, microphone/WASAPI loopback capture, device enumeration, recording, and transcription helpers. The immediate risk is blocking the next application publish; further risk remains in real Windows audio behavior after compilation is fixed. Recommendation: do not merge. Rebase, implement an explicit NAudio 3 migration with green builds for both targets, then perform attended playback/recording/device-recovery/transcription checks and merge manually outside automations.9bb9d2f2cato1def70535c1def70535cto8f50715138Weekly recheck — high risk; NAudio3 migration required
Reviewed
8f507151387f9312dc7a8e96bfa570fc3e8ff83b, NAudio2.3.0 →3.1.0. Runs3442 and 3443 restore then fail CS0246 at WorkflowRulesEditorSamplePlaybackQueue.cs:85: WaveOutEvent is unavailable on net10.0. Tests never execute.Affected: proven build breakage, likely native audio exposure. The application uses real microphone/WASAPI loopback capture, device recovery, playback, WAV recording and speaker snippets. Migration guidance changes packaging/provider reads/packet delivery/stream ownership. WaveOutEvent remains an obsolete Windows alias; it is not universally removed, and renaming alone is not a sufficient fix. New3.1 marshalling/AOT/resampling changes have no direct matched callsites in committed application code.
The current test project targets net10.0: a win-x64 RID and Windows-labeled step do not establish a Windows-specific TFM build. Deliberately migrate, build both target frameworks, run tests, and perform attended capture/playback/device-recovery/transcription checks before explicitly merging outside automations. Rebase against current main before renewed validation; rebase alone cannot fix this incompatibility. Rollback restores2.3.0/prior app while idle, with no identified data migration.
8f50715138toe23d04a38cEdited/Blocked Notification
Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.
You can manually request rebase by checking the rebase/retry box above.
⚠️ Warning: custom changes will be lost.
Weekly status — HIGH at
d93d758a8f96fdddb43d46bc8f30f43da65e7108: NAudio2.3.0→3.1.0 still fails before tests. Exact-head3714 confirms CS0246 missing WaveOutEvent at WorkflowRulesEditorSamplePlaybackQueue.cs:85 on net10.0. Existing migration assessment stands. Branch contains Manuel’s main merge; Renovate warns regeneration discards custom changes, so preserve it. Implement a deliberate migration, validate both target frameworks and attended Windows capture/playback/device recovery/transcription, then explicitly merge outside automations. Rollback restores2.3.0/prior complete publish while idle; no known data migration.Attended remediation at exact head
fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5: NAudio 3.1's playback dependency is Windows-only. Sample playback and DI now use the Windows implementation only for the Windows target; the neutral build returns an actionable unsupported-build result and honors cancellation. Added a public DI/queue behavior regression plus the matching accepted-spec/docs addendum. Local full suite: 521/521 passed, both target frameworks built, strict meeting-session spec validation passed. Native Windows NAudio 3.1 microphone/loopback capture, silent playback, and clean stop/drain passed. Independent review found no actionable defect.Resumed 2026-09-17: exact-head push/PR checks 3821 and 3822 are now green. Leave open only for the coordinated merge order: this tested head includes #49, whose outage-failed checks are being rerun. Merge #49 first once its exact-head checks pass, then this PR, followed by #51 → #48 → #53. No forced merge or status override. Rollback is the preceding source/package commit; no data migration.
Completed attended review on 2026-09-18: merged exact head
fbd5a0852fc7ac1bbc5d50ec2c337af6a2b371d5after the current push and PR checks were green. Separate safe preflight and execute verified the exact head and the merged/closed readback; no force or status override was used.521/521 local tests, both target frameworks, strict spec validation, independent review, and native NAudio 3.1 capture/playback/stop checks passed. Windows-only sample playback now has the tested neutral-build fallback.
The coordinated stack landed in order #49 → #45 → #51 → #48 → #53. Main is now
e011e36ef7febc899c87604c0797572dd7402b99; its Git tree exactly matches the final reviewed and testedb249e5d97716f6f277fbad92df8c99745a1c54c6tree. The new main CI run 3900 is queued at this comment's timestamp. Local checkout is clean and synced. No workstation application restart or deployment was performed.