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 Velocity + MW inverted|2 Vibrato Velocity|3 Vibrato MW|4 Vibrato to Senza Vibrato Velocity|5 Accent Vibrato Velocity|6 Bendy Short Velocity|7 Senza Vibrato Velocity + MW inverted|8 Senza Vibrato Velocity|9 Senza Vibrato MW|10 Senza Vibrato to Vibrato Velocity|11 Senza Vibrato Velocity X Vibrato MW|12 Marcato sfz - fp - Velocity|13 Crescendo Velocity X Marcato sfz MW|14 Pianissimo Velocity|15 Staccato Velocity|16 Bendy Staccato Velocity|17 Staccato + Bend Velocity|18 Bend RS Velocity|19 Bend RS MW|20 Staccato + Fall Velocity|21 Fall RS Velocity|22 Fall RS MW|23 Flutter Tongue Velocity + MW inverted|24 Flutter Tongue Velocity|25 Flutter Tongue MW|26 Senza Vibrato Velocity X Flutter Tongue MW|27 Senza Vibrato MW X Flutter Tongue CC#2 two dimensional|28 Growling Velocity|29 Growling MW|30 Senza Vibrato Velocity X Growling MW|31 Senza Vibrato MW X Growling CC#2 two dimensional|32 Voice Breathing Fifth Velocity|33 Voice Breathing Fifth MW|34 Senza Vibrato Velocity X Voice Breathing Fifth MW|35 Senza Vib MW X Voice Breath Fifth CC#2 two dimensional|36 Voice Breathing Sixth Velocity|37 Voice Breathing Sixth MW|38 Senza Vibrato Velocity X Voice Breathing Sixth MW|39 Senza Vib MW X Voice Breath Sixth CC#2 two dimensional|40 Voice Breathing Velocity Fifth X Sixth MW|41 Senza Vib MW X Voice Breath 5+6 CC#2 two dimensional|42 Multiphonics Long Velocity|43 Multiphonics Long MW|44 Multiphonics Short Velocity|45 Multiphonics Short MW|46 Multiphonics Try Velocity|47 Multiphonics Try MW|48 Key Noises Velocity|49 Key Noise Sequences Velocity|50 Body Strokes + Vacuum Suck Velocity|51 Slap Tongue Velocity|52 Air Noises Velocity|53 Air Noises MW|54 Air Noises Accent Velocity|55 Undefined Sounds 1 Velocity|56 Undefined Sounds 1 MW|57 Undefined Sounds 2 Velocity|58 Undefined Sounds 2 MW|59 Portato Velocity|60 Secco Velocity|61 Pseudo Piccolo Velocity + MW inverted|62 Pseudo Piccolo Staccato Velocity|63 Pseudo Alto Velocity + MW inverted|64 Pseudo Alto 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)
