Old 07-12-2019, 11:51 AM   #1
Westrabua
Human being with feelings
 
Join Date: Aug 2008
Location: Germany
Posts: 53
Default Retrieve LoopTimeRange information within web browser interface

Is there any way to retrieve the LoopTimeRange information within the web browser interface html context?

I mean the information one can get via lua with
Code:
local pos_a, pos_b = reaper.GetSet_LoopTimeRange( false, false, 1, 1, false )
I'm trying to extend the web interface (index.html) for my recording usecase and this is the one bit of information I'm missing.
Westrabua is offline   Reply With Quote
Old 07-12-2019, 02:16 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 974
Default

Might be something in these links ??
http://starlight.paulcuth.me.uk
http://moonshinejs.org
http://www.keplerproject.org
https://keplerproject.github.io/cgilua/manual.html
http://lua.space/webdev/why-we-rewrote-lua-in-js
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 07-12-2019, 02:39 PM   #3
Westrabua
Human being with feelings
 
Join Date: Aug 2008
Location: Germany
Posts: 53
Default

Thanks.
Hmm, maybe I don't get it but these look to me like a way of running Lua in the web browser, which isn't exactly what I'm looking for.
Programming with javascript in regards to the web remote control is fine.

What I'm looking for is the actual information the Lua API provided by Reaper offers: the information about the start and end time of the current loop selection in Reaper.

I couldn't find anything within the documentation in main.js or the existing remote control versions that fits this.
My initial hope was to just call the mentioned lua code via
Code:
wwr_req(<my_custom_lua_script>)
and somehow return the data to the web remote control. But I don't seem to find a way to achieve this.
Westrabua is offline   Reply With Quote
Old 07-12-2019, 06:05 PM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 974
Default

Somewhere there I thought I saw that, have a look at this
https://stackoverflow.com/questions/...ript-file-page
ReaperWRB will run scripts, but you need the pos_a, pos_b from the script to the web interface.
X-Raym has this X-Raym_Convert Lyrics track items notes for dedicated web browser interface.lua
https://forum.cockos.com/showthread.php?t=220320
so you should be able to do it.
Sorry I haven't done any of that so don't want to give you a bum steer.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 07-12-2019, 09:02 PM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,868
Default

Quote:
Originally Posted by Westrabua View Post
Is there any way to retrieve the LoopTimeRange information within the web browser interface html context?
I am not that experienced with the web browser control stuff in Reaper but the documentation seems to suggest getting that information just isn't supported with the web browser API. (At least not in any straightforward manner.)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 07-13-2019, 11:54 AM   #6
Westrabua
Human being with feelings
 
Join Date: Aug 2008
Location: Germany
Posts: 53
Default The solution

Quote:
Originally Posted by MusoBob View Post
Somewhere there I thought I saw that, have a look at this
https://stackoverflow.com/questions/...ript-file-page
ReaperWRB will run scripts, but you need the pos_a, pos_b from the script to the web interface.
X-Raym has this X-Raym_Convert Lyrics track items notes for dedicated web browser interface.lua
https://forum.cockos.com/showthread.php?t=220320
so you should be able to do it.
Sorry I haven't done any of that so don't want to give you a bum steer.
Alright, that script by X-Raym put me on the right track and I finally got it working.


Here's how you can do it:

First make a lua script with something along the lines of this:
Code:
local pos_a, pos_b = reaper.GetSet_LoopTimeRange( false, false, 1, 1, false )
local pos_str = pos_a .. ";" .. pos_b
reaper.SetProjExtState(0, "GOLI_WEB", "lts_pos_str", pos_str)
Then within the web control code start the retrieval like so:

Code:
wwr_req_recur("GET/PROJEXTSTATE/GOLI_WEB/lts_pos_str",100);
and add something like this in the web controls wwr_onreply(results) function:

Code:
      case "PROJEXTSTATE":
        // Returns: PROJEXTSTATE \t section \t key \t string
        if ((tok[1] == "GOLI_WEB") && (tok[2] == "lts_pos_str")) {
          tmp_str = tok[3].split(";");
          last_lts_pos[0] = parseFloat((parseFloat(tmp_str[0])).toFixed(11));
          last_lts_pos[1] = parseFloat((parseFloat(tmp_str[1])).toFixed(11));
        }
      break;
So it basically boils down to:
  1. Put the needed information within lua into a string and set as a key-value pair with the SetProjExtState() API
  2. Retrieve the information in the web control via the GET/PROJEXTSTATE/section/key API and parse it as needed

This means we can pretty much transfer whatever might be needed to the web control. So yeah, not straightforward at first, but doable. Good stuff!
Westrabua is offline   Reply With Quote
Old 07-14-2019, 12:25 PM   #7
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,490
Default

Here's an introduction I made on how to program from/to WebInterface in Reaper.
It is an enhanced version of Reaper's own docs hidden in a js-file.

As you already wrote, write a script, that sets these values to an extstate, which can be retrieved.
You can run this script, by retrieving it's commandid and using the command-id and run it.
Just follow the examples, to get an understanding on how to do it, as the examples show you, how to get/set the extstates you wrote.

https://mespotin.uber.space/Ultrasch...mentation.html

If you're already familiar with that, read the following parts for:

ProjectExtStates:
https://mespotin.uber.space/Ultrasch...TE/section/key

or normal ExtStates:
https://mespotin.uber.space/Ultrasch...TE/section/key

and the one for getting the right command-id for your script:
https://mespotin.uber.space/Ultrasch...GET/command_id

and use them accordingly.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.