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 Molto Vibrato MW|3 Staccato Velocity 1 MW Shape|4 Staccato Velocity 2 MW Shape|5 Flutter Tongue MW|6 Jet Whistle + Slap Tongue|7 Slap Tongue Velocity|8 Airy Secco Velocity|9 Key Noises Velocity|10 Harmonics Velocity|11 Multiphonics Velocity|12 Air Noises Velocity|13 Voice Breathing octave|14 Voice Breathing fourth|15 Vibrato Velocity|16 Molto Vibrato Velocity|17 Flutter Tongue Velocity|18 Vibrato Velocity + MW inverted|19 Staccato + Key Noises X Air Velocity MW|20 Vibrato + Flutter Tongue Velocity X MW|21 Triple Tongue 16T|22 Staccato Velocity|23 Multiphonics MW|24 Air Noises MW|25 Voice Breathing MW|26 With Accent Velocity|27 Crescendo|28 Portato Velocity|29 Vibrato - Molto Vibrato Velocity X MW|30 Flutter Tongue Velocity + MW inverted|31 Pseudo Contrabass Velocity + MW inverted|32 Pseudo Contrabass Staccato 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)
