Ok, I think I need to clarify this even further:
Assume the following script:
Code:
-- this sets the gmem attached in this script to "ThisIsMyGMEM"
reaper.gmem_attach("ThisIsMyGMEM")
-- the following function sets the currently attached gmem to "jsfx_to_video"
Retvals=ultraschall.GetVideoPeekInformation()
-- now the scripter wants to read the gmem and assumes, it is from "ThisIsMyGMEM"
-- where ultraschall.GetVideoPeekInformation set it to "jsfx_to_video"
reaper.gmem_read(1)
-- So the user is now reading from the wrong gmem, as I had no
-- chance in ultraschall.GetVideoPeekInformation to reset
-- it back to "ThisIsMyGMEM" as there's no way to
-- store the old gmem-name in the backgronud, before I changed it
Additional parameters would be possible but are bad as well. If I add functions for the user and need to change stuff in the back, I always should restore the former states back without having to bother the user at all.
It would otherwise also mean burdening the management of what the current gmem-name is to the scripter, and if they are using different ones in a script, changing back and forth, it can become confusing, as they always would need to do stuff like:
Code:
CurrentAttach="name"
reaper.gmem_attach(CurrentAttach)
retval = ultraschall.GetVideoPeekInformation(CurrentAttach)
my_value=reaper.gmem_read(1)
CurrentAttach="Another name"
reaper.gmem_attach(CurrentAttach)
my_value=reaper.gmem_read(123)
ultraschall.GetVideoPeekInformation(CurrentAttach)
This simply clutters code, even in this simple example, let alone more complex scripts. And cluttering is always a great source for bugs.
I would prefer it more like that:
Code:
reaper.gmem_attach("name")
retval = ultraschall.GetVideoPeekInformation()
my_value=reaper.gmem_read(1)
reaper.gmem_attach("Another name")
my_value=reaper.gmem_read(123)
ultraschall.GetVideoPeekInformation()
Much cleaner.
Good API-functions should not build up clutter and barricades. They should step aside and help you make things easier, not harder and possibly confusing.
And as I intend to do a lot with the video-processor in the future as well(using tons of gmems), having to deal with that could become a pure coding-clusterfuck, if users would work with their own gmems in these Lua-Scripts alongside my video-processor-functions.
I prefer to make this stuff as clean and simple as possible and clean up after myself.
And all I need to make this properly is a way of getting the current attached gmem in the current Lua-script, which should be known by Reaper anyway.