Jump to content


Photo

Using notifiers to always toggle autofade = ON after recording?


  • Please log in to reply
1 reply to this topic

#1 esaruoho

esaruoho

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 2678 posts
  • Gender:Male
  • Location:Kontula, Helsinki, Finland
  • Interests://Varying Interests//

Posted 20 June 2018 - 15:48

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

 


http://lackluster.org | on Bandcamp | on YouTube | on Facebook | on Spotify | on iTunes | on TiDAL | on Soundcloud | 

http://twitter.com/esaruoho | http://esaruoho.tumblr.com | GitHubesaruoho@gmail.com | 

| macOS 10.13 High Sierra | MacBook Pro 2.8 GHz Intel Core i7 / 16 Gb 1600 MHz DDR 3 |

| http://renoise.com/tools/paketti | BTC: 1BoZ9rvb8wT7dFNyVPwSX7DLj3stNo7844 | http://paypal.me/esaruoho |

| Latent Impulse Tracker/Scream Tracker 3/Schism Tracker <-> Renoise fanatic |

More API functions, please! ;) http://forum.renoise.com/index.php/topic/26329-the-api-wishlist-thread/page-3#entry240266

#2 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1525 posts
  • Gender:Male
  • Location:Spain

Posted 21 June 2018 - 09:54

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.


Edited by Raul (ulneiz), 21 June 2018 - 12:06.

:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler