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 Vowel A Velocity|2 Vowel E Velocity|3 Vowel O Velocity|4 Du Short|5 Ga Short|6 Ki Short|7 Pae Short|8 Tra Short|9 La Short|10 Ma Short|11 Ne Short|12 Schae Short|13 Su Short|14 Ha Short|15 He Short|16 Ho Short|17 Hum Velocity|18 Buzz W Velocity|19 Buzz S Velocity|20 AEIOU Velocity MW reverse|21 Du Staccato Velocity|22 Ga Staccato Velocity|23 Ki Staccato Velocity|24 Pae Staccato Velocity|25 Tra Staccato Velocity|26 L-A Staccato Velocity RS MW Release - |27 M-A Staccato Velocity RS MW Release -|28 N-E Staccato Velocity RS MW Release -|29 Sch-E Staccato Velocity RS MW Release -|30 S-U Staccato Velocity RS MW Release -|31 Breath - Chew - Sigh - Undefined Sounds Velocity|32 Cough - Laugh - MMMM - Rocket Velocity|33 Vowel A MW|34 Vowel E MW|35 Vowel O MW|36 Vowel Move MW E - O - A Velocity|37 Vowel Move MW A - O Velocity|38 Vowel Move MW O - E Velocity|39 Vowel Move MW Formant Filter A - O - U Velocity|40 Vowel Move MW Formant Filter A - E - I Velocity|41 Hum - Vowel O Velocity|42 A x Hum MW Velocity|43 O x Hum MW Velocity|44 Buzz W x O MW Velocity|45 A x L MW Velocity|46 L - AE Staccato RS MW Release -|47 L - E Staccato RS MW Release -|48 M - AE Staccato RS MW Release -|49 M - U Staccato RS MW Release -|50 N - A Staccato RS MW Release -|51 N - AE Staccato RS MW Release -|52 N - U Staccato RS MW Release -|53 Ha Staccato Velocity|54 He Staccato Velocity|55 Ho Staccato Velocity|56 K - Vowel E Velocity|57 D - Vowel O Velocity|58 Trrrr Velocity MW Rra|59 Sch Velocity|60 P Velocity MW AE|61 K Velocity MW I|62 D Velocity MW U|63 Sss Velocity|64 G Velocity MW A|65 Choir A Velocity + MW|66 Choir E Velocity + MW|67 Choir O Velocity + MW||")
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)
