Changeset 495

Show
Ignore:
Timestamp:
08/18/07 10:40:36 (1 year ago)
Author:
shans
Message:

Example of envelopes for an instrument

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ocaml-remix/trunk/instrument.ml

    r494 r495  
    55type soundFunction = amplitude -> Tone.tone -> Sound.sound;; 
    66type instrument = {sound_function : soundFunction; mutable position : float};; 
    7  
    8 let sound_function_from_wave wave amp tone = wave amp tone 
    97 
    108let from_sound_function ?(start=0.0) sf = {sound_function=sf; position=start};; 
  • ocaml-remix/trunk/instrument.mli

    r494 r495  
    1313 
    1414val 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  
    22 
    33let remix = Remix.create 44000 2 120.;; 
    4 let instrument = Instrument.from_sound_function  
    5     (Instrument.sound_function_from_wave Wave.tri);; 
     4 
     5let env = Envelope.adsr (Time.Seconds 0.05) (Time.Seconds 0.1) 0.8  
     6                                                    (Time.Seconds 0.05);; 
     7 
     8let sf amp tone = Envelope.apply env (Wave.tri amp tone);; 
     9   
     10 
     11let instrument = Instrument.from_sound_function sf;;  
    612 
    713let layer = Layer.empty ();; 
    814Instrument.add_notes instrument layer 30000. 
    915  [(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)];; 
    1120 
    1221let sound = Layer.to_sound layer;; 
    1322 
    14 Sound.preview remix sound (Time.Beats 0., Time.Beats 4.)  
    15         (Time.Beats 0., Time.Beats 4.);; 
     23Sound.preview remix sound (Time.Beats 0., Time.Beats 12.)  
     24        (Time.Beats 0., Time.Beats 12.);;