
<CsoundSynthesizer>
<CsOptions>

</CsOptions>
<CsInstruments>

sr = 44100
kr = 882
ksmps = 50
nchnls = 2

#define SURMULOTDIR #d:/devel/surmulot#

;|menu SoundFont
;|MaestroVelocity
; #define SOUNDFONT #$SURMULOTDIR/soundfonts/Maestro_Velocity.sf2# 
; #define PRESET #0#
;|NylonGuitar
#define SOUNDFONT #$SURMULOTDIR/soundfonts/NylonGuitar1.SF2#
#define PRESET #0#
;|Cister
; #define SOUNDFONT #$SURMULOTDIR/soundfonts/cister.sf2# 
; #define PRESET #127#
;|Psaltry
; #define SOUNDFONT #$SURMULOTDIR/soundfonts/Psaltry.sf2# 
; #define PRESET #0#
;|ProTrax
; #define SOUNDFONT #$SURMULOTDIR/soundfonts/ProTrax_Classical_Guitar.sf2# 
; #define PRESET #0#
;|endmenu

#ifndef VOLUME
#define VOLUME #70000#
#end

#ifndef BANK
#define BANK #0#
#end

#ifndef PRESET
#define PRESET #0#
#end

#ifndef SOUNDFONT
#define SOUNDFONT #$SURMULOTDIR/soundfonts/Maestro_Velocity.sf2# 
#end

giengine  fluidEngine
isfnum    fluidLoad "$SOUNDFONT", giengine, 1
          fluidProgramSelect giengine, 1, isfnum, $BANK, $PRESET

instr 1
/* 
((pitchField: 4)
 (pitchFormat: cps)
 (ampField: 5)
 (ampMin:max: (0 127))
 (iTemplate: "i 1 0 0.5 440 80 0 1"))
*/
            ;; p4   base pitch (cps)
            ;; p5   velocity
            ;; p6   pitch bend envelope over p3 (in semitones)
            ;; p7   envelope multiplier

  imfloat   =  (17.31234049066757 * log(p4)) - 36.376316562296
  ikey      =  round(imfloat)
  ipbend    =  (imfloat - ikey) / 2

  ivel      init      p5

  kpbend    =  0
if p6=0 goto noEnvelope
  kndx      line      0, p3, 1
  ksemitones   table  kndx, p6, 1 
  kpbend    =  p7 * ksemitones / 200
noEnvelope:

  kfullbend =  round(8192 * (1 + ipbend + kpbend))

  kdata1    =  kfullbend & 127
  kdata2    =  kfullbend >> 7

            fluidControl giengine, 224, 1, kdata1, kdata2  
            fluidNote   giengine, 1, ikey, ivel

  imvol     init      $VOLUME
  asigl, asigr fluidOut   giengine
            outs      asigl * imvol, asigr * imvol
endin
	
</CsInstruments>
<CsScore>
nil
i1 0.002 0.364 788.409 80 0 1 
i1 0.369 0.364 523.251 80 0 1 
i1 0.738 0.364 987.767 80 0 1 
i1 1.107 0.364 493.883 80 0 1 
i1 1.476 0.375 1046.502 80 0 1 
i1 1.845 0.375 369.994 80 0 1 
i1 2.214 0.369 466.164 80 0 1 
i1 2.583 0.369 554.365 80 0 1 
i1 2.952 0.508 349.228 80 0 1 
i1 3.452 0.5 493.883 80 0 1 
i1 3.952 0.508 830.609 80 0 1 
i1 4.452 0.494 246.942 80 0 1 
i1 4.952 0.508 880.0 80 0 1 
i1 5.452 0.494 174.614 80 0 1 
i1 5.952 0.5 415.305 80 0 1 
i1 6.452 0.508 554.365 80 0 1 
i1 6.952 0.494 880.0 80 0 1 

</CsScore>
</CsoundSynthesizer>
