Can Using Functions have input arguments

I’d like to ask if, or propose a feature, that “using” functions be able to pass in arguments for variables (mostly for colors).

So, for instance, I have 2 different snippets of code, identical except for the COLOR value they use.

// Pusling Blade
using Style2_Pulsing = Pulsing<
	TRANSPARENT,
	RotateColorsX<Variation, RgbArg<ALT_COLOR2_ARG, Rgb<255, 255, 255>>>,
	1200
>;

and

// Pusling Blade
using Style3_Pulsing = Pulsing<
	TRANSPARENT,
	RotateColorsX<Variation, RgbArg<ALT_COLOR3_ARG, Rgb<255, 255, 255>>>,
	1200
>;

So, in my main blade style it is used like this:

	ColorSelect<
		IntArg<STYLE_OPTION2_ARG, 0>,
		TrInstant,
		Style2_Pulsing
	>,

	// Tirtiary blade Styles
	ColorSelect<
		IntArg<STYLE_OPTION3_ARG, 0>,
		TrInstant,
		Style3_Pulsing
	>,

It would be cool If I could just use one “using” function and pass in the color used, like so:

// Pusling Blade
using Style_Pulsing = Pulsing(COLOR)<
	TRANSPARENT,
	RotateColorsX<Variation, COLOR>,
	1200
>;
	ColorSelect<
		IntArg<STYLE_OPTION2_ARG, 0>,
		TrInstant,
		Style_Pulsing<RgbArg<ALT_COLOR2_ARG, Rgb<255, 255, 255>>>
	>,

	// Tirtiary blade Styles
	ColorSelect<
		IntArg<STYLE_OPTION3_ARG, 0>,
		TrInstant,
		Style_Pulsing<RgbArg<ALT_COLOR3_ARG, Rgb<255, 255, 255>>>
	>,

Is such a thing currently possible? If not, could it be added?

Yes this was added in OS7, my config helper tool already handles.
See info here and watch videos at the top of tool.

Additional info here:

1 Like

It’s already there, the syntax is:

template<class COLOR>
using Style_Pulsing = Pulsing<
  TRANSPARENT,
  RotateColorsX<Variation, COLOR>,
  1200
>;

This is a standard C++ feature, so you can read more about it here:
https://en.cppreference.com/w/cpp/language/templates
(But don’t expect that to be easy to read.)

Still not getting it. I tried what you suggested but got an error:

Compilation error: expected '=' before '<' token

I’m wanting to know if I can pass a color argument from the main style that’s calling a “using” function, into the using function itself.

In one of my utility files I already have all the color argments set as USING functions:

// Base Color
using BASECOLOR = RgbArg<BASE_COLOR_ARG, Rgb<255, 255, 255>>;
// Alt Colors
using ALTCOLOR = RgbArg<ALT_COLOR_ARG, Rgb<255, 255, 255>>;
using ALTCOLOR2 = RgbArg<ALT_COLOR2_ARG, Rgb<255, 255, 255>>;
using ALTCOLOR3 = RgbArg<ALT_COLOR3_ARG, Rgb<255, 255, 255>>;

I tried having this as one of my small segments of style in a using function, which I want to use in both STYLE_OPTIONS2 and STYLE_OPTIONS3 but each using a different color (ALTCOLOR2, ALTCOLOR3, repsepctivly)

// Pusling Blade
template<class COLOR>
using Style_Pulsing<COLOR> = Pulsing<
	TRANSPARENT,
	RotateColorsX<Variation, COLOR>,
	1200
>;

