Old 09-24-2017, 12:06 AM   #1
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default Anyone interested in a C++ REAPER API helper library?

Anyone interested in a C++ REAPER API helper library?

example usage:

Code:
String MoveItemsToTrackBasedOnName(String param)
{
		int num_items_moved = 0;
		ITEMLIST ItemList;
		ItemList.CollectSelectedItems();

		if (ItemList.empty()) return "No items are selected.";

		UI();
		UNDO();

		for (auto& item : ItemList)
		{
			item.track(item.name())
			++num_items_moved;
		}

		UNDO("Move items to tracks based on name");
		UI();
		UpdateArrange();

		return String(num_items_moved) + " items were moved.";
}
not ready for public, but it's getting there...


ok what is going on here... I might change the interface to be more verbose. This is a bit weird.
Code:
		for (auto& item : ItemList)
			item.track(item.name())
			++num_items_moved;
item.track() takes in a string or int. If string, find track with name, move item to that track. If int, find nth track, move to that track.
More verbose would be item.setTrack() / item.getTrack()

right now actually item.track is both set and get depending on whether you put something in the parens or not.


features
- easy handling of project markers
- comparing project markers with items
- comparing items to items
- super simple track folder handling
- simple audio handling
- simple envelope / envelope item / envelopes in items handling
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 09-24-2017 at 12:45 AM.
Argitoth is offline   Reply With Quote
Old 09-24-2017, 01:34 AM   #2
Geoff Waddington
Human being with feelings
 
Geoff Waddington's Avatar
 
Join Date: Mar 2009
Location: Dartmouth, Nova Scotia
Posts: 11,254
Default

Always interested in cutting down lines of code !!

As you may know I'm currently working on an open source control surface integration project.

One of the features of the design is treatment of Reaper functionality.

Sorry to overload, in the code there is a class called Action, which is a superset of reaper actions that also includes concepts like channel strips, faders that control volume, etc.

So each Action is encapsulated within an object.

At first this may seem like overkill, but anything less has insufficient flexibility.

The plan is for the Reaper community to write and contribute actions, using a model similar to Reaper extensions(e.g. sws).

Coding an Action can be as simple as a 2 line code change to a template, and as complex as desired.

Any help with allowing the community (including me ) to code these Actions is much appreciated !

I'm presuming this will be open source ?
__________________
To install you need the CSI Software and Support Files
For installation instructions and documentation see the Wiki
Donate -- via PayPal to waddingtongeoff@gmail.com
Geoff Waddington is offline   Reply With Quote
Old 09-24-2017, 02:07 AM   #3
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,791
Default

GREAT !!!

I suppose I will ned this some day ...

Thanks for sharing,
-Michael
mschnell is online now   Reply With Quote
Old 09-24-2017, 03:10 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,901
Default

hi !
i think that where a c++ extension would be very useful is by bringing OS-friendly GUI elements to Lua, contrary to GFX which is only a canvas, and like Tkinter can do for python.

https://forum.cockos.com/showthread.php?t=196288

Thing is we cant load C++ or C based Lua GUI helper from a ReaScript.

According to cfillion, a c++ extension could wrap GUI helpers functions for usage with ReaScript. in this case, fltk4lua seems a good choice for me as it is lua 5.3 compatible, or maybe our own functions, as long as GUI elements are cross platforms and easy to use.

https://github.com/siffiejoe/lua-fltk4lua

I know you were exprimenting this with Xenakios two years ago :P

https://forum.cockos.com/showthread.php?t=170117

maybe it is time to dig this subject ?

thanks for your proposition !
X-Raym is offline   Reply With Quote
Old 09-24-2017, 05:54 AM   #5
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

heyyyy people, this not for a reaper extensions, but it is to help in creating REAPER extensions by providing a C++ interface of classes to help deal with REAPER's C-based API.

Quote:
Originally Posted by Geoff Waddington View Post
I'm presuming this will be open source ?
Yes, I could use help to integrate more of REAPER's API into the class paradigm I am going for.


