-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclapdefs.pas
1902 lines (1564 loc) · 70.8 KB
/
clapdefs.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit clapdefs;
//Delphi translation of the CLAP audio plugin header files from https://github.com/free-audio/clap
//MIT license
interface
uses
System.SysUtils;
type
uint16_t = uint16;
uint32_t = uint32;
uint64_t = uint64;
int16_t = int16;
int32_t = int32;
int64_t = int64;
//version.h
// This is the major ABI and API design
// Version 0.X.Y correspond to the development stage, API and ABI are not stable
// Version 1.X.Y correspont to the release stage, API and ABI are stable
Tclap_version = record
major: uint32_t;
minor: uint32_t;
revision: uint32_t;
end;
const
CLAP_VERSION_MAJOR = 1;
CLAP_VERSION_MINOR = 1;
CLAP_VERSION_REVISION = 2;
CLAP_VERSION_INIT: Tclap_version = (
major: CLAP_VERSION_MAJOR;
minor: CLAP_VERSION_MINOR;
revision: CLAP_VERSION_REVISION;
);
// versions 0.x.y were used during development stage and aren't compatible
function clap_version_is_compatible(const v: Tclap_version): boolean; inline;
//string-sizes.h
const
// String capacity for names that can be displayed to the user.
CLAP_NAME_SIZE = 256;
// String capacity for describing a path, like a parameter in a module hierarchy or path within a
// set of nested track groups.
//
// This is not suited for describing a file path on the disk, as NTFS allows up to 32K long
// paths.
CLAP_PATH_SIZE = 1024;
type TClapString = array[0..CLAP_NAME_SIZE-1] of byte; // for function parameters you need a type
//id.h
type
Tclap_id = uint32_t;
const
CLAP_INVALID_ID = UINT32.MaxValue;
//fixedpoint.h
/// We use fixed point representation of beat time and seconds time
/// Usage:
/// double x = ...; // in beats
/// clap_beattime y = round(CLAP_BEATTIME_FACTOR * x);
// This will never change
const
CLAP_BEATTIME_FACTOR = int64_t(1) shl 31;
CLAP_SECTIME_FACTOR = int64_t(1) shl 31;
type
Tclap_beattime = int64_t;
Tclap_sectime = int64_t;
//events.h
// event header
// must be the first attribute of the event
type
Tclap_event_header = record
size: uint32_t; // event size including this header, eg: sizeof (clap_event_note)
time: uint32_t; // sample offset within the buffer for this event
space_id: uint16_t; // event space, see clap_host_event_registry
_type: uint16_t; // event type , changed by RE
flags: uint32_t; // see clap_event_flags
end;
Pclap_event_header = ^Tclap_event_header;
// The clap core event space
const
CLAP_CORE_EVENT_SPACE_ID = 0;
// Indicate a live user event, for example a user turning a physical knob
// or playing a physical key.
CLAP_EVENT_IS_LIVE = 1 shl 0;
// indicate that the event should not be recorded.
// For example this is useful when a parameter changes because of a MIDI CC,
// because if the host records both the MIDI CC automation and the parameter
// automation there will be a conflict.
CLAP_EVENT_DONT_RECORD = 1 shl 1;
// Some of the following events overlap, a note on can be expressed with:
// - CLAP_EVENT_NOTE_ON
// - CLAP_EVENT_MIDI
// - CLAP_EVENT_MIDI2
//
// The preferred way of sending a note event is to use CLAP_EVENT_NOTE_*.
//
// The same event must not be sent twice: it is forbidden to send a the same note on
// encoded with both CLAP_EVENT_NOTE_ON and CLAP_EVENT_MIDI.
//
// The plugins are encouraged to be able to handle note events encoded as raw midi or midi2,
// or implement clap_plugin_event_filter and reject raw midi and midi2 events.
// NOTE_ON and NOTE_OFF represents a key pressed and key released event, respectively.
// A NOTE_ON with a velocity of 0 is valid and should not be interpreted as a NOTE_OFF.
//
// NOTE_CHOKE is meant to choke the voice(s), like in a drum machine when a closed hihat
// chokes an open hihat. This event can be sent by the host to the plugin. Here are two use cases:
// - a plugin is inside a drum pad in Bitwig Studio's drum machine, and this pad is choked by
// another one
// - the user double clicks the DAW's stop button in the transport which then stops the sound on
// every tracks
//
// NOTE_END is sent by the plugin to the host. The port, channel, key and note_id are those given
// by the host in the NOTE_ON event. In other words, this event is matched against the
// plugin's note input port.
// NOTE_END is useful to help the host to match the plugin's voice life time.
//
// When using polyphonic modulations, the host has to allocate and release voices for its
// polyphonic modulator. Yet only the plugin effectively knows when the host should terminate
// a voice. NOTE_END solves that issue in a non-intrusive and cooperative way.
//
// CLAP assumes that the host will allocate a unique voice on NOTE_ON event for a given port,
// channel and key. This voice will run until the plugin will instruct the host to terminate
// it by sending a NOTE_END event.
//
// Consider the following sequence:
// - process()
// Host->Plugin NoteOn(port:0, channel:0, key:16, time:t0)
// Host->Plugin NoteOn(port:0, channel:0, key:64, time:t0)
// Host->Plugin NoteOff(port:0, channel:0, key:16, t1)
// Host->Plugin NoteOff(port:0, channel:0, key:64, t1)
// # on t2, both notes did terminate
// Host->Plugin NoteOn(port:0, channel:0, key:64, t3)
// # Here the plugin finished processing all the frames and will tell the host
// # to terminate the voice on key 16 but not 64, because a note has been started at t3
// Plugin->Host NoteEnd(port:0, channel:0, key:16, time:ignored)
//
// Those four events use clap_event_note.
CLAP_EVENT_NOTE_ON = 0;
CLAP_EVENT_NOTE_OFF = 1;
CLAP_EVENT_NOTE_CHOKE = 2;
CLAP_EVENT_NOTE_END = 3;
// Represents a note expression.
// Uses clap_event_note_expression.
CLAP_EVENT_NOTE_EXPRESSION = 4;
// PARAM_VALUE sets the parameter's value; uses clap_event_param_value.
// PARAM_MOD sets the parameter's modulation amount; uses clap_event_param_mod.
//
// The value heard is: param_value + param_mod.
//
// In case of a concurrent global value/modulation versus a polyphonic one,
// the voice should only use the polyphonic one and the polyphonic modulation
// amount will already include the monophonic signal.
CLAP_EVENT_PARAM_VALUE = 5;
CLAP_EVENT_PARAM_MOD = 6;
// Indicates that the user started or finished adjusting a knob.
// This is not mandatory to wrap parameter changes with gesture events, but this improves
// the user experience a lot when recording automation or overriding automation playback.
// Uses clap_event_param_gesture.
CLAP_EVENT_PARAM_GESTURE_BEGIN = 7;
CLAP_EVENT_PARAM_GESTURE_END = 8;
CLAP_EVENT_TRANSPORT = 9; // update the transport info; clap_event_transport
CLAP_EVENT_MIDI = 10; // raw midi event; clap_event_midi
CLAP_EVENT_MIDI_SYSEX = 11; // raw midi sysex event; clap_event_midi_sysex
CLAP_EVENT_MIDI2 = 12; // raw midi 2 event; clap_event_midi2
type
// Note on, off, end and choke events.
// In the case of note choke or end events:
// - the velocity is ignored.
// - key and channel are used to match active notes, a value of -1 matches all.
Tclap_event_note = record
header: Tclap_event_header;
note_id: int32_t; // -1 if unspecified, otherwise >=0
port_index: int16_t;
channel: int16_t; // 0..15
key: int16_t; // 0..127
velocity: double; // 0..1
end;
const
// with 0 < x <= 4, plain = 20 * log(x)
CLAP_NOTE_EXPRESSION_VOLUME = 0;
// pan, 0 left, 0.5 center, 1 right
CLAP_NOTE_EXPRESSION_PAN = 1;
// relative tuning in semitone, from -120 to +120
CLAP_NOTE_EXPRESSION_TUNING = 2;
// 0..1
CLAP_NOTE_EXPRESSION_VIBRATO = 3;
CLAP_NOTE_EXPRESSION_EXPRESSION = 4;
CLAP_NOTE_EXPRESSION_BRIGHTNESS = 5;
CLAP_NOTE_EXPRESSION_PRESSURE = 6;
type
Tclap_note_expression = int32_t;
Tclap_event_note_expression = record
header: Tclap_event_header;
expression_id: Tclap_note_expression;
// target a specific note_id, port, key and channel, -1 for global
note_id: int32_t;
port_index: int16_t;
channel: int16_t;
key: int16_t;
value: double; // see expression for the range
end;
Tclap_event_param_value = record
header: Tclap_event_header;
// target parameter
param_id: Tclap_id; // @ref clap_param_info.id
cookie: pointer; // @ref clap_param_info.cookie
// target a specific note_id, port, key and channel, -1 for global
note_id: int32_t;
port_index: int16_t;
channel: int16_t;
key: int16_t;
value: double;
end;
Tclap_event_param_mod = record
header: Tclap_event_header;
// target parameter
param_id: Tclap_id; // @ref clap_param_info.id
cookie: pointer; // @ref clap_param_info.cookie
// target a specific note_id, port, key and channel, -1 for global
note_id: int32_t;
port_index: int16_t;
channel: int16_t;
key: int16_t;
amount: double; // modulation amount
end;
Tclap_event_param_gesture = record
header: Tclap_event_header;
// target parameter
param_id: Tclap_id; // @ref clap_param_info.id
end;
const
CLAP_TRANSPORT_HAS_TEMPO = 1 shl 0;
CLAP_TRANSPORT_HAS_BEATS_TIMELINE = 1 shl 1;
CLAP_TRANSPORT_HAS_SECONDS_TIMELINE = 1 shl 2;
CLAP_TRANSPORT_HAS_TIME_SIGNATURE = 1 shl 3;
CLAP_TRANSPORT_IS_PLAYING = 1 shl 4;
CLAP_TRANSPORT_IS_RECORDING = 1 shl 5;
CLAP_TRANSPORT_IS_LOOP_ACTIVE = 1 shl 6;
CLAP_TRANSPORT_IS_WITHIN_PRE_ROLL = 1 shl 7;
type
Tclap_event_transport = record
header: Tclap_event_header;
flags: uint32_t; // see clap_transport_flags
song_pos_beats: Tclap_beattime; // position in beats
song_pos_seconds: Tclap_sectime; // position in seconds
tempo: double; // in bpm
tempo_inc: double; // tempo increment for each samples and until the next
// time info event
loop_start_beats: Tclap_beattime;
loop_end_beats: Tclap_beattime;
loop_start_seconds: Tclap_sectime;
loop_end_seconds: Tclap_sectime;
bar_start: Tclap_beattime; // start pos of the current bar
bar_number: int32_t; // bar at song pos 0 has the number 0
tsig_num: uint16_t; // time signature numerator
tsig_denom: uint16_t; // time signature denominator
end;
Pclap_event_transport = ^Tclap_event_transport;
Tclap_event_midi = record
header: Tclap_event_header;
port_index: uint16_t;
data: array[0..2] of byte;
end;
Tclap_event_midi_sysex = record
header: Tclap_event_header;
port_index: uint16_t;
buffer: pointer; // midi buffer
size: uint32_t;
end;
// While it is possible to use a series of midi2 event to send a sysex,
// prefer clap_event_midi_sysex if possible for efficiency.
Tclap_event_midi2 = record
header: Tclap_event_header;
port_index: uint16_t;
data: array[0..3] of uint32_t;
end;
// Input event list, events must be sorted by time.
Pclap_input_events = ^Tclap_input_events;
Tclap_input_events = record
ctx: TObject; // reserved pointer for the list
// returns the number of events in the list
//uint32_t (*size)(const struct clap_input_events *list);
size: function(list: Pclap_input_events): uint32_t; cdecl;
// Don't free the returned event, it belongs to the list
//const clap_event_header_t *(*get)(const struct clap_input_events *list, uint32_t index);
get: function(list: Pclap_input_events; index: uint32_t): Pclap_event_header; cdecl;
end;
// Output event list, events must be sorted by time.
Pclap_output_events = ^Tclap_output_events;
Tclap_output_events = record
ctx: TObject; // reserved pointer for the list
// Pushes a copy of the event
// returns false if the event could not be pushed to the queue (out of memory?)
//bool (*try_push)(const struct clap_output_events *list, const clap_event_header_t *event);
try_push: function(list: Pclap_output_events; event: Pclap_event_header): boolean; cdecl;
end;
//audio-buffer.h
type
// Sample code for reading a stereo buffer:
//
// bool isLeftConstant = (buffer->constant_mask & (1 << 0)) != 0;
// bool isRightConstant = (buffer->constant_mask & (1 << 1)) != 0;
//
// for (int i = 0; i < N; ++i) {
// float l = data32[0][isLeftConstant ? 0 : i];
// float r = data32[1][isRightConstant ? 0 : i];
// }
//
// Note: checking the constant mask is optional, and this implies that
// the buffer must be filled with the constant value.
// Rationale: if a buffer reader doesn't check the constant mask, then it may
// process garbage samples and in result, garbage samples may be transmitted
// to the audio interface with all the bad consequences it can have.
//
// The constant mask is a hint.
Tclap_audio_buffer = record
// Either data32 or data64 pointer will be set.
data32: PPointerArray;
data64: PPointerArray;
channel_count: uint32_t;
latency: uint32_t; // latency from/to the audio interface
constant_mask: uint64_t;
end;
//process.h
const
// Processing failed. The output buffer must be discarded.
CLAP_PROCESS_ERROR = 0;
// Processing succeeded, keep processing.
CLAP_PROCESS_CONTINUE = 1;
// Processing succeeded, keep processing if the output is not quiet.
CLAP_PROCESS_CONTINUE_IF_NOT_QUIET = 2;
// Rely upon the plugin's tail to determine if the plugin should continue to process.
// see clap_plugin_tail
CLAP_PROCESS_TAIL = 3;
// Processing succeeded, but no more processing is required,
// until the next event or variation in audio input.
CLAP_PROCESS_SLEEP = 4;
type
Tclap_process_status = int32_t;
Tclap_process = record
// A steady sample time counter.
// This field can be used to calculate the sleep duration between two process calls.
// This value may be specific to this plugin instance and have no relation to what
// other plugin instances may receive.
//
// Set to -1 if not available, otherwise the value must be greater or equal to 0,
// and must be increased by at least `frames_count` for the next call to process.
steady_time: uint64_t;
// Number of frame to process
frames_count: uint32_t;
// time info at sample 0
// If null, then this is a free running host, no transport events will be provided
transport: Pclap_event_transport;
// Audio buffers, they must have the same count as specified
// by clap_plugin_audio_ports->count().
// The index maps to clap_plugin_audio_ports->get().
// Input buffer and its contents are read-only.
audio_inputs: pointer { Pclap_audio_buffer_t };
audio_outputs: pointer { Pclap_audio_buffer_t };
audio_inputs_count: uint32_t;
audio_outputs_count: uint32_t;
// Input and output events.
//
// Events must be sorted by time.
// The input event list can't be modified.
in_events: Pclap_input_events;
out_events: Pclap_output_events;
end;
Pclap_process = ^Tclap_process;
//host.h
Pclap_host = ^Tclap_host;
Tclap_host = record
clap_version: Tclap_version; // initialized to CLAP_VERSION
host_data: TObject; // reserved pointer for the host
// name and version are mandatory.
name: PAnsiChar; // eg: "Bitwig Studio"
vendor: PAnsiChar; // eg: "Bitwig GmbH"
url: PAnsiChar; // eg: "https://bitwig.com"
version: PAnsiChar; // eg: "4.3"
// Query an extension.
// [thread-safe]
//const void *(*get_extension)(const struct clap_host *host, const char *extension_id);
get_extension: function(host: Pclap_host; extension_id: PAnsiChar): pointer; cdecl;
// Request the host to deactivate and then reactivate the plugin.
// The operation may be delayed by the host.
// [thread-safe]
//void (*request_restart)(const struct clap_host *host);
request_restart: procedure(host: Pclap_host); cdecl;
// Request the host to activate and start processing the plugin.
// This is useful if you have external IO and need to wake up the plugin from "sleep".
// [thread-safe]
//void (*request_process)(const struct clap_host *host);
request_process: procedure(host: Pclap_host); cdecl;
// Request the host to schedule a call to plugin->on_main_thread(plugin) on the main thread.
// [thread-safe]
//void (*request_callback)(const struct clap_host *host);
request_callback: procedure(host: Pclap_host); cdecl;
end;
//plugin.h
type
TPAnsiCharArray = array[0..(High(Integer) div SizeOf(PChar))-1] of PAnsiChar;
PPAnsiCharArray = ^TPAnsiCharArray;
Tclap_plugin_descriptor = record
clap_version: Tclap_version; // initialized to CLAP_VERSION
// Mandatory fields must be set and must not be blank.
// Otherwise the fields can be null or blank, though it is safer to make them blank.
id: PAnsiChar; // eg: "com.u-he.diva, mandatory"
name: PAnsiChar; // eg: "Diva", mandatory
vendor: PAnsiChar; // eg: "u-he"
url: PAnsiChar; // eg: "https://u-he.com/products/diva/"
manual_url: PAnsiChar; // eg: "https://dl.u-he.com/manuals/plugins/diva/Diva-user-guide.pdf"
support_url: PAnsiChar; // eg: "https://u-he.com/support/"
version: PAnsiChar; // eg: "1.4.4"
description: PAnsiChar; // eg: "The spirit of analogue"
// Arbitrary list of keywords.
// They can be matched by the host indexer and used to classify the plugin.
// The array of pointers must be null terminated.
// For some standard features see plugin-features.h
features: PPAnsiCharArray;
end;
Pclap_plugin_descriptor = ^Tclap_plugin_descriptor;
Pclap_plugin = ^Tclap_plugin;
Tclap_plugin = record
desc: Pclap_plugin_descriptor;
plugin_data: pointer; // reserved pointer for the plugin
// Must be called after creating the plugin.
// If init returns false, the host must destroy the plugin instance.
// [main-thread]
//bool (*init)(const struct clap_plugin *plugin);
init: function(plugin: Pclap_plugin): boolean; cdecl;
// Free the plugin and its resources.
// It is required to deactivate the plugin prior to this call. */}
// [main-thread & !active]
//void (*destroy)(const struct clap_plugin *plugin);
destroy: procedure(plugin: Pclap_plugin); cdecl;
// Activate and deactivate the plugin.
// In this call the plugin may allocate memory and prepare everything needed for the process
// call. The process's sample rate will be constant and process's frame count will included in
// the [min, max] range, which is bounded by [1, INT32_MAX].
// Once activated the latency and port configuration must remain constant, until deactivation.
//
// [main-thread & !active_state]
//bool (*activate)(const struct clap_plugin *plugin,
// double sample_rate,
// uint32_t min_frames_count,
// uint32_t max_frames_count);
activate: function(plugin: Pclap_plugin; sample_rate: double; min_frames_count: uint32_t; max_frames_count: uint32_t): boolean; cdecl;
// [main-thread & active_state]
//void (*deactivate)(const struct clap_plugin *plugin);
deactivate: procedure(plugin: Pclap_plugin); cdecl;
// Call start processing before processing.
// [audio-thread & active_state & !processing_state]
//bool (*start_processing)(const struct clap_plugin *plugin);
start_processing: function(plugin: Pclap_plugin): boolean; cdecl;
// Call stop processing before sending the plugin to sleep.
// [audio-thread & active_state & processing_state]
//void (*stop_processing)(const struct clap_plugin *plugin);
stop_processing: procedure(plugin: Pclap_plugin); cdecl;
// - Clears all buffers, performs a full reset of the processing state (filters, oscillators,
// enveloppes, lfo, ...) and kills all voices.
// - The parameter's value remain unchanged.
// - clap_process.steady_time may jump backward.
//
// [audio-thread & active_state]
//void (*reset)(const struct clap_plugin *plugin);
reset: procedure(plugin: Pclap_plugin); cdecl;
// process audio, events, ...
// [audio-thread & active_state & processing_state]
//clap_process_status (*process)(const struct clap_plugin *plugin, const clap_process_t *process);
process: function(plugin: Pclap_plugin; process: Pclap_process): Tclap_process_status; cdecl;
// Query an extension.
// The returned pointer is owned by the plugin.
// [thread-safe]
//const void *(*get_extension)(const struct clap_plugin *plugin, const char *id);
get_extension: function(plugin: Pclap_plugin; id: PAnsiChar): pointer; cdecl;
// Called by the host on the main thread in response to a previous call to:
// host->request_callback(host);
// [main-thread]
//void (*on_main_thread)(const struct clap_plugin *plugin);
on_main_thread: procedure(plugin: Pclap_plugin); cdecl;
end;
//plugin-features.h
// This files provides a set of standard plugin features meant to be used
// within clap_plugin_descriptor.features.
//
// For practical reasons we'll avoid spaces and use `-` instead to facilitate
// scripts that generate the feature array.
//
// Non standard features should be formated as follow: "$namespace:$feature"
const
/////////////////////
// Plugin category //
/////////////////////
// Add this feature if your plugin can process note events and then produce audio
CLAP_PLUGIN_FEATURE_INSTRUMENT = 'instrument';
// Add this feature if your plugin is an audio effect
CLAP_PLUGIN_FEATURE_AUDIO_EFFECT = 'audio-effect';
// Add this feature if your plugin is a note effect or a note generator/sequencer
CLAP_PLUGIN_FEATURE_NOTE_EFFECT = 'note-effect';
// Add this feature if your plugin is an analyzer
CLAP_PLUGIN_FEATURE_ANALYZER = 'analyzer';
/////////////////////////
// Plugin sub-category //
/////////////////////////
CLAP_PLUGIN_FEATURE_SYNTHESIZER = 'synthesizer';
CLAP_PLUGIN_FEATURE_SAMPLER = 'sampler';
CLAP_PLUGIN_FEATURE_DRUM = 'drum'; // For single drum
CLAP_PLUGIN_FEATURE_DRUM_MACHINE = 'drum-machine';
CLAP_PLUGIN_FEATURE_FILTER = 'filter';
CLAP_PLUGIN_FEATURE_PHASER = 'phaser';
CLAP_PLUGIN_FEATURE_EQUALIZER = 'equalizer';
CLAP_PLUGIN_FEATURE_DEESSER = 'de-esser';
CLAP_PLUGIN_FEATURE_PHASE_VOCODER = 'phase-vocoder';
CLAP_PLUGIN_FEATURE_GRANULAR = 'granular';
CLAP_PLUGIN_FEATURE_FREQUENCY_SHIFTER = 'frequency-shifter';
CLAP_PLUGIN_FEATURE_PITCH_SHIFTER = 'pitch-shifter';
CLAP_PLUGIN_FEATURE_DISTORTION = 'distortion';
CLAP_PLUGIN_FEATURE_TRANSIENT_SHAPER = 'transient-shaper';
CLAP_PLUGIN_FEATURE_COMPRESSOR = 'compressor';
CLAP_PLUGIN_FEATURE_LIMITER = 'limiter';
CLAP_PLUGIN_FEATURE_FLANGER = 'flanger';
CLAP_PLUGIN_FEATURE_CHORUS = 'chorus';
CLAP_PLUGIN_FEATURE_DELAY = 'delay';
CLAP_PLUGIN_FEATURE_REVERB = 'reverb';
CLAP_PLUGIN_FEATURE_TREMOLO = 'tremolo';
CLAP_PLUGIN_FEATURE_GLITCH = 'glitch';
CLAP_PLUGIN_FEATURE_UTILITY = 'utility';
CLAP_PLUGIN_FEATURE_PITCH_CORRECTION = 'pitch-correction';
CLAP_PLUGIN_FEATURE_RESTORATION = 'restoration'; // repair the sound
CLAP_PLUGIN_FEATURE_MULTI_EFFECTS = 'multi-effects';
CLAP_PLUGIN_FEATURE_MIXING = 'mixing';
CLAP_PLUGIN_FEATURE_MASTERING = 'mastering';
////////////////////////
// Audio Capabilities //
////////////////////////
CLAP_PLUGIN_FEATURE_MONO = 'mono';
CLAP_PLUGIN_FEATURE_STEREO = 'stereo';
CLAP_PLUGIN_FEATURE_SURROUND = 'surround';
CLAP_PLUGIN_FEATURE_AMBISONIC = 'ambisonic';
//plugin-factory.h
const
CLAP_PLUGIN_FACTORY_ID = AnsiString('clap.plugin-factory');
type
Pclap_plugin_factory = ^Tclap_plugin_factory;
// Every method must be thread-safe.
// It is very important to be able to scan the plugin as quickly as possible.
//
// The host may use clap_plugin_invalidation_factory to detect filesystem changes
// which may change the factory's content.
Tclap_plugin_factory = record
// Get the number of plugins available.
// [thread-safe]
//uint32_t (*get_plugin_count)(const struct clap_plugin_factory *factory);
get_plugin_count: function(factory: Pclap_plugin_factory): uint32_t; cdecl;
// Retrieves a plugin descriptor by its index.
// Returns null in case of error.
// The descriptor must not be freed.
// [thread-safe]
//const clap_plugin_descriptor_t *(*get_plugin_descriptor)(
// const struct clap_plugin_factory *factory, uint32_t index);
get_plugin_descriptor: function(factory: Pclap_plugin_factory; index: uint32_t): Pclap_plugin_descriptor; cdecl;
// Create a clap_plugin by its plugin_id.
// The returned pointer must be freed by calling plugin->destroy(plugin);
// The plugin is not allowed to use the host callbacks in the create method.
// Returns null in case of error.
// [thread-safe]
//const clap_plugin_t *(*create_plugin)(const struct clap_plugin_factory *factory,
// const clap_host_t *host,
// const char *plugin_id);
create_plugin: function(factory: Pclap_plugin_factory; host: Pclap_host; plugin_id: PAnsiChar): Pclap_plugin; cdecl;
end;
//plugin-invalidation.h
type
Tclap_plugin_invalidation_source = record
// Directory containing the file(s) to scan, must be absolute
directory: PAnsiChar;
// globing pattern, in the form *.dll
filename_glob: PAnsiChar;
// should the directory be scanned recursively?
recursive_scan: boolean;
end;
Pclap_plugin_invalidation_source = ^Tclap_plugin_invalidation_source;
const
CLAP_PLUGIN_INVALIDATION_FACTORY_ID = AnsiString('clap.plugin-invalidation-factory/draft0');
// Used to figure out when a plugin needs to be scanned again.
// Imagine a situation with a single entry point: my-plugin.clap which then scans itself
// a set of "sub-plugins". New plugin may be available even if my-plugin.clap file doesn't change.
// This interfaces solves this issue and gives a way to the host to monitor additional files.
type
Pclap_plugin_invalidation_factory = ^Tclap_plugin_invalidation_factory;
Tclap_plugin_invalidation_factory = record
// Get the number of invalidation source.
//uint32_t (*count)(const struct clap_plugin_invalidation_factory *factory);
count: function(factory: Pclap_plugin_invalidation_factory): uint32_t; cdecl;
// Get the invalidation source by its index.
// [thread-safe]
//const clap_plugin_invalidation_source_t *(*get)(
// const struct clap_plugin_invalidation_factory *factory, uint32_t index);
get: function(factory: Pclap_plugin_invalidation_factory; index: uint32_t): Pclap_plugin_invalidation_source; cdecl;
// In case the host detected a invalidation event, it can call refresh() to let the
// plugin_entry update the set of plugins available.
// If the function returned false, then the plugin needs to be reloaded.
//bool (*refresh)(const struct clap_plugin_invalidation_factory *factory);
refresh: function(factory: Pclap_plugin_invalidation_factory): boolean; cdecl;
end;
//entry.h
// This interface is the entry point of the dynamic library.
//
// CLAP plugins standard search path:
//
// Linux
// - ~/.clap
// - /usr/lib/clap
//
// Windows
// - %CommonFilesFolder%/CLAP/
// - %LOCALAPPDATA%/Programs/Common/CLAP/
//
// MacOS
// - /Library/Audio/Plug-Ins/CLAP
// - ~/Library/Audio/Plug-Ins/CLAP
//
// In addition to the OS-specific default locations above, a CLAP host must query the environment
// for a CLAP_PATH variable, which is a list of directories formatted in the same manner as the host
// OS binary search path (PATH on Unix, separated by `:` and Path on Windows, separated by ';', as
// of this writing).
//
// Each directory should be recursively searched for files and/or bundles as appropriate in your OS
// ending with the extension `.clap`.
//
// Every method must be thread-safe.
Tclap_plugin_entry = record
clap_version: Tclap_version; // initialized to CLAP_VERSION
// This function must be called first, and can only be called once.
//
// It should be as fast as possible, in order to perform a very quick scan of the plugin
// descriptors.
//
// It is forbidden to display graphical user interface in this call.
// It is forbidden to perform user interaction in this call.
//
// If the initialization depends upon expensive computation, maybe try to do them ahead of time
// and cache the result.
//
// If init() returns false, then the host must not call deinit() nor any other clap
// related symbols from the DSO.
//bool (*init)(const char *plugin_path);
init: function (plugin_path: PAnsiChar): boolean; cdecl;
// No more calls into the DSO must be made after calling deinit().
//void (*deinit)(void);
deinit: procedure; cdecl;
// Get the pointer to a factory. See plugin-factory.h for an example.
//
// Returns null if the factory is not provided.
// The returned pointer must *not* be freed by the caller.
//const void *(*get_factory)(const char *factory_id);
get_factory: function(factory_id: PAnsiChar): pointer; cdecl;
end;
Pclap_plugin_entry = ^Tclap_plugin_entry;
// Entry point
const
clap_entry = 'clap_entry';
//stream.h
type
Pclap_istream = ^Tclap_istream;
Tclap_istream = record
ctx: TObject; // reserved pointer for the stream
// returns the number of bytes read; 0 indicates end of file and -1 a read error
//int64_t (*read)(const struct clap_istream *stream, void *buffer, uint64_t size);
read: function(stream: Pclap_istream; buffer: pointer; size: uint64_t): int64_t; cdecl;
end;
Pclap_ostream = ^Tclap_ostream;
Tclap_ostream = record
ctx: TObject; // reserved pointer for the stream
// returns the number of bytes written; -1 on write error
//int64_t (*write)(const struct clap_ostream *stream, const void *buffer, uint64_t size);
write: function(stream: Pclap_ostream; buffer: pointer; size: uint64_t): int64_t; cdecl;
end;
//ext\gui.h
/// @page GUI
///
/// This extension defines how the plugin will present its GUI.
///
/// There are two approaches:
/// 1. the plugin creates a window and embeds it into the host's window
/// 2. the plugin creates a floating window
///
/// Embedding the window gives more control to the host, and feels more integrated.
/// Floating window are sometimes the only option due to technical limitations.
///
/// Showing the GUI works as follow:
/// 1. clap_plugin_gui->is_api_supported(), check what can work
/// 2. clap_plugin_gui->create(), allocates gui resources
/// 3. if the plugin window is floating
/// 4. -> clap_plugin_gui->set_transient()
/// 5. -> clap_plugin_gui->suggest_title()
/// 6. else
/// 7. -> clap_plugin_gui->set_scale()
/// 8. -> clap_plugin_gui->can_resize()
/// 9. -> if resizable and has known size from previous session, clap_plugin_gui->set_size()
/// 10. -> else clap_plugin_gui->get_size(), gets initial size
/// 11. -> clap_plugin_gui->set_parent()
/// 12. clap_plugin_gui->show()
/// 13. clap_plugin_gui->hide()/show() ...
/// 14. clap_plugin_gui->destroy() when done with the gui
///
/// Resizing the window (initiated by the plugin, if embedded):
/// 1. Plugins calls clap_host_gui->request_resize()
/// 2. If the host returns true the new size is accepted,
/// the host doesn't have to call clap_plugin_gui->set_size().
/// If the host returns false, the new size is rejected.
///
/// Resizing the window (drag, if embedded)):
/// 1. Only possible if clap_plugin_gui->can_resize() returns true
/// 2. Mouse drag -> new_size
/// 3. clap_plugin_gui->adjust_size(new_size) -> working_size
/// 4. clap_plugin_gui->set_size(working_size)
const
CLAP_EXT_GUI = AnsiString('clap.gui');
// If your windowing API is not listed here, please open an issue and we'll figure it out.
// https://github.com/free-audio/clap/issues/new
// uses physical size
// embed using https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setparent
CLAP_WINDOW_API_WIN32 = AnsiString('win32');
// uses logical size, don't call clap_plugin_gui->set_scale()
CLAP_WINDOW_API_COCOA = AnsiString('cocoa');
// uses physical size
// embed using https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html
CLAP_WINDOW_API_X11 = AnsiString('x11');
// uses physical size
// embed is currently not supported, use floating windows
CLAP_WINDOW_API_WAYLAND = AnsiString('wayland');
type
Tclap_hwnd = pointer;
Tclap_nsview = pointer;
Tclap_xwnd = UInt32;
// Represent a window reference.
Tclap_window = record
api: PAnsiChar; // one of CLAP_WINDOW_API_XXX
case integer of
0:(cocoa: Tclap_nsview);
1:(x11: Tclap_xwnd);
2:(win32: Tclap_hwnd);
3:(ptr: pointer); // for anything defined outside of clap
end;
Pclap_window = ^Tclap_window;
// Information to improve window resizing when initiated by the host or window manager.
Tclap_gui_resize_hints = record
can_resize_horizontally: boolean;
can_resize_vertically: boolean;
// only if can resize horizontally and vertically
preseve_aspect_ratio: boolean;
aspect_ratio_width: uint32_t;
aspect_ratio_height: uint32_t;
end;
// Size (width, height) is in pixels; the corresponding windowing system extension is
// responsible for defining if it is physical pixels or logical pixels.
Tclap_plugin_gui = record
// Returns true if the requested gui api is supported
// [main-thread]
//bool (*is_api_supported)(const clap_plugin_t *plugin, const char *api, bool is_floating);
is_api_supported: function(plugin: Pclap_plugin; api: PAnsiChar; is_floating: boolean): boolean; cdecl;
// Returns true if the plugin has a preferred api.
// The host has no obligation to honor the plugin preferrence, this is just a hint.
// The const char **api variable should be explicitly assigned as a pointer to
// one of the CLAP_WINDOW_API_ constants defined above, not strcopied.
// [main-thread]
//bool (*get_preferred_api)(const clap_plugin_t *plugin, const char **api, bool *is_floating);
get_preferred_api: function(plugin: Pclap_plugin; var api: PAnsiChar; var is_floating: boolean): boolean; cdecl;
// Create and allocate all resources necessary for the gui.
//
// If is_floating is true, then the window will not be managed by the host. The plugin
// can set its window to stays above the parent window, see set_transient().
// api may be null or blank for floating window.
//
// If is_floating is false, then the plugin has to embbed its window into the parent window, see
// set_parent().
//
// After this call, the GUI may not be visible yet; don't forget to call show().
// [main-thread]
//bool (*create)(const clap_plugin_t *plugin, const char *api, bool is_floating);
create: function(plugin: Pclap_plugin; api: PAnsiChar; is_floating: boolean): boolean; cdecl;
// Free all resources associated with the gui.
// [main-thread]
//void (*destroy)(const clap_plugin_t *plugin);
destroy: procedure(plugin: Pclap_plugin); cdecl;
// Set the absolute GUI scaling factor, and override any OS info.
// Should not be used if the windowing api relies upon logical pixels.
//
// If the plugin prefers to work out the scaling factor itself by querying the OS directly,
// then ignore the call.
//
// Returns true if the scaling could be applied
// Returns false if the call was ignored, or the scaling could not be applied.
// [main-thread]
//bool (*set_scale)(const clap_plugin_t *plugin, double scale);
set_scale: function(plugin: Pclap_plugin; scale: double): boolean; cdecl;
// Get the current size of the plugin UI.
// clap_plugin_gui->create() must have been called prior to asking the size.
// [main-thread]
//bool (*get_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);
get_size: function(plugin: Pclap_plugin; var width: uint32_t; var height: uint32_t): boolean; cdecl;
// Returns true if the window is resizeable (mouse drag).
// Only for embedded windows.
// [main-thread]
//bool (*can_resize)(const clap_plugin_t *plugin);
can_resize: function(plugin: Pclap_plugin): boolean; cdecl;
// Returns true if the plugin can provide hints on how to resize the window.
// [main-thread]
//bool (*get_resize_hints)(const clap_plugin_t *plugin, clap_gui_resize_hints_t *hints);
get_resize_hints: function(plugin: Pclap_plugin; var hints: Tclap_gui_resize_hints): boolean; cdecl;
// If the plugin gui is resizable, then the plugin will calculate the closest
// usable size which fits in the given size.
// This method does not change the size.
//
// Only for embedded windows.
// [main-thread]
//bool (*adjust_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);
adjust_size: function(plugin: Pclap_plugin; var width: uint32_t; var height: uint32_t): boolean; cdecl;
// Sets the window size. Only for embedded windows.
// [main-thread]
//bool (*set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height);
set_size: function(plugin: Pclap_plugin; width: uint32_t; height: uint32_t): boolean; cdecl;