Skip to content

Instantly share code, notes, and snippets.

@ryrun
Last active December 19, 2015 19:39
Show Gist options
  • Save ryrun/2af8cb6fe7333d09675d to your computer and use it in GitHub Desktop.
Save ryrun/2af8cb6fe7333d09675d to your computer and use it in GitHub Desktop.
create phrases for pitching (Renoise)
-- create phrases to pitch sample
-- get current insturment and selected sample
local instrIndex = renoise.song().selected_instrument_index
local smplIndex = renoise.song().selected_sample_index
local instr = renoise.song().instruments[instrIndex]
local basenote =instr.sample_mappings[renoise.Instrument.LAYER_NOTE_ON][smplIndex].base_note
-- how many steps
local steps = 12
local looping = true
-- shortcuts
local phraseIdx = 1
local phrase = nil
local phrasemap = nil
local line = nil
--remove all current phrases
local anz = table.getn(instr.phrases)
for i = anz, 1 , -1 do
instr:delete_phrase_at( i )
end
for i = -steps, steps, 1 do
-- insert phrase
instr:insert_phrase_at( phraseIdx )
phrase = instr:phrase( phraseIdx )
-- in renoise 3.1, you need to add the mapping manually
instr:insert_phrase_mapping_at( phraseIdx, phrase )
--
phrasemap = instr:phrase_mapping( phraseIdx )
-- phrase config
phrase.lpb = 8
phrase.number_of_lines = 8
phrase.visible_note_columns = 1
phrasemap.key_tracking = renoise.InstrumentPhraseMapping.KEY_TRACKING_NONE
phrasemap.looping = looping
phrasemap.note_range = {basenote+i, basenote+i}
-- edit phrase
line = phrase:line(1)
line:clear()
line:note_column(1).note_value = basenote
line = phrase:line(2)
line:clear()
if i < 0 then
line:effect_column(1).number_string = "0D"
line:effect_column(1).amount_value = 15*math.abs(i)
elseif i > 0 then
line:effect_column(1).number_string = "0U"
line:effect_column(1).amount_value = 15*i
end
-- next idx
phraseIdx = phraseIdx + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment