root/ocaml-remix/trunk/instrument_test.ml

Revision 508, 1.0 kB (checked in by shans, 1 year ago)

Layers now accept plugins instead of sounds (getting closer to original remix
approach). To embed sounds, use Plugin.from_sound.

Line 
1 open Tone;;
2
3 let remix = Remix.create 44000 2 120.;;
4
5 let env = Envelope.adsr (Time.Seconds 0.05) (Time.Seconds 0.1) 0.8
6                                                     (Time.Seconds 0.01);;
7
8 let sf wave amp tone = Envelope.apply env (wave amp tone);;
9  
10
11 let instrument1 = Instrument.from_sound_function (sf Wave.tri);;
12 let instrument2 = Instrument.from_sound_function ~start:6. (sf Wave.square);;
13
14 let tonote (t,r,l) = (note t r, l);;
15
16 let layer = Layer.empty ();;
17 Instrument.add_notes instrument1 layer (Volume.ramp 5000. 30000.)
18   (List.map tonote [(c, 0, 0.5); (d, 0, 0.5); (e, 0, 0.5); (f, 0, 0.5);
19                     (g, 0, 0.5); (a, 0, 0.5); (b, 0, 0.5); (c, 1, 2.5)]);;
20
21 Instrument.add_notes instrument2 layer (Volume.ramp 30000. 5000.)
22   (List.map tonote [(g, -1, 0.5); (a, -1, 0.5); (b flat, -1, 0.5); (c, 0, 0.5);
23               (d, 0, 0.5); (e flat, 0, 0.5); (f sharp, 0, 0.5); (g, 0, 2.5)]);;
24
25 let sound = Layer.to_sound layer Sound.silence;;
26
27 Sound.preview remix sound (Time.Beats 0., Time.Beats 12.)
28         (Time.Beats 0., Time.Beats 12.);;
Note: See TracBrowser for help on using the browser.