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 Double Reeds + Flutes Velocity|2 Double Reeds + Flutes Staccato Velocity|3 Reeds + Flutes Flutter Tongue Velocity|4 Reeds Velocity|5 Reeds Staccato Velocity|6 Double Reeds Senza Vibrato + Flutes Velocity|7 Double Reeds + Reeds Staccato Velocity|8 Flutes Velocity|9 Flutes Staccato Velocity|10 Secco X Key Noises Velocity|11 Key Noises Velocity|12 Air Noises Velocity|13 Multiphonics Velocity|14 Undefined Tones Velocity|15 Double Reeds + Flutes MW|16 Reeds MW|17 Double Reed + Reed Senza Vibrato MW|18 Flutes MW|19 Double Reeds Flutter Tongue Velocity|20 Flutes Flutter Tongue Velocity|21 Double Reeds + Flutes Velocity + MW inverted|22 Reeds Velocity + MW inverted|23 Double Reeds + Reeds Senza Vibrato Velocity + MW inverted|24 Flutes Velocity + MW inverted|25 Wododwinds Velocity X MW X CC2|26 Changing Staccato Velocity|27 Triple Tongue 16T|28 Air Noises MW|29 Multiphonics MW|30 Reeds Flutter Tongue MW|31 Double Reeds Flutter Tongue MW|32 Flutes Flutter Tongue MW|33 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)
