-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspectrogram.ml
61 lines (47 loc) · 1.41 KB
/
spectrogram.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
open Graphics;;
let print_spectr t spect=
let spec= Array.make_matrix (Array.length spect) 1 (rgb 0 0 0) in
for i=0 to Array.length spect -1 do
spec.(i).(0)<- (rgb (spect.(i)) (spect.(i)) (spect.(i))) ;
(*TODO : Adjust linearization*)
done;
let im= make_image spec in
draw_image im t 0
let defiler x1 y1 x2 y2 =
let a = get_image x1 y1 x2 y2 in
draw_image a (x1-1) y1
let swip_and_print spect x1 y1 x2 y2 =
defiler x1 y1 x2 y2;
print_spectr (x2) spect
(* Paramètres de normalisation*)
module Example2(K: Interface.S)=struct
module K = K
module Lib = Kahn.Lib(K)
open Lib
let a = 1.
let b = 0.
let rec normalisation = function
|t::q->let value=int_of_float(a *. t +. b) in (max (min 255 value) 0 ):: (normalisation q)
|[]->[]
let printer (l_chan : Complex.t K.in_port list) : unit K.process =
let rec accumulate l lwork = match l with
|t::q-> (K.get t) >>= ( fun v-> accumulate q (v::lwork))
| [] -> let lfinal= List.map Complex.norm lwork in
let lfinal =List.map normalisation lfinal in
swip_and_print (Array.of_list lfinal) 1 0 500 (List.length l_chan);
accumulate l_chan []
in
open_graph " 800x600";
accumulate l_chan
end
(*
let () =
open_graph " 800x600";
while(true)
do
let a = Array.make 600 0 in
for i=0 to 599 do
a.(i) <- Random.int 255
done;
swip_and_print (a) 1 0 500 600;
done*)