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 Position 1 Velocity MW Plectrum - CC4 Slides|2 Position 2 Velocity MW Plectrum - CC4 Slides|3 Position 3 Velocity MW Plectrum - CC4 Slides|4 Position 4 Velocity MW Plectrum - CC4 Slides|5 Position 5 Velocity MW Plectrum - CC4 Slides|6 Position 6 Velocity MW Plectrum - CC4 Slides|7 Dead Notes Velocity - CC4 Strokes|8 Undefined Tones - Strokes Velocity - CC4 Dead Notes|9 Slides 1 Velocity|10 Slides 2 Velocity|11 Position 1 Velocity MW Shape|12 Position 2 Velocity MW Shape|13 Position 3 Velocity MW Shape|14 Position 4 Velocity MW Shape|15 Position 5 Velocity MW Shape|16 Position 6 Velocity MW Shape|17 Position 1 - 5 Round Robin MW Shape|18 Position 1 - 5 Plectrum Round Robin MW Shape|19 Velocity MW Slaps|20 Slaps Velocity MW Shape||")
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)