and then calling it in my main style in two places (under both STLYE_OPTION2 and STYLE_OPTION3 as:

		// Option 3: Pusling ALTCOLOR2
		Style_Pulsing<ALTCOLOR2>,

and again under ColorSelect for STYLE_OPTION3

		// Option 3: Pusling ALTCOLOR3
		Style_Pulsing<ALTCOLOR3>,

In code, they’re called input argments. So, I’m trying to find out if a using function itself can take different input arguments, and if so, how to set them per use of the function.

This is incorrect, adding <COLOR> after Style_Pulsing makes it a template specialization rather than a template definition. (Template syntax is stupid, but there is nothing I can do to fix that.)

Did you try it the way I typed it?

There are also lots of examples of this in the code you can look at for inspiration:

Even Pulsing is in fact one of these “using” templates:

So then, my question becomes, how do I set the COLOR for the Template from the place I call the Style_Pulsing, so that it is different for each call? I;m trying to do this from within the Style code itself.

// Secondary blade Styles
	ColorSelect<
		IntArg<STYLE_OPTION2_ARG, 0>,
		TrInstant,
		// STYLE OPTION2 using Pusling with ALTCOLOR2
		Style_Pulsing
	>,
// Tirtiary blade Styles
	ColorSelect<
		IntArg<STYLE_OPTION3_ARG, 0>,
		TrInstant,
		// STYLE OPTION 3 using Pusling with ALTCOLOR3
		Style_Pulsing
	>,

Style_Pulsing<ALTCOLOR2>, same as before.
It’s only in the definition that you shouldn’t put anything after “Style_Pulsing”.

ok, i’ll try that.

Another dumb Q: If i’m doing this with multiple using style functions, do i need a template<class COLOR> for each one?

yes you do

so, like this?

// AudioFlicker
template<class COLOR>
using Style_AudioFilter = AudioFlicker<
	TRANSPARENT,
	RotateColorsX<Variation, COLOR>
>;

// Random Flicker
template<class COLOR>
using Style_RandomFlicker = RandomFlicker<
	TRANSPARENT,
	COLOR
>;

// Pusling Blade
template<class COLOR>
using Style_Pulsing = Pulsing<
	TRANSPARENT,
	RotateColorsX<Variation, COLOR>,
	1200
>;

// RandomPerLEDFlicker
template<class COLOR>
using Style_RandomPerLEDFlicker = RandomPerLEDFlicker<
		TRANSPARENT,
		COLOR
>;

Or does each Template need a different name for it’s COLOR arg? template<class COLOR1> template<class COLOR2> template<class COLOR3> template<class COLOR4>

then in my style color select, I just say

	ColorSelect<
		IntArg<STYLE_OPTION2_ARG, 0>,
		TrInstant,
		Style_AudioFilter<ALTCOLOR2>,
		Style_RandomFlicker<ALTCOLOR2>,
		Style_Pulsing<ALTCOLOR2>,
		Style_RandomPerLEDFlicker<ALTCOLOR2>
	>,
	ColorSelect<
		IntArg<STYLE_OPTION3_ARG, 0>,
		TrInstant,
		Style_AudioFilter<ALTCOLOR3>,
		Style_RandomFlicker<ALTCOLOR3>,
		Style_Pulsing<ALTCOLOR3>,
		Style_RandomPerLEDFlicker<ALTCOLOR3>
	>,

Yes, that should work.
But…

Why not just use:

template<class COLOR>
using Style_AudioFilter = AudioFlickerL<
  RotateColorsX<Variation, COLOR>
>;

instead?

no

Nice, it works :slight_smile: Now I have some refactoring to do :slight_smile:

I assume I can pass multiple arguments, such as timers for variation into them too?

EDIT: Yay, that works too. Awesome.

BTW: I am curious, has anyone ever coded a style using this method before?

I have no idea what you’re doing LOL.
To be honest, I didn’t read in detail, but what are you accomplishing? Is it making something more convenient?
How is it improving your workflow compared to more typical blade style usage?

I’m making a blade style using several composited snippets of code, using the using functions.

Think of it as taking a blade style, breaking it up into it’s individual components, and adding each component as an option in EDIT MODE settings. I’ve already got enough options plugged into it to fill a Proffieboard V2 to 98%, soon i’ll have to disable TALKIE and Mass Storage/Web USB on the SD card reading on that upload.

So, I am using STYLE OPTIONS for a base blade layer which uses BASE COLOR ARG and some of the options use ALT COLOR ARG.

Then, I have optionally a STYLE OPTIONS 2 setting which can be overlayed ontop of that, which uses ALT COLOR 2 ARG.

And a 3rd layer using STYLE OPTIONS 3, using ALT COLOR 3 ARG. So you can mix and match different basic styles together to create a custom blade style presets using EDIT MODE.

So, you can combine an audio flicker that uses a mix of blue/red as STYLE OPTION 1, and then add a Pulsing yellow ontop of it as STYLE OPTION 2, and maybe a 3rd layer could be a fire style, or emitter spark, or etc…

Using these templates, I can make the STYLE OPTION 2 and STYLE OPTION 3 options use the exact same using functions, which reduces duplicate code and makes tweaking/adding things easier. The style i’m working on is on my Github, i’ve posted a link to it in a couple of threads where I’ve found bugs/asked questions. You’re welcome to take a look at my progress.

So far i’m mostly tinkering and learning how to use various functions. I think my next goal will be to try to make some of these styles more interactive by finding ways to incorporate BladeAngle/TwistAngle to effect speeds and timing. Then I’ll tackle looking at Special Abilities, which look interesting…

I tend to learn best by looking at working examples, then tweaking them, then trying to make my own things from scratch based on what I’ve learned from them. My first “original” written style was a hump that follows blade angle. My roommate said “So you made a level” lol

I see. So am I correct in understanding that your basically taking the things that Edit Mode can do, and mimicking the methods used to create styles by Fett263’s Style Library website, but instead having them locally and generating them yourself?
It just sounds like, other than a cool learning experience, a lot of that work is already done for you, no?

Well, it is a learning experience yes. And I know the webtool for building style can probably build the same or similar style to what i’m making, but I prefer to write the code myself in Visual Studio, as I can also pop open the proffie source and see how all the functions work.

And who knows, maybe I’ll come up with some hand written options that aren’t on the website, or find bugs that nobody’s found yet. :slight_smile:

I do use the style builder to get working examples to study from. I’m looking forward to OS7 phase 2 rollout to see how some of the new stuff works. Though I have had trouble finding any free sound fonts that are designed to use some of the new features, like interactive blast effects.

This is the Way.
And I’m trying to wrangle some font creators to make some full blown fonts that incorporate all current features (or by OS8 anyway) like Alt Sounds, transition sounds, dynamic clash, and I guess add “interactive blasts” to the list.
Then hopefully the Default Proffieboard SD font package will have a good example/template to work with to play with all this stuff.

I’ve been doing the same, as well as building corresponding “recipes” into the library to make it easier for users to get and customize styles to support the fonts. If you make any headway and wouldn’t mind letting them know I’m looking to help and support as well, it’d be much appreciated. I’ve had some luck with a few but haven’t been able to connect with others, ideally I’m hoping to make it easier for font makers to get the most out of the capabilities and make it easier for users to implement everything we can do.

1 Like