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 Cymbals|2 Cymbals Damped|3 Cymbal Rolls MW|4 Tamtam Velocity MW Shape|5 Big Drum Velocity MW Shape|6 Snare Velocity MW Shape + Roll MW|7 Tambourine Velocity MW Shape|8 Castanets + Woodblocks + Claves|9 Wood + Bar Chimes Velocity MW Shape|10 Triangle Velocity MW Shape|11 Tom-Toms 16 + 14 + 12 + 10 inch|12 Cymbals Bowed Velocity MW Shape|13 Cymbals on the floor|14 Cymbals on the floor Ensemble|15 Map 1 Tamb Triangle Castanets Woodbl Claves Chimes|16 Map 2 Big Drum Tamtam Cymbals + Damped MW|17 Map 3 Big Drum Tom-Toms Snare||")
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)
