Hi, how would I go about making it so that every time that I record, when the recording is complete, the autofade=true is triggered after sample has been written to the Instrument Box?
I’m no good with notifiers, so could use some halp :o
Hi, how would I go about making it so that every time that I record, when the recording is complete, the autofade=true is triggered after sample has been written to the Instrument Box?
I’m no good with notifiers, so could use some halp :o
Hi, how would I go about making it so that every time that I record, when the recording is complete, the autofade=true is triggered after sample has been written to the Instrument Box?
I’m no good with notifiers, so could use some halp :o
Related documentation:
-- Selected in the instrument's sample list. Only nil when no samples
-- are present in the selected instrument.
renoise.song().selected_sample, _observable
-> [read-only, renoise.Sample object or nil]
-- Has sample data?
renoise.song().instruments[].samples[].sample_buffer.has_sample_data
-> [read-only, boolean]
renoise.song().instruments[].samples[].autofade, _observable
-> [boolean]
-- Invoked periodically in the background, more often when the work load
-- is low, less often when Renoise's work load is high.
-- The exact interval is undefined and can not be relied on, but will be
-- around 10 times per sec.
-- You can do stuff in the background without blocking the application here.
-- Be gentle and don't do CPU heavy stuff please!
renoise.tool().app_idle_observable
-> [renoise.Document.Observable object]
I have built a solution that checks the status of the autofade after recording the sample, using an idle_obserbable notifier and a checkbox to activate it. Make sure you add this checkbox (CHECKBOX_AUTOFADE) in your GUI and activate it manually when you need it.Personally, I do not like having an idle_notifier working all the time. I think it’s better to have control with a checkbox.
--globals
vb = renoise.ViewBuilder()
vws = vb.views
rna = renoise.app()
rnt = renoise.tool()
--automatic autofade function
function enable_autofade()
--print("working")
local song = renoise.song()
--check if the Sample Recorder dialog is visible
if ( rna.window.sample_record_dialog_is_visible == false ) then
return
else
--check if the selected instrument has at least one sample slot available
if ( song.selected_sample == nil ) then
return
else
--check if the selected sample has a buffer
if ( song.selected_sample.sample_buffer.has_sample_data == false ) then
return
else
--check if the selected sample has the autofade false
if ( song.selected_sample.autofade == true ) then
return
else
--enable autofade
song.selected_sample.autofade = true
end
--here you can change other properties of the sample
--
--
end
end
end
end
--checkbox function with idle_obserbable for enable_autofade()
function checkbox_autofade()
if ( CHECKBOX_AUTOFADE.value == false ) then
if ( rnt.app_idle_observable:has_notifier(enable_autofade) ) then
rnt.app_idle_observable:remove_notifier(enable_autofade)
end
else
if not ( rnt.app_idle_observable:has_notifier(enable_autofade) ) then
rnt.app_idle_observable:add_notifier(enable_autofade)
end
end
end
--checkbox for automatic autofade function
CHECKBOX_AUTOFADE = vb:checkbox {
value = false,
notifier = function() checkbox_autofade() end,
tooltip = "Enable/disable automatic autofade with Sample Recorder"
}
Maybe there is a more elegant and direct way to solve it, with a specific observable, that you check only once after recording the sample. This would avoid the idle_observable.
Is there an observable to indicate that the sample recording is over?
Edit :This could also be done with a slower timer, about 500ms or something like that. So not so many checks.
Edit2 :Keep in mind that it will also activate the autofade when you insert any new sample, even when you activate the checkbox(CHECKBOX_AUTOFADE) when there is a selected sample, as long as the Sample Recorder dialog is active…Be careful with this.
Hmm. Thanks Raul, however, I’d prefer to not have to have a GUI open to tick a box to enable it.
I’m trying to figure out how to enable it at startup. Running into heaps of trouble with that one.
Here’s what I’ve tried
-- Start of Startup notifier
function sample_loaded_change_to_sample_editor_v2()
local w=renoise.app().window
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR
renoise.song().selected_instrument.active_tab=1
renoise.app().window.active_middle_frame=5
-- renoise.app().window.active_middle_frame=4
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].autofade=true
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].interpolation_mode=4
renoise.app():show_error("Transport to waveform successful")
print ("sample_loaded_change_to_sample_editor_v2 was shot")
end
function startup_notifier()
local s=renoise.song()
renoise.song().sequencer.keep_sequence_sorted=false
if renoise.song().selected_sample == nil then renoise.app():show_status("Notifier: No samples found") return else
if renoise.song().selected_sample.sample_buffer_observable:has_notifier(sample_loaded_change_to_sample_editor_v2)
then renoise.song().selected_sample.sample_buffer_observable:remove_notifier(sample_loaded_change_to_sample_editor_v2)
else renoise.song().selected_sample.sample_buffer_observable:add_notifier(sample_loaded_change_to_sample_editor_v2)
renoise.app():show_error("Notifier: sample_loaded_change_to_sample_Editor_v2 added")
end
end
renoise.song().instruments[renoise.song().selected_instrument_index].active_tab=1
renoise.app().window.active_middle_frame=1
end
---------- Load startup_notifier
if not renoise.tool().app_new_document_observable:has_notifier(startup_notifier)
then renoise.tool().app_new_document_observable:add_notifier(startup_notifier)
renoise.app():show_error("Notifier: startup_notifier has been added")
else renoise.tool().app_new_document_observable:remove_notifier(startup_notifier)
end
yet it seems to only work once. like this:
If I go to any other slot, and load a sample in, it doesn’t have autofade.
What am I missing here? I tried removing the remove_notifier’s but that did not seem to help either.
I think the thing that is the problem here is that this binds a notifier to a specific, just a specific, selected sample. whichever sample happens to 1) be there 2) have selected.