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 Vibrato MW|2 Senza Vibrato MW|3 Staccato Velocity MW Shape|4 Flutter Tongue MW|5 Airy Tones Velocity MW Shape|6 Soft Whistle Velocity MW Shape|7 Harmonics Velocity MW Shape|8 Bendings Up-Down Velocity MW|9 Glissandi Velocity MW Shape|10 Undefined Tones Velocity MW Shape|11 Vibrato Velocity|12 Senza Vibrato Velocity|13 Vibrato Velocity + MW inverted|14 Senza Vibrato Velocity + MW inverted|15 Vibrato + Flutter Tongue Velocity X MW|16 Senza Vibrato + Flutter Tongue Velocity X MW|17 Vibrato + Senza Vibrato MW 2 dimensional X CC2|18 Vibrato + Senza Vibrato Velocity X MW|19 Triple Tongue 16T|20 Staccato Velocity|21 With Accent Velocity|22 Airy Tones MW|23 Harmonics Velocity|24 Glissandi MW|25 Undefined Tones Velocity|26 Soft Whistle Tones MW|27 Crescendo|28 Portato Velocity|29 Vibrato to Senza Vibrato Velocity|30 Senza Vibrato to Vibrato Velocity|31 Secco Velocity|32 Flutter Tongue 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)
