Old 12-15-2011, 09:19 PM   #1
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default New Reaper extension plugin example code

Edit 19th April 2018 : I've requested this thread be locked, because the Google Code page is no longer working and the code is probably outdated too.

Edit 12th December 2014 : Googlecode repository now again has simpler code at the master branch. Some messy experimental stuff was committed previously to the master branch.

Edit 17th December 2012, updated code is at :

http://code.google.com/p/simple-reap...ension-plugin/

The example plugin for creating a new action for Reaper that comes with the Reaper extension SDK can be a bit confusing for people not yet familiar with C and C++ and the Windows API and includes using things like network access and Windows dialogs. While what the example does is pretty cool, I've often thought perhaps a more trivial example with comments might be more useful for people wanting to start learning the Reaper extensions coding.

Here's the current code, if some experienced programmer wants to check it out and suggest improvements (this code file as such isn't yet useful for newbies to use as Visual Studio and XCode require project files set up too) :

http://pastebin.com/fnJq84eY

I also know ReaScript is probably what people should be using to add their own coded actions into Reaper, but I am a bit old fashioned and believe the C and C++ based plugins could still be useful and implement functionality not possible with ReaScript yet. (Like adding actions that have toggle states for the toolbar buttons, like shown in this new example I wrote.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 04-19-2018 at 11:18 AM.
Xenakios is offline  
Old 12-16-2011, 04:32 AM   #2
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Hopefully i can use this to get on my way with converting some of my macros into togglable extensions
Thanks a lot Xenakios
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline  
Old 12-16-2011, 05:09 AM   #3
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Awesome

Many thanks. I'm always on the edge with learning how to do C++ extensions for Reaper. But I've yet to go any further than to stare with big eyes at the example code. From your description this might be what I need to kick me a bit further in to the waters.
gofer is offline  
Old 12-16-2011, 11:43 AM   #4
EnkelMagnus
Human being with feelings
 
Join Date: Feb 2010
Posts: 96
Default

Brilliant,i was going to ask for something like that the other day but now i don't have to. Thank you very much.
EnkelMagnus is offline  
Old 12-16-2011, 11:58 AM   #5
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Yes, great stuff.
Thanks...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline  
Old 12-16-2011, 01:00 PM   #6
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Well done Xen, that needed doing. Somebody sticky this.
IXix is offline  
Old 12-20-2011, 01:39 PM   #7
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Dang! For some reasons that still escape me, I said I'll cook something similar in another thread (I even started to..). So, thanks Xen: this is the perfect exit door for me, ha hahha!

Since you are asking for some feedback (FWIW + I didn't compiled it), I have nothing to say about the code itself (well maybe the "%s\\example_extension.ini" which won't work on OSX) but more general remarks:
- I think it would help to upload a full zip (à la reaSDK: with project files, WDL bits if really needed, etc..)
- to limit spaghetti issues, it ould be great to totally "hide" the action registration mechanism (eg in a "core.cpp" file with "pre-mapping" for all API functions) so that the user just has to define his/her actions and code them in a dedicated file (eg "my_actions.cpp") with 1 action definition = 1 line. Obviously here you still have to define 3 things per action + register + hook the action + hook the toggle state + map API funcs + etc..

Oof course, there is an end point where people will have to deal with C but I think it could really help to get started (there is a bunch of people who are ok/can adapt to C but not with what is around: those coming from C#, java,..)
Quote:
Originally Posted by gpunk_w View Post
Hopefully i can use this to get on my way with converting some of my macros into togglable extensions
hey g_punk, don't count on me to demotivate about the C approach but just for the record, you can define macros with toggle states in the "cycle action editor" of the SWS extension..
Jeffos is offline  
Old 12-20-2011, 05:39 PM   #8
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Quote:
Originally Posted by Jeffos View Post
hey g_punk, don't count on me to demotivate about the C approach but just for the record, you can define macros with toggle states in the "cycle action editor" of the SWS extension..
Did try that, but the icon still does not toggle when you press the toolbar button, so i don't see the difference between that and a normal two action macro ?
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline  
Old 12-20-2011, 09:50 PM   #9
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Jeffos View Post
(well maybe the "%s\\example_extension.ini" which won't work on OSX) but more general remarks:
- I think it would help to upload a full zip (à la reaSDK: with project files, WDL bits if really needed, etc..)
- to limit spaghetti issues, it ould be great to totally "hide" the action registration mechanism (eg in a "core.cpp" file with "pre-mapping" for all API functions) so that the user just has to define his/her actions and code them in a dedicated file (eg "my_actions.cpp") with 1 action definition = 1 line. Obviously here you still have to define 3 things per action + register + hook the action + hook the toggle state + map API funcs + etc..
Yeah the code wasn't supposed to be yet used by beginners, but I rather put it up there for someone to comment on, who already knows about the extensions stuff. So thanks for the comments!

A package with WDL and project files for Visual Studio (and hopefully for XCode in some manner though I can't prepare that myself) should of course be made.

Doing things abstracted and in several code files would of course be desirable but might also be confusing or give a too optimistic view of the complexities of coding if things are hidden away. Some kind of balance would need to be found there, to provide some beginner friendliness as well as some educational value.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 12-20-2011, 11:27 PM   #10
caseyjames
Human being with feelings
 
caseyjames's Avatar
 
Join Date: Jul 2009
Posts: 632
Default

Thanks mr!

This is a very handy little insight for someone like me who is just getting started with Reapers C side.
caseyjames is offline  
Old 01-10-2012, 04:35 PM   #11
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I haven't done anything for this for a while, but it's still at the back of my head, so not forgotten entirely.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 01-11-2012, 10:04 AM   #12
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Xenakios View Post
I haven't done anything for this for a while, but it's still at the back of my head, so not forgotten entirely.
The back of my head is so cluttered that I can't find a thing.
IXix is offline  
Old 02-15-2012, 06:06 PM   #13
KarlLai
Human being with feelings
 
KarlLai's Avatar
 
Join Date: Feb 2012
Posts: 26
Default

Thanks for the detailed comments!

However, where should I expect to see it after I compile and put the dll into the plugins folder (I use the ninjam project solution and it works for the code posted in this thread)? Should it be one of the actions?

I am thinking maybe I am running on a 64 bit windows 7 and probably need some special setup? Because I can compile both the M3U and ninjam example, but I cannot find them in the Reaper.

Anyone has similiar issues?


Edit: okay it is caused by the 64 bit version. It works in x86 version. Thanks!

Last edited by KarlLai; 02-15-2012 at 08:32 PM.
KarlLai is offline  
Old 02-15-2012, 11:20 PM   #14
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by KarlLai View Post
Edit: okay it is caused by the 64 bit version. It works in x86 version. Thanks!
You will need to build a 64 bit dll binary to be used with Reaper's 64 bit build. If you are using Visual Studio Express, that won't be possible, as that doesn't come with the 64 bit compiler, unfortunately. The 64 bit compiler can be got with the Windows SDK (free of charge, but no easy IDE integration, you will need to use it from the command line) or a payware version of Visual Studio.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 07-03-2012, 01:51 PM   #15
benf
Human being with feelings
 
benf's Avatar
 
Join Date: Oct 2008
Location: France
Posts: 3,698
Default R6034

I'm a newbie in dll programming.
I picked up xenakios code, put it in a dll project in VS C++ 2008, finally built it after solving a fistful of problems, and got a dll.
I put it into plugins folder and, when I launch Reaper, I got an R6034 error message about manifest. I looked a little on the web and found things about properties to adjust in VS. Checked it and found that all the properties are already well settled.
Does anybody have encountered this problem ?
__________________
Ma Zique
Mes Partoches
benf is offline  
Old 07-05-2012, 03:21 AM   #16
benf
Human being with feelings
 
benf's Avatar
 
Join Date: Oct 2008
Location: France
Posts: 3,698
Default

Very strange. I did the same on another PC and I got no error message. Does anyone help me understand the reason why I got this message ?

Thanks
__________________
Ma Zique
Mes Partoches
benf is offline  
Old 07-05-2012, 08:25 AM   #17
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by benf View Post
Very strange. I did the same on another PC and I got no error message. Does anyone help me understand the reason why I got this message ?

Thanks
Perhaps it's about the Visual Studio runtimes. Though it's weird it wouldn't work because of that on your development machine...You could try statically linking the runtime library to your dll. (It's somewhere in the VS project options, I don't exactly remember where because I don't actively use the VS IDE anymore.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 08-15-2012, 12:48 PM   #18
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

This is great! With this, sws source and ninjam loop example I`m starting to understand some stuff.

I was able to add one simple action to sws source code! (even compile it - and it worked ) But I hate that I can`t understand how basics are handled (registering actions, getting api commands)

So I atm feel pretty lost - it`s all a guessing game for now. The problem is that I`ve never touched anything but python and pascal so I got C++ primer plus
I hope that after I finish that book (along with examining sws source) I will be able to understand this stuff more fully and contribute to community.

Anyway, I will probably bug you people with silly questions around this part of the forum. And I as well may start with one.

It says here: http://code.google.com/p/sws-extension/wiki/Building that I need to patch WDL before using it with SWS.

1. Why do I need to patch it? What does it do exactly?
2. How do I patch it on windows? What tool should I use?

Last edited by Breeder; 08-15-2012 at 03:04 PM.
Breeder is offline  
Old 08-15-2012, 01:17 PM   #19
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Breeder View Post

It says here: http://code.google.com/p/sws-extension/wiki/Building that I need to patch WDL before using it with SWS.

1. Why do I need to patch it? What does it do exactly?
2. How do I patch it on windows? What tool should I use?
It's exactly this kind of stuff why I don't think the SWS codebase is a good thing for beginners to look into...(Building it is now so complicated I can't be bothered to try it myself anymore.) Anyway, if you already managed to actually build and run the plugin, I would make a guess things are already ok for you...? The building instructions at the SWS code site might be out of date and WDL might already be as it should be for it.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 08-15-2012, 03:04 PM   #20
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by Xenakios View Post
It's exactly this kind of stuff why I don't think the SWS codebase is a good thing for beginners to look into...(Building it is now so complicated I can't be bothered to try it myself anymore.) Anyway, if you already managed to actually build and run the plugin, I would make a guess things are already ok for you...? The building instructions at the SWS code site might be out of date and WDL might already be as it should be for it.
Thanks for answering!

I just used the latest WDL (without patching ofc) and it compiled/runs as expected.

But as far as I know, something in there may not work as expected due to the lack of patching. That`s why I`m asking these questions
Breeder is offline  
Old 08-16-2012, 01:39 AM   #21
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Breeder View Post
1. Why do I need to patch it? What does it do exactly?
It looks like it addresses some cross-platform issues. Not exactly sure what issues but the changes only apply to swell-ini.cpp and look pretty minor.

Quote:
Originally Posted by Breeder View Post
2. How do I patch it on windows? What tool should I use?
If you're using TortoiseSVN, right-click on the wdl.patch file and select "Apply Patch" from the TSVN menu (assuming you let TSVN have shell menus). This will launch TortoiseMerge and if all's well you should see a pop-up listing swell-ini.cpp . Click "Patch all items" button at the bottom of the pop-up and that should be it.

Not sure how you do it if you don't have the TSVN shell menu.
IXix is offline  
Old 08-16-2012, 10:20 AM   #22
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by IXix View Post
It looks like it addresses some cross-platform issues. Not exactly sure what issues but the changes only apply to swell-ini.cpp and look pretty minor.


If you're using TortoiseSVN, right-click on the wdl.patch file and select "Apply Patch" from the TSVN menu (assuming you let TSVN have shell menus). This will launch TortoiseMerge and if all's well you should see a pop-up listing swell-ini.cpp . Click "Patch all items" button at the bottom of the pop-up and that should be it.

Not sure how you do it if you don't have the TSVN shell menu.
Hey, thanks for all the advice!
I tried with both TortoiseSVN and TortoiseGit but I couldn't patch it no matter what - I was getting strange errors like Patch format detection failed and Patch is not a working copy

However, I learned how to read a patch file so I did it by hand since it's not so big. I will still try to understand what am I doing wrong but at least it's patched for now.

But thanks to your advice I actually learned of TortoiseSVN. It really is a neat way to track all of your changes! Really nice tool! Yeah, I know, I'm a newbie
Breeder is offline  
Old 08-16-2012, 12:23 PM   #23
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Breeder View Post
Hey, thanks for all the advice!
I tried with both TortoiseSVN and TortoiseGit but I couldn't patch it no matter what - I was getting strange errors like Patch format detection failed and Patch is not a working copy

However, I learned how to read a patch file so I did it by hand since it's not so big. I will still try to understand what am I doing wrong but at least it's patched for now.

But thanks to your advice I actually learned of TortoiseSVN. It really is a neat way to track all of your changes! Really nice tool! Yeah, I know, I'm a newbie
Can't help with the errors. I'm a SVN n00b too. I have to do a lot of googling before I use it for anything other than just updating a repo.
IXix is offline  
Old 12-16-2012, 03:28 PM   #24
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Updated the example a bit (to use REAPER API calls to handle ini-file) and moved it to a Google Code git repository. There's now a Qt Creator compatible qmake .pro-file, so if you have Qt Creator using the Microsoft compiler the example should now be buildable with that combination. (It might also work on OS-X, but I didn't test yet.) I know people might not want to use Qt Creator (though it's really IMHO a good IDE), so the Visual Studio and XCode project files should still be added...qmake actually can generate those files, but initial testing unfortunately produced an XCode project with file paths pointing to my local Windows directories, so that isn't yet usable for other people.

http://code.google.com/p/simple-reap...ension-plugin/
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 12-17-2012, 03:10 PM   #25
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

What else is available and useful apart from sws extension?
TonE is offline  
Old 12-17-2012, 04:45 PM   #26
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Xenakios View Post
Updated the example a bit (to use REAPER API calls to handle ini-file) and moved it to a Google Code git repository. There's now a Qt Creator compatible qmake .pro-file, so if you have Qt Creator using the Microsoft compiler the example should now be buildable with that combination. (It might also work on OS-X, but I didn't test yet.) I know people might not want to use Qt Creator (though it's really IMHO a good IDE), so the Visual Studio and XCode project files should still be added...qmake actually can generate those files, but initial testing unfortunately produced an XCode project with file paths pointing to my local Windows directories, so that isn't yet usable for other people.

http://code.google.com/p/simple-reap...ension-plugin/
I just took a quick peek at it on OS X. I messed a bit with some paths, to point to WDL/Swell, but I couldn't get it to work just yet. Although that doesn't mean very much, as I am not very comfortable with C++ yet. Big ups for sharing, anyway, Xen!

__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline  
Old 05-23-2014, 10:45 PM   #27
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Xenakios View Post
Updated the example a bit (to use REAPER API calls to handle ini-file) and moved it to a Google Code git repository. There's now a Qt Creator compatible qmake .pro-file, so if you have Qt Creator using the Microsoft compiler the example should now be buildable with that combination. (It might also work on OS-X, but I didn't test yet.) I know people might not want to use Qt Creator (though it's really IMHO a good IDE), so the Visual Studio and XCode project files should still be added...qmake actually can generate those files, but initial testing unfortunately produced an XCode project with file paths pointing to my local Windows directories, so that isn't yet usable for other people.

http://code.google.com/p/simple-reap...ension-plugin/
Hi Xenakios. Thanks for sharing this.
I was wondering if you could post a link for which version of QT creator to use to open the pro file and build the extension?
Is there anything else needed?

Thanks, Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline  
Old 05-24-2014, 04:56 AM   #28
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by WyattRice View Post
Hi Xenakios. Thanks for sharing this.
I was wondering if you could post a link for which version of QT creator to use to open the pro file and build the extension?
Is there anything else needed?

Thanks, Wyatt
On Windows, you need Visual Studio installed too. (To get a compiler that produces binaries compatible with Reaper, Mingw generally speaking doesn't really work for doing Reaper extension plugins.) But if you install VS, you might just as well use it, instead of Qt Creator(*). You would then need to set up a Visual Studio project to produce a dll file.

On OS-X you would need to install XCode. Setting up a XCode project to output a proper Reaper extension .dylib is tricky, if I recall right. And I can't really give any good current advice on that. (I haven't been able to run OS-X and build software on it for almost a year now.)

edit : You might also want to check out some earlier version of the source code. I've added some sundry stuff in the main.cpp that might not really do anything useful/work properly...I should have created a new git branch for those things...I think the git revision 89f62d7095b2 is closest to what the main.cpp would work as a "simple extension example".

(*) I myself use and like Qt Creator a lot, but it's not commonly used by other people/projects, so you are probably best off using Visual Studio on Windows and XCode and OS-X...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 05-24-2014 at 08:47 AM.
Xenakios is offline  
Old 05-25-2014, 11:38 AM   #29
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Thanks.
Man, I'm a complete noob when it come to c++
I would like to try to build it with QT. Is this the right link (open source version)?
https://qt-project.org/downloads

Can you tell me what's needed from there?
Thanks, Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline  
Old 05-25-2014, 12:26 PM   #30
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by WyattRice View Post
Thanks.
Man, I'm a complete noob when it come to c++
I would like to try to build it with QT. Is this the right link (open source version)?
https://qt-project.org/downloads

Can you tell me what's needed from there?
Thanks, Wyatt
I think trying to use Qt Creator with the Visual Studio compiler will be much more complicated for a newbie than using just Visual Studio...(I didn't really add the Qt Creator .pro file to be newbie-friendly, but just in case someone would find it useful, if they already had a development system with Qt Creator and the compiler from Visual Studio or XCode set up.)

I highly recommend you only download and install Visual Studio 2013 Express. For your convenience, I can try setting up and upload a Visual Studio project file that builds the example extension code. (The reason I haven't done it so far is that I haven't had the chance to do a XCode project file at the same time too...)

If you insist on trying to use Qt Creator, you need to install Qt, Qt Creator and Microsoft's Visual Studio. What version of Qt you need to install would depend on the Visual Studio version you have installed. The versions of Qt that have the MinGW toolchain included are not really suitable for developing Reaper extension plugins. If you insist on trying to use MinGW anyway, you will be on your own.

Qt Creator doesn't really add anything immediately useful for developing Reaper extension plugins. Using the actual Qt toolkit to do Reaper plugins is quite complicated and messy, I've myself been struggling years with that and I still think it probably isn't a very good way to go. Not recommended for newbies.

edit : What is it that you are planning to do with Reaper C(++) extensions? Is there some reason why ReaScript wouldn't work? The complexity that C++ brings with it, even to just build a simple piece of code, isn't necessarily worth it unless you are planning to go really deep with the language.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 05-25-2014 at 12:43 PM.
Xenakios is offline  
Old 05-25-2014, 01:34 PM   #31
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Here's a .zip file that has the earlier version of the main.cpp and a Visual Studio 2013 compatible solution/project file.

http://ge.tt/6MPGEuh1/v/0?c

Hopefully it works...

And sorry, if you are on OS-X, this doesn't really help at all...(I can't produce a working XCode project from my Windows machine.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 05-25-2014 at 01:42 PM.
Xenakios is offline  
Old 05-25-2014, 01:59 PM   #32
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Banned View Post
I just took a quick peek at it on OS X. I messed a bit with some paths, to point to WDL/Swell, but I couldn't get it to work just yet. Although that doesn't mean very much, as I am not very comfortable with C++ yet. Big ups for sharing, anyway, Xen!

Sorry I never got around to replying to this. The errors are some OS-X specific quirks with the compiler and some other stuff, but I can't currently check what exactly should be changed to make the build work on OS-X. Still waiting for someone to donate me that Intel Mac...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 05-25-2014, 07:24 PM   #33
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Xenakios View Post
Here's a .zip file that has the earlier version of the main.cpp and a Visual Studio 2013 compatible solution/project file.

http://ge.tt/6MPGEuh1/v/0?c

Hopefully it works...

And sorry, if you are on OS-X, this doesn't really help at all...(I can't produce a working XCode project from my Windows machine.)
Thank you very much for this. I'll check it out and report back.
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline  
Old 05-25-2014, 07:41 PM   #34
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

oh man I really want to get into REAPER extensions. Thank you Xenakios!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline  
Old 05-26-2014, 03:01 PM   #35
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Xenakios,
I can't thank you enough for doing this.

I only have one python script that I use, and the rest that I've done, I've converted to eel.

The python script I'm trying to covert or make an extension for is using GetUserInputs and the default web browser (won't work in eel).

Here's my working python script. It brings up an input box, and I type something in, and it does a google site search.
Code:
#Reaper Google Search
#Thanks gofer for the input box example.
import webbrowser
dialog_name = "Reaper Google Search"
howmanyfields = 1
field_names = "Search Reaper Forums"
default_values = ""
maxreturnlength = 100
User_Input = RPR_GetUserInputs(dialog_name,howmanyfields, field_names, default_values, maxreturnlength)

if User_Input[0] == 1:
	UserValues = User_Input[4].split(',') 
	myinput = str(UserValues[0])
	search = str('http://www.google.com/search?hl=en&biw=1280&bih=844&as_q=' + myinput + 
	'&as_epq=&as_oq=&as_eq=&tbs=&lr=&as_filetype=&ft=i&as_' +
	'sitesearch=forum.cockos.com&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images')
	webbrowser.open(search)
Here's what I have so far in c++ using your extension template.

Code:
void doAction1()
{
	char* dialog_name = "Reaper Google Search";
	int howmanyfields = 1;
	const char* field_names = "Search Reaper Forums";
	char* default_values = "";
	int maxreturnlength = 50;

GetUserInputs(dialog_name, howmanyfields, field_names, default_values, maxreturnlength);

}
Not sure where to go from here. Would also like to put this in the help menu(does Reaper allow this?) Any help would greatly be appreciated.
Again, many thanks for helping a total noob.
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline  
Old 05-26-2014, 03:33 PM   #36
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by WyattRice View Post
Xenakios,
I can't thank you enough for doing this.

I only have one python script that I use, and the rest that I've done, I've converted to eel.

The python script I'm trying to covert or make an extension for is using GetUserInputs and the default web browser (won't work in eel).

Here's my working python script. It brings up an input box, and I type something in, and it does a google site search.
Code:
#Reaper Google Search
#Thanks gofer for the input box example.
import webbrowser
dialog_name = "Reaper Google Search"
howmanyfields = 1
field_names = "Search Reaper Forums"
default_values = ""
maxreturnlength = 100
User_Input = RPR_GetUserInputs(dialog_name,howmanyfields, field_names, default_values, maxreturnlength)

if User_Input[0] == 1:
	UserValues = User_Input[4].split(',') 
	myinput = str(UserValues[0])
	search = str('http://www.google.com/search?hl=en&biw=1280&bih=844&as_q=' + myinput + 
	'&as_epq=&as_oq=&as_eq=&tbs=&lr=&as_filetype=&ft=i&as_' +
	'sitesearch=forum.cockos.com&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images')
	webbrowser.open(search)
Here's what I have so far in c++ using your extension template.

Code:
void doAction1()
{
	char* dialog_name = "Reaper Google Search";
	int howmanyfields = 1;
	const char* field_names = "Search Reaper Forums";
	char* default_values = "";
	int maxreturnlength = 50;

GetUserInputs(dialog_name, howmanyfields, field_names, default_values, maxreturnlength);

}
Not sure where to go from here. Would also like to put this in the help menu(does Reaper allow this?) Any help would greatly be appreciated.
Again, many thanks for helping a total noob.
Hmm, I might need to think about that a bit. I have never needed to use the win32 API directly to open the web browser. But first, you need to make your code not have deprecated and undefined behavior. All the string literals need to be const char*, not char*. (The compiler allows doing that, but it's not really good modern style to use that.) The char* that gets the user input result must be initialized properly to point to a valid writable memory buffer, the char* default_values="" will not do that.

Code:
// put the include line near the beginning of the code file
#include <vector>

void doAction1()
{
const char* dialog_name = "Reaper Google Search";
int howmanyfields = 1;
const char* field_names = "Search Reaper Forums";
int maxreturnlength = 50;
std::vector<char> resultvec(maxreturnlength);
GetUserInputs(dialog_name, howmanyfields, field_names, resultvec.data(), maxreturnlength);
// ??? here to open the browser
// resultvec doesn't need to be explicitly freed to avoid a memory leak,
// std::vector cleans up automatically at the end of this function
}
Adding the action to the Help menu is easiest done by Reaper's own menu customization system, not from C++ code.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 05-26-2014 at 03:40 PM.
Xenakios is offline  
Old 05-26-2014, 03:54 PM   #37
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by WyattRice View Post
The python script I'm trying to covert or make an extension for is using GetUserInputs and the default web browser (won't work in eel).
To open web page with win32 api just do something like this

Code:
ShellExecute(NULL, "open", "http://www.google.com" , NULL, NULL, SW_SHOWNORMAL);
It should also work in OSX if using WDL SWELL
Breeder is offline  
Old 05-26-2014, 03:56 PM   #38
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Breeder View Post
To open web page with win32 api just do something like this

Code:
ShellExecute(NULL, "open", "http://www.google.com" , NULL, NULL, SW_SHOWNORMAL);
It should also work in OSX if using WDL SWELL
Yeah, I did the code already...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 05-26-2014, 03:58 PM   #39
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

This appears to be working at least for me :

http://pastebin.com/EF1rFA4b

Also add these somewhere to the beginning of the main.cpp file :

Code:
#include <vector>
#include <string>
Oh, and remember to do the IMPAPI(GetUserInputs); thing where there are the other IMPAPI lines too. I forgot to do that when testing this and of course got a nasty crash...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline  
Old 05-26-2014, 04:46 PM   #40
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Xenakios. Working great! Many thanks!

The Reaper context menu can't be customized, or at least I can't seem to find a way?

Thanks!
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline  
Closed Thread

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 04:41 PM.


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