Scripting in OpenMPT

Started by Saga Musix, August 25, 2010, 18:02:18

Previous topic - Next topic

Saga Musix

With languages like lua, it's rather easy to implement scripting into programs these days. I have been playing with the thought for a very long time now, but I have not made up any usable specifications so far. So I'm asking you, what functionality would you need? I thought about providing scripting functionalities for the pattern editor. Now the question is of course what should be possible, i.e. what kind of pre-made functions should exist?
I've come up with:
- A "for each"-style command, which applies a custom lua function on every mod command
- Retrieving and changing the order list (+ sequences)
- Retrieving and changing a pattern command using given coordinates

It would be possible to call exisiting OpenMPT functionality from these scripts, but that cannot be done automatically - every function would have to be bound to a lua identificator manually first. That's why I would like to know which functions really should be usable from within lua (f.e. something like AddChannel() or RemoveChannels()).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

LPChip

I doubt that scripting would work inside a song, but I can see it a bit useful as macro functionality to make a tedious task easier by doing it scripted.

For instance, do a copy/paste between songs, transpose the song in a specific way not possible by the replace dialog (can't think of one but I'm sure there must be one)

Would it be inside the song, then the only thing I can think of is, a simple script that would be; if xxx is true, then yyy.

This could be useful for jumping to a specific pattern or perhaps using automation.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Saga Musix

I said pattern editor. Of course that doesn't mean "song scripting".
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

LPChip

Quote from: "Jojo"I said pattern editor. Of course that doesn't mean "song scripting".

Since you program the song in the pattern editor, I wasn't sure. Don't blame me for the fact that both answers are possible.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Rakib

Since Renoise is getting the LUA-scripting I would like to see what it brings before I can say how it would be useful. (Just have to wait for the beta release to show up).

Could better automation be one of the functions that could be done?

But generally LUA is way easier to program than c++, so I reckon we would have more users contributing to the project. So I am all for it, just don't how it would be useful. And is LUA the only alternative, how about Python or Erlang?
^^

Saga Musix

Quote from: "Rakib"And is LUA the only alternative, how about Python or Erlang?
How simple is it to implement those languages in a C++ project then? Lua is not without reason the most wide-spread scripting language that can be found in many well-known programs.

QuoteSince Renoise is getting the LUA-scripting I would like to see what it brings before I can say how it would be useful. (Just have to wait for the beta release to show up).
Well, it would making editing patterns a lot easier, and people would not have to bug the developers to implement each and every pattern edit function into OpenMPT which probably noone else needs (f.e. a special transpose function which only transposes certain instruments on certain channels or whatever).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Rakib

http://code.google.com/p/epi/
http://www.language-binding.net/

But it was just an question, LUA sounds nice.

But I know in many scientific areas c or fortran is used to do the calculation and python for the non-speed related stuff.
^^

Snu

hmm, interesting thought, i can definitely see it being useful!
i would also like to see instrument/sample modification possible, like making a script to iterate through all the samples and disable panning (ugh, i hate doing that).

the question i have is: would these scripts only be macros (like i can see the 'cleanup' command becoming a script, or the interpolate volume/effect column), or could they be an always-running thing that would modify the way mpt behaves (such as keyboard split becoming a script, or making mpt display .xm effects as .it style instead, or even creating custom dialogs...)?

i would put in my vote for python tho, simply because its the scripting in another of my favorite programs (blender) and im trying to learn some of it, but hey, whatever works.

Saga Musix

I thought more of macro-like actions, but it is probably possible to let them run in the background - I don't know yet.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Relabsoluness

How scripting compares to allowing people to write plugins?

Saga Musix

I'd say it's the same amount for integrating it, but the advantage of scripting would be that the user can directly write scripts in/for OpenMPT without having to use a separate compiler. And a script is practically platform-independent and no plugin interface has to be designed carefully (of course there is still a scripting interface to be designed, but this is easier to fix than a plugin interface IMO).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Rakib

By looking at the renoise forum and all the tools they are building their, I very much want to something similar in modplug. But if implemented,  I'd like a in-built script-editor and maybe a debugger and if it's not to much work a form builder.

http://www.renoise.com/board/index.php?showtopic=27164&pid=213885&st=0&#entry213885
^^

Saga Musix

A debugger is extremely unlikely to happen, and neither is a fully fletched script editor planned. Of course it is possible to display errors in scripts, but not much more than that. And there are enough good Lua editors out there.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Saga Musix

At the moment, I'd rather prefer a C implementation like picoc instead of LUA. Though I'm not sure how useful picoc will be, since there's a chance that it won't work with Visual Studio, at least not out of the box.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Saga Musix

#14
As LPChip has been asking about the status of this, here are some concept I have been writing up over the last few months. Feel free to discuss and add remarks. It is very much possible that I've forgot about important functions that should be available to the scripts.

Concept: Running scripts

Obviously there would be some kind of button / shortcut: Run Script
This would open the "Scripts" dialog, which offers a list of existing scripts (most recently used script would be preselected).
Frequently used scripts could be assigned to freely configurable shortcuts (maybe 10 of them?).

Concept: Actual Scripting

Things that the scripts should have access to:
- Patterns
- Order list
- Sequences
- Samples
- Instruments
- Plugins?

Actual interface functions

- Read / write playback/edit position
- Read / write access to Order list
- Read / write / create / delete / switch sequences
- Read / write access to patterns: GetNote(chn, row), GetInstrument(chn, row), ..., SetNote(chn, row)..., ForEachModCommand style callback functions (with row, channel, order parameters), AddChannel, RemoveChannel, MoveChannel, ResizePattern, ShrinkPattern, GrowPattern
- CreatePattern (concept: returns new pattern number, -1 if failed), DeletePattern, DuplicatePattern
- Read / write access to sample data, create samples
- UI access: Get and set selection boundaries (pattern data / order items / sample data)
- Dialogs: GetInteger / GetFloat / GetString input boxes (all with optional min/max parameters), Message Boxes
- Callback functions that are called on every tick / row / pattern change.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.