// Bosendorfer NI Akoustik piano sfz mapping

//// idea from DimensionalTips.pdf: transpose and repitch complementarily to
//// preserve tuning but change the samples used so as to alter the tone

//// http://project5.technetos.com/synth/dimension/sfz-grand-piano.shtml mentions:
//// “higher notes on the keyboard shorten the final 'decay' time of the envelope's
//// release portion. Just like a real piano.”

<group> // sustain resonance (SF) [CC75 == "Sound Control 6"]
////locc75=1 hicc75=127 locc64=127 hicc64=127 off_by=1001 // 1. "resource-saver": don't trigger if silent, or if pedal is up
xfin_locc64=0 xfin_hicc64=127 // 2. "pedal-fade": always trigger to make sustain always available for pedal-downs
//// 3. "cut-only" : triggered and audible, only silenced when special pedalup+keyup regions at bottom trigger
////    use off_by=_KEY_ per note to match the mute regions, apparently needs every note defined by its own
////    region here. :(
xfin_locc75=0 xfin_hicc75=127 xf_cccurve=gain loop_mode=one_shot off_mode=normal ampeg_release=0.1
!*SF*|s/.*R(\([^)]*\)).*/\1/!<region> sample=_SAMPLE_ pitch_keycenter=_KEY_ lokey=_LOKEY_ hikey=_HIKEY_

<group> // release resonance (RF) [CC76 == "Sound Control 7"]
locc76=1 hicc76=127 locc64=0 hicc64=0 // don't trigger if silent, or pedal is down
////xfout_locc64=0 xfout_hicc64=127 // always trigger to make release always available for pedal-ups
xfin_locc76=0 xfin_hicc76=127 xf_cccurve=gain trigger=release off_by=1000
!*RF*|s/.*R(\([^)]*\)).*/\1/!<region> sample=_SAMPLE_ pitch_keycenter=_KEY_ lokey=_LOKEY_ hikey=_HIKEY_

<group> // action release noise (HN) [CC77 == "Sound Control 8"]
locc77=1 hicc77=127 // don't trigger if silent
xfin_locc77=0 xfin_hicc77=127 trigger=release pitch_keytrack=0
!*HN*|s/.*R(\([^)]*\)).*/\1/!<region> sample=_SAMPLE_ pitch_keycenter=_KEY_ lokey=_LOKEY_ hikey=_HIKEY_

<group> // pedal noise [CC78 == "Sound Control 9"]
locc78=1 hicc78=127 // don't trigger if silent
xfin_locc78=0 xfin_hicc78=127 ampeg_release=0.05
hikey=-1 // "must be done" for midi-cc triggering according to http://www.drealm.info/sfz/plj-sfz.xhtml
@*Pedal?Down*@<region> sample=_SAMPLE_ on_locc64=127 on_hicc64=127 group=1000 off_by=1001 // pedal down
@*Pedal?Up*@<region> sample=_SAMPLE_ on_locc64=0 on_hicc64=0 group=1001 off_by=1000 // pedal up

<group> // "open lid?" MF notes [CC74 == "Sound Brightness"]
locc74=1 hicc74=127 // don't trigger if silent
xfin_locc74=0 xfin_hicc74=127 xf_cccurve=gain ampeg_release=0.1
!*MF*|s/.*R(\([^)]*\)).*/\1/!<region> sample=_SAMPLE_ pitch_keycenter=_KEY_ lokey=_LOKEY_ hikey=_HIKEY_ lovel=_LOVEL_ hivel=_HIVEL_

<group> // "closed lid?" ML notes [CC74 == "Sound Brightness"]
locc74=0 hicc74=126 // don't trigger if silent
xfout_locc74=0 xfout_hicc74=127 xf_cccurve=gain
!*ML*|s/.*R(\([^)]*\)).*/\1/!<region> sample=_SAMPLE_ pitch_keycenter=_KEY_ lokey=_LOKEY_ hikey=_HIKEY_ lovel=_LOVEL_ hivel=_HIVEL_

//// cut-only: regions to trigger sustain-cuts
////<group> trigger=release locc64=0 hicc64=0 // key release while pedal is up
////%*%<region> key=_KEY_ group=_KEY_
////<group> hikey=-1 on_locc64=0 on_hicc64=0 // pedal release while key is up
////%*%<region> sw_lokey=_KEY_ sw_hikey=_KEY_ sw_up=_KEY_ group=_KEY_