Author Topic: Scripting in OpenMPT  (Read 5811 times)

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« on: August 25, 2010, 18:02:18 »
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.

Offline LPChip

  • Administrator
  • *****
  • Posts: 4,935
    • http://lpchip.nl
  • Operating System: Windows 7 (x64bit)
Scripting in OpenMPT
« Reply #1 on: August 25, 2010, 18:10:41 »
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

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« Reply #2 on: August 25, 2010, 18:41:28 »
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.

Offline LPChip

  • Administrator
  • *****
  • Posts: 4,935
    • http://lpchip.nl
  • Operating System: Windows 7 (x64bit)
Scripting in OpenMPT
« Reply #3 on: August 25, 2010, 20:41:19 »
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

Offline Rakib

  • Crazy artist
  • ****
  • Posts: 880
  • Operating System: win7x64
Scripting in OpenMPT
« Reply #4 on: August 25, 2010, 22:03:38 »
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?
^^

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« Reply #5 on: August 25, 2010, 22:19:54 »
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.

Quote
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).
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.

Offline Rakib

  • Crazy artist
  • ****
  • Posts: 880
  • Operating System: win7x64
Scripting in OpenMPT
« Reply #6 on: August 25, 2010, 22:55:34 »
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.
^^

Offline Snu

  • Workaholic artist
  • ***
  • Posts: 320
  • Gender: Male
    • http://www.snuq.com
  • Operating System: Windows 7 64bit
Scripting in OpenMPT
« Reply #7 on: August 26, 2010, 08:19:27 »
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.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« Reply #8 on: August 26, 2010, 10:13:53 »
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.

Offline Relabsoluness

  • OpenMPT Developers
  • *****
  • Posts: 707
Scripting in OpenMPT
« Reply #9 on: August 27, 2010, 15:35:34 »
How scripting compares to allowing people to write plugins?

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« Reply #10 on: August 27, 2010, 15:38:11 »
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.

Offline Rakib

  • Crazy artist
  • ****
  • Posts: 880
  • Operating System: win7x64
Scripting in OpenMPT
« Reply #11 on: October 13, 2010, 12:39:50 »
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
^^

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Scripting in OpenMPT
« Reply #12 on: October 13, 2010, 15:01:16 »
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.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Re: Scripting in OpenMPT
« Reply #13 on: December 03, 2010, 21:44:18 »
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.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,127
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Re: Scripting in OpenMPT
« Reply #14 on: April 06, 2011, 20:34:52 »
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.
« Last Edit: September 01, 2011, 18:22:44 by Jojo »
» 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.