Jump to content


Photo

How can I install this module I found (inspect)?


  • Please log in to reply
10 replies to this topic

#1 tunabee

tunabee

    Member

  • Normal Members
  • PipPip
  • 68 posts

Posted 07 December 2017 - 01:50

There's a library on github called Inspect (https://github.com/kikito/inspect.lua) which looks like it could be handy for inspecting objects, however I've not been able to get it to work in the Lua environment. I've tried importing it as suggested in the tool's instructions, copying/pasting into the terminal, and all to no avail. It tells me inspect isn't declared.


>>> local inspect = require 'inspect'
>>> inspect(renoise.song().instruments)
*** [string "inspect(renoise.song().instruments)"]:1: variable 'inspect' is not declared
*** stack traceback:
***   [C]: in function '_error'
***   [string "local mt = getmetatable(_G)..."]:29: in function <[string "local mt = getmetatable(_G)..."]:24>
***   [string "inspect(renoise.song().instruments)"]:1: in main chunk



#2 Neurogami

Neurogami

    Big Super Masta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPip
  • 637 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 07 December 2017 - 03:01

Lua code needs to know where to look for files when you invoke "require"

 

Lua uses a thing called "package.path" to track possible locations.

 

I was curious what this was for Renoise.  You can see for yourself by running (in the terminal/editor thing):

   rprint(package.path)

In my case it showed that, among the paths listed, there was one that would work well for me because it was part of my Renoise user data:

      C:\Users\james\AppData\Roaming\Renoise\V3.1.1\Scripts\Libraries\?.lua

There was no existing "Scripts\Libraries" folder, so I made one.

 

Then I added a file, inspect_tool.lua, with the code from Github.  

 

I was then able to do this:

 

    local i = require "inspect_tool"
    rprint(i)
and get some interesting output.
 
The details of package.path can be found here: https://www.lua.org/pil/8.1.html


#3 tunabee

tunabee

    Member

  • Normal Members
  • PipPip
  • 68 posts

Posted 07 December 2017 - 06:25

Thanks! Looks like I was just using it incorrectly (apparently, if you just try to run the function on an object, it isn't happy. You have to nest it in a print function).


Also, it doesn't seem to do what I thought it would do, that being giving me some useful data about the complete table. Since it doesn't do what I'm hoping it would do, could I ask: has anyone made a function that will print the entire structure of renoise.song()? Like, the tables, the properties, and the methods? I want to get a "feel" for the structure and how everything works so I can start making some useful utilities.


  • joule likes this

#4 Neurogami

Neurogami

    Big Super Masta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPip
  • 637 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 07 December 2017 - 16:39

One way to get an idea of songs in general is to look at the Renoise song API listing.     But I find it overwhelming.   (What I really want is the API  docs as dynamic tree that I can expand/collapse.)

 

renoise.song() does not return a table,   I found some code that should do recursive table inspection:

 

 https://gist.githubu...5/gistfile1.lua

 

But when passed renoise.song() it complains that it was given userdata, not a table.

 

    bad argument #1 to 'pairs' (table expected, got userdata)

 

Update: Info on "userdata"   https://stackoverflo...userdata-in-lua


Edited by Neurogami, 07 December 2017 - 16:41.


#5 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

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

Posted 07 December 2017 - 16:49

FYI I started working on a simple interactive browser for the lua _G table. It should help new users to familiarize themselves with the API.

 

https://www.dropbox....ox/gbrowser.png

 

The more complex thing about it is to view objects with properties and methods, like you say, but it should be totally doable by using objinfo, loadstring/pcall and string manipulation.. I'm on it :)


Edited by joule, 07 December 2017 - 16:57.

  • Ledger likes this

#6 tunabee

tunabee

    Member

  • Normal Members
  • PipPip
  • 68 posts

Posted 08 December 2017 - 00:42

joule, that sounds awesome. I understand a lot of the limitations of Lua are deliberate (so it could be more portable), but using Lua feels like programming blindfolded a lot of the time. Something like what you're working on is absolutely brilliant.

 

What I think would really help though would be a slightly easier-to-navigate set of docs. They're not the worst I've seen, but they could be better. Honestly, a webpage with a sidebar you can browse would do the job. I may end up trying to work on something like that once I get my head around Lua and Renoise.

 

Thank you Neurogami and joule for your help--there's very few places to turn for help on Renoise/Lua (although the guys in the Lua Reddit have helped a bit as well).

 

Still wish they went with Python for the scripting language :)



#7 tunabee

tunabee

    Member

  • Normal Members
  • PipPip
  • 68 posts

Posted 08 December 2017 - 00:49

Quick question: can you alter `package.path`? I have Lua 5.3 installed on my computer (OS X) and want it to search for libraries there (for debugging purposes).



#8 Neurogami

Neurogami

    Big Super Masta Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPip
  • 637 posts
  • Gender:Male
  • Location:Scottsdale AZ
  • Interests:Art, music, technology

Posted 08 December 2017 - 01:09

Quick question: can you alter `package.path`? I have Lua 5.3 installed on my computer (OS X) and want it to search for libraries there (for debugging purposes).

 

Yes. It's similar to $PATH in *nix environments, except it doesn't store paths, exactly, but path/patterns.

 

I wrote about tweaking it in Renoise: http://jamesbritt.co...oise-tools.html



#9 tunabee

tunabee

    Member

  • Normal Members
  • PipPip
  • 68 posts

Posted 08 December 2017 - 03:52

Very cool! I will have to read all your articles now :)



#10 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

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

Posted 08 December 2017 - 10:23

What I think would really help though would be a slightly easier-to-navigate set of docs. They're not the worst I've seen, but they could be better. Honestly, a webpage with a sidebar you can browse would do the job. I may end up trying to work on something like that once I get my head around Lua and Renoise.

 

Nice idea. I once made an extraction script for the Renoise LUA API that also extracted the hierarchy/structure of renoise.* with all comments.

I'll try to use all this API data in the _G browser as well.

 

I think LUA is a very elegant and simple language really. But a doc interface like this should be able to help minimize the initial "scare factor".



#11 ffx

ffx

    Composes without Wires burns Directly from Brain to DVD that is already in Store Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3039 posts
  • Gender:Not Telling
  • Interests:macOS fanboying

Posted 13 December 2017 - 14:26

As already mentioned, Steinberg seems to use a proper tool to auto generate the lua docs for halion. It looks pretty pro.


MacOS 10.12.6 Retina, Renoise 3.1 64 bit   -   Tuned Shortcuts | Multi-Jump From/To Send | Quick Template | Insert Native DSP Menu (incl. deprecated)
HM Soundcloud | HM Bandcamp