root/ocaml-remix/trunk/layer_test_sins.ml

Revision 529, 1.1 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 (* middle A has a frequency of 440 Hz.  at a samplerate of 44 kHz, that is
2    a period of 100 samples *)
3
4 let remix = Remix.create 44000 2 120.;;
5
6 let e t = Envelope.adsr t (Time.Seconds 0.1) (Time.Seconds 0.4) 0.8
7                                                           (Time.Seconds 0.1);;
8
9 let a t    = Note.from_sound
10         (Envelope.apply (e t) (Wave.sin    (Volume.constant 1.) 440.));;
11 let hi_a t = Note.from_sound
12         (Envelope.apply (e t) (Wave.square (Volume.constant 0.7) 880.));;
13 let e t    = Note.from_sound
14         (Envelope.apply (e t) (Wave.tri    (Volume.constant 0.7) 660.));;
15
16 let layer = Layer.empty ();;
17
18 let add note start len =
19     Layer.add_note layer (note (Time.Seconds len))
20                           (Time.Seconds start, Time.Seconds len);;
21
22 add a    2.0  4.0;;
23 add hi_a 6.0  2.0;;
24 add e    12.0 3.0;;
25
26 Layer.print layer;;
27 let sound = Layer.to_note layer Sound.silence;;
28                                                            
29 Sound.preview remix sound (Time.Seconds 0.0)
30                     (Time.Seconds 0.0, Time.Seconds 15.0);;
Note: See TracBrowser for help on using the browser.