Jump to content


Photo

Some questions regarding LUA editor / LUA api


  • Please log in to reply
9 replies to this topic

#1 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 01 April 2015 - 23:07

Hi,

 

have a bunch of beginner questions regarding the LUA editor/ LUA api:

 

- Is there a way to re-indent the code?

 

- Is there a shortcut to "find next", like Apple-G on OSX?

 

- Is there an observable for general "file renaming", deletion and creation ?  Or an observable when the disk browser will unfocus?

 

- Can I change the current path of the current song?

 

- Is there a default song path available?

 

- is it possible to rename the current song using LUA, so that this new name will be used, if the save-song-dialogue appears and in the window title bar?

 

Thanks.


Edited by Jurek, 02 April 2015 - 09:31.

Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#2 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 02 April 2015 - 09:32

:( No answer means:  WTF RTFM ?


Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#3 dblue

dblue

    Dodgy Geezer

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

Posted 03 April 2015 - 15:47

- Is there a way to re-indent the code?
- Is there a shortcut to "find next", like Apple-G on OSX?

Select a multi-line block of text in the editor, then use [ Tab ] to indent, or [ Shift ] + [ Tab ] to un-indent.

[ Ctrl ] + [ G ] will find the next match, if a search has previously been made using [ Ctrl ] + [ F ]. You can also simply continue pressing [ Return ] in the find box, after entering a keyword.

Refer to Editor&Terminal.txt in the scripting documentation for a full list of available shortcuts.


The other stuff you mentioned is a bit more tricky.

In general, there are no observables to keep track of changes happening at the file system level. We do have observables such as renoise.tool().app_new_document_observable (called whenever a new song is created, or an existing song is loaded) and renoise.tool().app_saved_document_observable, so your tool could listen to those and know when to check the song's file name, path, etc., in order to update its internal state. More details in Renoise.ScriptingTool.API.lua

Anything related to the currently loaded song's file name and path is pretty much read-only, and can only be changed indirectly by re-saving the song under a different file name and path.

You could in theory rename the XRNS file directly in the file system, but Renoise will not do anything special in response to this -- your tool will still need to re-load the song from its new location. Take a look at Lua.Standard.API.lua to read about the various os.* functions you can use to access and manipulate files, directories, and so on.

There's no default song path, so you'll have to take care of this yourself, and prompt the user to define one when necessary. You can use renoise.app():prompt_for_path(dialog_title) to let the user pick a directory. More details in Renoise.Application.API.lua
  • ffx likes this

#4 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 04 April 2015 - 11:18

Hey thanks dblue,

Some more questions:

- do you think the r3 lua api provides all functions for loading a xrns song next to the current song, copying all fx from specified tracks to the current songs, also copying creating send tracks including fx and reconnect all stuff (send and meta) afterwards automatically like in the original song?

- is it possible to create an event/observer on click on a custom menu or if menu is focussing in general?

Thx

Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#5 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 08 April 2015 - 09:42

Guys, can you gurus take a second of your time for my little 2 questions? Yes or no would be enough for me, I don't expect you to list all needed functions.

 

Ah, and a third:

 

- If it's possible, should I wait until Renoise of 3.1, since a bunch will change in the API?


Edited by Jurek, 08 April 2015 - 09:44.

Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#6 toblerpone

toblerpone

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 905 posts
  • Gender:Not Telling
  • Location::c

Posted 08 April 2015 - 11:53

I think you can have that xrns opening thing, will be hell of a project for you though, just open the xrns as a zip and see

 

The menu thing, no

 

only the devs can answer the latter and probably aren't too sure themselves at the moment



#7 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 08 April 2015 - 12:01

I think you can have that xrns opening thing, will be hell of a project for you though, just open the xrns as a zip and see

 

The menu thing, no

 

only the devs can answer the latter and probably aren't too sure themselves at the moment

Oh ok, thought like accessing the second "virtual" song object using the normal song functions like "copy fx chain"etc, and not raw processing the xml data in the song  :)


Edited by Jurek, 08 April 2015 - 12:02.

Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#8 dblue

dblue

    Dodgy Geezer

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

Posted 08 April 2015 - 16:07

- do you think the r3 lua api provides all functions for loading a xrns song next to the current song (...)

The Lua API only provides methods for operating directly on the currently loaded song.

There's no native method of loading an XRNS song into a temporary object, and then copying some of it contents to/from the currently loaded song. (This would of course be awesome, but it simply isn't possible at this time.)

So pretty much anything you do here will be a hack, whether it's somehow opening the XRNS ZIP archive and then reading the raw XML, or having Renoise load multiple different songs in series and performing operations back and forth with them, etc. There are ways to get it done, but they certainly won't be pretty.
 

- is it possible to create an event/observer on click on a custom menu or if menu is focussing in general?

Not exactly sure what you're trying to do here, but if you're using a custom popup menu (a dropdown) in your GUI, then you can attach a notifier that will fire when the selected item changes.

There's no notifier to alert you when the popup is opened or focused.

See: Renoise.ViewBuilder.API.lua
 

- If it's possible, should I wait until Renoise of 3.1, since a bunch will change in the API?

We're not talking about a huge change to the entire API here. There'll likely be a few small tweaks necessary when moving your code from 3.0 to 3.1, but it shouldn't require a major overhaul or rewrite.

#9 toblerpone

toblerpone

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 905 posts
  • Gender:Not Telling
  • Location::c

Posted 08 April 2015 - 16:48

@jurek: Honestly, processing the raw xml data, in something outside of renoise altogether (processing all that will be slow), seems much easier than using the internal copying functions, just look at the xrni-merger tool.



#10 ffx

ffx

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

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3442 posts
  • Gender:Not Telling

Posted 08 April 2015 - 16:55

Ok guys, thanks lots for info.


Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes