Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 07-12-2019, 11:51 AM   #1
Westrabua
Human being with feelings
 
Join Date: Aug 2008
Location: Germany
Posts: 76
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.
__________________
Graphical manager application for LinVst: https://github.com/Goli4thus/linvstmanager

A.k.a Goli4thus (on github). Donate
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: 2,643
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
STASH Downloads https://stash.reaper.fm/u/ReaTrak
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: 76
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.
__________________
Graphical manager application for LinVst: https://github.com/Goli4thus/linvstmanager

A.k.a Goli4thus (on github). Donate
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: 2,643
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
STASH Downloads https://stash.reaper.fm/u/ReaTrak
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: 8,062
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.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 07-13-2019, 11:54 AM   #6
Westrabua
Human being with feelings
 
Join Date: Aug 2008
Location: Germany
Posts: 76
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!
__________________
Graphical manager application for LinVst: https://github.com/Goli4thus/linvstmanager

A.k.a Goli4thus (on github). Donate
Westrabua is offline   Reply With Quote
Old 07-14-2019, 12:25 PM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,622
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.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   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 06:50 AM.


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