Here's another example:
Code:
String ConvertEveryTwoMarkersToRegions()
{
		UI();
		UNDO();

		MARKERLIST MarkerList;
		MarkerList.CollectMarkers();
		MarkerList.FilterByRange(TIMESELECTION::range());

		if (is_odd(MarkerList.size())) 
			MarkerList.pop_back();

		MARKERLIST RegionsToBeAdded;

		for (int i = 0; i < MarkerList.size(); i+=2)
		{				
			MARKER g;
			g.name(MarkerList[i].name());
			g.startPos(MarkerList[i].startPos());
			g.endPos(MarkerList[i+1].startPos());
			RegionsToBeAdded.push_back(g);
		}

		MarkerList.RemoveAllFromProject(); // removes only markers inside your list, not entire project
		RegionsToBeAdded.AddAllToProject();  // similar paradigm here

		UNDO("ST: Markers: Convert every two markers to regions in time selection");
		UI();

		return String(RegionsToBeAdded.size()) + " regions were created.";
}
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 09-24-2017, 06:14 AM   #6
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Question: If this is all open source, could I include JUCE? That would allow for my library to have some helpful GUI stuff. Hmm. Maybe include it but make it optional (avoid build errors when you don't have JUCE).
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 09-24-2017, 09:38 AM   #7
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,820
Default

Argitoth! man i love your plugins!
deeb is offline   Reply With Quote
Old 09-24-2017, 02:53 PM   #8
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Quote:
Originally Posted by deeb View Post
Argitoth! man i love your plugins!
uhhh... reaper plugins or audio plugins?
Edit: Don't let this turn into another "this plug in is amazing" thread (https://www.kvraudio.com/forum/viewt...p?f=1&t=204964)
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 09-24-2017, 03:18 PM   #9
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,820
Default

Quote:
Originally Posted by Argitoth View Post
uhhh... reaper plugins or audio plugins?
Edit: Don't let this turn into another "this plug in is amazing" thread (https://www.kvraudio.com/forum/viewt...p?f=1&t=204964)
the Audio ones! i am amazed by the videos
deeb is offline   Reply With Quote
Old 09-24-2017, 05:09 PM   #10
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

Quote:
Originally Posted by Argitoth View Post
Anyone interested in a C++ REAPER API helper library?
features
- easy handling of project markers
- comparing project markers with items
- comparing items to items
- super simple track folder handling
- simple audio handling
- simple envelope / envelope item / envelopes in items handling
Yes, I would be interested.

Thanks,
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 09-24-2017, 06:56 PM   #11
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Argitoth View Post
Question: If this is all open source, could I include JUCE? That would allow for my library to have some helpful GUI stuff. Hmm. Maybe include it but make it optional (avoid build errors when you don't have JUCE).
The code already appears to depend on Juce, you are using the String class from it...?
__________________
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 09-24-2017, 07:01 PM   #12
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Most of my stuff doesn't use String's special functions. I think I can slowly go about removing it.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 09-24-2017, 07:07 PM   #13
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Argitoth View Post
Most of my stuff doesn't use String's special functions. I think I can slowly go about removing it.
OK, but what are you going to use instead? std::string is a royal pain in the ass, and no sane C++ code would use char* or const char* extensively...
__________________
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 09-24-2017, 07:14 PM   #14
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
Default

Quote:
Originally Posted by Xenakios View Post
std::string is a royal pain in the ass
How so?
cfillion is offline   Reply With Quote
Old 09-24-2017, 07:47 PM   #15
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Quote:
Originally Posted by cfillion View Post
How so?
I second this question/notion.

also who here is trying to make money with a REAPER plugin? JUCE is free if you're open sourcing your stuff, which you might as well do if you're not trying to make money.

Edit: Therefore I think my library should just require JUCE.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 09-24-2017 at 07:56 PM.
Argitoth is offline   Reply With Quote
Old 09-24-2017, 08:00 PM   #16
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by cfillion View Post
How so?
Well, it's just my opinion after using things like Qt's QString or Juce's String. In any case, the Juce Core module that has the String class has a more permissive license. (It can be used in non-GPL projects too, without paying the license fee.)
__________________
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 10-04-2017, 08:02 AM   #17
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

https://github.com/elanhickler/seObjectiveReaper

there's a lot of code cleanup to do and i need to rename all functions to get/set. So it's not ready to be used, but if you're curious you can see what kind of functionality I'm going for by exploring the Reaper Classes.

https://github.com/elanhickler/seObj...aper%20Classes
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 10-07-2017, 11:33 PM   #18
Kyran
Human being with feelings
 
Join Date: Sep 2010
Posts: 49
Default

For what it's worth, I find it acceptable to omit the "Get" when the method is const without side effects.

Code:
class MyClass
{
    int m_favorite_color;
public:
    int FavoriteColor() const;
    void SetFavoriteColor( int color );
}
Kyran is offline   Reply With Quote
Old 10-08-2017, 03:57 AM   #19
Geoff Waddington
Human being with feelings
 
Geoff Waddington's Avatar
 
Join Date: Mar 2009
Location: Dartmouth, Nova Scotia
Posts: 11,254
Default

Quote:
Originally Posted by Kyran View Post
For what it's worth, I find it acceptable to omit the "Get" when the method is const without side effects.

Code:
class MyClass
{
    int m_favorite_color;
public:
    int FavoriteColor() const;
    void SetFavoriteColor( int color );
}
Hmmm...

Being a C/C++/Assembly/Smalltalk guy, I've always found the Get Set naming convention strange, redundant, and cluttered.

Why not name them both FavoriteColor a la:
int FavoriteColor();
void FavoriteColor(int color);

It's completely obvious from the signature what's going on.

Keeping the names the same underscores their semantic affinity and makes it easier to reason about the code as you peruse it.

And before you say "I just strip off the Set Get mentally, it's trivial", I would argue strongly that you are dead wrong, it detracts from the ability to reason about the code for precisely that reason, it requires extra mental processing to strip off the prefix, leaving less to reason about the code, it is most assuredly not trivial, why have this mental cycle chewing impediment there in the first place ?

my 2c
__________________
To install you need the CSI Software and Support Files
For installation instructions and documentation see the Wiki
Donate -- via PayPal to waddingtongeoff@gmail.com

Last edited by Geoff Waddington; 10-08-2017 at 04:05 AM.
Geoff Waddington is offline   Reply With Quote
Old 10-08-2017, 07:05 AM   #20
Kyran
Human being with feelings
 
Join Date: Sep 2010
Posts: 49
Default

I guess it gets messy when dealing with output parameters.
Code:
class MyClass
{
// ...
public:
    void ColoredShape( Color& color, Shape& shape );
}
Am I passing in a color and shape to be copied into the object's member variables, or expecting to have the object's member variables' values assigned to the color and shape? Sure, I could just return a pair<Color, Shape> but that's besides the point.

I do find it semantically cleaner to say when I'm setting something vs accessing a value. One is a mutating operation, the other is immutable. Saying the name of the property you're looking for is really just an alias for the value, potentially with some extra non-mutating behavior attached. Supplying an argument to that function makes me think it's an index or otherwise involved in fetching the value I'm looking for. FavoriteColor(2) makes me think the second favorite color, not assign the value 2. Of course using a strong data type instead of a raw int would help clarify things but there's still room for ambiguity.

For me it comes down to an accessor method essentially being a noun, and a mutator method being a verb, so their names should reflect that.
Kyran is offline   Reply With Quote
Old 10-08-2017, 08:38 AM   #21
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

guys, guys! I've already run into several problems because of the lack of get/set. It has become very messy *without* get/set.

There are functions where I need multiple types of set and multiple types of get, for example, and you won't know what function gets or sets. Then there are times where the lack of "get" made me think I was using a member object rather than a member function.

example:

item.getTake();

vs

item.take

vs

item.take();

It's so much clearer with get/set what is going on, especially with intellisense in VS, you start typing "get" and then "OH LOOK AT ALL THE THINGS I CAN GET"! There's no argument for me here. IF you want a class interface that anyone can pick up and start using right away without confusion, you need get/set.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 10-08-2017, 07:25 PM   #22
Geoff Waddington
Human being with feelings
 
Geoff Waddington's Avatar
 
Join Date: Mar 2009
Location: Dartmouth, Nova Scotia
Posts: 11,254
Default

Quote:
Originally Posted by Argitoth View Post
guys, guys! I've already run into several problems because of the lack of get/set. It has become very messy *without* get/set.

There are functions where I need multiple types of set and multiple types of get, for example, and you won't know what function gets or sets. Then there are times where the lack of "get" made me think I was using a member object rather than a member function.

example:

item.getTake();

vs

item.take

vs

item.take();

It's so much clearer with get/set what is going on, especially with intellisense in VS, you start typing "get" and then "OH LOOK AT ALL THE THINGS I CAN GET"! There's no argument for me here. IF you want a class interface that anyone can pick up and start using right away without confusion, you need get/set.
Haha, perhaps my humour was too subtle

Seriously, I use Set all the time but am not quite religious about always using Get, perhaps I should be
__________________
To install you need the CSI Software and Support Files
For installation instructions and documentation see the Wiki
Donate -- via PayPal to waddingtongeoff@gmail.com
Geoff Waddington 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 07:40 AM.


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