selected = false
muted = false
midiChan = 0

gfx.init("Xsample",1,1)

gfx.x = gfx.mouse_x
gfx.y = gfx.mouse_y

input = gfx.showmenu("1 Finger Open MW Damp RT|2 Finger|3 Finger Velocity Foot Slide Noise|4 Finger Vibrato|5 Sul Tasto Open|6 Sul Tasto|7 Sul Pont Open|8 Sul Pont|9 Nail Open|10 Nail|11 Artificial Harmonics MW Release -|12 Natural Harmonics Velocity MW Release -|13 Bartok Pizzicato|14 Prepared Open MW Damp RT|15 Prepared|16 Finger Short MW Long|17 Damp|18 Body Strokes|19 Stringholder and Bridge Plucks and Noises|20 Dead Notes|21 Undefined Harmonics|22 Slide Noises|23 Slide Noises Pressure|24 Slides Down|25 Slides Up|26 Damp RT|27 Sul Tasto - Sul Pont MW X|28 Nail - Sul Pont MW X|29 Finger - Nail MW X|30 Finger + Slap Velocity Foot Slide Noise|31 Major Up MW 6-4 Strings - PB Variation - Velocity Speed|32 Major Down MW 6-4 Strings - PB Variation - Velocity Speed|33 Major Arpeggio 16th MW Shape PB Variation|34 Natural Harmonics Sul E - MW Release -|35 Natural Harmonics Sul A - MW Release -|36 Natural Harmonics Sul D - MW Release -|37 Natural Harmonics Sul G - MW Release -|38 Natural Harmonics Sul B - MW Release -|39 Natural Harmonics Sul Eo - MW Release -|40 Finger - Nail - Sul Pont MW Switch|41 Finger Variation|42 Finger Variation MW Damp RT|43 Natural Harmonics Sul D dropped - MW release -||")
if input >= 0 then 

function main() 
  take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
  if take == nil then return end
  item = reaper.GetMediaItemTake_Item(take)
  pos = reaper.GetCursorPosition() 
  ppq = reaper.MIDI_GetPPQPosFromProjTime(take, pos)
  
  MSB = 0
  LSB = 0
  PC  = 0
  
  if input ~= 0 then
  
  reaper.MIDI_InsertCC(
    take, 
    selected,
    muted,
    ppq,
    0xB0,-- midi CC
    midiChan,
    0, -- controller #0: Bank Select MSB
    input-1 -- MSB value
  )
  reaper.MIDI_InsertCC(
    take, 
    selected,
    muted,
    ppq,
    0xB0,-- midi CC
    midiChan,
    32, -- controller #32: Bank Select LSB
    0 -- LSB value
  )
  reaper.MIDI_InsertCC(
    take, 
    selected,
    muted,
    ppq,
    0xC0,-- Program Change
    midiChan,
    PC, -- program change value
    0
  )
  end
  reaper.UpdateItemInProject(item)   
end
end

script_title = "Xsample Acoustic Instruments"
reaper.Undo_BeginBlock()
main()
reaper.Undo_EndBlock(script_title, 0)
