[SOLVED] How to define start_pos end_pos for render

how do i set start_pos + end_pos to be “the selection in track”? or how to define “the whole song”?

    -- Optionally, set start_pos and end_pos if you want to 
render a specific part of the song

There is no track in SongPos. You need to mute the tracks and/or columns that you want to exclude before rendering.

1 Like

yep, i wrote this, and i wanted to limit it to the selected pattern, or make it render the whole track: - i think it now renders the whole track.

it does all these things:

  1. Solo Selected Track (RenderTrack)
  2. Render Selection on (RenderTrack)
  3. (RenderTrack) is Rendered
  4. Unsolo RenderTrack
  5. RenderTrack is muted (and note columns set to Off)
  6. Collapse RenderTrack
  7. New Track is created
  8. New Track is renamed to be RenderTrackName (Rendered)
  9. New Instrument is created
  10. New Instrument is renamed to be RenderTrackName (Rendered)
  11. RenderTrack is loaded to New Instrument SampleBuffer
  12. Rendered sample has Autoseek toggled ON
  13. Rendered Track now has Rendered Instrument added to Line 1 at C-4 - so Rendered Sample plays

still working on it since i want to make it realize if there’s a #Line-In input instrument, then it’ll switch from High to Realtime. and mine is coded in such a simple way that it doesn’t yet detect which OS it is, so i’ll need to have a different folder for Windows / Linux.

and next steps are to set up Paketti Preferences for the bitrate, samplerate.

-- Function to initiate rendering
function start_rendering()
  -- Set up rendering options
  
  -- TODO// Detect #Line-In then use realtime otherwise high
  local render_options = {
    sample_rate = 88200,
    bit_depth = 32,
    interpolation = "precise",
    priority = "high",
    -- Optionally, set start_pos and end_pos if you want to render a specific part of the song
  }
  
  -- Define a temporary path for the rendered audio
  local temp_file_path = "/tmp/rendered_sample.wav"

  -- Start rendering with the correct function call
  local success, error_message = renoise.song():render(render_options, temp_file_path, rendering_done_callback)
  if not success then
    print("Rendering failed: " .. error_message)
  else
    -- Start a timer to monitor rendering progress
    renoise.tool():add_timer(monitor_rendering, 500)
  end
end

-- Callback function that gets called when rendering is complete
function rendering_done_callback()
local renderTrack = renoise.song().selected_track_index
local renderedTrack = renderTrack+1
local renderTrack2 = renderedTrack-1
local renderedInstrument = renoise.song().selected_instrument_index+1

  -- Remove the monitoring timer
  renoise.tool():remove_timer(monitor_rendering)
-- Un-Solo Selected Track
renoise.song().tracks[renderTrack]:solo()

-- Turn All Render Track Note Columns to "Off"
for i=1,12 do
renoise.song().tracks[renoise.song().selected_track_index]:set_column_is_muted(i, true)
end
-- Collapse Render Track
renoise.song().tracks[renoise.song().selected_track_index].collapsed=true

-- Add Sample Slot to New Instrument
renoise.song().instruments[renoise.song().selected_instrument_index]:insert_sample_at(1)
-- Load Sample into New Instrument Sample Buffer
renoise.song().instruments[renoise.song().selected_instrument_index].samples[1].sample_buffer:load_from("/tmp/rendered_sample.wav")
-- Insert New Track Next to Render Track
renoise.song():insert_track_at(renoise.song().selected_track_index+1)
local renderName = renoise.song().tracks[renoise.song().selected_track_index].name
-- Rename Sample Slot to Render Track
renoise.song().instruments[renoise.song().selected_instrument_index].samples[1].name=(renderName .. " (Rendered)")
-- Select New Track
renoise.song().selected_track_index=renoise.song().selected_track_index+1
-- Rename New Track using Render Track Name
renoise.song().selected_track.name=(renderName .. " (Rendered)")
-- Insert C-4 + Rendered Instrument number to Rendered Track
renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[1].note_columns[1].note_string="C-4"
renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[1].note_columns[1].instrument_value=renoise.song().selected_instrument_index-1
renoise.song().selected_instrument.name=(renderName .. " (Rendered)")
renoise.song().instruments[renoise.song().selected_instrument_index].samples[1].autofade = true
renoise.song().instruments[renoise.song().selected_instrument_index].samples[1].autoseek = true

end

-- Function to monitor rendering progress
function monitor_rendering()
  if renoise.song().rendering then
    local progress = renoise.song().rendering_progress
    print("Rendering in progress: " .. (progress * 100) .. "% complete")
  else
    -- Remove the monitoring timer once rendering is complete or if it wasn't started
    renoise.tool():remove_timer(monitor_rendering)
    print("Rendering not in progress or already completed.")
  end
end

function pakettiCleanRenderSelection()
local renderTrack = renoise.song().selected_track_index
local renderedTrack = renderTrack+1
local renderTrack2 = renderedTrack-1
local renderedInstrument = renoise.song().selected_instrument_index+1
-- Create New Instrument
renoise.song():insert_instrument_at(renoise.song().selected_instrument_index+1)
-- Select New Instrument
renoise.song().selected_instrument_index=renderedInstrument

-- Solo Selected Track
renoise.song().tracks[renderTrack]:solo()
-- Render Selected Track
start_rendering()
end

