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 Setup 1 Standard Mallets Velocity|2 Setup 1 Rolls Standard Mallets MW|3 Setup 1 Hard Mallets Velocity|4 Setup 1 Rolls Hard Mallets MW|5 Setup 1 Short Damped Velocity|6 Setup 1 Damping Release Switch|7 Setup 1 Hand Strokes Velocity|8 Setup 1 Brush Velocity|9 Rolls with Cymbal 8+16 on Skin Velocity|10 Kettle Strokes Velocity|11 Setup 2 Standard Mallets Velocity|12 Setup 2 Rolls Standard Mallets MW|13 Setup 2 Hard Mallets Velocity|14 Setup 2 Rolls Hard Mallets MW|15 Setup 2 Short Damped Velocity|16 Setup 2 Damping Release Switch|17 Setup 2 Hand Strokes Velocity|18 Setup 2 Brush Velocity|19 Stir + Wipe Velocity MW Shape|20 Stir + Wipe + Kettle Strokes + Cymbals on Skin MW Switch|21 Setup 3 Standard Mallets Velocity|22 Setup 3 Rolls Standard Mallets MW|23 Setup 3 Hard Mallets Velocity|24 Setup 3 Rolls Hard Mallets MW|25 Setup 3 Short Damped Velocity|26 Setup 3 Damping Release Switch|27 Setup 3 Hand Strokes Velocity|28 Setup 3 Brush Velocity|29 Setup 4 Standard Mallets Velocity|30 Setup 4 Rolls Standard Mallets MW|31 Setup 4 Hard Mallets Velocity|32 Setup 4 Rolls Hard Mallets MW|33 Setup 4 Short Damped Velocity|34 Setup 4 Damping Release Switch|35 Setup 4 Hand Strokes Velocity|36 Setup 4 Brush Velocity|37 Setup 5 Standard Mallets Velocity|38 Setup 5 Rolls Standard Mallets MW|39 Setup 5 Hard Mallets Velocity|40 Setup 5 Rolls Hard Mallets MW|41 Setup 5 Short Damped Velocity|42 Setup 5 Damping Release Switch|43 Setup 5 Hand Strokes Velocity|44 Setup 5 Brush Velocity||")
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)
