Tool (2.7): Add/Remove Silence

Adds the ability to either destructively remove silent parts of a sample (sounds that fall below a threshold), and the ability to add silence to the end or beginning of a sample. The latter can often be useful for FX processing. Shows up as ‘Add Silence…’ and ‘Remove Silence…’ in the Sample Editor’s ‘Process’ context menu.

visit its page.

I actually made this quite a lot of time ago but forgot to add it to the tools page :)

could add silence use the currenty selection if there is one, and the whole sample otherwise?

because adding silence would be very handy for me, but I hardly ever need to at it at the start or end of a sample, always between words in a vocal sample ^^

I can try doing that myself, but I figured I’d mention it anyway, maybe someone else is quicker :D

ok, I took note of this. let’s see who is faster :)

anyway could be a good exercise for newbies

yeah, let’s make lists and strike items haha.

  • a button near the duration boxes, to take the duration from the current selection

  • for delete silence, buttons to get the average/peak volume from the current selection.

Hmm I just noticed that while the tool window is open you can’t change the selection (or access the sample editor window in any way) :(

this isn’t true for the custom wave generator however :)

the Custom Wave Generator has been designed to be like this. Making dialogs not modal (like CWG) requires a lot of additional programming because you have to take in count of changes into instruments and samples lists (through “observable” variables, which were actually not already available when this tool was coded).

you should firstly select the sample portion you want to make changes onto and then use the tool

aha, thanks for the pointers… :D

okay, with copypasta and guessing I begun to made the add silence dialog modal, using the CWG as a guide. but I guess it will take a while until I figured out and taken into account all the little things…

… but hey, it seems even changing between samples works “out of the box”, it always applies to the currently selected sample… seems like I’m well on my way :D

nope, not anymore :D

does this seem okay GUI-wise? it does seem to work, too :D (haven’t touched “remove silence” at all yet)

hmm I’ll prolly change the “add” back to “apply” though.

good work Johann!

I don’t think that the button is a good idea: in my opinion, if the user has selected something in the sample, the script should automatically work on the selection only.

you mean the “from selection” button? that gets the time and frames from the length of the current selection.

otherwise it does exactly what you said, since in renoise there is always a selection anyway (no selection means whole sample).

which is awkward when you just click in the sample (which Renoise doesn’t seem to consider a selection), because then it adds the silence at end/start/both of the sample, and not where you clicked. but I don’t see how I can do anything about that from here?

the seconds field is confusing with very short durations as in the screenshot, because you don’t get to see the E at the end, but hey… shrugs

otherwise they update each other, which works fine as long as the duration is longer than 2 frames, which totally confuses me, so I’ll attach what I have before I progress. maybe someone can spot my mistake, especially since I might have broken other stuff too, or done it badly :P

(there are now two variables named int_frames (one holds the silence duration in frames), and while I don’t think they’re clashing I’ll rename that of course, so ignore that)

just for now don’t use it while you have any super important songs loaded, PLEASE, I still don’t really know what I’m doing here ^^

oh, I see… it’s a pity that sample’s selection is not observable, so this info retrieval cannot be performed automatically…

by the way, the script you attached crashes on Renoise load because of this line:

local int_frames = 1.0 * -- !?!!  

upon Renoise loading there is no selected sample, so you should use this code:

if then  
 int_frames = 0  
 int_frames = 1.0 *  

yeah I err noticed :confused: it breaks in other places too (for example when you hit “apply” upon an empty sample… although you can’t open the tool on an empty sample, you can then switch to one. well, now it throws an error like it should)

so now I’m using  

since in the docs it says selected_sample is “never nil”, and that seems to work nicely.

I updated the attachment above… (also notice I made the remove silence dialog modal now, though I haven’t changed anything else there. it’s just sooo much nicer to have the tool open and switch between samples!)

from remove silence:

 --these will be useful when sample selection will be available in LUA API  
 local int_range_start = 1  
 local int_range_end = int_frames  

would it make sense to just set that to the (now available) selection range?

I’m asking because I don’t really get what all the code does haha… and I don’t really need to, either, to do the “get duration from selection” and “get average volume” things…

yet I wonder what the trim, trim left, trim right options do? I don’t understand that at all, neither from the code nor from look at what happens to the sample (if you use that two times nearly the whole sample gets cut?), so a little explanation would be useful (probably also for the page on tools.renoise)

yes, sure, but the problem is that, being the dialog non modal, the user can change the selection but the script will not be aware of it. I’m not sure if always using selection to perform the script will be 100% error free, as the user could also even delete the sample while keeping the dialog open (here is where observable variables come in action)

“trim silence” is a standard action in sample editors: it removes silence before or/and after the actual sounding sample data

I have got the “detect peak volume of current selection” working perfectly, and I ditched the idea of getting the average volume because a.) I don’t know how to easily do that, and b.) who needs that anyway?

but only when you hit a button to actually do something it uses the selection (and if there is no sample it aborts), so I don’t see how that would cause problems.

ahh okay, I get it now… but have you tried applying it twice… something isn’t right there? or did I introduce that?

also, it can be a bit confusing because remove/silence apply to silence, while trim applies to non-silence - so I propose changing “remove” to “remove silence” and “silence” to “mute silence”, leaving trim as is, and removing the “with relevant data” header…

Awesome! 99% awesome! The extra 1% would be achieved if song-relative lengths of silence could be inserted - in lines, beats, lines from selection in pattern, etc. as well as seconds.

I am a bit in a hurry so I will reply only to this:

a] open “add silence” dialog
b] click on the sample window and select a part of the sample
c] now rightclick on the sample box list and click on “delete” to delete the selected sample from the list
d] the “add silence” dialog is still open. press “apply” => crash


 if ~= nil then  
 int_frames = 0  
 int_frames = 1.0 *  

this snippet I have written before should be moved to the beginning of show_add_silence_dialog() function otherwise it will still crash upon Renoise loading

it’s a bit of a mess right now, but it seems to work okay, and only applies to the current selection which is very useful…

lies!! up pops a dialog saying “no sample selected.”


yeah, and in many other places too. basically whenever it accesses the sample. that’s why there is no problem with having no sample selected ;)

here it is how it works on my version:

using a sample which has silence at the end, use “trim right” once: it will remove all the silence at the end. using it once more will not affect the sample, which is how it should behave