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 Big Drum Standard Mallets Velocity|2 Big Drum Hard Mallets Velocity|3 Big Drum Rods Velocity MW Shape|4 Big Drum Hand Velocity MW Shape|5 Big Drum Brush Velocity MW Shape|6 Big Drum Rolls MW|7 Big Drum Body Strokes Velocity MW Shape|8 Big Drum Wiped Velocity MW Shape|9 Big Drum Rub Tones Velocity MW Shape|10 Big Drum Map Velocity MW Shape|11 Piatti Standard Velocity 18 + 20 inch MW Shape|12 Piatti Damped Velocity 18 + 20 inch MW Shape|13 Piatti Wiped Velocity 18 + 20 inch MW Shape|14 Piatti Tremolo Velocity 18 + 20 inch MW Shape|15 Piatti Map Velocity 18 + 20 inch MW Shape|16 Thunder Sheet Standard Velocity MW Shape|17 Thunder Sheet Hard Velocity MW Shape|18 Thunder Sheet Hand Velocity MW Shape|19 Thunder Sheet Finger Velocity MW Shape|20 Thunder Sheet Tremolo Velocity MW Shape|21 Thunder Sheet Tremolo Long Velocity|22 Thunder Sheet Map Velocity MW Shape|23 Tamtam Velocity|24 Map - Big Drum + Tamtam + Thunder Sheet + Piatti||")
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)
