CLAP: The New Audio Plug-in Standard (by U-he, Bitwig and others)
- KVRAF
- 3417 posts since 28 Jan, 2006 from Phoenix, AZ
Does CLAP have a "default interface" thing like VST? And if so... uhh... how do you make a parameter in C? Looking through the code, I can't find a "first step" kind of project, taking the `plugin-template.c` and then adding one parameter to, for example, control gain. Is there something in the repository like this?
- KVRAF
- 7938 posts since 12 Feb, 2006 from Helsinki, Finland
It does not avoid rounding errors in general, it just makes them independent of the magnitude of the integer part. In fact, it results in more rounding errors than doubles when the integer part fits to less than ~22 bits (=less than 4 million beats/seconds).robbert-vdh wrote: ↑Mon Jul 25, 2022 9:51 pmThe conversion factors are in *fixedpoint.h. They're fixed-point numbers to avoid rounding errors.S0lo wrote: ↑Mon Jul 25, 2022 9:50 pm So I was trying to map some VST timeinfo/transport into clap and vise versa,
I noticed that clap_beattime and clap_sectime are defined as int64_t. Shouldn't these be double/float. I guess there has to be some sort of scaling? or these count in nano seconds? nano beats ?
The beattime increases by tempo/(60*samplerate) per frame and sectime increases by 1/samplerate per frame. For almost all values of tempo, this will not have a finite fixed (or floating) point representation (since 60=3*5*2 and samplerate usually has plenty of prime factors too), so practically speaking even if you had the exact time for sample 0, you can't really compute the exact time for sample 1.
There might be some special cases where fixed point (if you're actually computing in fixed point) would allow you to be slightly more consistent, but unless you specify how every single computation involving these values should be done by both host and plugin, there's basically no obvious advantage to fixed point that I can see... not that it really matters one way or another, because it's not exactly hard to convert back and forth.
- KVRian
- 1260 posts since 31 Dec, 2008
hmm, I'm assuming significant errors may only arise from accumulative addition over a long track?mystran wrote: ↑Tue Jul 26, 2022 4:56 amIt does not avoid rounding errors in general, it just makes them independent of the magnitude of the integer part. In fact, it results in more rounding errors than doubles when the integer part fits to less than ~22 bits (=less than 4 million beats/seconds).robbert-vdh wrote: ↑Mon Jul 25, 2022 9:51 pmThe conversion factors are in *fixedpoint.h. They're fixed-point numbers to avoid rounding errors.S0lo wrote: ↑Mon Jul 25, 2022 9:50 pm So I was trying to map some VST timeinfo/transport into clap and vise versa,
I noticed that clap_beattime and clap_sectime are defined as int64_t. Shouldn't these be double/float. I guess there has to be some sort of scaling? or these count in nano seconds? nano beats ?
The beattime increases by tempo/(60*samplerate) per frame and sectime increases by 1/samplerate per frame. For almost all values of tempo, this will not have a finite fixed (or floating) point representation (since 60=3*5*2 and samplerate usually has plenty of prime factors too), so practically speaking even if you had the exact time for sample 0, you can't really compute the exact time for sample 1.
There might be some special cases where fixed point (if you're actually computing in fixed point) would allow you to be slightly more consistent, but unless you specify how every single computation involving these values should be done by both host and plugin, there's basically no obvious advantage to fixed point that I can see... not that it really matters one way or another, because it's not exactly hard to convert back and forth.
What if we assume a different fixed point counter (call it beat_counter) that counts in integers of beattime. So when beat_counter=1 thats a beattime of tempo/(60*samplerate). When beat_counter=2 thats 2*tempo/(60*samplerate). I think, this would handle whatever tempo and irrationality errors we have. So whenever we want an actual value, beattime = beat_counter * tempo/(60*samplerate). Edit: Nah, won't work for tempo changes.
Last edited by S0lo on Tue Jul 26, 2022 11:44 am, edited 1 time in total.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.
Advice is heavy. So don’t send it like a mountain.
- KVRAF
- 7938 posts since 12 Feb, 2006 from Helsinki, Finland
The fixed point representation in CLAP starts to become more accurate when your track is over 2-3 weeks long (depending a bit on tempo).
This doesn't work because tempo in general is not a constant, which is the whole reason beat_time (aka. ppqTime) exists in the first place. It measures musical time, not actual real-time.What if we assume a different fixed point counter (call it beat_counter) that counts in integers of beattime. So when beat_counter=1 thats a beattime of tempo/(60*samplerate). When beat_counter=2 thats 2*tempo/(60*samplerate). I think, this would handle whatever tempo and irrationality errors we have. So whenever we want an actual value, beattime = beat_counter * tempo/(60*samplerate)
What you could do is compute in rational arithemetics with a denominator of 60*samplerate and then restrict your tempo to integers only... but seriously this is so academic it just doesn't matter at all. It's not hard to write code to deal with (very very slightly) inexact computations, it's just that you shouldn't pretend that everything magically becomes exact if you use fixed-point.
- KVRian
- 1260 posts since 31 Dec, 2008
Yeah, tempo changes would wreck the whole thing.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.
Advice is heavy. So don’t send it like a mountain.
-
- KVRian
- 871 posts since 25 Dec, 2018
Default Interfaces are properties of DAWs not plugins. But yes bitwig has a default interface for CLAPs as does the example host and others.
https://github.com/free-audio/clap/blob ... ams.h#L190And if so... uhh... how do you make a parameter in C? Looking through the code, I can't find a "first step" kind of project, taking the `plugin-template.c` and then adding one parameter to, for example, control gain. Is there something in the repository like this?
you implement that function and the associated count method near it.
A example (though the C++ wrapper, but its' really no different) is https://github.com/surge-synthesizer/cl ... mo.cpp#L63
-
MirkoVanHauten MirkoVanHauten https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=376111
- KVRist
- 408 posts since 12 Mar, 2016
This parameter index is just used for the initial parameter description and everywhere else the id is used, right? So the plugin could reorder or add parameters without messing up automation?
-
- KVRist
- 36 posts since 24 Jun, 2022
Exactly.MirkoVanHauten wrote: ↑Tue Jul 26, 2022 1:43 pm This parameter index is just used for the initial parameter description and everywhere else the id is used, right? So the plugin could reorder or add parameters without messing up automation?
- KVRAF
- 1748 posts since 2 Jul, 2018
That's awesome! It allows you to add additional parameters easily in later updates without messing the logical grouping of parameters.robbert-vdh wrote: ↑Tue Jul 26, 2022 1:48 pmExactly.MirkoVanHauten wrote: ↑Tue Jul 26, 2022 1:43 pm This parameter index is just used for the initial parameter description and everywhere else the id is used, right? So the plugin could reorder or add parameters without messing up automation?
Clap is a really well-thought plug in format. Things like this is what the industry really needs.
Thanks to all involved in this
-
- KVRian
- 871 posts since 25 Dec, 2018
Parameters also have modules (basically a / separated path) which a daw could use to group basically just as another string. The demo clap host actually gives you a tree view using these!Markus Krause wrote: ↑Tue Jul 26, 2022 7:42 pmThat's awesome! It allows you to add additional parameters easily in later updates without messing the logical grouping of parameters.robbert-vdh wrote: ↑Tue Jul 26, 2022 1:48 pmExactly.MirkoVanHauten wrote: ↑Tue Jul 26, 2022 1:43 pm This parameter index is just used for the initial parameter description and everywhere else the id is used, right? So the plugin could reorder or add parameters without messing up automation?
Clap is a really well-thought plug in format. Things like this is what the industry really needs.
Thanks to all involved in this
Thanks for the kind words
- u-he
- 28094 posts since 8 Aug, 2002 from Berlin
In the meantime we assembled a few pages about a couple of things we find important:
https://cleveraudio.org
More to come, sure, yet maybe a good start to get past fragmented information in a dozen forum threads.
https://cleveraudio.org
More to come, sure, yet maybe a good start to get past fragmented information in a dozen forum threads.
- KVRian
- 1260 posts since 31 Dec, 2008
I devoured the whole text in half an hour lying on bed. Exciting and well thought of.Urs wrote: ↑Wed Jul 27, 2022 1:08 pm In the meantime we assembled a few pages about a couple of things we find important:
https://cleveraudio.org
More to come, sure, yet maybe a good start to get past fragmented information in a dozen forum threads.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.
Advice is heavy. So don’t send it like a mountain.
- KVRAF
- 4185 posts since 13 May, 2004
Meanwhile the 3rd part of my "Developing with CLAP" tutorial series is online:
https://youtu.be/oko5xJDY39E
Full Playlist:
https://www.youtube.com/playlist?list=P ... AqNQhcwF4W
https://youtu.be/oko5xJDY39E
Full Playlist:
https://www.youtube.com/playlist?list=P ... AqNQhcwF4W
- KVRian
- 1260 posts since 31 Dec, 2008
Did any one experience an issue where the host automatically ends sending modulations for an active note_id when another note_id gets triggered for the same musical note?
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.
Advice is heavy. So don’t send it like a mountain.