Changeset 503
- Timestamp:
- 09/10/07 22:33:24 (1 year ago)
- Files:
-
- ocaml-remix/trunk/ladspa.ml (modified) (2 diffs)
- ocaml-remix/trunk/ladspa_impl.c (modified) (2 diffs)
- ocaml-remix/trunk/ladspa_raw.ml (modified) (1 diff)
- ocaml-remix/trunk/ladspa_raw.mli (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ocaml-remix/trunk/ladspa.ml
r502 r503 43 43 let channels = Remix.channels remix in 44 44 let rs = s remix (s_s, s_l) (r_s, r_l) in 45 Ladspa_raw.raw_sound_to_buffers rs channels 45 let len = (Array.length rs) / channels in 46 let out_arr = 47 Array.init channels (fun _ -> Ladspa_raw.empty_buffer len) in 48 Ladspa_raw.raw_sound_to_buffers rs out_arr; 49 out_arr 46 50 ) 47 51 | Plugin (name, trees, adding, outputs) -> … … 67 71 let result = _render_tree tree in 68 72 Ladspa_raw.buffers_to_raw_sound result length_in_samples;; 73 74 75 (* compiled pipeline approach. What's a compiled ladpsa pipeline look like? 76 * 77 * We'll need a list of input buffers to fill, a list of plugins to run in 78 * order, a list of output buffers to return, and a maximum length in samples. 79 * We'll also need a list of all used buffers for deallocation and cleanup 80 * purposes. 81 *) 82 type compiledPipeline = 83 { inputs : Ladspa_raw.buffer list; 84 plugins : Ladspa_raw.plugin list; 85 outputs : Ladspa_raw.buffer list; 86 maxlength : int; 87 allbuffers : Ladspa_raw.buffer list 88 };; 89 90 ocaml-remix/trunk/ladspa_impl.c
r502 r503 176 176 } 177 177 178 CAMLprim c_ex_ladspa_raw_sound_to_buffers(value ml_sound, value ml_ channels) {178 CAMLprim c_ex_ladspa_raw_sound_to_buffers(value ml_sound, value ml_buffers) { 179 179 180 180 CAMLparam1(ml_sound); 181 181 182 182 int length = Wosize_val(ml_sound); 183 int channels = Int_val(ml_ channels);183 int channels = Int_val(ml_buffers); 184 184 int i; 185 185 186 LADSPA_Data **data = malloc( (channels + 1)* sizeof(LADSPA_Data *));186 LADSPA_Data **data = malloc(channels * sizeof(LADSPA_Data *)); 187 187 188 188 for (i = 0; i < channels; i++) { 189 data[i] = malloc(length/channels * sizeof(LADSPA_Data)); 190 } 191 192 data[channels] = NULL; 193 189 value b = (value)Field(ml_buffers, i); 190 data[i] = (LADSPA_Data *)Field(b, 0); 191 } 192 194 193 for (i = 0; i < length; i++) { 195 194 int v = Int_val(Field(ml_sound, i)); … … 197 196 } 198 197 199 CAMLlocal1(block); 200 block = alloc_array((value (*)(char const *))make_arr_entry, 201 (char const **)data); 202 free(data); 203 CAMLreturn(block); 198 CAMLreturn(Val_unit); 204 199 } 205 200 ocaml-remix/trunk/ladspa_raw.ml
r501 r503 14 14 external activate : plugin -> handle -> unit = "c_ex_ladspa_activate";; 15 15 16 external raw_sound_to_buffers : int array -> int -> buffer array=16 external raw_sound_to_buffers : int array -> buffer array -> unit = 17 17 "c_ex_ladspa_raw_sound_to_buffers";; 18 18 external buffers_to_raw_sound : buffer array -> int -> int array = ocaml-remix/trunk/ladspa_raw.mli
r501 r503 15 15 val activate : plugin -> handle -> unit;; 16 16 17 (* provide sound and number of channels*)18 val raw_sound_to_buffers : int array -> int -> buffer array;;17 (* provide sound and output buffer array *) 18 val raw_sound_to_buffers : int array -> buffer array -> unit;; 19 19 (* provide buffers and length of each one in samples *) 20 20 val buffers_to_raw_sound : buffer array -> int -> int array;;
