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 - Gongs - standard mallet|2 - Gongs - hard mallet|3 - Gongs - stick|4 - Gongs - brush|5 - Gongs - water|6  - Feng Gong 55 - violin bow|7 - Chau Gong 40 - violin bow|8 - Hump Gong 36 - violin bow|9 - Hump Gong 32 - violin bow|10 - Feng Gong 25 - violin bow|11 - Chau Gong 18 - violin bow|12 - Feng Gong 55 - friction mallet|13 - Chau Gong 40 - friction mallet|14 - Hump Gong 36 - friction mallet|15 - Hump Gong 32 - friction mallet|16 Feng Gong 25 - friction mallet|17 - Chau Gong 18 - friction mallet||")
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)
