<info>
ESM Csound Library instrument algorithm  MIDIWAVE :
Mono output only.
The default score file included here specifies a sine wave for
the audio waveform function. Other available waveforms include
a sawtooth, square and triangle. Csound score files including
one of these functions can be created in a shell window with
the "getmidiscore" command, then read into Cecilia for use
by selecting the "Open score file" option under "Module" in the
CEC Editor window.
The MORE_EX subdirectory includes the module "midiwave.sawtooth,"
identical to this current module except that a sawtooth wave
is used for audio waveforms.
Allan Schindler  1/97
</info>
<tk_interface>


</tk_interface>
<mono>
; instrument algorithm "wave" (samples fixed wave form functions)
	instr	1
inum    notnum     ; needed only for stereo localization options
icps	cpsmidi
iamp	ampmidi	14000, 97

; ------ Clavinola pedals :  ------------------------
iatt = .05
    ; Clavinla RIGHT pedal, MIDI ctrl #  64 (continuous but very poor resolution)
    ; used as a sustain pedal :
     ; midictrl opcodes obsolete as of Csound 3.48
     ; isust  midictrl  64 
     ;idecay = (isust = 0 ? .2 : .4 * isust )  ; "fade-out" time after key released
isust  imidic7  64, .2, 40
idecay = (isust = 0 ? .2 : isust )  ; "fade-out" time after key released
iatdec  =  .02
iscale = 1.

   ; Clavinola left and middle pedals
   ; middle pedal (ctrl # 66) creates legato, left pedal creates (ctrl # 67) staccato
    ;  these 2 controllers are NOT continuous -- they are inits (either off or on)
ileftped    imidic7 67, 0, 1.
imidped    imidic7 66, 0, 1.

if ileftped > .5 igoto staccato  ; if left ped down, staccato articulation
if imidped > .5 igoto legato  ; if middle ped down, legato articulation
   igoto gotartic

legato:    ; MIddle pedal down
   ; if both left & middle pedals are down, use default normal articulation values
if imidped > .5 igoto gotartic 
   iatt    ampmidi  1.
   iatt  =  (.9 - iatt ) 
   idecay  = 3.5 * idecay
   iatdec  =  .04
   iscale = 1.3
   igoto gotartic
staccato:   ; left pedal down
   idecay  = .35 * idecay
   iatdec  =  .01
   iscale = .7
   igoto gotartic
;  ------- end of pedal controller input ----------
gotartic:

kamp	expon	iamp, iscale * 6, iamp/icps   ;freq-dependent overall decay
amp	linenr	kamp, iatt, idecay , iatdec
a1	oscil	amp, icps, 1
       out a1 
       endin 
    
</mono>
<stereo>


</stereo>
<quad>


</quad>
<score>
f1 0 2048 10 1.   ;  sinusoid
f97 0 128 5 1 128 18   ;for veloc to non-linear amp

 
f0 300 
e 

</score>

