package lilv

  1. Overview
  2. Docs

Source file function_description.ml

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
open Ctypes

(* This Types_generated module is an instantiation of the Types functor defined in the type_description.ml file. *)
module Types = Types_generated

module Functions (F : Ctypes.FOREIGN) = struct
  open F

  module LV2 = struct
    include Types.LV2

    (* Function pointers are tricky, see https://discuss.ocaml.org/t/ctypes-how-to-cast-a-function-pointer-and-then-call-it/9653/4 *)

    let descriptor_uri = field descriptor "URI" string

    let descriptor_instantiate =
      field descriptor "instantiate" descriptor_instantiate_ptr_type

    let descriptor_connect_port =
      field descriptor "connect_port" descriptor_connect_port_ptr_type

    let descriptor_activate =
      field descriptor "activate" descriptor_activate_ptr_type

    let descriptor_run = field descriptor "run" descriptor_run_ptr_type

    let descriptor_deactivate =
      field descriptor "deactivate" descriptor_deactivate_ptr_type

    let descriptor_cleanup =
      field descriptor "cleanup" descriptor_cleanup_ptr_type

    let descriptor_extension_data =
      field descriptor "extension_data" descriptor_extension_data_ptr_type

    let () =
      ignore descriptor_uri;
      ignore descriptor_instantiate;
      ignore descriptor_cleanup;
      ignore descriptor_extension_data;
      seal descriptor

    module Core = struct
      let uri = "http://lv2plug.in/ns/lv2core"
      let prefix s = uri ^ "#" ^ s
      let input_port = prefix "InputPort"
      let output_port = prefix "OutputPort"
      let audio_port = prefix "AudioPort"
      let control_port = prefix "ControlPort"
      let connection_optional = prefix "connectionOptional"
    end
  end

  type world = unit ptr

  let world : world typ = ptr void

  type plugin = unit ptr

  let plugin : plugin typ = typedef (ptr void) "LilvPlugin *"
  let const_plugin : plugin typ = typedef plugin "const LilvPlugin *"

  let plugin_opt : plugin option typ =
    typedef (ptr_opt void) "const LilvPlugin *"

  type instance_impl

  let instance_impl : instance_impl structure typ = structure "LilvInstanceImpl"

  let instance_impl_descriptor =
    field instance_impl "lv2_descriptor" (ptr LV2.descriptor)

  let instance_impl_handle = field instance_impl "lv2_handle" LV2.handle
  let instance_impl_pimpl = field instance_impl "pimpl" (ptr void)

  let () =
    ignore instance_impl_pimpl;
    seal instance_impl

  type instance = instance_impl structure ptr

  let instance : instance typ = ptr instance_impl

  type plugins = unit ptr

  let plugins : plugins typ = typedef (ptr void) "const LilvPlugins *"

  type port = unit ptr

  let port : port typ = typedef (ptr void) "const LilvPort *"

  type plugin_class = unit ptr

  let plugin_class : plugin_class typ =
    typedef (ptr void) "const LilvPluginClass *"

  type node = unit ptr

  let node : node typ = typedef (ptr void) "LilvNode *"
  let const_node : node typ = typedef node "const LilvNode *"
  let node_opt : node option typ = ptr_opt void
  let const_string = typedef string "const char *"

  type nodes = unit ptr

  let nodes : nodes typ = typedef (ptr void) "const LilvNode *"

  type iterator = unit ptr

  let iterator : iterator typ = ptr void

  module Node = struct
    type t = node

    let null : t = from_voidp void null
    let free = foreign "lilv_node_free" (node @-> returning void)
    let equals = foreign "lilv_node_equals" (node @-> node @-> returning bool)
    let is_uri = foreign "lilv_node_is_uri" (node @-> returning bool)
    let to_uri = foreign "lilv_node_as_uri" (node @-> returning const_string)
    let uri = foreign "lilv_new_uri" (world @-> string @-> returning node)
    let is_blank = foreign "lilv_node_is_blank" (node @-> returning bool)
    let to_blank = foreign "lilv_node_as_blank" (node @-> returning const_string)
    let is_string = foreign "lilv_node_is_string" (node @-> returning bool)

    let to_string =
      foreign "lilv_node_as_string" (node @-> returning const_string)

    let string = foreign "lilv_new_string" (world @-> string @-> returning node)
    let is_int = foreign "lilv_node_is_int" (node @-> returning bool)
    let to_int = foreign "lilv_node_as_int" (node @-> returning int)
    let int = foreign "lilv_new_int" (world @-> int @-> returning node)
    let is_float = foreign "lilv_node_is_float" (node @-> returning bool)
    let to_float = foreign "lilv_node_as_float" (node @-> returning float)
    let float = foreign "lilv_new_float" (world @-> float @-> returning node)
    let is_bool = foreign "lilv_node_is_bool" (node @-> returning bool)
    let bool = foreign "lilv_new_bool" (world @-> bool @-> returning node)
  end

  module Nodes = struct
    type t = nodes
    type nodes_iterator = t * iterator

    let length = foreign "lilv_nodes_size" (nodes @-> returning int)
    let iterate = foreign "lilv_nodes_begin" (nodes @-> returning iterator)
    let get = foreign "lilv_nodes_get" (nodes @-> iterator @-> returning nodes)

    let next =
      foreign "lilv_nodes_next" (nodes @-> iterator @-> returning iterator)

    let is_end =
      foreign "lilv_nodes_is_end" (nodes @-> iterator @-> returning bool)
  end

  module Port = struct
    type t = (world * plugin) * port

    let make plugin port : t = (plugin, port)
    let get_world (p : t) = fst (fst p)
    let get_plugin (p : t) = snd (fst p)
    let get_port (p : t) = snd p

    let is_a =
      foreign "lilv_port_is_a" (plugin @-> port @-> node @-> returning bool)

    let has_property =
      foreign "lilv_port_has_property"
        (plugin @-> port @-> node @-> returning bool)

    let index =
      foreign "lilv_port_get_index" (plugin @-> port @-> returning uint32_t)

    let symbol =
      foreign "lilv_port_get_symbol" (plugin @-> port @-> returning const_node)

    let name = foreign "lilv_port_get_name" (plugin @-> port @-> returning node)

    let range =
      foreign "lilv_port_get_range"
        (plugin @-> port @-> ptr node @-> ptr node @-> ptr node
       @-> returning void)
  end

  module Plugin = struct
    type t = world * plugin

    let make w p : t = (w, p)
    let get_world (p : t) = fst p
    let get_plugin (p : t) = snd p
    let uri = foreign "lilv_plugin_get_uri" (plugin @-> returning const_node)
    let name = foreign "lilv_plugin_get_name" (plugin @-> returning node)

    let author_name =
      foreign "lilv_plugin_get_author_name" (plugin @-> returning node_opt)

    let author_email =
      foreign "lilv_plugin_get_author_email" (plugin @-> returning node_opt)

    let author_homepage =
      foreign "lilv_plugin_get_author_homepage" (plugin @-> returning node_opt)

    module Class = struct
      type t = plugin_class

      let label =
        foreign "lilv_plugin_class_get_label"
          (plugin_class @-> returning const_node)
    end

    let plugin_class =
      foreign "lilv_plugin_get_class" (plugin @-> returning plugin_class)

    let supported_features =
      foreign "lilv_plugin_get_supported_features" (plugin @-> returning nodes)

    let required_features =
      foreign "lilv_plugin_get_required_features" (plugin @-> returning nodes)

    let optional_features =
      foreign "lilv_plugin_get_optional_features" (plugin @-> returning nodes)

    let num_ports =
      foreign "lilv_plugin_get_num_ports" (plugin @-> returning int32_t)

    let is_replaced =
      foreign "lilv_plugin_is_replaced" (plugin @-> returning bool)

    let port_by_index =
      foreign "lilv_plugin_get_port_by_index"
        (plugin @-> int32_t @-> returning port)

    let port_by_symbol =
      foreign "lilv_plugin_get_port_by_symbol"
        (plugin @-> node @-> returning port)

    let has_latency =
      foreign "lilv_plugin_has_latency" (plugin @-> returning bool)

    let latency_port_index =
      foreign "lilv_plugin_get_latency_port_index" (plugin @-> returning int32_t)

    module Instance = struct
      type t = instance

      let free = foreign "lilv_instance_free" (instance @-> returning void)
      let descriptor (i : t) = getf !@i instance_impl_descriptor
      let handle (i : t) = getf !@i instance_impl_handle
    end

    let instantiate =
      foreign "lilv_plugin_instantiate"
        (plugin @-> double @-> ptr void @-> returning instance)
  end

  module Plugins = struct
    type t = world * plugins
    type plugins_iterator = t * iterator

    let make world plugins : t = (world, plugins)
    let get_world (p : t) = fst p
    let get_plugins (p : t) = snd p
    let length = foreign "lilv_plugins_size" (plugins @-> returning int)
    let iterate = foreign "lilv_plugins_begin" (plugins @-> returning iterator)

    let get =
      foreign "lilv_plugins_get"
        (plugins @-> iterator @-> returning const_plugin)

    let get_by_uri =
      foreign "lilv_plugins_get_by_uri"
        (plugins @-> node @-> returning plugin_opt)

    let next =
      foreign "lilv_plugins_next" (plugins @-> iterator @-> returning iterator)

    let is_end =
      foreign "lilv_plugins_is_end" (plugins @-> iterator @-> returning bool)
  end

  module State = struct end

  module World = struct
    type t = world

    let t = world
    let free = foreign "lilv_world_free" (t @-> returning void)
    let create = foreign "lilv_world_new" (void @-> returning t)
    let load_all = foreign "lilv_world_load_all" (t @-> returning void)
    let plugins = foreign "lilv_world_get_all_plugins" (t @-> returning plugins)
  end
end