Skip to content

Feature/track context info#260

Open
th3godfather wants to merge 2 commits intorobbert-vdh:masterfrom
kaikenlabs:feature/track-context-info
Open

Feature/track context info#260
th3godfather wants to merge 2 commits intorobbert-vdh:masterfrom
kaikenlabs:feature/track-context-info

Conversation

@th3godfather
Copy link

Summary

This PR adds a TrackInfo API that exposes track name, color, channel count, and track type to plugins. Implements the backing host integrations for both CLAP (clap.track-info extension) and VST3 (IInfoListener::setChannelContextInfos).

Resolves #119.

New API

// Available from InitContext, ProcessContext, and GuiContext:
if let Some(info) = context.track_info() {
    let name = info.name.as_deref().unwrap_or("unnamed");
    let color = info.color;                // Option<TrackColor>
    let channels = info.audio_channel_count; // Option<u32> (CLAP only)
    let track_type = info.track_type;      // TrackType enum (CLAP only)
}

New types (re-exported via nih_plug::prelude)

  • TrackInfo — name, color, channel count, track type
  • TrackColor — RGBA (u8 per channel)
  • TrackType — Regular | Return | Bus | Master

Implementation details

CLAP

  • Uses clap.track-info extension with CLAP_EXT_TRACK_INFO_COMPAT fallback for older hosts
  • Pull model: plugin queries host via clap_host_track_info::get()
  • changed callback triggers re-query
  • Provides all fields including channel count and track type
  • Safe u32::try_from() cast for audio_channel_count (guards against negative sentinels)

VST3

  • Implements IInfoListener (added to #[VST3(implements(...))])
  • Push model: host calls set_channel_context_infos(IAttributeList*)
  • Reads kChannelNameKey (UTF-16) and kChannelColorKey (ARGB packed u32)
  • Merges partial updates rather than replacing — Ableton Live sends name and color in separate calls
  • Cannot provide channel count or track type (VST3 API limitation)
  • Null-termination guard on name buffer for defensive hardening

Standalone

  • Returns None for all contexts (no host to query)

Host compatibility

Verified working with REAPER (VST3 track name confirmed).
VST3 IInfoListener known to be supported by Cubase, Nuendo, REAPER, Ableton Live, Bitwig, Studio One, FL Studio, Digital Performer, and Cakewalk.

Important note

Track info arrives after initialize(). Both VST3 and CLAP hosts push/provide track info after the plugin is fully set up. Plugins should query from process() or the GUI, not rely on it during init.

Test plan

  • cargo build (default features)
  • cargo build --no-default-features
  • cargo test --features "standalone,zstd" — all tests pass
  • cargo clippy — no new warnings
  • Manual: REAPER VST3 shows track name "Drums"
  • Manual: REAPER CLAP shows track info

Juan Pablo and others added 2 commits March 3, 2026 16:48
Expose track/channel context information to plugins through the existing
context traits (InitContext, ProcessContext, GuiContext). This adds a new
TrackInfo struct with optional name, color, audio channel count, and
track type fields.

CLAP: Uses the track-info extension (with compat fallback) to query
track name, color, channel count, and type (master/return/bus).

VST3: Implements IInfoListener to receive channel context updates from
the host, with partial-update merging for hosts like Ableton that send
name and color in separate calls.

Standalone: Returns None for all track info queries.

Closes robbert-vdh#119

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use u32::try_from() instead of `as u32` for CLAP audio_channel_count
  to avoid wrapping negative sentinel values from buggy hosts
- Add Eq and Default derives to TrackInfo
- Import TrackType in VST3 wrapper instead of using fully qualified path
- Add null-termination guard for VST3 name buffer hardening

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track context information for VST3 and CLAP

1 participant