ModLoop Tool of doom!

Quick snippet if it helps for closing dialog on new song.

If you just want to reset some variables instead of closing the dialog just attach a relevant function instead of closer(d)

--------------------------------------------    
  --close dialog function ON NEW SONG
  --------------------------------------------
  local function closer(d)
     
    if (d ~= nil) and (d.visible == true) then
      d:close()
    end
     
    -- remove other notifiers here if needed

    --reset global my_dialog to nil again if needed
    my_dialog = nil 

  end

  -- attach notifier to close dialog on load of new song, my_dialog gets passed to closer()
  renoise.tool().app_release_document_observable:add_notifier(closer,my_dialog) 
  -------------------------------------------------------------------------------

Thanks for testing Djeroek

You’re welcome :slight_smile: ,

right now I’m slapping a recorder vst on the particular track I’m modlooping, tweaking the sliders while recording to create .wav files of crazy timestretching/granular-like effects. As stated above, I’d love to be able to use Renoises native render selection to sample in the pattern editor, but as far as I can see, Renoise resets the tool start to stop whenever you try to do this. Could there be a way to circumvent the reset? I see the the gui sliders and buttons can be midi mapped, but not sure how the midi mappings can be recorded inside the pattern editor so I can for example aim the tool to start at line 0. Currently playing around with an instr midi control meta device without any luck yet.

Also got this after closing the tool after midimapping the pitch slider to a controllers knob, and re-opening a new tool window;

‘C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx\main.lua’ failed in one of its notifiers.

The notifier will be disabled to prevent further errors.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

.\process_slicer.lua:111: std::logic_error: ‘ViewBuilder: invalid value for slider: ‘112’. value must be [21 - 107].’

stack traceback:

[C]: in function ‘error’

.\process_slicer.lua:111: in function <.\process_slicer.lua:98>

Thanks Djeroek I’ll see if I can fix it soon. Behind the scene, I’ve returned to work (fixing computers) during the day so I’m spending less time with the code however I’m motivated to finish it up.

Last night I managed to deal with the song switcharoo thanks to Ledger however I am having some trouble detecting when the GUI has been closed, for taking care of properly restoring the previous sample properties. I may have to resort to a button. It may take me some time yet before I do another version bump, this weekend at the latest I think.

I’ll keep at it!

Yes, in theory a stream of midi data can modulate the loop points (when the code works). I assigned some knobs on the bcr2000 to it. Actually having control over the points in the composition or via a sample modulation set item is probably up to the renoise developers…

Yes, as the [X] button on the tool scripts has no notifier, you have to take care of it somehow else. One way is to use a timer function like this:

line 2 - add the timer in the function that builds and displays your gui (could be added in main() if you build the gui there)
line 13 - when the dialog is detected as nil or not visible, you can do your cleanup code after. (Maybe setting global my_dialog to nil again if it was the .visible test that was false)
line 18 - the timer removes itself

each time you re-build/ open the gui a new timer is added and process repeats.

note: here my_timer() is a global; function (no local keyword) so can be placed at end of file/ different .lua if wanted

--add timer to fire once every 50ms
if not renoise.tool():has_timer(my_timer) then
  renoise.tool():add_timer(my_timer,50)
end

----------------
--timer function
----------------
function my_timer()
  
  --is GUI is closed?
  if(my_dialog == nil) or (my_dialog.visible == false) then
    
    --gui is closed so relevant code here
    
    --release `this function` "my_timer()" from the tool timer  
    if renoise.tool():has_timer(my_timer) then
      renoise.tool():remove_timer(my_timer)
    end
  end
end

I think this timer could be called “broom car timer” ^_^. What I do is remove the notifiers and timers inside themselves, at the end of each function with notifier / timer.Each notifier or timer has to have its remove.

But I still think that programmers should be able to execute a function when closing with the X in the window.This would make it possible to do it centrally, all from a single function.

Something handy to be aware of too though, is that when you delete a renoise object (track/ dsp) in the song then notifiers will be removed automatically in the API .

(you still need to release timers manually)

https://forum.renoise.com/t/does-deleting-a-renoise-object-release-attached-notifiers-automaticall/39477

Thank you Ledger Raul and Djeroek for checking it out and the very helpful suggestions. v0.24 is out now. More to come soon.

v0.25 released with restoring sample properties options and button as well as various bug fixes, included no longer allowing multiple dialogs… more updates soon…

Got this with 0.24;

'C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx' failed to execute in one of its menu entry functions.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

std::logic_error: ‘The given timer function was already registered.’

stack traceback:

[C]: in function ‘add_timer’

main.lua:705: in function <main.lua:700

opened up a new tool instance after looping multiple samples in a multisampled instrument.

Will update to 0.25

Got this in 0.25 playing around with the tool gui sliders, suddenly;

‘C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx\main.lua’ failed in one of its notifiers.

The notifier will be disabled to prevent further errors.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

.\process_slicer.lua:111: main.lua:180: attempt to index global ‘gui’ (a nil value)

