7
44
Fork
You've already forked nice-plug
22

Add Plugin.track_info_updated #57

Merged
BillyDM merged 3 commits from AlexCharlton/nice-plug:track-names into main 2026年06月30日 23:46:58 +02:00
Contributor
Copy link

This adds a new Plugin.track_info_updated method, enabling the user to get the name and color of the track associated with the Plugin. These two attributes were selected as they are both present in the data provided to VST3's IInfoListener and CLAP's CLAP_EXT_TRACK_INFO.

VST3 support was tested on Ableton, Bitwig, Cubase, FL Studio, and Reaper. Of these, only FL Studio does not call setChannelContextInfos, and so the plugin gets no TrackInfo in this case.

CLAP support was tested in Bitwig. It appears that version 7.68 of Reaper was the first to support the CLAP_EXT_TRACK_INFO, but my version of Reaper predates this.

Track info display was added into the gain_egui example.

This adds a new `Plugin.track_info_updated` method, enabling the user to get the name and color of the track associated with the Plugin. These two attributes were selected as they are both present in the data provided to VST3's `IInfoListener` and CLAP's `CLAP_EXT_TRACK_INFO`. VST3 support was tested on Ableton, Bitwig, Cubase, FL Studio, and Reaper. Of these, only FL Studio does not call `setChannelContextInfos`, and so the plugin gets no `TrackInfo` in this case. CLAP support was tested in Bitwig. It appears that version 7.68 of Reaper was the first to support the `CLAP_EXT_TRACK_INFO`, but my version of Reaper predates this. Track info display was added into the gain_egui example.
Add Plugin.track_info_updated
Some checks are pending
ci/woodpecker/pr/test Pipeline is pending approval
7081c2e596
@ -1852,0 +1886,4 @@
letmutcolor=current_track_info.color();
ifclap_info.flags&CLAP_TRACK_INFO_HAS_TRACK_NAME!=0{
name=unsafe{CStr::from_ptr(clap_info.name.as_ptr())}
Owner
Copy link

There is an edge case where this can cause UB if the host filled in exactly CLAP_NAME_SIZE characters in the name array, causing Cstr::from_ptr to read out of bounds.

I'm not sure what the proper way to do this is, but a quick let has_null_bit = clap_info.name.iter().any(|c| c == 0); would probably suffice (and just ignore strings that are exactly CLAP_NAME_SIZE characters long).

There is an edge case where this can cause UB if the host filled in exactly `CLAP_NAME_SIZE` characters in the `name` array, causing `Cstr::from_ptr` to read out of bounds. I'm not sure what the proper way to do this is, but a quick `let has_null_bit = clap_info.name.iter().any(|c| c == 0);` would probably suffice (and just ignore strings that are exactly `CLAP_NAME_SIZE` characters long).
Author
Contributor
Copy link

Good thinking. Updated to use from_bytes_until_nul which performs the null check.

Good thinking. Updated to use `from_bytes_until_nul` which performs the null check.
AlexCharlton marked this conversation as resolved
@ -1952,0 +1987,4 @@
)
}==kResultOk
&&letOk(parsed_name)=
unsafe{U16CStr::from_ptr_str(name_buf.as_ptr()as*constu16).to_string()}
Owner
Copy link

Same thing here, make sure that there is actually a null bit in the string first.

Same thing here, make sure that there is actually a null bit in the string first.
AlexCharlton marked this conversation as resolved
Ensure name is null terminated
Some checks failed
ci/woodpecker/pr/test Pipeline failed
3416ffed13
fix clippy warnings, use to_string_lossy in VST3 setChannelContextInfos
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
fb964c0d1f

Thanks!

Thanks!
Author
Contributor
Copy link

Thank you, @BillyDM for your stewardship!

Thank _you_, @BillyDM for your stewardship!
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RustAudio/nice-plug!57
Reference in a new issue
RustAudio/nice-plug
No description provided.
Delete branch "AlexCharlton/nice-plug:track-names"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?