Changeset 495
- Timestamp:
- 08/18/07 10:40:36 (1 year ago)
- Files:
-
- ocaml-remix/trunk/instrument.ml (modified) (1 diff)
- ocaml-remix/trunk/instrument.mli (modified) (1 diff)
- ocaml-remix/trunk/instrument_test.ml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ocaml-remix/trunk/instrument.ml
r494 r495 5 5 type soundFunction = amplitude -> Tone.tone -> Sound.sound;; 6 6 type instrument = {sound_function : soundFunction; mutable position : float};; 7 8 let sound_function_from_wave wave amp tone = wave amp tone9 7 10 8 let from_sound_function ?(start=0.0) sf = {sound_function=sf; position=start};; ocaml-remix/trunk/instrument.mli
r494 r495 13 13 14 14 val from_sound_function : ?start:float -> soundFunction -> instrument;; 15 16 val sound_function_from_wave : Wave.wave -> soundFunction;;ocaml-remix/trunk/instrument_test.ml
r494 r495 2 2 3 3 let remix = Remix.create 44000 2 120.;; 4 let instrument = Instrument.from_sound_function 5 (Instrument.sound_function_from_wave Wave.tri);; 4 5 let env = Envelope.adsr (Time.Seconds 0.05) (Time.Seconds 0.1) 0.8 6 (Time.Seconds 0.05);; 7 8 let sf amp tone = Envelope.apply env (Wave.tri amp tone);; 9 10 11 let instrument = Instrument.from_sound_function sf;; 6 12 7 13 let layer = Layer.empty ();; 8 14 Instrument.add_notes instrument layer 30000. 9 15 [(note c 0, 0.5); (note d 0, 0.5); (note e 0, 0.5); (note f 0, 0.5); 10 (note g 0, 0.5); (note a 0, 0.5); (note b 0, 0.5); (note c 1, 0.5)];; 16 (note g 0, 0.5); (note a 0, 0.5); (note b 0, 0.5); (note c 1, 2.5); 17 (note g (-1), 0.5); (note a (-1), 0.5); (note (b flat) (-1), 0.5); 18 (note c 0, 0.5); (note d 0, 0.5); (note (e flat) 0, 0.5); 19 (note (f sharp) 0, 0.5); (note g 0, 2.5)];; 11 20 12 21 let sound = Layer.to_sound layer;; 13 22 14 Sound.preview remix sound (Time.Beats 0., Time.Beats 4.)15 (Time.Beats 0., Time.Beats 4.);;23 Sound.preview remix sound (Time.Beats 0., Time.Beats 12.) 24 (Time.Beats 0., Time.Beats 12.);;
