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 Open MW|2 Flutter Tongue Velocity MW Shape|3 Staccato Velocity MW Shape|4 Soft Tone - without mouthpiece Velocity MW Shape|5 Cup Mute co MW|6 Cup Mute co Short Velocity MW Shape|7 Cup Completely Closed MW|8 Cup Completely Closed Staccato Velocity MW Shape|9 Harmon Mute MW|10 Harmon Mute Staccato Velocity MW Shape|11 Straight Mute MW|12 Straight Mute Staccato Velocity MW Shape|13 Mouthpiece Tones Velocity MW Shape|14 Pedal Tones Velocity MW Shape|15 Shakes Whole Tone Velocity RS MW Shape|16 Voice Breathing Velocity CC4 + AT|17 Lip Trill Whole Tone Velocity MW Shape|18 Undefined Tones Velocity MW Shape|19 Air Noises Velocity MW Shape CC4|20 Valve Noises Velocity|21 Mouthpiece Strokes Velocity|22 Glissando up + down Velocity MW Shape|23 Gliss 2 Octaves up + down Velocity MW Shape|24 Gliss Free High up + down Velocity MW Shape|25 Shake up + down Glissando Velocity MW Shape|26 Open Glissando down RS Velocity|27 Open Glissando up RS Velocity|28 Open Velocity + MW inverted|29 Open Velocity|30 Open Velocity x MW Flutter Tongue|31 Cup Mute Velocity X MW|32 Harmon Mute Velocity X MW|33 Straight Mute Velocity X MW|34 Open Velocity Bell MW|35 Triple Tongue 16T|36 Staccato Velocity|37 Harmon Mute Staccato Velocity|38 Straight Mute Staccato Velocity|39 Flutter Tongue MW|40 Pedal Tones MW|41 With Accent Velocity|42 Without Mouthpiece MW|43 Cup Mute co Short Velocity|44 Mouthpiece Tones MW|45 Shakes Velocity|46 Voice Breathing MW|47 Lip Trill MW|48 Undefined Tones Velocity|49 Air Noises Velocity|50 Glissando up-down Velocity MW|51 Shake up-down Glissando Free MW|52 Crescendo|53 Vibrato MW|54 Vibrato Velocity|55 Vibrato Velocity + MW inverted|56 Secco Velocity|57 Portato Velocity|58 Pseudo Horn Open Velocity + MW inverted|59 Pseudo Horn Staccato Velocity|60 Pseudo Piccolo Trumpet Open Velocity + MW inverted|61 Pseudo Piccolo Trumpet 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)