stack traceback:

[C]: in function ‘error’

.\process_slicer.lua:111: in function <.\process_slicer.lua:98>

opening up a new empty song after that last error notice gives;

‘C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx\main.lua’ failed in one of its notifiers.

The notifier will be disabled to prevent further errors.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

.\process_slicer.lua:111: std::logic_error: ‘trying to access a nil object of type ‘class RenoiseSong’. the object is not or no longer available.’

stack traceback:

[C]: in function ‘error’

.\process_slicer.lua:111: in function <.\process_slicer.lua:98>

Thanks Djeroek for all of your testing and bug reports! I’ll see what I can do about those.

Edit: released v0.26 with additional checks

Ey, stil getting the following notice in 0.26 when using your tool in a track, then opening up a new songfile;

‘C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx\main.lua’ failed in one of its notifiers.

The notifier will be disabled to prevent further errors.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

.\process_slicer.lua:111: main.lua:351: attempt to index global ‘gui’ (a nil value)

stack traceback:

C: in function ‘error’

.\process_slicer.lua:111: in function <.\process_slicer.lua:98>

‘C:\Users\pluge\AppData\Roaming\Renoise\V3.1.1\Scripts\Tools\ca.tonyscc.ModLoop.xrnx\main.lua’ failed in one of its notifiers.

The notifier will be disabled to prevent further errors.

Please contact the author (artaslove [bonafide@martica.org]) for assistance…

std::logic_error: ‘trying to access a nil object of type ‘class RenoiseSong’. the object is not or no longer available.’

stack traceback:

C: in function ‘__index’

[string “do…”]:37: in function <[string “do…”]:35>

main.lua:380: in function ‘close_tool’

main.lua:771: in function main.lua:769

Sorry about that Djeroek I fixed that in v0.27. It involved the timer I just added. Thank you again for all your testing!

Yeah that was a tricky one, it was actually the notifier and has been broken for a while. However I’m confident you’ll find v0.27 more reasonable as far as new songs.

Edit: I’m still not handling it quite properly. I have to do some additional work, because while it traverses new songs now the renoise song object is still nil. Argh! :wink: I’m having fun though.

Hurrah! I finally got that sorted out. It handles new songs, including blank songs, whether or not the tool is currently working!

Now I can focus on some of the other features. :slight_smile:

(I uploaded the latest version however it’s still marked v0.27 … I’m continuing to work)

I had no idea that moving the loop points outside of the current playback position would work the way that it does with the restore right now function during playback, however there are certainly some interesting effects , like being able to jump around depending on loop types and positions! Looks like depending on where you are the loop type set can change whether it moves or jumps to the loop. I might be able to change the loop type for an instant before moving the points to always enable a jump back to the original loop (Right now it restores the loop type at the same time). Hmm. This would help a lot with random mode. :slight_smile:

bumped to version v0.28 for clarity (additional code cleanups, moving some init stuff to functions).

My apologies for all the recent trouble, I hope we’re at a solid version 1 sooner rather than later. I still have many plans for the tool.

Finally fixed loose mode getting stuck… I had written code for it previously that I realized just now left out two important considerations. v0.29

Edit: Alas, still not perfect. I have to look ahead a few steps to really fix it.

It’s certainly been a while since I’ve thought about this, but I spent some time this weekend experimenting and patched up the code a bit. V0.30 still far from perfect, but seems more stable to me.

I’ve concluded that many of my plans won’t be possible as a renoise tool because I don’t have information I need like the exact sample playback position and direction at any one given moment in time, however I’ve been spending some time thinking about how I might be able to create a DSSI or VST plugin instead.

V0.31 has a fix for a bug in pitch mode… silly lua starting arrays at 1… I’ll get used to it someday :slight_smile:

When I MIDI map some knobs on my controller to the “Maximum speed” and “Maximum Frames” sliders in ModLoop’s GUI, and then twist those knobs down far enough, I get errors like these:

Error Message: ‘/home/me/.renoise/V3.2.2/Scripts/Tools/ca.tonyscc.ModLoop.xrnx/main.lua’ failed in one of its notifiers. Renoise LOG> Error Message: The notifier will be disabled to prevent further errors.
Error Message: Please contact the author (artaslove [bonafide@martica.org]) for assistance…
Error Message: ./process_slicer.lua:111: std::logic_error: ‘ViewBuilder: invalid value for slider: ‘0’. value must be [1 - 2048].’
Error Message: stack traceback:
Error Message: [C]: in function ‘error’
Error Message: ./process_slicer.lua:111: in function <./process_slicer.lua:98>
ScriptingEngine: ./process_slicer.lua:111: std::logic_error: ‘ViewBuilder: invalid value for slider: ‘0’. value must be [1 - 512].’
stack traceback:
[C]: in function ‘error’
./process_slicer.lua:111: in function <./process_slicer.lua:98>

Thanks for reporting this bug! I hope version 0.32 fixes this for your application!