@musical-patterns/spec v1.0.52
Musical Patterns - Spec
interface Spec<SpecsType extends Specs = Specs> {
computeValidations?: ComputeValidations<SpecsType>,
configurations: Configurations<SpecsType>,
initialSpecs: SpecsType,
presets?: ObjectOf<Preset<SpecsType>>,
}Spec is the name for this data structure which is attached to Pattern. In this context it is used in the conceptual singular sense.
An individual "spec" is one property which controls the materials for the pattern.
A value for one of these properties is typed as a SpecValue, and key is currently just a string but may one day be a nominally-typed string called a SpecKey
The object containing such specs is typed as Specs.
The Pattern type is generic, and takes a type of Specs as its single parameter, which is then passed to the pattern's Spec property.
initialSpecsis what the compiler from@musical-patterns/materialwill use as your pattern'sSpecswhen materializing your pattern if you do not specifically provide aSpecsobject.presetsis an object containingSpecsthat your pattern could materialize with. Use presets when there are a few particular combinations of spec settings you'd like to highlight and make easily accessible.configurationsare again mapped to yourPattern'sSpecsTypeargument, and eachConfigurationdetermines how the control for that spec will work. -inputTypeis either ranged (numeric), optioned (set of strings), toggled (boolean), or stringed (an arbitary string, almost certainly heavily custom validated). -isArrayed, when true, indicates that your spec is actually an array of values of the above type.@musical-patterns/playroomprovides add and remove buttons for changing the length. These control elements are calledfields. -arrayedNewFieldInitialValueso you can make new fields start out with a defined value rather than empty. -hideInputis used only for the rangedinputType, which has two types of inputs, one text-based, one a slider. By default, each field contains both input types, but you can hide one or the other. -constraintdiffers byinputType. Any time spec is submitted, it is first checked against these constraints before attempting to compile. - Ranged inputs have min/max, step sizes, and can be constrained to integers. - Optioned inputs - this is where you provide the set of options. - Toggled inputs - no constraint, as these are simple booleans. - Stringed inputs - min/max length in chars.computeValidationsis a function that will get called by the@musical-patterns/playroomwhenever a potential object ofSpecsis submitted from the UI. It's necessary whenever the conditions of yourSpecs' validity involve relationships between multiple specs, or just conditions within a single spec which are more complicated than the basic providedconstraints.
There are several standard specs, including base duration and base frequency. Any pattern should be able to use these, but your pattern's specs type is not forced to extend them.
The Presentable interface from the metadata module is extended by several other interfaces in the spec module, including Preset, Configuration, and OptionedConstraintOption.
In the case of these spec interfaces, the description property will display to the @musical-patterns/playroom user as hover text.
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago