-
Notifications
You must be signed in to change notification settings - Fork 4
Adds the ability to automatically run a task and Reaper actions after debugger launch #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… the debugger has been launched. Can execute any multiple reaper action with delay.
|
As an aside, one of the bigger challenges in getting reaper to play nice with external debuggers is handling errors. Reaper pops up an modal dialog box that breaks the flow of debugging. One solution to this might be to get a reaper FR to send the errors over to the debugger. This could be done using OSC or some other method such as a win32 hook/callback. |
|
Hello, Thank you for this PR! I can take a closer look tomorrow or Monday. |
|
Yes, it is windows based but uses oscpack under the hood which works with windows and posix. I forgot all the details now ;/ but the idea is that we need some way to trigger an action in reaper. Many ways this could be achieved. Not sure if reaper supports DDE or similar methods but I chose osc since that is what I had available at the time. One simply assigns the action to the script(ideally one could run a script by name directly using DDE or cli or whatever and the task will execute the mechanism to run the script. Again, I used osc in this case but ideally there would be some cli or DDE for reaper to do things like this. With osc though it allows integrating other osc devices if one had the desire. It at least shows how one can go about doing it. I've been using it and it works quite well. Sometimes though it simply does not trigger the script when the debugger is run from vscode(not sure what happens, in those cases I typically just run the script in reaper and the debugger will then catch it). Not sure if things get bogged down and the time out hits or what. In some cases when running the debugger it can get out of sync with the script. If the script is running and you try to debug it then it may terminate the script rather than execute it. Ideally here the script run action would always terminate the script when being run. The way one typically has to do the work is make sure to stop the script first then disconnect. All this could be fixed if there were a proper way to interact with reaper but baring that this does work. |
|
Interesting. How does your solution improve over using reaper’s native CLI commands ? Maybe it’s just that we don’t have this documented well, but @GoranKovac set this up so that you can run it as tasks: {
"version": "2.0.0",
"tasks": [
{
"label": "Run Reaper Script",
"type": "shell",
"command": "reaper",
"args": [
"-nonewinst",
"${file}"
],
"problemMatcher": [],
"presentation": {
"reveal": "never"
}
},
{
"label": "Debug Script",
"command": "${command:workbench.action.debug.start}"
},
{
"label": "Debug and Run",
"dependsOrder": "sequence",
"dependsOn": [
"Debug Script",
"Run Reaper Script"
],
"problemMatcher": []
}
]
}This executes reaper CLI commands. In this task it means: It works on all platforms. In vscode’s case, it will run on the currently-focused tab/script. Oh… I’m just realizing now that we don’t have these tasks setup for the workspace. |
|
Cool. Well, that task then accomplishes the same thing simply using a different method. The OSC solution provides an alternative method that might be beneficial in some cases. For example, I routinely run multiple reaper installs and I'm not sure if the reaper.exe cli will be forced to work with only one or if it running one reaper.exe will work on another. In my setting, since I use multiple installs all that sym link to a common scripts dir(among other things). This is not an issue with OSC as one sets it up the same way in all installs so which ever is running will respond. If the reaper cli will work on any active instance(not match the path) then it should work too. Alternatively one could have multiple tasks that use the different paths(this would just be a pain to always choose the right one. I guess the path to the current running reaper.exe could be determined through the task. Barring those issues with the cli, the only thing I can see the OSC really being useful for is potentially running actions rather so that one doesn't have to put them in a script. E.g., one could, in theory, add some vscode ui elements or shortcuts to control reaper using OSC. This could be done with scripts too but it would add a layer of indirection. In rare cases with other osc devices controlling reaper and debugging it might would be useful. E.g., using something like a tablet running touchosc to help debug scripts. E.g., one could design some android debugging interface control panel for reaper that might be useful. In this case having some way reaper, vscode, and android to communicate would be necessary and OSC fills that gap without much hassle. It's just another tool in the toolbag. Since there already seems to be a way to do it for the main use cases it makes it less likely to be used unless there are issues for using multiple installs. I'll try and test it out when I get some time. I imagine most people will use only one install so it's already limited use case but most people also do not code or debug scripts so in that sense it's all limited use case. The reason I created this is that I was told by someone or read somewhere that one had to run the scripts from reaper and that was the main downside of the extension. I was actually working on extending the debugger to display more info in the watch and auto. E.g., we can make it display reaper type info rather than the pointer value. To make it work I wanted an easier/faster way to launch debugging. |
|
If reaper is not added to ENV PATH (by install or manual) then you need to specify full path to it: You can create multiple tasks for every version. Tasks are something that we unfortunately cannot generate that would work out of the box (portable installs) and cover all use cases (like yours with multiple installs) |
|
I understand the rationale. @Universal-Invariant in your case, if you were to still try to use the native CLI, I suppose you’d have to be setting aliases to the alternate reaper locations in your shell. It’s true that using multiple reaper installs is niche. Also, triggering actions from OSC is pretty nice. About the |
|
The oscahk dll I used uses oscpack from https://github.com/RossBencina/oscpack. The oscahk was ripped from somewhere online I think. https://www.autohotkey.com/boards/viewtopic.php?t=89647 but I had to hack it to get it to work since there was some versioning issues. oscahk simply sets up the osc server so it can send and receive messages(but it's only used to send). oscpack is the server code. The readme.md in the zip file explains a lot of the details. My main contribution was simply getting the code to compile on my end, the ffi wrappings, and modifying extensions.ts. (note that it also adds a general task execution routine that could be used to run reaper cli or any task) I guess I didn't include the code(I thought I did at some point but it's been a while and maybe it was done to my local). I was going to try and create an command line executable that could send Osc commands because I was having trouble getting the ffi to work since everything seemed to be outdated. At the time I didn't know there was a way to get vscode to run the script so I was just trying to hack something together and go from there. From there you should be able to compile the dll. The biggest problem I had is that it wasn't properly setup for x64 so it took some time. It may or may not be an issue for you but it does(or did) compile on my end. There may be other ways to send OSC commands. I looked a bit but couldn't find anything os besides oscahk. The ffi extensions could be used as a template for integrating other libraries into the extension. I only coded this for windows so that likely needs to be dealt with. It's mainly a proof of concept/prototype and likely needs to be polished. Again, I didn't know at the time there was already a way to do what I was ultimately wanting. It might be better to hold off on merging it until it is polished. I don't know enough about linux to know how to get it all to work although I could do it. It would be more efficient of someone more adept could try getting it to work. Likely the main issue is getting the oscahk library to work and then dealing with the ffi. I might try my hand at it if I ever get the time but since I have no need for it likely it won't happen(too many other things to do). I will install vscode and reaper on WSL and maybe that will start things off. |
|
There is a native extension for OSC and works fine with Reaper. Personally I don't see the use cases for extension to run actions. Main focus was you are developing a script and need autocomplete/suggestions/debug and ability to run it without losing focus. But don't mind my views, if this is something that would make other users happy and would find useful then I'm all for it. |
|
Well… as Goran pointed out, there is indeed the OSC sender extension for vscode. I’m not against the idea of triggering actions through OSC instead of tasks - this is kind of remote from my use case at this point, but I’m willing to accommodate it if the approach is solid. Looking at the vsc-osc-sender, it looks like they’re doing it natively inside vscode with 60 lines of typescript and a dependency on the OSC package - which is probably acceptable. I wouldn’t want to add the full vsc-osc-sender as an extension dependency, though. So, if you are willing to look into porting some code over from vsc-osc-sender or a similar extension, I think it would be a much more satisfactory approach - rather than passing around a zip file without a repo that needs compiling and pulling your hair over getting it to play nice on WSL. Obviously, no rush - I do realize there are only 24 hours in a day, and we’re all getting pulled in all kinds of directions. |
|
Yea, I didn't realize there such a thing or it would have made things easier. It likely would not be that difficult to add. One doesn't want to use the vscode-osc extension I believe but add the dependency https://www.npmjs.com/package/osc then follow along a similar line of what is in https://github.com/gabe927/vsc-osc-sender/blob/main/src/extension.ts Unless one can set them up as a task and the integrate it into the reaper extension(probably so). If I ever get around to it I will look into it. |
|
Everything that has a command can be set as a task, in this case: |
|
Whats also possible is to use Reaper web interface and 40001 is action to create new track and reaper happily responds to it and adds track. |
|
You’re kidding, that’s insane! |
|
Well, there you go ;) Reaper never fails to amaze. Always seems to have the functionality one wants. Maybe the real problem is that there is not really a good way to discover this? Maybe what is needed is a LLM trained on all things reaper? |
One problem I've noticed just trying this is that when one uses reaper "cli" to run the script it creates a new project. At least that is what is happening on my side. I end up with a lot of tabs and I guess it would start a new tab and the script won't run in the right project context. So this actually isn't a good solution unless reaper and has or adds a flag to run the script or file one opens inside the current open project. Also, one needs to close out the script. Right now I'm having it run close all scripts but it we really would want a way to close out a specific script so we can start a fresh debug session. If one needs to run other scrips in the background while debugging a different script then they will be closed out also. |
Uses OSC (from OSC2AHK) to send osc commands to reaper. By creating a control/OSC/web OSC control surface from the preferences and configuring the ip and ports(defaults are fine) then enable "allow binding message to REAPER actions". Click listen and run the debugger and the actions should show up. Create a reaper action to run a script and copy the command ID to use.
add these to the launch action. Multiple commands seperated by ; can be executed with delays added by the - suffix. The delay may need to be increased if the script is executing before the debugger has time to finish listening.
"debuggerTask": "Execute Last Reaper Script",
can also be executed after debugger launch.