Jump to content


Photo

Custom renoise.values example


  • Please log in to reply
4 replies to this topic

#1 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

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

Posted 19 September 2018 - 15:13

Here is a simple principle that can be used for storing custom values inside renoise objects, if your tool needs it. Using the Document API, the values will also be observable, just like most other data accessible in the Song API.

Spoiler


NB1. Doing this per note_column would be more complex, but for something like patterns, tracks or instruments it works really well. These lists are more easy to 'mirror'.
NB2. Do note that it's probably not something you want to do per note_column anyway, as custom properties creates some slight extra overhaul (probably due to native __index metatable stuff)
NB3. It's per session only. Any persistent storage would require something like xml dumping or song comment abuse.

Edited by joule, 19 September 2018 - 15:19.

  • Ledger and Neurogami like this

#2 Neurogami

Neurogami

    Big Super GrandMasta Member

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

Posted 19 September 2018 - 17:39

Thanks!



#3 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

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

Posted 19 September 2018 - 18:06

NP. Here is an alternative approach (simplified example) if you don't want to affect the global class, but only the particular object(s).
 
local track = renoise.song():track(1)
track.__STRICT = function() return false end
track.my_prop = 10
print(track.my_prop)

Edited by joule, 19 September 2018 - 18:06.


#4 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3646 posts
  • Gender:Male

Posted 19 September 2018 - 21:30

NP. Here is an alternative approach (simplified example) if you don't want to affect the global class, but only the particular object(s).
 

local track = renoise.song():track(1)
track.__STRICT = function() return false end
track.my_prop = 10
print(track.my_prop)

So here you are replacing __STRICT in the new object instance?
 
From just seeing  4Tey`s post here, it`s there to catch undeclared variables. Did you find any consequences/ or things to watch out for with this, since that thread?


Edited by Ledger, 19 September 2018 - 21:42.

  • 4Tey likes this

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#5 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

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

Posted 20 September 2018 - 10:26

Did you find any consequences/ or things to watch out for with this, since that thread?

 
Not that I know of. AFAIK, it's only a matter of the __newindex metatable checking if __STRICT is true or not.


  • Ledger and 4Tey like this