root/ocaml-remix/trunk/transparency.ml

Revision 529, 0.9 kB (checked in by shans, 4 years ago)

Replacing sound implementation - WAS ocaml int arrays, IS native float
arrays. This has not yet been completely been debugged!

Line 
1 type raw_transparency = FB.buffer;;
2
3 type transparency = Remix.remix -> Time.extent -> Time.extent ->
4           raw_transparency;;
5
6 let linear_ramp start_val end_val remix (start, length) (ostart,olength) =
7   let _to_raw a = (Time.time_to_raw_time remix a) in
8   let raw_start = _to_raw start in
9   if length = Time.Forever then
10     Printf.printf "can't create a linear ramp with an unbounded end time!\n%!";
11   let raw_length = _to_raw length in
12   let raw_ostart = _to_raw ostart in
13   let raw_olength = _to_raw olength in
14   let _fill pos =  start_val +.
15       float_of_int (pos + raw_ostart - raw_start) /.
16                       float_of_int raw_length *. (end_val -. start_val) in
17   let b = FB.create raw_olength (Remix.channels remix) in
18   FB.fill b _fill; b;;
19
20 let constant value remix (start, len) (rstart, rlength) =
21   let len = (Time.time_to_raw_time remix rlength) in
22   let b = FB.create len (Remix.channels remix) in
23   FB.fill b (fun a -> value); b;;
Note: See TracBrowser for help on using the browser.