Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
I'd like to create my own library of objects
Avatar
GaryW
Member
Members
December 28, 2020 - 11:00 am
Member Since: December 24, 2020
Forum Posts: 7
sp_UserOfflineSmall Offline

I'm sure the answer to this is straightforward, but looking for guidance anyway.  One block I use all the time is a crossfade.  I used 4 or five of them in my first VST.  I just added this to the PluginCore class so I could use it in the audio processing routine.  Now I'd like to make it into its own object so I can use it in all my projects.  I was going to follow the pattern of fxobjects.cpp and .h.  Is there a preferred location to put my files?

Note: the following code is untested, use at your own risk.

 

double PluginCore::CrossFade(double channel_1, double channel_2, double fadeValue, crossfadeTypeID fadeType=crossfadeTypeID::linear)
{
switch (fadeType)
{
case crossfadeTypeID::linear:
return (1 - fadeValue) * channel_1 + fadeValue * channel_2;
break;
case crossfadeTypeID::erica6dBBump:
double gain1, gain2;
if (fadeValue <= 0.50)
{
gain1 = 1.0;
gain2 = 2 * fadeValue;
}
else
{
gain2 = 1.0;
gain1 = 2 - 2 * fadeValue;
}
return gain1 * channel_1 + gain2 * channel_2;
break;
case crossfadeTypeID::twoStage:
if (fadeValue <= 0.50)
{
gain1 = 1.0 - 0.586 * fadeValue;
gain2 = 1.414 * fadeValue;
}
else
{
gain2 = 0.586 * fadeValue + 0.414;
gain1 = 1.414 - 1.414 * fadeValue;
}
return gain1 * channel_1 + gain2 * channel_2;
break;
case crossfadeTypeID::equalPowerSine:
gain1 = cos(fadeValue * 1.57079632679489661923);
gain2 = sin(fadeValue * 1.57079632679489661923);
return gain1 * channel_1 + gain2 * channel_2;
break; default:
return (1 - fadeValue) * channel_1 + fadeValue * channel_2;
break;
}
}

Avatar
W Pirkle
Admin
December 28, 2020 - 11:37 am
Member Since: January 29, 2017
Forum Posts: 573
sp_UserOfflineSmall Offline

Use the PluginObjects folder for your additional files - that folder is specifically for plugin objects that are not part of ASPiK and are part of your own creation. 

If you use the same set of objects for each project, you can take advantage of the new feature I added that lets you use the PluginTemplate folder as the basis for new project creation, rather than an encrypted brick that you can't edit. This would copy over whatever added files you used in the PluginObjects folder into each new project. 

But you will still need to add the files to the compiler project, and there are two ways to do that:

1) manually, using the Visual Studio or XCode method of adding existing items into your project

2) edit the CMakeLists.txt files -- if you do this in the PluginTemplate correctly, then each new project will automatically have your files in the compiler project, ready to compile.

Performing (2) is not that difficult, but there is a separate CMakeLists.txt file for each API, and these are in the /project_source/cmake/xyz_cmake/CMakeLists.txt where xyz is the plugin API (aax, au, or vst). The top parts of these files are identical and have the source file lists. You would add your own files in the same spot as the existing pluginobjects, for example:

set(plugin_object_sources
${OBJECTS_SOURCE_ROOT}/fxobjects.h
${OBJECTS_SOURCE_ROOT}/filters.h
${OBJECTS_SOURCE_ROOT}/fxobjects.cpp

${OBJECTS_SOURCE_ROOT}/myobjects.h     #<- your new object files

${OBJECTS_SOURCE_ROOT}/myobjects.cpp. #<- your new object files
)

Hope that helps!

Will 

Avatar
GaryW
Member
Members
December 28, 2020 - 12:57 pm
Member Since: December 24, 2020
Forum Posts: 7
sp_UserOfflineSmall Offline

Thanks a bunch!  I will try it.

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Chaes: 51

Skyler: 48

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

clau_ste: 39

jim: 34

JimmyM: 33

Gwen: 32

Member Stats:

Guest Posters: 1

Members: 698

Moderators: 1

Admins: 5

Forum Stats:

Groups: 13

Forums: 41

Topics: 757

Posts: 2895

Newest Members:

lance, Mistahbrock, Jas, Rowan, sojourn, fabhenr, rg1, Niklas, Wutru, Tim Campbell

Moderators: W Pirkle: 573

Administrators: Tom: 74, JD Young: 80, Will Pirkle: 0, W Pirkle: 573, VariableCook: 3