ModLoop Tool of doom!

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!

@Tony_L - would this happen to be able to move the start/end points around (like a window/frame), and is it able to take advantage of the start point of sample playback’s ability to be contained within the window vs. starting at the beginning of the sample? Looks like another neato granular/loop tool and I’m going to start fiddling with it now.

And got some errors:

std::logic_error: ‘invalid loop_end index ‘11334355’. valid values are (1 to 1898496).’
stack traceback:
[C]: ?
[C]: in function ‘__newindex’
[string “do…”]:22: in function <[string “do…”]:9>
main.lua:410: in function main.lua:406

std::logic_error: ‘invalid loop_end index ‘11334355’. valid values are (1 to 1898496).’
stack traceback:
[C]: ?
[C]: in function ‘__newindex’
[string “do…”]:22: in function <[string “do…”]:9>
main.lua:410: in function ‘restorerightnow’
main.lua:541: in function main.lua:519

std::logic_error: ‘invalid loop_end index ‘11334355’. valid values are (1 to 204578).’
stack traceback:
[C]: ?
[C]: in function ‘__newindex’
[string “do…”]:22: in function <[string “do…”]:9>
main.lua:410: in function <mai

I got another error for you. This one came up after I created a new song with a simple sine wave as the only instrument. Then, when I tried to start ModLoop, I got this error:

‘/home/me/.renoise/V3.2.2/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: ‘ViewBuilder: invalid value for slider: ‘225.84’. value must be [-84 - 84].’
stack traceback:
[C]: in function ‘slider’
main.lua:680: in function ‘create_gui’
main.lua:798: in function main.lua:793