[Help] Quickly return the keymapped phrase from the pressed note???


I’m looking for the fastest way to return the keymapped phrase that sounds pressing a note. What I’m looking for is to return the phrase from the pressed note.

7988 return-phrase-keymaped.png

Is there any way to return the object of the phrase, without having to do it through the note_range?I need to access the properties of the phrase quickly, for example the number of its index or its name.I am using this function:

--phrase name keymapped
function phrase_keymapped_name( nte )
  local song = renoise.song()
  local ins = song.selected_instrument
  for i = #ins.phrases, 1, -1 do
    local phr = ins:phrase( i )
    if ( phr.mapping ~= nil ) then
      local note_table = phr.mapping.note_range
      if ( nte >= note_table[1] ) and ( nte <= note_table[2] ) then
        --song.selected_phrase_index = i
        vws["PHT_PHRASE_NAME_1"].text = ("%.02X | %s"):format( i, phr.name ) 

I have tried to use mapping.note_range ,but it is excessively slow.What I have done is to verify that the value of the note (nte) is within the range, between the beginning and the end of the .mapping.note_range table. But this method is very slow. I need something instantaneous.

Accessing these numbers is very slow:

  1. note_table[1] renoise.song().selected_instrument:phrase( i ).mapping.note_range[1]
  2. note_table[2] renoise.song().selected_instrument:phrase( i ).mapping.note_range[2]

Is there any way to do it instantaneous?There is no direct way?

Note:The index of the phrase that sounds does not necessarily match with selected_phrase_index