Changeset 503

Show
Ignore:
Timestamp:
09/10/07 22:33:24 (1 year ago)
Author:
shans
Message:

converted raw_sound_to_buffers to work on already instantiated buffers,
started sketching interface for ladspa compiled pipelines

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ocaml-remix/trunk/ladspa.ml

    r502 r503  
    4343        let channels = Remix.channels remix in 
    4444        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 
    4650      ) 
    4751    | Plugin (name, trees, adding, outputs) -> 
     
    6771  let result = _render_tree tree in 
    6872  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 *) 
     82type 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  
    176176} 
    177177 
    178 CAMLprim c_ex_ladspa_raw_sound_to_buffers(value ml_sound, value ml_channels) { 
     178CAMLprim c_ex_ladspa_raw_sound_to_buffers(value ml_sound, value ml_buffers) { 
    179179 
    180180  CAMLparam1(ml_sound); 
    181181 
    182182  int length = Wosize_val(ml_sound); 
    183   int channels = Int_val(ml_channels); 
     183  int channels = Int_val(ml_buffers); 
    184184  int i; 
    185185   
    186   LADSPA_Data **data = malloc((channels + 1) * sizeof(LADSPA_Data *)); 
     186  LADSPA_Data **data = malloc(channels * sizeof(LADSPA_Data *)); 
    187187   
    188188  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 
    194193  for (i = 0; i < length; i++) { 
    195194    int v = Int_val(Field(ml_sound, i)); 
     
    197196  } 
    198197 
    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); 
    204199} 
    205200 
  • ocaml-remix/trunk/ladspa_raw.ml

    r501 r503  
    1414external activate : plugin -> handle -> unit = "c_ex_ladspa_activate";; 
    1515 
    16 external raw_sound_to_buffers : int array -> int -> buffer array =  
     16external raw_sound_to_buffers : int array -> buffer array -> unit =  
    1717                                          "c_ex_ladspa_raw_sound_to_buffers";; 
    1818external buffers_to_raw_sound : buffer array -> int -> int array = 
  • ocaml-remix/trunk/ladspa_raw.mli

    r501 r503  
    1515val activate : plugin -> handle -> unit;; 
    1616 
    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 *) 
     18val raw_sound_to_buffers : int array -> buffer array -> unit;; 
    1919(* provide buffers and length of each one in samples *) 
    2020val buffers_to_raw_sound : buffer array -> int -> int array;;