Jump to content


Photo

Beginner question regarding objects


  • Please log in to reply
2 replies to this topic

#1 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1410 posts
  • Gender:Not Telling
  • Location:Sweden
  • Interests:music, philosophy, engineering

Posted 02 June 2016 - 16:08

Is there a way to copy an object in LUA? Not only referencing it.

 

For exampel, if I do

local voices = { }
table.insert(voices, renoise.song():pattern(1):track(1):line(1):note_column(1))

then voices[1] will just be a reference to the object in the renoise.song() class. Can I somehow make it unique (copy it to a slot, so to speak), and perhaps even copy it back to renoise.song() without an error?

 

This would make things a lot easier to me. Otherwise I'd have to construct my own custom data structure to store/restore values from.



#2 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5574 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 02 June 2016 - 16:29

At the moment you'll have to maintain your own custom tables and manually get/set the particular values that you're interested in working with.

If you write a few useful helper functions to take care of the boring work for you, then it should hopefully not be too painful :)
  • joule likes this

#3 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1410 posts
  • Gender:Not Telling
  • Location:Sweden
  • Interests:music, philosophy, engineering

Posted 02 June 2016 - 17:14

Thanks for answering!

 

The one thing that makes that a bit extra tedious is that you can't (?) see within an object where it is situated (for example which track a note_column belongs to). So programming wise, I'll have to pass a lot of values from function to function in order to store such information in my custom object. It's not the prettiest..

 

I'll do it like this for now. Seems to work, but feels a bit awkward.. It will eventually be used for ordering chord voices by pitch in xStream.

 

Spoiler

Edited by joule, 02 June 2016 - 18:18.