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 Senza Vibrato Velocity + MW inverted|2 Spiccato Pizzicato Col Legno MW Switch|3 Tremolo Velocity + MW inverted|4 Tremolo SP + Sul Ponticello MW|5 Harmonics + Glissando|6 Con Sordino Vibrato + Senza Vibrato Velocity MW|7 Vibrato Velocity + MW inverted|8 Spiccato + Martellato CC2 MW Shape|9 Pizzicato + Bartok Pizzicato CC2 MW Shape|10 Col Legno + Finger CC2 MW Shape|11 Vibrato Velocity Ensemble 3 Voices|12 Spiccato Velocity Ensemble 3 Voices|13 Pizzicato Velocity Ensemble 3 Voices|14 Tremolo Velocity Ensemble 3 Voices|15 Bartok Pizzicato Velocity Ensemble 3 Voices|16 Col Legno Velocity Ensemble 3 Voices|17 Con Sordino Vibrato Velocity Ensemble 3 Voices|18 Finger Velocity Ensemble 3 Voices|19 Tremolo Sul Ponticello Velocity Ensemble 3 Voices|20 Sul Ponticello Velocity Ensemble 3 Voices|21 Undefined tones A Ensemble|22 Random Pizzicato Garden MW Shape|23 Unpredictable Ensemble|24 Undefined tones A|25 Harmonics Glissando natural + artificial|26 Pizzicato Harmonics C-G-D-A + Dead Notes|27 Gettato MW Shape|28 Pizzicato Vibrato|29 Pizzicato Vibrato Ensemble 3 Voices|30 Spiccato Tempo Sync 16T|31 Senza Vibrato MW|32 Vibrato MW|33 Vibrato + Senza Vibrato MW 2 dimensional X CC2|34 Natural Harmonics|35 Glissando Harmonics + Artificial|36 Uncommon Articulation Delay 16|37 Tremolo MW|38 Spiccato Velocity|39 Pizzicato Velocity|40 Bartok Pizzicato Velocity|41 Col Legno Velocity|42 Finger Velocity|43 Tremolo Sul Ponticello MW|44 Sul Ponticello MW|45 Con Sordino Senza Vibrato MW|46 Con Sordino Vibrato MW|47 Sul Ponticello Short Velocity|48 Martellato Velocity|49 Artificial Harmonics MW|50 Portato Velocity|51 Col Legno Gettato Velocity|52 Flautando MW|53 Spiccato Con Sordino Velocity|54 Spiccato Sul Ponticello Velocity|55 Pizzicato Sul Ponticello Velocity|56 Pizzicato Con Sordino Velocity|57 Gettato Velocity|58 Staccato Velocity MW Spiccato|59 Harmonics Tremolo MW|60 Harmonics Glissando MW|61 Harmonics Tremolo Glissando MW|62 Artificial Harmonics Glissando MW|63 Bridge Bowed MW|64 Bow Scratch MW|65 Scroll Kiss MW|66 Bowed Between Stringholder and Bridge MW|67 Pizzicato Behind Bridge Velocity|68 Pizzicato in Peg Box Velocity|69 Body Strokes Velocity|70 Dead Notes Velocity|71 Pizzicato Harmonics sul C + sul D Velocity|72 Pizzicato Harmonics sul G + sul A Velocity|73 Natural Harmonics sul C MW|74 Natural Harmonics sul G MW|75 Natural Harmonics sul D MW|76 Natural Harmonics sul A MW|77 With Accent 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)
