Is It possible to transpose the notes of a phrase và a script..?


(Circe) #1

A tiny question…
Is It possible to transpose the notes of a phrase vía script…? ?


(joule) #2

If someone made that script, yes. All note data is accessible in the Lua API.


(Circe) #3

Thanks, Joule…
It,s in the documentatión Renoise scripting Lua ?


(joule) #4

Yes. The most relevant stuff should be found here:

https://github.com/renoise/xrnx/blob/master/Documentation/Renoise.Song.API.lua#L1461-L1617

https://github.com/renoise/xrnx/blob/master/Documentation/Renoise.Song.API.lua#L2919-L3122


(Circe) #5

Thanks.

Meanwhile, any tiny code line ?


(Zer0 Fly) #6

If you need it quick for some project already rolling, and don’t need to transpose a lot - you can copy/paste from phrase to a track (make sure you enable all columns needed first), then transpose there, then copy/paste back to the phrase.


(danoise) #7

I think I have an idea about what Circe is working on… :slight_smile:

If you need it quick for some project already rolling, and don’t need to transpose a lot - you can copy/paste from phrase to a track (make sure you enable all columns needed first), then transpose there, then copy/paste back to the phrase.

Wait - you are aware the transpose shortcuts from the pattern editor also applies to phrases?


(joule) #8

Thanks.

Meanwhile, any tiny code line ?

Sure, since it’s Saturday! Here is a basic function to transpose all notes in a phrase. You can run in Testpad.lua

Click to view contents
local song = renoise.song()
function transpose_phrase(phrase, steps)
  
  assert( phrase and type(phrase) == "InstrumentPhrase", "Invalid phrase" )
  assert( steps and tonumber(steps), "Invalid steps argument" )
  
  for _, line in ipairs(phrase.lines) do
    if not line.is_empty then
      for _, ncol in ipairs(line.note_columns) do
        if not ncol.is_empty then
          local note_value = ncol.note_value
          if not (note_value == renoise.PatternLine.EMPTY_NOTE or note_value == renoise.PatternLine.NOTE_OFF) then
             ncol.note_value = math.max( 0, math.min( 119, note_value + steps ) )
          end
        end
      end
    end
  end
  
end
transpose_phrase( song.selected_phrase, -3 )

(Raul (ulneiz)) #9
...  
assert( phrase and type(phrase) == "InstrumentPhrase", "Invalid phrase" )
assert( steps and tonumber(steps), "Invalid steps argument" )
...
ncol.note_value = math.max( 0, math.min( 119, note_value + steps ) )
...

:DI suppose the icon says it all!

It would be good if the function could point to the index of the phrase, so that it is not always the selected phrase. It would be great to have another similar function managing the phrase index.

This thread should not be in another forum site?


(Circe) #10

Just can say T H A N K S
. To all.