renoise.tool():add_menu_entry{name="--Pattern Editor:Paketti..:Clean Render Selection",invoke = function() pakettiCleanRenderSelection() end}
renoise.tool():add_menu_entry{name="Mixer:Paketti..:Clean Render Selection",invoke = function() pakettiCleanRenderSelection() end}

as per your response, i’m not sure how i’m supposed to call it. i tried
oprint (song_pos.sequence) and it told me nothing, just an error.

>>> oprint (song_pos.sequence)
*** [string "oprint (song_pos.sequence)"]:1: variable 'song_pos' is not declared
*** stack traceback:
***   [C]: in function '_error'
***   [string "local mt = getmetatable(_G)..."]:29: in function <[string "local mt = getmetatable(_G)..."]:24>
***   [string "oprint (song_pos.sequence)"]:1: in main chunk

then i tried

>>> oprint (renoise.song().song_pos.sequence)
*** [string "oprint (renoise.song().song_pos.sequence)"]:1: unknown property or function 'song_pos' for an object of type 'Song'
*** stack traceback:
***   [C]: in function '_error'
***   [string "do..."]:48: in function <[string "do..."]:35>
***   [string "oprint (renoise.song().song_pos.sequence)"]:1: in main chunk

>>> oprint (renoise.song_pos.sequence)
*** [string "oprint (renoise.song_pos.sequence)"]:1: attempt to index field 'song_pos' (a nil value)
*** stack traceback:
***   [string "oprint (renoise.song_pos.sequence)"]:1: in main chunk

>>> oprint (renoise.song.song_pos.sequence)
*** [string "oprint (renoise.song.song_pos.sequence)"]:1: attempt to index field 'song' (a function value)
*** stack traceback:
***   [string "oprint (renoise.song.song_pos.sequence)"]:1: in main chunk

not sure how to proceed.

i’m barely making sense of this. i did get “User Data” out of oprint (renoise.SongPos) but i can’t proceed with that. i tried doing renoise.SongPos.song_pos.sequence but got nothing.

>>> oprint (renoise.SongPos)
userdata: 0x600007f2bb68
>>> oprint (renoise.SongPos.song_pos.sequence)
*** no static 'song_pos' in class 'SongPos'
*** stack traceback:
***   [C]: ?
***   [string "oprint (renoise.SongPos.song_pos.sequence)"]:1: in main chunk

maybe i’m working with outdated documentation?

but also

>>> oprint (renoise.SongPos.sequence)
*** no static 'sequence' in class 'SongPos'
*** stack traceback:
***   [C]: ?
***   [string "oprint (renoise.SongPos.sequence)"]:1: in main chunk

i’m not sure how to wrap my mind around this:

--------------------------------------------------------------------------------
-- renoise.SongPos
--------------------------------------------------------------------------------

-- Helper class used in Transport and Song, representing a position in the song.

-------- Properties

-- Position in the pattern sequence.
song_pos.sequence
  -> [number]

-- Position in the pattern at the given pattern sequence.
song_pos.line
  -> [number]


-------- Operators

==(song_pos, song_pos) -> [boolean]
~=(song_pos, song_pos) -> [boolean]
>(song_pos, song_pos) -> [boolean]
>=(song_pos, song_pos) -> [boolean]
<(song_pos, song_pos) -> [boolean]
<=(song_pos, song_pos) -> [boolean]

You’ll need to create instances of this class:

renoise.SongPos(1,1) -- seq, line

hmm

>>> oprint (renoise.SongPos(1,1).line)
1
>>> oprint (renoise.SongPos(1,1).line)
1
>>> oprint (renoise.SongPos(1,1).line)
1
>>> oprint (renoise.SongPos(1,2).line)
2
>>> oprint (renoise.SongPos(1,64).line)
64
>>> oprint (renoise.SongPos(2,64).line)
64
>>> oprint (renoise.SongPos(2,65).line)
65
>>> oprint (renoise.SongPos(2,65).sequence)
2
>>> oprint (renoise.SongPos(1,65).sequence)
1
>>> oprint (renoise.SongPos(1,656).sequence)
1
>>> oprint (renoise.SongPos(1,656).line)
656

still clueless. i thought for sure 656 would not work. (two patterns in sequence, 64 each.

You need to pass this as start_pos or end_pos to the render options.

This renders the first 16 lines of the first pattern in the sequence:

  local render_options = {
    start_pos = renoise.SongPos(1, 1),
    end_pos = renoise.SongPos(1, 16),
  }

1 Like

thank you! can i somehow incorporate renoise.song().selected_pattern_index into 1 as a replacement?

i.e.

 local render_options = {
    start_pos = renoise.SongPos(renoise.song().selected_pattern_index, 1),
    end_pos = renoise.SongPos(renoise.song().selected_pattern_index, renoise.song().patterns[renoise.song().selected_pattern_index].number_of_lines),
  }

like this?

so i tried this

  local render_options = {
    sample_rate = 88200,
    bit_depth = 32,
    interpolation = "precise",
    priority = "high",
    start_pos = renoise.SongPos(renoise.song().selected_pattern_index, renoise.song().selected_pattern_index),
    end_pos = renoise.SongPos(renoise.song().selected_pattern_index, renoise.song().patterns[renoise.song().selected_pattern_index].number_of_lines),
  }

and all i get is silence - it looks like it’s rendering the first pattern, and i have selected the second pattern and am trying to “point to it”

EDIT: ok i think i get it. i need to use renoise.song().selected_sequence_index.
fingers crossed.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.