Some ambiguities in the CLAP standard to discuss #414
Replies: 8 comments 51 replies
-
So my thoughts. Again these aren't definitive just reactions. I'm happy to take the result of this convo with our collaborators and turn it into a set of PRs. Item 1 - what's the spec / standardThe standard is the c code. The documentation of the standard is the comments in the c code. We try to make the comments unambiguous and useful. But the only documents that exist are the code and comments in headers, so the code comments need to iterate towards unambiguous. Item 2 - sleepI propose
Item 3 - Thread SafeTo date I have interpreted this as (1) can be called from any thread (2) including the audio thread. And the audio thread is realtime safe. de-facto hosts generally implement these as something akin to toggling a We should update thread.h to make this clear. Item 4
|
Beta Was this translation helpful? Give feedback.
-
To be honest I think producing a real technical specification defining the CLAP standard, in addition to the existing documentation in the C headers, is not a particularly monumental task, so once I am further along with my support for CLAP in my DAW and have more knowledge under my belt I may try to pursue that (perhaps as one giant markdown file.) I think the only really complex part of the API right now is the params extension. On Discord someone mentioned there were concerns about the difficulty of keeping that kind of thing in sync when changes are made but I think it is worth it. I'm still not clear on how much work has already been done towards something like that, whether there is anything started and then abandoned. |
Beta Was this translation helpful? Give feedback.
-
Regarding
This goes for plugin and host functions. This is also being true in a offline rendering context - there is no reason why this should not be behave the same. |
Beta Was this translation helpful? Give feedback.
-
Well gosh I just went and read the doc for [plugin|host] extension say
that raises a few questions and i'd be interested in @defiantnerd @abique and others view
Since this function almost always just returns a static object reference, realtime safe (implied in thread safe) is not a high bar. But we should make sure it is what we want. |
Beta Was this translation helpful? Give feedback.
-
Some more answered and unanswered questions from my excursion today. clap_process nullability
I assume the answer in both cases is "yes" but it is not currently specified unless I missed it. clap.tail extensionThere is currently no explanation of what "tail" is or what the host is supposed to do in response to Are plugins allowed to cancel the tail (by returning something other than
|
Beta Was this translation helpful? Give feedback.
-
Further clarification on
|
Beta Was this translation helpful? Give feedback.
-
More
|
Beta Was this translation helpful? Give feedback.
-
What is a .clap file?This is pretty important but isn't specified anywhere as far as I know. I don't know if there is anything I am missing or misunderstanding but in my DAW I am going to be making the following assumptions:
|
Beta Was this translation helpful? Give feedback.
-
I'm working on adding CLAP support to my DAW. I am quite early in development and my knowledge of CLAP is still limited. This is a bunch of things that I have run into so far that I think are ambiguous, open to interpretation, or not specified. Most of these discussions started on Discord and we felt it would be a good idea to bring it here so that they can be discussed in a more structured way. Since I am so new to CLAP some of my comments may very well be based on misinterpretations, misunderstandings, ignorance or just basic stupidity, so be patient with me.
ITEM 1 - Documentation vs Standard
This first item is a more general one but it has an effect on everything else here.
What are the comments in the C headers? Are they:
Since I'm not sure the answer to this yet I will just refer to them as "C header comments".
A distinction to keep in mind is that in documentation, ambiguous and badly-defined language can often be very helpful. The writer can draw on analogies and existing concepts to help the reader understand the API. Whereas in a standard, language like that is bad. It is OK to give suggestions for best practices, but details shouldn't be open to interpretation. So whatever the C header comments are, they cannot be both documentation, and also a standard.
ITEM 2 - SLEEP 😴
The word "sleep" is used several times in the C header comments, but is not explicitly defined anywhere. There is ambiguity around what it means for a plugin to "fall asleep" and "wake up". It is ambiguous whether the state of "asleep" is:
CLAP_PROCESS_SLEEP
fromprocess
, or the host callingstop_processing
), or,process.h - Plugins can return
CLAP_PROCESS_SLEEP
fromprocess
.processing
, or until the next call tostart_processing
, or neither?stop_processing
in response toCLAP_PROCESS_SLEEP
, or is it merely a suggestion?plugin.h - "Call
stop_processing
before sending the plugin to sleep."This language suggests that:
stop_processing
, the plugin is not considered to be logically "asleep"processing
is no longer being called at regular intervals."start_processing
,stop_processing
andprocessing
The C header comments imply to me that
start_processing
should be called beforeprocessing
, and when the host no longer wants to callingprocessing
at regular intervals, it should callstop_processing
. So a potential API trace may look something like:However, since the term "sleep" is left unspecified, a fair interpretation of the C header comments may lead to something more like:
i.e. the host developer simply wraps any call to
processing
in astart_processing/stop_processing
pair.It is ambiguous whether this usage of the API would be good or bad, or neither good nor bad. I can't suggest how to improve the C header comments around this because I don't actually know what the point is of the
start_processing
andstop_processing
functions, or what the plugins developers are expected to do in these calls. (In the plugins in the clap-plugins repository, these functions are no-ops outside of validation checks.)My general proposal to consider is to remove the words "sleep" and "wake" entirely from the standard, and reserve those concepts for the documentation. This is why I wanted to start the discussion with the distinction between "standard" and "documentation". These words are potentially helpful analogies to use in the documentation. In the standard they are open to interpretation, unless they are explicitly defined ahead of their usage.
If the concept of "sleep" is to be included in the standard then a proposed definition of "asleep" might be something like:
That is probably still ambiguous so could be improved further. Again I am not a CLAP expert so I'm probably not the one who should be writing this kind of thing yet. Personally I can't see what purpose a definition like this would actually serve in the standard which is why I instead propose removing the word "sleep" entirely, and just being explicit about when and where the functions
start_processing
andstop_processing
can and should be called.ITEM 3 -
thread-safe
andrealtime-safe
The
[thread-safe]
tag is used to denote functions that are safe to call from any thread. "Safe" is ambiguous here. Is it safe to call from a realtime processing context, or merely safe from data races?If
thread-safe
also means "realtime-safe", that should be stated somewhere.If
thread-safe
does not necessarily mean "realtime-safe", then is a new tag, perhaps something like[realtime-safe]
, required? Or is this information better expressed some other way?ITEM 4 -
clap_host
functionsAre plugins allowed to call
get_extension
duringprocess
?Currently unspecified.
Are plugins allowed to call
request_restart
if they are not currently active?Currently unspecified.
Proposed answer from baconpaul via Discord:
Are plugins allowed to call
request_process
if they are not already processing?Currently unspecified.
Proposed answer from baconpaul via Discord:
Beta Was this translation helpful? Give feedback.
All reactions