Jump to content


Photo

Callback custom function

lua scripting

  • Please log in to reply
5 replies to this topic

#1 georges

georges

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 25 September 2016 - 17:09

Hi everyone, I just have started experimenting with Renoise. I am trying to figure out if it is possible for Renoise to call my function at an event. As an example, I have a pattern with length 64 and I want to get a notification when the position in the pattern is 0.

 

Is this possible?

 

Best regards 



#2 Neurogami

Neurogami

    Big Super GrandMasta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 768 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 25 September 2016 - 23:15

Yes, if you write some code.


Some (maybe correct) snippets that might help:
 

current_pattern = renoise.song().sequencer.pattern_sequence[renoise.song().transport.playback_pos.sequence] - 1

current_line = renoise.song().transport.playback_pos.line

You need to have Renoise automatically invoke the code by registering a function that does the pattern-position checking:
 

renoise.tool():add_timer(function_name, timer_interval)  -- An interval of 100 or so should be OK.  Need to experiment

Something like that.  



 



#3 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1852 posts
  • Gender:Not Telling

Posted 26 September 2016 - 09:54

Cool! I thought I was fairly up-to-date, but didn't know until now that Renoise had a timer.

 

I am guessing that this is a more forceful and predictable way than using the good old app_idle_observable trick for this task? (which on the other hand probably has the advantage of being more transparent in terms of cpu load, and might be better if your need for correct timing is not crucial).

 

Spoiler

Edited by joule, 26 September 2016 - 09:57.


#4 Neurogami

Neurogami

    Big Super GrandMasta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 768 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 26 September 2016 - 16:46

I've no idea what's the best way to do this.  My experience is largely from hacking about, getting something that appears to work, often by copying bits of code form other people's tools or comments.

 

In my case I was working on a script that would track position in patterns, count how often a loop has executed, and schedule new looping points.    Although there was constant position tracking I didn't notice any side-effects from CPU load.

 

I did use some flags to track previous state,



#5 georges

georges

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 26 September 2016 - 19:59

Thanks everyone, especially @Neurogami


  • Neurogami likes this

#6 Neurogami

Neurogami

    Big Super GrandMasta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 768 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 26 September 2016 - 23:48

Thanks everyone, especially @Neurogami

 

Let us know how this works out.  New tools always welcome!







Also tagged with one or more of these keywords: lua, scripting