-
Notifications
You must be signed in to change notification settings - Fork 84
Preset Configuration
In Proffie OS the term Preset means the combination of:
- Sound Font
- Music Track
- Color Style
Presets are defined in object array of type Preset. A single Preset looks something like this:
{
"fontdir",
"tracks/track.wav",
style definition, // NUM_BLADES specifies how many style definitions there are
"description",
}
The first part of a preset is the directory of the sound font. ProffieOS supports most of the major sound font formats that are widely used. Sound-playing engine automatically detects through the files in the directory and switches to the appropriate mode.
- Plecter-style Fonts (Including CFX style fonts, from ProffieOS 3.x)
- Nec-styled Fonts
- Smooth Swing V1
- Smooth Swing V2
Note: Font directory should not exceed 8 characters
Note: Default sample rate in ProffieOS is 44kHz so all sounds with lower sample rates are upsampled automatically.
In the second field is configured the audio track which can be used for soundtrack music or ambient sound in parallel to the rest of the sounds that are played by the saber. Music Track invoke is configured to be runned via button combination or with Command send via the Serial port/Bluetooth module.
The style definition specifies the look and behavior of the blade itself. If more then one blade is used (NUM_BLADES is greater than 1) then more then one styles have to be defined in the current preset.
I won't go into all the possible ways to write a style definition here, but I will explain how the syntax works in general. First of all, the style definition needs to be a pointer to a style factory. The easiest way to create a pointer to a style factory is to use StylePtr. StylePtr is a templated function that takes a template, creates an instance of it and returns a pointer to that instance. If none of that makes sense to you don't worry, all you need to do is that StylePtr looks like this:
StylePtr<COLOR>()
And COLOR is the interesting part which defines how the blade will behave. There are a lot of possibilities for the COLOR should work. However, in general, the COLOR is either the name of a color, or a style template. Style templates look like this:
StyleTemplate<Argument1, Argument2, Argument3>
Where "StyleTemplate" is the name of the template. Note that the < and > work like parenthesis, and are not to be interpreted as "less/greater than". The arguments can be either numbers, colors or other templates. Each template will have a list of arguments it expects. Perhaps the simplest one is the Rgb template:
Rgb<R, G, B>
The Rgb template takes three numbers between 0 and 255 and returns the corresponding rgb color. Since none of the three arguments can be other templates, Rgb templates will never grow complicated. Other templates however, can become long and unwieldy because of the nesting of templates. For this reason it's probably best to use the style editor to create definitions.
The last element in a preset is the Preset Name. It is in the form of a character string. The preset name is used by BLE, WebUSB and OLED screens to identify the preset. The preset description generally uses the StarJedi font.
Cool Footer