# WaveNodeRealTime silences a clip's extra channels after its source file is changed for a wider one

**URL:** <https://forum.juce.com/t/wavenoderealtime-silences-a-clips-extra-channels-after-its-source-file-is-changed-for-a-wider-one/70045>\
**Category:** Tracktion Engine\
**Created:** [November 29, 2026, 8:36pm UTC](https://forum.juce.com/t/wavenoderealtime-silences-a-clips-extra-channels-after-its-source-file-is-changed-for-a-wider-one/70045 "2026-11-29T20:36:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![p-o-b](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@p-o-b](https://forum.juce.com/u/p-o-b)\
**Post date:** [November 29, 2026, 8:36pm UTC](https://forum.juce.com/t/wavenoderealtime-silences-a-clips-extra-channels-after-its-source-file-is-changed-for-a-wider-one/70045/1 "2026-11-29T20:36:16Z")

</div>

**Tracktion Engine** `develop` at `a5e44996f5f0`, `modules/tracktion_engine/playback/graph/tracktion_WaveNode.cpp`.

**## What happens**

A launcher clip is created on a 2-channel file, then its source is changed to a 6-channel file (`clip.getSourceFileReference().setToFile (...)`). The graph is rebuilt and the new `WaveNodeRealTime` is 6 channels wide, but only the first two carry sound. Channels 3 to 6 are silent.

**## Why**

```cpp
`WaveNodeRealTime::replaceStateIfPossible (WaveNodeRealTime& other)` // takes the old node's per-channel state whatever its size:

// This will be used to fade out the last block if the state hash is different

channelState = other.channelState;

```

The old node played a 2-channel file, so `channelState` holds two samples. `processSection`

then clears every channel that has no entry in it:

```cpp
// Crossfade if a fade needs to be applied

jassert (numChannels <= (choc::buffer::ChannelCount) channelState->size()); // this should always have been made big enough

for (choc::buffer::ChannelCount channel = 0; channel < numChannels; ++channel)

{
if (channel < (choc::buffer::ChannelCount) channelState->size())

{
    ...
}

else
{
    destBuffer.getChannel (channel).clear();
}

}

```

The `jassert` fires in a debug build. `buildAudioReaderGraph` only makes a new `channelState` when there is none, so the short one stays for the life of the node and is handed on at every later rebuild.

`WaveNode` (the non-real-time one) already guards the same hand-over:

```cpp

if (other.channelState->size() == numChannelsToUse)

channelState = other.channelState;

```

**## Fix**

Take the old state only when it has an entry for every channel the new node plays. Otherwise leave it null and `buildAudioReaderGraph` makes one of the right size:

```cpp

if (other.channelState != nullptr

 && other.channelState->size() >= (size_t) std::max (channelsToUse.getNumChannels(), destChannels.getNumChannels()))

channelState = other.channelState;

```

The cost is one transition without the last-sample fade, when a clip’s file changes for a wider one.

**## How to reproduce**

1. Build an Edit with one audio track and a clip slot holding a wave clip on a 2-channel WAV.

2. Start playback so the graph is built.

3. Point the clip at a 6-channel WAV whose channels each hold a different constant.

4. Launch the clip and read the track’s buffer before any plugin narrows it (a plugin whose

`getNumOutputChannelsGivenInputs (n)` answers `n` sees all six channels).

1. Channels 1 and 2 hold their constants; channels 3 to 6 are zero.

With the fix, all six hold their constants.

## Related, in `tracktion_AudioFileCache.cpp`

`AudioFileCache::Reader::readSamples` has `static constexpr int maxNumChannels = 32` and clears the destination for any source channel at or above it, with nothing reported. A 36-channel file (fifth-order Ambisonics) plays its first 32 channels. The array is of pointers, so raising it to 64 costs 512 bytes of stack.
